[Intel-gfx] [PATCH 3/6] drm/i915: make dsm struct resource centric
Chris Wilson
chris at chris-wilson.co.uk
Thu Nov 23 13:03:46 UTC 2017
Quoting Matthew Auld (2017-11-22 21:19:17)
> Signed-off-by: Matthew Auld <matthew.auld at intel.com>
> Cc: Joonas Lahtinen <joonas.lahtinen at linux.intel.com>
> Cc: Chris Wilson <chris at chris-wilson.co.uk>
> Cc: Paulo Zanoni <paulo.r.zanoni at intel.com>
> ---
> drivers/gpu/drm/i915/i915_drv.h | 5 ++---
> drivers/gpu/drm/i915/i915_gem_stolen.c | 19 +++++++++++--------
> drivers/gpu/drm/i915/intel_fbc.c | 4 ++--
> drivers/gpu/drm/i915/intel_pm.c | 8 ++++----
> 4 files changed, 19 insertions(+), 17 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
> index d575a56fc100..6136f92d5188 100644
> --- a/drivers/gpu/drm/i915/i915_drv.h
> +++ b/drivers/gpu/drm/i915/i915_drv.h
> @@ -1536,9 +1536,6 @@ struct i915_gem_mm {
> */
> struct pagevec wc_stash;
>
> - /** Usable portion of the GTT for GEM */
> - dma_addr_t stolen_base; /* limited to low memory (32-bit) */
> -
> /**
> * tmpfs instance used for shmem backed objects
> */
> @@ -2252,6 +2249,8 @@ struct drm_i915_private {
>
> const struct intel_device_info info;
>
> + struct resource dsm;
> +
Next patch, keep the dsm grouped. Don't forget some comment here, if at
least to expand the acronym and explanation of where it comes from and
what purpose we could use it for, trying to keep it reasonably general.
> void __iomem *regs;
>
> struct intel_uncore uncore;
> diff --git a/drivers/gpu/drm/i915/i915_gem_stolen.c b/drivers/gpu/drm/i915/i915_gem_stolen.c
> index f1b8eeda0058..36c8ec04fd7a 100644
> --- a/drivers/gpu/drm/i915/i915_gem_stolen.c
> +++ b/drivers/gpu/drm/i915/i915_gem_stolen.c
> @@ -185,7 +185,7 @@ static void g4x_get_stolen_reserved(struct drm_i915_private *dev_priv,
> uint32_t reg_val = I915_READ(IS_GM45(dev_priv) ?
> CTG_STOLEN_RESERVED :
> ELK_STOLEN_RESERVED);
> - dma_addr_t stolen_top = dev_priv->mm.stolen_base + ggtt->stolen_size;
> + dma_addr_t stolen_top = dev_priv->dsm.start + ggtt->stolen_size;
Did you update stolen_top to resource_size_t ?
>
> if ((reg_val & G4X_STOLEN_RESERVED_ENABLE) == 0) {
> *base = 0;
> @@ -316,7 +316,7 @@ static void bdw_get_stolen_reserved(struct drm_i915_private *dev_priv,
> return;
> }
>
> - stolen_top = dev_priv->mm.stolen_base + ggtt->stolen_size;
> + stolen_top = dev_priv->dsm.start + ggtt->stolen_size;
>
> *base = reg_val & GEN6_STOLEN_RESERVED_ADDR_MASK;
>
> @@ -352,11 +352,14 @@ int i915_gem_init_stolen(struct drm_i915_private *dev_priv)
> if (ggtt->stolen_size == 0)
> return 0;
>
> - dev_priv->mm.stolen_base = i915_stolen_to_dma(dev_priv);
> - if (dev_priv->mm.stolen_base == 0)
> + dev_priv->dsm.start = i915_stolen_to_dma(dev_priv);
> + if (dev_priv->dsm.start == 0)
> return 0;
>
> - stolen_top = dev_priv->mm.stolen_base + ggtt->stolen_size;
> + dev_priv->dsm.end = dev_priv->dsm.start + ggtt->stolen_size - 1;
> + dev_priv->dsm.flags = IORESOURCE_MEM;
> +
> + stolen_top = dev_priv->dsm.end + 1;
> reserved_base = 0;
> reserved_size = 0;
>
> @@ -397,12 +400,12 @@ int i915_gem_init_stolen(struct drm_i915_private *dev_priv)
> reserved_base = stolen_top;
> }
>
> - if (reserved_base < dev_priv->mm.stolen_base ||
> + if (reserved_base < dev_priv->dsm.start ||
> reserved_base + reserved_size > stolen_top) {
> dma_addr_t reserved_top = reserved_base + reserved_size;
> DRM_ERROR("Stolen reserved area [%pad - %pad] outside stolen memory [%pad - %pad]\n",
> &reserved_base, &reserved_top,
> - &dev_priv->mm.stolen_base, &stolen_top);
> + &dev_priv->dsm.start, &stolen_top);
> return 0;
> }
>
> @@ -460,7 +463,7 @@ i915_pages_create_for_stolen(struct drm_device *dev,
> sg->offset = 0;
> sg->length = size;
>
> - sg_dma_address(sg) = (dma_addr_t)dev_priv->mm.stolen_base + offset;
> + sg_dma_address(sg) = (dma_addr_t)dev_priv->dsm.start + offset;
> sg_dma_len(sg) = size;
>
> return st;
> diff --git a/drivers/gpu/drm/i915/intel_fbc.c b/drivers/gpu/drm/i915/intel_fbc.c
> index 4aefc658a5cf..374cfe8a33ad 100644
> --- a/drivers/gpu/drm/i915/intel_fbc.c
> +++ b/drivers/gpu/drm/i915/intel_fbc.c
> @@ -616,9 +616,9 @@ static int intel_fbc_alloc_cfb(struct intel_crtc *crtc)
> fbc->compressed_llb = compressed_llb;
>
> I915_WRITE(FBC_CFB_BASE,
> - dev_priv->mm.stolen_base + fbc->compressed_fb.start);
> + dev_priv->dsm.start + fbc->compressed_fb.start);
> I915_WRITE(FBC_LL_BASE,
> - dev_priv->mm.stolen_base + compressed_llb->start);
> + dev_priv->dsm.start + compressed_llb->start);
Around here we need
GEM_BUG_ON(range_overflow(dev_priv->dsm.start, blah->start, U32_MAX));
Similarly for all the write into 32bit registers.
> }
>
> DRM_DEBUG_KMS("reserved %llu bytes of contiguous stolen space for FBC, threshold: %d\n",
> diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c
> index 7d41aad79166..4a326bbdac6c 100644
> --- a/drivers/gpu/drm/i915/intel_pm.c
> +++ b/drivers/gpu/drm/i915/intel_pm.c
> @@ -7070,7 +7070,7 @@ static void valleyview_check_pctx(struct drm_i915_private *dev_priv)
> {
> unsigned long pctx_addr = I915_READ(VLV_PCBR) & ~4095;
>
> - WARN_ON(pctx_addr != dev_priv->mm.stolen_base +
> + WARN_ON(pctx_addr != dev_priv->dsm.start +
> dev_priv->vlv_pctx->stolen->start);
> }
>
> @@ -7093,7 +7093,7 @@ static void cherryview_setup_pctx(struct drm_i915_private *dev_priv)
> pcbr = I915_READ(VLV_PCBR);
> if ((pcbr >> VLV_PCBR_ADDR_SHIFT) == 0) {
> DRM_DEBUG_DRIVER("BIOS didn't set up PCBR, fixing up\n");
> - paddr = (dev_priv->mm.stolen_base +
> + paddr = (dev_priv->dsm.start +
> (ggtt->stolen_size - pctx_size));
>
> pctx_paddr = (paddr & (~4095));
> @@ -7115,7 +7115,7 @@ static void valleyview_setup_pctx(struct drm_i915_private *dev_priv)
> /* BIOS set it up already, grab the pre-alloc'd space */
> int pcbr_offset;
>
> - pcbr_offset = (pcbr & (~4095)) - dev_priv->mm.stolen_base;
> + pcbr_offset = (pcbr & (~4095)) - dev_priv->dsm.start;
> pctx = i915_gem_object_create_stolen_for_preallocated(dev_priv,
> pcbr_offset,
These stolen interfaces should also be updated to take resource_size_t.
-Chris
More information about the Intel-gfx
mailing list