aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2019-02-20 16:03:40 -0500
committerEric Anholt <eric@anholt.net>2019-04-01 13:44:34 -0400
commit13f0ec3417c566ae29603eb5d18f4b7d581ade52 (patch)
tree54c94340b076880d0eec2bcd5ad15372f0be7acd
parent3a3fe6e766630aacf8cc212cceb1d57d7b346463 (diff)
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 <eric@anholt.net> Link: https://patchwork.freedesktop.org/patch/msgid/20190220210343.28157-4-eric@anholt.net Reviewed-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
-rw-r--r--drivers/gpu/drm/vc4/vc4_bo.c48
1 files changed, 14 insertions, 34 deletions
diff --git a/drivers/gpu/drm/vc4/vc4_bo.c b/drivers/gpu/drm/vc4/vc4_bo.c
index 92e3f98d8478..276ea9c550c0 100644
--- a/drivers/gpu/drm/vc4/vc4_bo.c
+++ b/drivers/gpu/drm/vc4/vc4_bo.c
@@ -40,7 +40,7 @@ static bool is_user_label(int label)
40 return label >= VC4_BO_TYPE_COUNT; 40 return label >= VC4_BO_TYPE_COUNT;
41} 41}
42 42
43static void vc4_bo_stats_dump(struct vc4_dev *vc4) 43static void vc4_bo_stats_print(struct drm_printer *p, struct vc4_dev *vc4)
44{ 44{
45 int i; 45 int i;
46 46
@@ -48,21 +48,21 @@ static void vc4_bo_stats_dump(struct vc4_dev *vc4)
48 if (!vc4->bo_labels[i].num_allocated) 48 if (!vc4->bo_labels[i].num_allocated)
49 continue; 49 continue;
50 50
51 DRM_INFO("%30s: %6dkb BOs (%d)\n", 51 drm_printf(p, "%30s: %6dkb BOs (%d)\n",
52 vc4->bo_labels[i].name, 52 vc4->bo_labels[i].name,
53 vc4->bo_labels[i].size_allocated / 1024, 53 vc4->bo_labels[i].size_allocated / 1024,
54 vc4->bo_labels[i].num_allocated); 54 vc4->bo_labels[i].num_allocated);
55 } 55 }
56 56
57 mutex_lock(&vc4->purgeable.lock); 57 mutex_lock(&vc4->purgeable.lock);
58 if (vc4->purgeable.num) 58 if (vc4->purgeable.num)
59 DRM_INFO("%30s: %6zdkb BOs (%d)\n", "userspace BO cache", 59 drm_printf(p, "%30s: %6zdkb BOs (%d)\n", "userspace BO cache",
60 vc4->purgeable.size / 1024, vc4->purgeable.num); 60 vc4->purgeable.size / 1024, vc4->purgeable.num);
61 61
62 if (vc4->purgeable.purged_num) 62 if (vc4->purgeable.purged_num)
63 DRM_INFO("%30s: %6zdkb BOs (%d)\n", "total purged BO", 63 drm_printf(p, "%30s: %6zdkb BOs (%d)\n", "total purged BO",
64 vc4->purgeable.purged_size / 1024, 64 vc4->purgeable.purged_size / 1024,
65 vc4->purgeable.purged_num); 65 vc4->purgeable.purged_num);
66 mutex_unlock(&vc4->purgeable.lock); 66 mutex_unlock(&vc4->purgeable.lock);
67} 67}
68 68
@@ -72,30 +72,9 @@ int vc4_bo_stats_debugfs(struct seq_file *m, void *unused)
72 struct drm_info_node *node = (struct drm_info_node *)m->private; 72 struct drm_info_node *node = (struct drm_info_node *)m->private;
73 struct drm_device *dev = node->minor->dev; 73 struct drm_device *dev = node->minor->dev;
74 struct vc4_dev *vc4 = to_vc4_dev(dev); 74 struct vc4_dev *vc4 = to_vc4_dev(dev);
75 int i; 75 struct drm_printer p = drm_seq_file_printer(m);
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);
88 76
89 mutex_lock(&vc4->purgeable.lock); 77 vc4_bo_stats_print(&p, vc4);
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);
99 78
100 return 0; 79 return 0;
101} 80}
@@ -475,8 +454,9 @@ struct vc4_bo *vc4_bo_create(struct drm_device *dev, size_t unaligned_size,
475 } 454 }
476 455
477 if (IS_ERR(cma_obj)) { 456 if (IS_ERR(cma_obj)) {
457 struct drm_printer p = drm_info_printer(vc4->dev->dev);
478 DRM_ERROR("Failed to allocate from CMA:\n"); 458 DRM_ERROR("Failed to allocate from CMA:\n");
479 vc4_bo_stats_dump(vc4); 459 vc4_bo_stats_print(&p, vc4);
480 return ERR_PTR(-ENOMEM); 460 return ERR_PTR(-ENOMEM);
481 } 461 }
482 bo = to_vc4_bo(&cma_obj->base); 462 bo = to_vc4_bo(&cma_obj->base);