[Intel-gfx] [PATCH 05/15] drm/i915: Only refcount ppgtt if it actually is one

Thierry, Michel michel.thierry at intel.com
Fri Aug 8 15:02:49 CEST 2014



> -----Original Message-----
> From: Intel-gfx [mailto:intel-gfx-bounces at lists.freedesktop.org] On Behalf
> Of Daniel Vetter
> Sent: Wednesday, August 06, 2014 2:05 PM
> To: Intel Graphics Development
> Cc: Daniel Vetter
> Subject: [Intel-gfx] [PATCH 05/15] drm/i915: Only refcount ppgtt if it
actually
> is one
> 
> This essentially unbreaks non-ppgtt operation where we'd scribble over
> random memory.
> 
> While at it give the vm_to_ppgtt function a proper prefix and make it
> a bit more paranoid.
> 
> Signed-off-by: Daniel Vetter <daniel.vetter at ffwll.ch>
> ---
>  drivers/gpu/drm/i915/i915_drv.h     | 10 +++++++++-
>  drivers/gpu/drm/i915/i915_gem.c     |  3 ++-
>  drivers/gpu/drm/i915/i915_gem_gtt.c |  3 ++-
>  3 files changed, 13 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_drv.h
> b/drivers/gpu/drm/i915/i915_drv.h
> index 194367f0ba1a..31422bc07445 100644
> --- a/drivers/gpu/drm/i915/i915_drv.h
> +++ b/drivers/gpu/drm/i915/i915_drv.h
> @@ -2475,6 +2475,15 @@ static inline bool i915_is_ggtt(struct
> i915_address_space *vm)
>  	return vm == ggtt;
>  }
> 
> +static inline struct i915_hw_ppgtt *
> +i915_vm_to_ppgtt(struct i915_address_space *vm)
> +{
> +	WARN_ON(i915_is_ggtt(vm));
> +
> +	return container_of(vm, struct i915_hw_ppgtt, base);
> +}
> +
> +
>  static inline bool i915_gem_obj_ggtt_bound(struct drm_i915_gem_object
> *obj)
>  {
>  	return i915_gem_obj_bound(obj, obj_to_ggtt(obj));
> @@ -2510,7 +2519,6 @@ void i915_gem_object_ggtt_unpin(struct
> drm_i915_gem_object *obj);
> 
>  /* i915_gem_context.c */
>  #define ctx_to_ppgtt(ctx) container_of((ctx)->vm, struct i915_hw_ppgtt,
> base)
> -#define vm_to_ppgtt(vm) container_of(vm, struct i915_hw_ppgtt, base)
>  int __must_check i915_gem_context_init(struct drm_device *dev);
>  void i915_gem_context_fini(struct drm_device *dev);
>  void i915_gem_context_reset(struct drm_device *dev);
> diff --git a/drivers/gpu/drm/i915/i915_gem.c
> b/drivers/gpu/drm/i915/i915_gem.c
> index b33a677b4b1e..c43ccfdf45a5 100644
> --- a/drivers/gpu/drm/i915/i915_gem.c
> +++ b/drivers/gpu/drm/i915/i915_gem.c
> @@ -4508,7 +4508,8 @@ void i915_gem_vma_destroy(struct i915_vma
> *vma)
> 
>  	vm = vma->vm;
> 
> -	i915_ppgtt_put(vm_to_ppgtt(vm));
> +	if (!i915_is_ggtt(vm))
> +		i915_ppgtt_put(i915_vm_to_ppgtt(vm));
> 
>  	list_del(&vma->vma_link);
> 
> diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c
> b/drivers/gpu/drm/i915/i915_gem_gtt.c
> index 83ee41e5c1c7..3753bf184865 100644
> --- a/drivers/gpu/drm/i915/i915_gem_gtt.c
> +++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
> @@ -2204,7 +2204,8 @@ i915_gem_obj_lookup_or_create_vma(struct
> drm_i915_gem_object *obj,
>  	if (!vma)
>  		vma = __i915_gem_vma_create(obj, vm);
> 
> -	i915_ppgtt_get(vm_to_ppgtt(vm));
> +	if (!i915_is_ggtt(vm))
> +		i915_ppgtt_get(i915_vm_to_ppgtt(vm));
> 
>  	return vma;
>  }
> --
> 1.9.3

Reviewed-by: Michel Thierry <michel.thierry at intel.com>
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 6656 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/intel-gfx/attachments/20140808/fdcf0372/attachment.bin>


More information about the Intel-gfx mailing list