Skip to contentSkip to conversation

drm/buddy: Fix drm_buddy_print() to work with printk printers

PATCH New Michal Wajdeczko 1 participant 1 message Jul 15, 2024

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/buddy: Fix drm_buddy_print() to work with printk printers

If we try to use printk-based drm_printer, like drm_dbg_printer(), output from drm_buddy_print() will be split into several lines:

[drm] chunk_size: 1024KiB, total: 7MiB, free: 7MiB, clear_free: 0MiB [drm] order- 2
[drm] free: 4 MiB
[drm] , blocks: 1
[drm] order- 1
[drm] free: 2 MiB
[drm] , blocks: 1
[drm] order- 0
[drm] free: 1 MiB
[drm] , blocks: 1

Fix that by using single drm_printf() per line.

Cc Arunpravin Paneer Selvam <[email protected]>
---
 drivers/gpu/drm/drm_buddy.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)
drivers/gpu/drm/drm_buddy.c +3 -8
index 6a8e45e9d0ec..474a4689269b 100644
@@ -1139,15 +1139,10 @@ void drm_buddy_print(struct drm_buddy *mm, struct drm_printer *p)
 			count++;
 		}
 
-		drm_printf(p, "order-%2d ", order);
-
 		free = count * (mm->chunk_size << order);
-		if (free < SZ_1M)
-			drm_printf(p, "free: %8llu KiB", free >> 10);
-		else
-			drm_printf(p, "free: %8llu MiB", free >> 20);
-
-		drm_printf(p, ", blocks: %llu\n", count);
+		drm_printf(p, "order-%2d free: %8llu %s, blocks: %llu\n",
+			   order, free >> (free < SZ_1M ? 10 : 20),
+			   free < SZ_1M ? "KiB" : "MiB", count);
 	}
 }
 EXPORT_SYMBOL(drm_buddy_print);
Signature · 1 line
2.43.0