Re: [PATCH v13 07/10] drm/gem: Get rid of *_with_mnt helpers

Maíra Canal
2025-12-07T14:16:53Z

Hi Loïc,

On 05/12/25 15:22, Loïc Molinari wrote:
> drm_gem_object_init_with_mnt() and drm_gem_shmem_create_with_mnt() can
> be removed now that the drivers use the new drm_gem_huge_mnt_create()
> and drm_gem_get_huge_mnt() helpers.
>
> v5:
> - use drm_gem_has_huge_mnt() helper
> - compile out shmem_file_setup_with_mnt() call in builds with
> CONFIG_TRANSPARENT_HUGEPAGE=n
>
> v9:
> - replace drm_gem_has_huge_mnt() with drm_gem_get_huge_mnt()
>
> Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
> Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>

Reviewed-by: Maíra Canal <mcanal@igalia.com>

Best Regards,
- Maíra

> ---
> drivers/gpu/drm/drm_gem.c | 37 +++++++------------------
> drivers/gpu/drm/drm_gem_shmem_helper.c | 38 ++++++--------------------
> drivers/gpu/drm/v3d/v3d_bo.c | 3 +-
> include/drm/drm_gem.h | 3 --
> include/drm/drm_gem_shmem_helper.h | 3 --
> 5 files changed, 19 insertions(+), 65 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
> index 32dddb23e211..6021c4087a08 100644
> --- a/drivers/gpu/drm/drm_gem.c
> +++ b/drivers/gpu/drm/drm_gem.c
> @@ -171,29 +171,28 @@ drm_gem_init(struct drm_device *dev)
> }
>
> /**
> - * drm_gem_object_init_with_mnt - initialize an allocated shmem-backed GEM
> - * object in a given shmfs mountpoint
> + * drm_gem_object_init - initialize an allocated shmem-backed GEM object
> *
> * @dev: drm_device the object should be initialized for
> * @obj: drm_gem_object to initialize
> * @size: object size
> - * @gemfs: tmpfs mount where the GEM object will be created. If NULL, use
> - * the usual tmpfs mountpoint (`shm_mnt`).
> *
> * Initialize an already allocated GEM object of the specified size with
> - * shmfs backing store.
> + * shmfs backing store. A huge mountpoint can be used by calling
> + * drm_gem_huge_mnt_create() beforehand.
> */
> -int drm_gem_object_init_with_mnt(struct drm_device *dev,
> - struct drm_gem_object *obj, size_t size,
> - struct vfsmount *gemfs)
> +int drm_gem_object_init(struct drm_device *dev, struct drm_gem_object *obj,
> + size_t size)
> {
> + struct vfsmount *huge_mnt;
> struct file *filp;
>
> drm_gem_private_object_init(dev, obj, size);
>
> - if (gemfs)
> - filp = shmem_file_setup_with_mnt(gemfs, "drm mm object", size,
> - VM_NORESERVE);
> + huge_mnt = drm_gem_get_huge_mnt(dev);
> + if (huge_mnt)
> + filp = shmem_file_setup_with_mnt(huge_mnt, "drm mm object",
> + size, VM_NORESERVE);
> else
> filp = shmem_file_setup("drm mm object", size, VM_NORESERVE);
>
> @@ -204,22 +203,6 @@ int drm_gem_object_init_with_mnt(struct drm_device *dev,
>
> return 0;
> }
> -EXPORT_SYMBOL(drm_gem_object_init_with_mnt);
> -
> -/**
> - * drm_gem_object_init - initialize an allocated shmem-backed GEM object
> - * @dev: drm_device the object should be initialized for
> - * @obj: drm_gem_object to initialize
> - * @size: object size
> - *
> - * Initialize an already allocated GEM object of the specified size with
> - * shmfs backing store.
> - */
> -int drm_gem_object_init(struct drm_device *dev, struct drm_gem_object *obj,
> - size_t size)
> -{
> - return drm_gem_object_init_with_mnt(dev, obj, size, NULL);
> -}
> EXPORT_SYMBOL(drm_gem_object_init);
>
> /**
> diff --git a/drivers/gpu/drm/drm_gem_shmem_helper.c b/drivers/gpu/drm/drm_gem_shmem_helper.c
> index e67216cbb469..f8bcd1b0eb32 100644
> --- a/drivers/gpu/drm/drm_gem_shmem_helper.c
> +++ b/drivers/gpu/drm/drm_gem_shmem_helper.c
> @@ -50,7 +50,7 @@ static const struct drm_gem_object_funcs drm_gem_shmem_funcs = {
> };
>
> static int __drm_gem_shmem_init(struct drm_device *dev, struct drm_gem_shmem_object *shmem,
> - size_t size, bool private, struct vfsmount *gemfs)
> + size_t size, bool private)
> {
> struct drm_gem_object *obj = &shmem->base;
> int ret = 0;
> @@ -62,7 +62,7 @@ static int __drm_gem_shmem_init(struct drm_device *dev, struct drm_gem_shmem_obj
> drm_gem_private_object_init(dev, obj, size);
> shmem->map_wc = false; /* dma-buf mappings use always writecombine */
> } else {
> - ret = drm_gem_object_init_with_mnt(dev, obj, size, gemfs);
> + ret = drm_gem_object_init(dev, obj, size);
> }
> if (ret) {
> drm_gem_private_object_fini(obj);
> @@ -103,13 +103,12 @@ static int __drm_gem_shmem_init(struct drm_device *dev, struct drm_gem_shmem_obj
> */
> int drm_gem_shmem_init(struct drm_device *dev, struct drm_gem_shmem_object *shmem, size_t size)
> {
> - return __drm_gem_shmem_init(dev, shmem, size, false, NULL);
> + return __drm_gem_shmem_init(dev, shmem, size, false);
> }
> EXPORT_SYMBOL_GPL(drm_gem_shmem_init);
>
> static struct drm_gem_shmem_object *
> -__drm_gem_shmem_create(struct drm_device *dev, size_t size, bool private,
> - struct vfsmount *gemfs)
> +__drm_gem_shmem_create(struct drm_device *dev, size_t size, bool private)
> {
> struct drm_gem_shmem_object *shmem;
> struct drm_gem_object *obj;
> @@ -129,7 +128,7 @@ __drm_gem_shmem_create(struct drm_device *dev, size_t size, bool private,
> obj = &shmem->base;
> }
>
> - ret = __drm_gem_shmem_init(dev, shmem, size, private, gemfs);
> + ret = __drm_gem_shmem_init(dev, shmem, size, private);
> if (ret) {
> kfree(obj);
> return ERR_PTR(ret);
> @@ -150,31 +149,10 @@ __drm_gem_shmem_create(struct drm_device *dev, size_t size, bool private,
> */
> struct drm_gem_shmem_object *drm_gem_shmem_create(struct drm_device *dev, size_t size)
> {
> - return __drm_gem_shmem_create(dev, size, false, NULL);
> + return __drm_gem_shmem_create(dev, size, false);
> }
> EXPORT_SYMBOL_GPL(drm_gem_shmem_create);
>
> -/**
> - * drm_gem_shmem_create_with_mnt - Allocate an object with the given size in a
> - * given mountpoint
> - * @dev: DRM device
> - * @size: Size of the object to allocate
> - * @gemfs: tmpfs mount where the GEM object will be created
> - *
> - * This function creates a shmem GEM object in a given tmpfs mountpoint.
> - *
> - * Returns:
> - * A struct drm_gem_shmem_object * on success or an ERR_PTR()-encoded negative
> - * error code on failure.
> - */
> -struct drm_gem_shmem_object *drm_gem_shmem_create_with_mnt(struct drm_device *dev,
> - size_t size,
> - struct vfsmount *gemfs)
> -{
> - return __drm_gem_shmem_create(dev, size, false, gemfs);
> -}
> -EXPORT_SYMBOL_GPL(drm_gem_shmem_create_with_mnt);
> -
> /**
> * drm_gem_shmem_release - Release resources associated with a shmem GEM object.
> * @shmem: shmem GEM object
> @@ -851,7 +829,7 @@ drm_gem_shmem_prime_import_sg_table(struct drm_device *dev,
> size_t size = PAGE_ALIGN(attach->dmabuf->size);
> struct drm_gem_shmem_object *shmem;
>
> - shmem = __drm_gem_shmem_create(dev, size, true, NULL);
> + shmem = __drm_gem_shmem_create(dev, size, true);
> if (IS_ERR(shmem))
> return ERR_CAST(shmem);
>
> @@ -899,7 +877,7 @@ struct drm_gem_object *drm_gem_shmem_prime_import_no_map(struct drm_device *dev,
>
> size = PAGE_ALIGN(attach->dmabuf->size);
>
> - shmem = __drm_gem_shmem_create(dev, size, true, NULL);
> + shmem = __drm_gem_shmem_create(dev, size, true);
> if (IS_ERR(shmem)) {
> ret = PTR_ERR(shmem);
> goto fail_detach;
> diff --git a/drivers/gpu/drm/v3d/v3d_bo.c b/drivers/gpu/drm/v3d/v3d_bo.c
> index 3ee8d9c36d92..c4316b768b3d 100644
> --- a/drivers/gpu/drm/v3d/v3d_bo.c
> +++ b/drivers/gpu/drm/v3d/v3d_bo.c
> @@ -153,8 +153,7 @@ struct v3d_bo *v3d_bo_create(struct drm_device *dev, struct drm_file *file_priv,
> struct v3d_bo *bo;
> int ret;
>
> - shmem_obj = drm_gem_shmem_create_with_mnt(dev, unaligned_size,
> - drm_gem_get_huge_mnt(dev));
> + shmem_obj = drm_gem_shmem_create(dev, unaligned_size);
> if (IS_ERR(shmem_obj))
> return ERR_CAST(shmem_obj);
> bo = to_v3d_bo(&shmem_obj->base);
> diff --git a/include/drm/drm_gem.h b/include/drm/drm_gem.h
> index 97b5fca8966d..cca815dc87f3 100644
> --- a/include/drm/drm_gem.h
> +++ b/include/drm/drm_gem.h
> @@ -529,9 +529,6 @@ void drm_gem_object_release(struct drm_gem_object *obj);
> void drm_gem_object_free(struct kref *kref);
> int drm_gem_object_init(struct drm_device *dev,
> struct drm_gem_object *obj, size_t size);
> -int drm_gem_object_init_with_mnt(struct drm_device *dev,
> - struct drm_gem_object *obj, size_t size,
> - struct vfsmount *gemfs);
> void drm_gem_private_object_init(struct drm_device *dev,
> struct drm_gem_object *obj, size_t size);
> void drm_gem_private_object_fini(struct drm_gem_object *obj);
> diff --git a/include/drm/drm_gem_shmem_helper.h b/include/drm/drm_gem_shmem_helper.h
> index 589f7bfe7506..6b6478f5ca24 100644
> --- a/include/drm/drm_gem_shmem_helper.h
> +++ b/include/drm/drm_gem_shmem_helper.h
> @@ -109,9 +109,6 @@ struct drm_gem_shmem_object {
>
> int drm_gem_shmem_init(struct drm_device *dev, struct drm_gem_shmem_object *shmem, size_t size);
> struct drm_gem_shmem_object *drm_gem_shmem_create(struct drm_device *dev, size_t size);
> -struct drm_gem_shmem_object *drm_gem_shmem_create_with_mnt(struct drm_device *dev,
> - size_t size,
> - struct vfsmount *gemfs);
> void drm_gem_shmem_release(struct drm_gem_shmem_object *shmem);
> void drm_gem_shmem_free(struct drm_gem_shmem_object *shmem);
>