@@ -40,29 +40,29 @@ static bool is_user_label(int label)
40
40
return label >= VC4_BO_TYPE_COUNT ;
41
41
}
42
42
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 )
44
44
{
45
45
int i ;
46
46
47
47
for (i = 0 ; i < vc4 -> num_labels ; i ++ ) {
48
48
if (!vc4 -> bo_labels [i ].num_allocated )
49
49
continue ;
50
50
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 );
55
55
}
56
56
57
57
mutex_lock (& vc4 -> purgeable .lock );
58
58
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 );
61
61
62
62
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 );
66
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
72
struct drm_info_node * node = (struct drm_info_node * )m -> private ;
73
73
struct drm_device * dev = node -> minor -> dev ;
74
74
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 );
88
76
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 );
99
78
100
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
456
if (IS_ERR (cma_obj )) {
457
+ struct drm_printer p = drm_info_printer (vc4 -> dev -> dev );
478
458
DRM_ERROR ("Failed to allocate from CMA:\n" );
479
- vc4_bo_stats_dump ( vc4 );
459
+ vc4_bo_stats_print ( & p , vc4 );
480
460
return ERR_PTR (- ENOMEM );
481
461
}
482
462
bo = to_vc4_bo (& cma_obj -> base );
0 commit comments