[Intel-gfx] [PATCH] drm/i915: Clean up PCI config register handling
Chris Wilson
chris at chris-wilson.co.uk
Fri Apr 15 10:18:32 UTC 2016
On Fri, Apr 15, 2016 at 12:17:18PM +0300, Joonas Lahtinen wrote:
> Do not use magic numbers, do not prefix stuff with "PCI_", do not
> declare registers in implementation files. Also move the PCI
> registers under correct comment in i915_reg.h.
>
> Cc: Jani Nikula <jani.nikula at intel.com>
> Cc: Chris Wilson <chris at chris-wilson.co.uk>
> Cc: Ville Syrjälä <ville.syrjala at linux.intel.com>
> Signed-off-by: Joonas Lahtinen <joonas.lahtinen at linux.intel.com>
> ---
> drivers/gpu/drm/i915/i915_dma.c | 15 ++++----------
> drivers/gpu/drm/i915/i915_gem_stolen.c | 9 ++++----
> drivers/gpu/drm/i915/i915_reg.h | 38 +++++++++++++++++++++++++---------
> drivers/gpu/drm/i915/intel_opregion.c | 24 ++++++++-------------
> drivers/gpu/drm/i915/intel_panel.c | 4 ++--
> 5 files changed, 48 insertions(+), 42 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
> index b377753..de95c9c 100644
> --- a/drivers/gpu/drm/i915/i915_dma.c
> +++ b/drivers/gpu/drm/i915/i915_dma.c
> @@ -257,13 +257,6 @@ static int i915_get_bridge_dev(struct drm_device *dev)
> return 0;
> }
>
> -#define MCHBAR_I915 0x44
> -#define MCHBAR_I965 0x48
> -#define MCHBAR_SIZE (4*4096)
> -
> -#define DEVEN_REG 0x54
> -#define DEVEN_MCHBAR_EN (1 << 28)
> -
> /* Allocate space for the MCH regs if needed, return nonzero on error */
> static int
> intel_alloc_mchbar_resource(struct drm_device *dev)
> @@ -325,7 +318,7 @@ intel_setup_mchbar(struct drm_device *dev)
> dev_priv->mchbar_need_disable = false;
>
> if (IS_I915G(dev) || IS_I915GM(dev)) {
> - pci_read_config_dword(dev_priv->bridge_dev, DEVEN_REG, &temp);
> + pci_read_config_dword(dev_priv->bridge_dev, DEVEN, &temp);
> enabled = !!(temp & DEVEN_MCHBAR_EN);
> } else {
> pci_read_config_dword(dev_priv->bridge_dev, mchbar_reg, &temp);
> @@ -343,7 +336,7 @@ intel_setup_mchbar(struct drm_device *dev)
>
> /* Space is allocated or reserved, so enable it. */
> if (IS_I915G(dev) || IS_I915GM(dev)) {
> - pci_write_config_dword(dev_priv->bridge_dev, DEVEN_REG,
> + pci_write_config_dword(dev_priv->bridge_dev, DEVEN,
> temp | DEVEN_MCHBAR_EN);
> } else {
> pci_read_config_dword(dev_priv->bridge_dev, mchbar_reg, &temp);
> @@ -360,9 +353,9 @@ intel_teardown_mchbar(struct drm_device *dev)
>
> if (dev_priv->mchbar_need_disable) {
> if (IS_I915G(dev) || IS_I915GM(dev)) {
> - pci_read_config_dword(dev_priv->bridge_dev, DEVEN_REG, &temp);
> + pci_read_config_dword(dev_priv->bridge_dev, DEVEN, &temp);
> temp &= ~DEVEN_MCHBAR_EN;
> - pci_write_config_dword(dev_priv->bridge_dev, DEVEN_REG, temp);
> + pci_write_config_dword(dev_priv->bridge_dev, DEVEN, temp);
> } else {
> pci_read_config_dword(dev_priv->bridge_dev, mchbar_reg, &temp);
> temp &= ~1;
> diff --git a/drivers/gpu/drm/i915/i915_gem_stolen.c b/drivers/gpu/drm/i915/i915_gem_stolen.c
> index ea06da0..872ee45 100644
> --- a/drivers/gpu/drm/i915/i915_gem_stolen.c
> +++ b/drivers/gpu/drm/i915/i915_gem_stolen.c
> @@ -95,7 +95,7 @@ static unsigned long i915_stolen_to_physical(struct drm_device *dev)
> u32 base;
>
> /* Almost universally we can find the Graphics Base of Stolen Memory
> - * at offset 0x5c in the igfx configuration space. On a few (desktop)
> + * at register BDSM in the igfx configuration space. On a few (desktop)
Offset is easier to find in cspec, so please include both.
BDSM? That doesn't match your usage and cpsec refers to GBSM, iirc. I
know the code is bad, but it is not naughty!
-Chris
--
Chris Wilson, Intel Open Source Technology Centre
More information about the Intel-gfx
mailing list