[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <e2085799-e235-436a-8c5c-f6a51cbaeaaa@suse.de>
Date: Mon, 31 Mar 2025 09:15:51 +0200
From: Thomas Zimmermann <tzimmermann@...e.de>
To: Adrián Larumbe <adrian.larumbe@...labora.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>,
Maxime Ripard <mripard@...nel.org>, David Airlie <airlied@...il.com>,
Simona Vetter <simona@...ll.ch>,
Boris Brezillon <boris.brezillon@...labora.com>,
Rob Herring <robh@...nel.org>, Steven Price <steven.price@....com>,
Liviu Dudau <liviu.dudau@....com>
Cc: kernel@...labora.com, linux-kernel@...r.kernel.org,
dri-devel@...ts.freedesktop.org
Subject: Re: [RFC PATCH v2 5/6] drm/shmem: Add a helper to check object's page
backing status
Hi
Am 26.03.25 um 03:14 schrieb Adrián Larumbe:
> Provide a helper function that lets shmem API users know whether a given
> object is backed by physical pages, or else in the case of a sparse
> shmem object, at least one of them is populated.
>
> The obvious user is fdinfo, which needs to know an object's resident
> status.
>
> Signed-off-by: Adrián Larumbe <adrian.larumbe@...labora.com>
> ---
> drivers/gpu/drm/drm_gem_shmem_helper.c | 18 ++++++++++++++++++
> include/drm/drm_gem_shmem_helper.h | 2 ++
> 2 files changed, 20 insertions(+)
>
> diff --git a/drivers/gpu/drm/drm_gem_shmem_helper.c b/drivers/gpu/drm/drm_gem_shmem_helper.c
> index 1bf33e5a1c4c..79ac7c7c953f 100644
> --- a/drivers/gpu/drm/drm_gem_shmem_helper.c
> +++ b/drivers/gpu/drm/drm_gem_shmem_helper.c
> @@ -1033,6 +1033,24 @@ drm_gem_shmem_prime_import_sg_table(struct drm_device *dev,
> }
> EXPORT_SYMBOL_GPL(drm_gem_shmem_prime_import_sg_table);
>
> +/**
> + * drm_gem_shmem_is_populated - Tell whether the shem object is backed by
> + * at least one page of physical memory
> + * @shmem: shmem GEM object
> + *
> + * Returns:
> + * A boolean, where the 'true' value depends on at least one page being preset
> + * in a sparse object's xarray, or all the shmem file pages for PRIME buffers
> + * and regular shmem objects.
> + */
> +bool drm_gem_shmem_is_populated(struct drm_gem_shmem_object *shmem)
> +{
> + return (shmem->base.import_attach ||
The field import_attach should no longer be tested for detecting
imported buffers. Use drm_gem_is_imported() instead.
Best regards
Thomas
> + (!shmem->sparse && shmem->pages) ||
> + (shmem->sparse && !xa_empty(&shmem->xapages)));
> +}
> +EXPORT_SYMBOL_GPL(drm_gem_shmem_is_populated);
> +
> MODULE_DESCRIPTION("DRM SHMEM memory-management helpers");
> MODULE_IMPORT_NS("DMA_BUF");
> MODULE_LICENSE("GPL v2");
> diff --git a/include/drm/drm_gem_shmem_helper.h b/include/drm/drm_gem_shmem_helper.h
> index cbe4548e3ff6..60d2b8ef230b 100644
> --- a/include/drm/drm_gem_shmem_helper.h
> +++ b/include/drm/drm_gem_shmem_helper.h
> @@ -302,6 +302,8 @@ drm_gem_shmem_prime_import_sg_table(struct drm_device *dev,
> int drm_gem_shmem_dumb_create(struct drm_file *file, struct drm_device *dev,
> struct drm_mode_create_dumb *args);
>
> +bool drm_gem_shmem_is_populated(struct drm_gem_shmem_object *shmem);
> +
> /**
> * DRM_GEM_SHMEM_DRIVER_OPS - Default shmem GEM operations
> *
--
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)
Powered by blists - more mailing lists