[PATCH v2 1/7] drm/ttm: Don't override vm_ops callbacks, if set

Daniel Vetter daniel at ffwll.ch
Thu Apr 15 13:21:21 UTC 2021


On Thu, Apr 15, 2021 at 12:17:34PM +0200, Thomas Zimmermann wrote:
> Drivers may want to set their own callbacks for a VM area. Only set
> TTM's callbacks if the vm_ops field is clear.
> 
> Signed-off-by: Thomas Zimmermann <tzimmermann at suse.de>

Reviewed-by: Daniel Vetter <daniel.vetter at ffwll.ch>

> ---
>  drivers/gpu/drm/ttm/ttm_bo_vm.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/ttm/ttm_bo_vm.c b/drivers/gpu/drm/ttm/ttm_bo_vm.c
> index b31b18058965..bf4a213bc66c 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo_vm.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo_vm.c
> @@ -534,7 +534,12 @@ static struct ttm_buffer_object *ttm_bo_vm_lookup(struct ttm_device *bdev,
>  
>  static void ttm_bo_mmap_vma_setup(struct ttm_buffer_object *bo, struct vm_area_struct *vma)
>  {
> -	vma->vm_ops = &ttm_bo_vm_ops;
> +	/*
> +	 * Drivers may want to override the vm_ops field. Otherwise we
> +	 * use TTM's default callbacks.
> +	 */
> +	if (!vma->vm_ops)
> +		vma->vm_ops = &ttm_bo_vm_ops;
>  
>  	/*
>  	 * Note: We're transferring the bo reference to
> -- 
> 2.31.1
> 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch


More information about the dri-devel mailing list