Patchwork [10/10] drm/i915: prefer stolen_usable_size for the range sanity check

login
register
mail settings
Submitter Matthew Auld
Date Dec. 6, 2017, 6:17 p.m.
Message ID <20171206181730.30551-11-matthew.auld@intel.com>
Download mbox | patch
Permalink /patch/10096753/
State New
Headers show

Comments

Matthew Auld - Dec. 6, 2017, 6:17 p.m.
In i915_pages_create_for_stolen it probably makes more sense to check if
the range overflows the stolen_usable_size, since the size of dsm will also
include the reserved portion which we can't touch.

Signed-off-by: Matthew Auld <matthew.auld@intel.com>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Paulo Zanoni <paulo.r.zanoni@intel.com>
---
 drivers/gpu/drm/i915/i915_gem_stolen.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Chris Wilson - Dec. 6, 2017, 6:41 p.m.
Quoting Matthew Auld (2017-12-06 18:17:30)
> In i915_pages_create_for_stolen it probably makes more sense to check if
> the range overflows the stolen_usable_size, since the size of dsm will also
> include the reserved portion which we can't touch.
> 
> Signed-off-by: Matthew Auld <matthew.auld@intel.com>
> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> Cc: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Paulo Zanoni <paulo.r.zanoni@intel.com>
> ---
>  drivers/gpu/drm/i915/i915_gem_stolen.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_gem_stolen.c b/drivers/gpu/drm/i915/i915_gem_stolen.c
> index 2267af68c3e1..f8c9f0446712 100644
> --- a/drivers/gpu/drm/i915/i915_gem_stolen.c
> +++ b/drivers/gpu/drm/i915/i915_gem_stolen.c
> @@ -430,7 +430,7 @@ i915_pages_create_for_stolen(struct drm_device *dev,
>         struct sg_table *st;
>         struct scatterlist *sg;
>  
> -       GEM_BUG_ON(range_overflows(offset, size, resource_size(&dev_priv->dsm)));
> +       GEM_BUG_ON(range_overflows(offset, size, dev_priv->stolen_usable_size));

I'm not sold. The usable size is a restriction placed on the drm_mm
range manager that not everyone may be privy to; certainly when coming
from HW that knows only about the stolen region.
-Chris

Patch

diff --git a/drivers/gpu/drm/i915/i915_gem_stolen.c b/drivers/gpu/drm/i915/i915_gem_stolen.c
index 2267af68c3e1..f8c9f0446712 100644
--- a/drivers/gpu/drm/i915/i915_gem_stolen.c
+++ b/drivers/gpu/drm/i915/i915_gem_stolen.c
@@ -430,7 +430,7 @@  i915_pages_create_for_stolen(struct drm_device *dev,
 	struct sg_table *st;
 	struct scatterlist *sg;
 
-	GEM_BUG_ON(range_overflows(offset, size, resource_size(&dev_priv->dsm)));
+	GEM_BUG_ON(range_overflows(offset, size, dev_priv->stolen_usable_size));
 
 	/* We hide that we have no struct page backing our stolen object
 	 * by wrapping the contiguous physical allocation with a fake