[Intel-gfx] [PATCH 5/9] drm/i915: make dsm struct resource centric
Chris Wilson
chris at chris-wilson.co.uk
Tue Dec 5 23:30:20 UTC 2017
Quoting Matthew Auld (2017-12-05 21:02:45)
> Now that we are using struct resource to track the stolen region, it is
> more convenient if we track dsm in a resource as well.
>
> v2: check range_overflow when writing to 32b registers (Chris)
> pepper in some comments (Chris)
> v3: refit i915_stolen_to_dma()
>
> 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>
> ---
> void i915_gem_cleanup_stolen(struct drm_device *dev)
> @@ -187,7 +181,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;
>
> if ((reg_val & G4X_STOLEN_RESERVED_ENABLE) == 0) {
> *base = 0;
> @@ -318,7 +312,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;
>
> @@ -354,11 +348,15 @@ 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 = intel_graphics_stolen_res;
> +
> + if (i915_adjust_stolen(dev_priv, &dev_priv->dsm))
> return 0;
>
> - stolen_top = dev_priv->mm.stolen_base + ggtt->stolen_size;
> + GEM_BUG_ON(dev_priv->dsm.start == 0);
> + GEM_BUG_ON(ggtt->stolen_size > resource_size(&dev_priv->dsm));
> +
> + stolen_top = dev_priv->dsm.end + 1;
I'm in favour of making better use of having the resource.end, as above,
killing off manual recalculation of that from
dsm.start + resource_size(dsm).
-Chris
More information about the Intel-gfx
mailing list