From: Boris Brezillon <boris.brezillon@collabora.com>
To: "Adrián Larumbe" <adrian.larumbe@collabora.com>
Cc: Steven Price <steven.price@arm.com>,
Liviu Dudau <liviu.dudau@arm.com>,
Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Maxime Ripard <mripard@kernel.org>,
Thomas Zimmermann <tzimmermann@suse.de>,
David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
kernel@collabora.com, dri-devel@lists.freedesktop.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/4] drm/panthor: Introduce BO labeling
Date: Wed, 19 Mar 2025 17:49:34 +0100 [thread overview]
Message-ID: <20250319174934.3efce6e5@collabora.com> (raw)
In-Reply-To: <20250319150953.1634322-2-adrian.larumbe@collabora.com>
On Wed, 19 Mar 2025 15:03:16 +0000
Adrián Larumbe <adrian.larumbe@collabora.com> wrote:
> Add a new character string Panthor BO field, and a function that allows
> setting it from within the driver.
>
> Driver takes care of freeing the string when it's replaced or no longer
> needed at object destruction time, but allocating it is the responsibility
> of callers.
>
> Signed-off-by: Adrián Larumbe <adrian.larumbe@collabora.com>
> ---
> drivers/gpu/drm/panthor/panthor_gem.c | 24 ++++++++++++++++++++++++
> drivers/gpu/drm/panthor/panthor_gem.h | 17 +++++++++++++++++
> 2 files changed, 41 insertions(+)
>
> diff --git a/drivers/gpu/drm/panthor/panthor_gem.c b/drivers/gpu/drm/panthor/panthor_gem.c
> index 8244a4e6c2a2..165c7f4eb920 100644
> --- a/drivers/gpu/drm/panthor/panthor_gem.c
> +++ b/drivers/gpu/drm/panthor/panthor_gem.c
> @@ -18,6 +18,9 @@ static void panthor_gem_free_object(struct drm_gem_object *obj)
> struct panthor_gem_object *bo = to_panthor_bo(obj);
> struct drm_gem_object *vm_root_gem = bo->exclusive_vm_root_gem;
>
> + kfree(bo->label.str);
/* Label might have been allocated with kstrdup_const(),
* we need to take that into account when freeing the memory.
*/
kfree_const(bo->label.str);
> + mutex_destroy(&bo->label.lock);
> +
> drm_gem_free_mmap_offset(&bo->base.base);
> mutex_destroy(&bo->gpuva_list_lock);
> drm_gem_shmem_free(&bo->base);
> @@ -196,6 +199,7 @@ struct drm_gem_object *panthor_gem_create_object(struct drm_device *ddev, size_t
> obj->base.map_wc = !ptdev->coherent;
> mutex_init(&obj->gpuva_list_lock);
> drm_gem_gpuva_set_lock(&obj->base.base, &obj->gpuva_list_lock);
> + mutex_init(&obj->label.lock);
>
> return &obj->base.base;
> }
> @@ -247,3 +251,23 @@ panthor_gem_create_with_handle(struct drm_file *file,
>
> return ret;
> }
> +
> +void
> +panthor_gem_bo_set_label(struct drm_gem_object *obj, const char *label)
> +{
> + struct panthor_gem_object *bo = to_panthor_bo(obj);
> + const char *old_label;
> +
> + mutex_lock(&bo->label.lock);
> + old_label = bo->label.str;
> + bo->label.str = label;
> + mutex_unlock(&bo->label.lock);
> +
> + kfree(old_label);
> +}
> +
> +void
> +panthor_gem_kernel_bo_set_label(struct panthor_kernel_bo *bo, const char *label)
> +{
> + panthor_gem_bo_set_label(bo->obj, kstrdup_const(label, GFP_KERNEL));
You ignore the OOM case. Not sure it can happen in practice, and it's
probably okay if we keep going in that case, because this is just debug
information, but maybe this should be documented here.
> +}
> diff --git a/drivers/gpu/drm/panthor/panthor_gem.h b/drivers/gpu/drm/panthor/panthor_gem.h
> index 5749ef2ebe03..0582826b341a 100644
> --- a/drivers/gpu/drm/panthor/panthor_gem.h
> +++ b/drivers/gpu/drm/panthor/panthor_gem.h
> @@ -46,6 +46,20 @@ struct panthor_gem_object {
>
> /** @flags: Combination of drm_panthor_bo_flags flags. */
> u32 flags;
> +
> + /**
> + * @label: BO tagging fields. The label can be assigned within the
> + * driver itself or through a specific IOCTL.
> + */
> + struct {
> + /**
> + * @label.str: Pointer to NULL-terminated string,
> + */
> + const char *str;
> +
> + /** @lock.str: Protects access to the @label.str field. */
> + struct mutex lock;
> + } label;
> };
>
> /**
> @@ -91,6 +105,9 @@ panthor_gem_create_with_handle(struct drm_file *file,
> struct panthor_vm *exclusive_vm,
> u64 *size, u32 flags, uint32_t *handle);
>
> +void panthor_gem_bo_set_label(struct drm_gem_object *obj, const char *label);
> +void panthor_gem_kernel_bo_set_label(struct panthor_kernel_bo *bo, const char *label);
> +
> static inline u64
> panthor_kernel_bo_gpuva(struct panthor_kernel_bo *bo)
> {
next prev parent reply other threads:[~2025-03-19 16:49 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-19 15:03 [PATCH v2 0/4] Panthor BO tagging and GEMS debug display Adrián Larumbe
2025-03-19 15:03 ` [PATCH v2 1/4] drm/panthor: Introduce BO labeling Adrián Larumbe
2025-03-19 16:49 ` Boris Brezillon [this message]
2025-03-19 15:03 ` [PATCH v2 2/4] drm/panthor: Add driver IOCTL for setting BO labels Adrián Larumbe
2025-03-19 16:53 ` Boris Brezillon
2025-03-19 15:03 ` [PATCH v2 3/4] drm/panthor: show device-wide list of DRM GEM objects over DebugFS Adrián Larumbe
2025-03-19 15:03 ` [PATCH v2 4/4] drm/panthor: Display heap chunk entries in DebugFS GEMS file Adrián Larumbe
2025-03-19 17:00 ` Boris Brezillon
2025-03-27 13:18 ` Adrián Larumbe
2025-03-28 14:24 ` Boris Brezillon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250319174934.3efce6e5@collabora.com \
--to=boris.brezillon@collabora.com \
--cc=adrian.larumbe@collabora.com \
--cc=airlied@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=kernel@collabora.com \
--cc=linux-kernel@vger.kernel.org \
--cc=liviu.dudau@arm.com \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=simona@ffwll.ch \
--cc=steven.price@arm.com \
--cc=tzimmermann@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox