Skip to content

Commit 37dee2a

Browse files
committed
accel/ivpu: Improve buffer object debug logs
Make debug logs more readable and consistent: - don't print handle as it is not always available for all buffers - use hashed ivpu_bo ptr as main buffer identifier - remove unused fields from ivpu_bo_print_info() Signed-off-by: Jacek Lawrynowicz <[email protected]> Reviewed-by: Wachowski, Karol <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent b7a0e75 commit 37dee2a

File tree

2 files changed

+22
-42
lines changed

2 files changed

+22
-42
lines changed

drivers/accel/ivpu/ivpu_gem.c

Lines changed: 22 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,11 @@ static const struct drm_gem_object_funcs ivpu_gem_funcs;
2424

2525
static inline void ivpu_dbg_bo(struct ivpu_device *vdev, struct ivpu_bo *bo, const char *action)
2626
{
27-
if (bo->ctx)
28-
ivpu_dbg(vdev, BO, "%6s: size %zu has_pages %d dma_mapped %d handle %u ctx %d vpu_addr 0x%llx mmu_mapped %d\n",
29-
action, ivpu_bo_size(bo), (bool)bo->base.pages, (bool)bo->base.sgt,
30-
bo->handle, bo->ctx->id, bo->vpu_addr, bo->mmu_mapped);
31-
else
32-
ivpu_dbg(vdev, BO, "%6s: size %zu has_pages %d dma_mapped %d handle %u (not added to context)\n",
33-
action, ivpu_bo_size(bo), (bool)bo->base.pages, (bool)bo->base.sgt,
34-
bo->handle);
27+
ivpu_dbg(vdev, BO,
28+
"%6s: bo %8p vpu_addr %9llx size %8zu ctx %d has_pages %d dma_mapped %d mmu_mapped %d wc %d imported %d\n",
29+
action, bo, bo->vpu_addr, ivpu_bo_size(bo), bo->ctx ? bo->ctx->id : 0,
30+
(bool)bo->base.pages, (bool)bo->base.sgt, bo->mmu_mapped, bo->base.map_wc,
31+
(bool)bo->base.base.import_attach);
3532
}
3633

3734
/*
@@ -49,12 +46,7 @@ int __must_check ivpu_bo_pin(struct ivpu_bo *bo)
4946
mutex_lock(&bo->lock);
5047

5148
ivpu_dbg_bo(vdev, bo, "pin");
52-
53-
if (!bo->ctx) {
54-
ivpu_err(vdev, "vpu_addr not allocated for BO %d\n", bo->handle);
55-
ret = -EINVAL;
56-
goto unlock;
57-
}
49+
drm_WARN_ON(&vdev->drm, !bo->ctx);
5850

5951
if (!bo->mmu_mapped) {
6052
struct sg_table *sgt = drm_gem_shmem_get_pages_sgt(&bo->base);
@@ -108,9 +100,7 @@ static void ivpu_bo_unbind_locked(struct ivpu_bo *bo)
108100
{
109101
struct ivpu_device *vdev = ivpu_bo_to_vdev(bo);
110102

111-
lockdep_assert_held(&bo->lock);
112-
113-
ivpu_dbg_bo(vdev, bo, "unbind");
103+
lockdep_assert(lockdep_is_held(&bo->lock) || !kref_read(&bo->base.base.refcount));
114104

115105
if (bo->mmu_mapped) {
116106
drm_WARN_ON(&vdev->drm, !bo->ctx);
@@ -122,7 +112,6 @@ static void ivpu_bo_unbind_locked(struct ivpu_bo *bo)
122112

123113
if (bo->ctx) {
124114
ivpu_mmu_context_remove_node(bo->ctx, &bo->mm_node);
125-
bo->vpu_addr = 0;
126115
bo->ctx = NULL;
127116
}
128117

@@ -156,8 +145,10 @@ void ivpu_bo_remove_all_bos_from_context(struct ivpu_device *vdev, struct ivpu_m
156145
mutex_lock(&vdev->bo_list_lock);
157146
list_for_each_entry(bo, &vdev->bo_list, bo_list_node) {
158147
mutex_lock(&bo->lock);
159-
if (bo->ctx == ctx)
148+
if (bo->ctx == ctx) {
149+
ivpu_dbg_bo(vdev, bo, "unbind");
160150
ivpu_bo_unbind_locked(bo);
151+
}
161152
mutex_unlock(&bo->lock);
162153
}
163154
mutex_unlock(&vdev->bo_list_lock);
@@ -209,9 +200,6 @@ ivpu_bo_create(struct ivpu_device *vdev, u64 size, u32 flags)
209200
list_add_tail(&bo->bo_list_node, &vdev->bo_list);
210201
mutex_unlock(&vdev->bo_list_lock);
211202

212-
ivpu_dbg(vdev, BO, "create: vpu_addr 0x%llx size %zu flags 0x%x\n",
213-
bo->vpu_addr, bo->base.base.size, flags);
214-
215203
return bo;
216204
}
217205

@@ -243,14 +231,14 @@ static void ivpu_bo_free(struct drm_gem_object *obj)
243231
struct ivpu_device *vdev = to_ivpu_device(obj->dev);
244232
struct ivpu_bo *bo = to_ivpu_bo(obj);
245233

234+
ivpu_dbg_bo(vdev, bo, "free");
235+
246236
mutex_lock(&vdev->bo_list_lock);
247237
list_del(&bo->bo_list_node);
248238
mutex_unlock(&vdev->bo_list_lock);
249239

250240
drm_WARN_ON(&vdev->drm, !dma_resv_test_signaled(obj->resv, DMA_RESV_USAGE_READ));
251241

252-
ivpu_dbg_bo(vdev, bo, "free");
253-
254242
ivpu_bo_unbind(bo);
255243
mutex_destroy(&bo->lock);
256244

@@ -293,11 +281,9 @@ int ivpu_bo_create_ioctl(struct drm_device *dev, void *data, struct drm_file *fi
293281
return PTR_ERR(bo);
294282
}
295283

296-
ret = drm_gem_handle_create(file, &bo->base.base, &bo->handle);
297-
if (!ret) {
284+
ret = drm_gem_handle_create(file, &bo->base.base, &args->handle);
285+
if (!ret)
298286
args->vpu_addr = bo->vpu_addr;
299-
args->handle = bo->handle;
300-
}
301287

302288
drm_gem_object_put(&bo->base.base);
303289

@@ -415,26 +401,21 @@ int ivpu_bo_wait_ioctl(struct drm_device *dev, void *data, struct drm_file *file
415401

416402
static void ivpu_bo_print_info(struct ivpu_bo *bo, struct drm_printer *p)
417403
{
418-
unsigned long dma_refcount = 0;
419-
420404
mutex_lock(&bo->lock);
421405

422-
if (bo->base.base.dma_buf && bo->base.base.dma_buf->file)
423-
dma_refcount = atomic_long_read(&bo->base.base.dma_buf->file->f_count);
424-
425-
drm_printf(p, "%-3u %-6d 0x%-12llx %-10lu 0x%-8x %-4u %-8lu",
426-
bo->ctx->id, bo->handle, bo->vpu_addr, bo->base.base.size,
427-
bo->flags, kref_read(&bo->base.base.refcount), dma_refcount);
428-
429-
if (bo->base.base.import_attach)
430-
drm_printf(p, " imported");
406+
drm_printf(p, "%-9p %-3u 0x%-12llx %-10lu 0x%-8x %-4u",
407+
bo, bo->ctx->id, bo->vpu_addr, bo->base.base.size,
408+
bo->flags, kref_read(&bo->base.base.refcount));
431409

432410
if (bo->base.pages)
433411
drm_printf(p, " has_pages");
434412

435413
if (bo->mmu_mapped)
436414
drm_printf(p, " mmu_mapped");
437415

416+
if (bo->base.base.import_attach)
417+
drm_printf(p, " imported");
418+
438419
drm_printf(p, "\n");
439420

440421
mutex_unlock(&bo->lock);
@@ -445,8 +426,8 @@ void ivpu_bo_list(struct drm_device *dev, struct drm_printer *p)
445426
struct ivpu_device *vdev = to_ivpu_device(dev);
446427
struct ivpu_bo *bo;
447428

448-
drm_printf(p, "%-3s %-6s %-14s %-10s %-10s %-4s %-8s %s\n",
449-
"ctx", "handle", "vpu_addr", "size", "flags", "refs", "dma_refs", "attribs");
429+
drm_printf(p, "%-9s %-3s %-14s %-10s %-10s %-4s %s\n",
430+
"bo", "ctx", "vpu_addr", "size", "flags", "refs", "attribs");
450431

451432
mutex_lock(&vdev->bo_list_lock);
452433
list_for_each_entry(bo, &vdev->bo_list, bo_list_node)

drivers/accel/ivpu/ivpu_gem.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ struct ivpu_bo {
1919

2020
struct mutex lock; /* Protects: ctx, mmu_mapped, vpu_addr */
2121
u64 vpu_addr;
22-
u32 handle;
2322
u32 flags;
2423
u32 job_status; /* Valid only for command buffer */
2524
bool mmu_mapped;

0 commit comments

Comments
 (0)