diff mbox

[1/5] drm/i915: Do not clear mappings beyond VMA size

Message ID 1429877343.19506.3.camel@jlahtine-mobl1 (mailing list archive)
State New, archived
Headers show

Commit Message

Joonas Lahtinen April 24, 2015, 12:09 p.m. UTC
Do not to clear mappings outside the allocated VMA under any
circumstances. Only clear the smaller of VMA or object page count.

This is required to allow creating partial object VMAs which in
turn are needed for partial GGTT views.

Signed-off-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
---
 drivers/gpu/drm/i915/i915_gem_gtt.c |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Comments

Tvrtko Ursulin April 27, 2015, 12:55 p.m. UTC | #1
On 04/24/2015 01:09 PM, Joonas Lahtinen wrote:
> Do not to clear mappings outside the allocated VMA under any
> circumstances. Only clear the smaller of VMA or object page count.
>
> This is required to allow creating partial object VMAs which in
> turn are needed for partial GGTT views.
>
> Signed-off-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> ---
>   drivers/gpu/drm/i915/i915_gem_gtt.c |    8 ++++++--
>   1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
> index 6fae6bd..ee9ff8e 100644
> --- a/drivers/gpu/drm/i915/i915_gem_gtt.c
> +++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
> @@ -1947,19 +1947,23 @@ static void ggtt_unbind_vma(struct i915_vma *vma)
>   	struct drm_device *dev = vma->vm->dev;
>   	struct drm_i915_private *dev_priv = dev->dev_private;
>   	struct drm_i915_gem_object *obj = vma->obj;
> +	const uint64_t size = min_t(uint64_t,
> +				    obj->base.size,
> +				    vma->node.size);
>
>   	if (vma->bound & GLOBAL_BIND) {
>   		vma->vm->clear_range(vma->vm,
>   				     vma->node.start,
> -				     obj->base.size,
> +				     size,
>   				     true);
>   	}
>
>   	if (dev_priv->mm.aliasing_ppgtt && vma->bound & LOCAL_BIND) {
>   		struct i915_hw_ppgtt *appgtt = dev_priv->mm.aliasing_ppgtt;
> +
>   		appgtt->base.clear_range(&appgtt->base,
>   					 vma->node.start,
> -					 obj->base.size,
> +					 size,
>   					 true);
>   	}
>   }
>

Looks good to me,

Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

Regards,

Tvrtko
Daniel Vetter May 4, 2015, 2:23 p.m. UTC | #2
On Mon, Apr 27, 2015 at 01:55:15PM +0100, Tvrtko Ursulin wrote:
> 
> On 04/24/2015 01:09 PM, Joonas Lahtinen wrote:
> >Do not to clear mappings outside the allocated VMA under any
> >circumstances. Only clear the smaller of VMA or object page count.
> >
> >This is required to allow creating partial object VMAs which in
> >turn are needed for partial GGTT views.
> >
> >Signed-off-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> >---
> >  drivers/gpu/drm/i915/i915_gem_gtt.c |    8 ++++++--
> >  1 file changed, 6 insertions(+), 2 deletions(-)
> >
> >diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
> >index 6fae6bd..ee9ff8e 100644
> >--- a/drivers/gpu/drm/i915/i915_gem_gtt.c
> >+++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
> >@@ -1947,19 +1947,23 @@ static void ggtt_unbind_vma(struct i915_vma *vma)
> >  	struct drm_device *dev = vma->vm->dev;
> >  	struct drm_i915_private *dev_priv = dev->dev_private;
> >  	struct drm_i915_gem_object *obj = vma->obj;
> >+	const uint64_t size = min_t(uint64_t,
> >+				    obj->base.size,
> >+				    vma->node.size);
> >
> >  	if (vma->bound & GLOBAL_BIND) {
> >  		vma->vm->clear_range(vma->vm,
> >  				     vma->node.start,
> >-				     obj->base.size,
> >+				     size,
> >  				     true);
> >  	}
> >
> >  	if (dev_priv->mm.aliasing_ppgtt && vma->bound & LOCAL_BIND) {
> >  		struct i915_hw_ppgtt *appgtt = dev_priv->mm.aliasing_ppgtt;
> >+
> >  		appgtt->base.clear_range(&appgtt->base,
> >  					 vma->node.start,
> >-					 obj->base.size,
> >+					 size,
> >  					 true);
> >  	}
> >  }
> >
> 
> Looks good to me,
> 
> Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

Queued for -next, thanks for the patch.
-Daniel
diff mbox

Patch

diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
index 6fae6bd..ee9ff8e 100644
--- a/drivers/gpu/drm/i915/i915_gem_gtt.c
+++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
@@ -1947,19 +1947,23 @@  static void ggtt_unbind_vma(struct i915_vma *vma)
 	struct drm_device *dev = vma->vm->dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct drm_i915_gem_object *obj = vma->obj;
+	const uint64_t size = min_t(uint64_t,
+				    obj->base.size,
+				    vma->node.size);
 
 	if (vma->bound & GLOBAL_BIND) {
 		vma->vm->clear_range(vma->vm,
 				     vma->node.start,
-				     obj->base.size,
+				     size,
 				     true);
 	}
 
 	if (dev_priv->mm.aliasing_ppgtt && vma->bound & LOCAL_BIND) {
 		struct i915_hw_ppgtt *appgtt = dev_priv->mm.aliasing_ppgtt;
+
 		appgtt->base.clear_range(&appgtt->base,
 					 vma->node.start,
-					 obj->base.size,
+					 size,
 					 true);
 	}
 }