Re: [PATCH v18 17/26] drm/v3d: Explicitly get and put drm-shmem pages

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 30 Oct 2023 02:01:56 +0300
Dmitry Osipenko <dmitry.osipenko@xxxxxxxxxxxxx> wrote:

> To simplify the drm-shmem refcnt handling, we're moving away from
> the implicit get_pages() that is used by get_pages_sgt(). From now on
> drivers will have to pin pages while they use sgt. V3D driver doesn't
> support shrinker, hence pages are pinned and sgt is valid as long as
> pages' use-count > 0.
> 
> Signed-off-by: Dmitry Osipenko <dmitry.osipenko@xxxxxxxxxxxxx>

Reviewed-by: Boris Brezillon <boris.brezillon@xxxxxxxxxxxxx>

> ---
>  drivers/gpu/drm/v3d/v3d_bo.c | 11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/v3d/v3d_bo.c b/drivers/gpu/drm/v3d/v3d_bo.c
> index 42cd874f6810..0597c6b01b6c 100644
> --- a/drivers/gpu/drm/v3d/v3d_bo.c
> +++ b/drivers/gpu/drm/v3d/v3d_bo.c
> @@ -47,6 +47,9 @@ void v3d_free_object(struct drm_gem_object *obj)
>  	/* GPU execution may have dirtied any pages in the BO. */
>  	bo->base.pages_mark_dirty_on_put = true;
>  
> +	if (!obj->import_attach)
> +		drm_gem_shmem_put_pages(&bo->base);
> +
>  	drm_gem_shmem_free(&bo->base);
>  }
>  
> @@ -135,12 +138,18 @@ struct v3d_bo *v3d_bo_create(struct drm_device *dev, struct drm_file *file_priv,
>  		return ERR_CAST(shmem_obj);
>  	bo = to_v3d_bo(&shmem_obj->base);
>  
> -	ret = v3d_bo_create_finish(&shmem_obj->base);
> +	ret = drm_gem_shmem_get_pages(shmem_obj);
>  	if (ret)
>  		goto free_obj;
>  
> +	ret = v3d_bo_create_finish(&shmem_obj->base);
> +	if (ret)
> +		goto put_pages;
> +
>  	return bo;
>  
> +put_pages:
> +	drm_gem_shmem_put_pages(shmem_obj);
>  free_obj:
>  	drm_gem_shmem_free(shmem_obj);
>  	return ERR_PTR(ret);





[Index of Archives]     [KVM Development]     [Libvirt Development]     [Libvirt Users]     [CentOS Virtualization]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux