Re: [PATCH v10 2/5] drm/gem/shmem: Introduce __drm_gem_shmem_free_sgt_locked()

Alexandre Courbot
2026-04-10T07:55:05Z

On Thu Apr 9, 2026 at 9:12 AM JST, Lyude Paul wrote:
> One of the complications of trying to use the shmem helpers to create a
> scatterlist for shmem objects is that we need to be able to provide a
> guarantee that the driver cannot be unbound for the lifetime of the
> scatterlist.
>
> The easiest way of handling this seems to be just hooking up an unmap
> operation to devres the first time we create a scatterlist, which allows us
> to still take advantage of gem shmem facilities without breaking that
> guarantee. To allow for this, we extract __drm_gem_shmem_free_sgt_locked()
> - which allows a caller (e.g. the rust bindings) to manually unmap the sgt
> for a gem object as needed.
>
> Signed-off-by: Lyude Paul <lyude@redhat.com>
> ---
> drivers/gpu/drm/drm_gem_shmem_helper.c | 32 +++++++++++++++++++++-----
> include/drm/drm_gem_shmem_helper.h | 1 +
> 2 files changed, 27 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_gem_shmem_helper.c b/drivers/gpu/drm/drm_gem_shmem_helper.c
> index 4500deef41278..addf8c1e5341e 100644
> --- a/drivers/gpu/drm/drm_gem_shmem_helper.c
> +++ b/drivers/gpu/drm/drm_gem_shmem_helper.c
> @@ -158,6 +158,30 @@ struct drm_gem_shmem_object *drm_gem_shmem_create(struct drm_device *dev, size_t
> }
> EXPORT_SYMBOL_GPL(drm_gem_shmem_create);
>
> +/**
> + * drm_gem_shmem_release_sgt_locked - Unpin and DMA unmap pages, and release the

The function name is missing the `__` prefix.

Outside of that, and fwiw,

Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>