Skip to content

Commit 13f0ec3

Browse files
committed
drm/vc4: Use drm_printer for the debugfs and runtime bo stats output.
Now I can extend the stats without more copy and pasting between the two. Signed-off-by: Eric Anholt <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] Reviewed-by: Paul Kocialkowski <[email protected]>
1 parent 3a3fe6e commit 13f0ec3

File tree

1 file changed

+14
-34
lines changed

1 file changed

+14
-34
lines changed

drivers/gpu/drm/vc4/vc4_bo.c

Lines changed: 14 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -40,29 +40,29 @@ static bool is_user_label(int label)
4040
return label >= VC4_BO_TYPE_COUNT;
4141
}
4242

43-
static void vc4_bo_stats_dump(struct vc4_dev *vc4)
43+
static void vc4_bo_stats_print(struct drm_printer *p, struct vc4_dev *vc4)
4444
{
4545
int i;
4646

4747
for (i = 0; i < vc4->num_labels; i++) {
4848
if (!vc4->bo_labels[i].num_allocated)
4949
continue;
5050

51-
DRM_INFO("%30s: %6dkb BOs (%d)\n",
52-
vc4->bo_labels[i].name,
53-
vc4->bo_labels[i].size_allocated / 1024,
54-
vc4->bo_labels[i].num_allocated);
51+
drm_printf(p, "%30s: %6dkb BOs (%d)\n",
52+
vc4->bo_labels[i].name,
53+
vc4->bo_labels[i].size_allocated / 1024,
54+
vc4->bo_labels[i].num_allocated);
5555
}
5656

5757
mutex_lock(&vc4->purgeable.lock);
5858
if (vc4->purgeable.num)
59-
DRM_INFO("%30s: %6zdkb BOs (%d)\n", "userspace BO cache",
60-
vc4->purgeable.size / 1024, vc4->purgeable.num);
59+
drm_printf(p, "%30s: %6zdkb BOs (%d)\n", "userspace BO cache",
60+
vc4->purgeable.size / 1024, vc4->purgeable.num);
6161

6262
if (vc4->purgeable.purged_num)
63-
DRM_INFO("%30s: %6zdkb BOs (%d)\n", "total purged BO",
64-
vc4->purgeable.purged_size / 1024,
65-
vc4->purgeable.purged_num);
63+
drm_printf(p, "%30s: %6zdkb BOs (%d)\n", "total purged BO",
64+
vc4->purgeable.purged_size / 1024,
65+
vc4->purgeable.purged_num);
6666
mutex_unlock(&vc4->purgeable.lock);
6767
}
6868

@@ -72,30 +72,9 @@ int vc4_bo_stats_debugfs(struct seq_file *m, void *unused)
7272
struct drm_info_node *node = (struct drm_info_node *)m->private;
7373
struct drm_device *dev = node->minor->dev;
7474
struct vc4_dev *vc4 = to_vc4_dev(dev);
75-
int i;
76-
77-
mutex_lock(&vc4->bo_lock);
78-
for (i = 0; i < vc4->num_labels; i++) {
79-
if (!vc4->bo_labels[i].num_allocated)
80-
continue;
81-
82-
seq_printf(m, "%30s: %6dkb BOs (%d)\n",
83-
vc4->bo_labels[i].name,
84-
vc4->bo_labels[i].size_allocated / 1024,
85-
vc4->bo_labels[i].num_allocated);
86-
}
87-
mutex_unlock(&vc4->bo_lock);
75+
struct drm_printer p = drm_seq_file_printer(m);
8876

89-
mutex_lock(&vc4->purgeable.lock);
90-
if (vc4->purgeable.num)
91-
seq_printf(m, "%30s: %6zdkb BOs (%d)\n", "userspace BO cache",
92-
vc4->purgeable.size / 1024, vc4->purgeable.num);
93-
94-
if (vc4->purgeable.purged_num)
95-
seq_printf(m, "%30s: %6zdkb BOs (%d)\n", "total purged BO",
96-
vc4->purgeable.purged_size / 1024,
97-
vc4->purgeable.purged_num);
98-
mutex_unlock(&vc4->purgeable.lock);
77+
vc4_bo_stats_print(&p, vc4);
9978

10079
return 0;
10180
}
@@ -475,8 +454,9 @@ struct vc4_bo *vc4_bo_create(struct drm_device *dev, size_t unaligned_size,
475454
}
476455

477456
if (IS_ERR(cma_obj)) {
457+
struct drm_printer p = drm_info_printer(vc4->dev->dev);
478458
DRM_ERROR("Failed to allocate from CMA:\n");
479-
vc4_bo_stats_dump(vc4);
459+
vc4_bo_stats_print(&p, vc4);
480460
return ERR_PTR(-ENOMEM);
481461
}
482462
bo = to_vc4_bo(&cma_obj->base);

0 commit comments

Comments
 (0)