Re: [PATCH 4/4] drm/panthor: Display heap chunk entries in DebugFS GEMS file

From: Boris Brezillon
Date: Mon Mar 17 2025 - 04:33:43 EST


On Sun, 16 Mar 2025 21:51:35 +0000
Adrián Larumbe <adrian.larumbe@xxxxxxxxxxxxx> wrote:

> Expand the driver's DebugFS GEMS file to display entries for the heap
> chunks' GEM objects, both those allocated at heap creation time through an
> ioctl(), or in response to a tiler OOM event.
>
> Signed-off-by: Adrián Larumbe <adrian.larumbe@xxxxxxxxxxxxx>
> ---
> drivers/gpu/drm/panthor/panthor_heap.c | 15 +++++++++++++++
> 1 file changed, 15 insertions(+)
>
> diff --git a/drivers/gpu/drm/panthor/panthor_heap.c b/drivers/gpu/drm/panthor/panthor_heap.c
> index db0285ce5812..520d1fcf5c36 100644
> --- a/drivers/gpu/drm/panthor/panthor_heap.c
> +++ b/drivers/gpu/drm/panthor/panthor_heap.c
> @@ -139,6 +139,10 @@ static int panthor_alloc_heap_chunk(struct panthor_device *ptdev,
> struct panthor_heap_chunk *chunk;
> struct panthor_heap_chunk_header *hdr;
> int ret;
> +#ifdef CONFIG_DEBUG_FS
> + struct panthor_gem_object *obj;
> + const char *label;
> +#endif
>
> chunk = kmalloc(sizeof(*chunk), GFP_KERNEL);
> if (!chunk)
> @@ -180,6 +184,17 @@ static int panthor_alloc_heap_chunk(struct panthor_device *ptdev,
> heap->chunk_count++;
> mutex_unlock(&heap->lock);
>
> +#ifdef CONFIG_DEBUG_FS
> + obj = to_panthor_bo(chunk->bo->obj);
> +
> + mutex_lock(&ptdev->gems_lock);
> + list_add_tail(&obj->gems_node, &ptdev->gems);
> + mutex_unlock(&ptdev->gems_lock);
> +
> + label = kstrdup_const("\"Tiler heap chunk\"", GFP_KERNEL);

Do we really need the extra quotes around 'Tiler heap chunk'?

> + panthor_gem_label_bo(chunk->bo->obj, label);
> +#endif

Let's define a helper to assign a label to a kernel BO instead of
open-coding it here. BTW, I suspect we'll want to assign labels to
other kernel BOs too (FW buffers).

> +
> return 0;
>
> err_destroy_bo: