panfrost: Label kernel BO's for newly created objects

To this end, provide a helper that passes the label to the kmod layer
upon demand. Helper returns the old label, in preparation for future
commits in which the label might not be in static RO memory, but
dynamically alocated instead, and its lifetime managed by the resource
layer.

Signed-off-by: Adrián Larumbe <adrian.larumbe@collabora.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34224>
This commit is contained in:
Adrián Larumbe
2025-06-12 01:37:43 +01:00
committed by Marge Bot
parent 32b128be01
commit b9b1c5438e
2 changed files with 26 additions and 3 deletions
+18 -3
View File
@@ -112,8 +112,8 @@ panfrost_bo_alloc(struct panfrost_device *dev, size_t size, uint32_t flags,
bo->ptr.gpu = vm_op.va.start;
bo->flags = flags;
bo->dev = dev;
bo->label = label;
return bo;
err_bind:
pan_kmod_bo_put(kmod_bo);
/* BO will be freed with the sparse array, but zero to indicate free */
@@ -243,7 +243,6 @@ panfrost_bo_cache_fetch(struct panfrost_device *dev, size_t size,
}
/* Let's go! */
bo = entry;
bo->label = label;
break;
}
pthread_mutex_unlock(&dev->bo_cache.lock);
@@ -309,7 +308,7 @@ panfrost_bo_cache_put(struct panfrost_bo *bo)
panfrost_bo_cache_evict_stale_bos(dev);
/* Update the label to help debug BO cache memory usage issues */
bo->label = "Unused (BO cache)";
panfrost_bo_set_label(bo, "Unused (BO cache)");
/* Must be last */
pthread_mutex_unlock(&dev->bo_cache.lock);
@@ -439,6 +438,8 @@ panfrost_bo_create(struct panfrost_device *dev, size_t size, uint32_t flags,
panfrost_bo_size(bo), NULL);
}
panfrost_bo_set_label(bo, label);
return bo;
}
@@ -571,3 +572,17 @@ panfrost_bo_from_kmod_bo(struct panfrost_device *dev,
return bo;
}
const char *
panfrost_bo_replace_label(struct panfrost_bo *bo, const char *label,
bool set_kernel_label)
{
const char *old_label = bo->label;
bo->label = label;
if (set_kernel_label)
pan_kmod_set_bo_label(bo->dev->kmod.dev, bo->kmod_bo, label);
return old_label;
}
+8
View File
@@ -140,4 +140,12 @@ struct panfrost_bo *panfrost_bo_import(struct panfrost_device *dev, int fd);
int panfrost_bo_export(struct panfrost_bo *bo);
void panfrost_bo_cache_evict_all(struct panfrost_device *dev);
const char *panfrost_bo_replace_label(struct panfrost_bo *bo, const char *label,
bool set_kernel_label);
static inline const char *
panfrost_bo_set_label(struct panfrost_bo *bo, const char *label)
{
return panfrost_bo_replace_label(bo, label, true);
}
#endif /* __PAN_BO_H__ */