Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

drm/file: Add fdinfo helper for printing regions with prefix

This is motivated by the desire of some drivers (eg. Panthor) to print the
size of internal memory regions with a prefix that reflects the driver
name, as suggested in the previous documentation commit.

That means adding a new argument to print_size and making it available for
DRM users.

Cc: Tvrtko Ursulin <tursulin@ursulin.net>
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
Signed-off-by: Adrián Larumbe <adrian.larumbe@collabora.com>
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20250130172851.941597-3-adrian.larumbe@collabora.com

authored by

Adrián Larumbe and committed by
Boris Brezillon
af6c2b7c 3ddf003c

+23 -8
+18 -8
drivers/gpu/drm/drm_file.c
··· 830 830 } 831 831 EXPORT_SYMBOL(drm_send_event); 832 832 833 - static void print_size(struct drm_printer *p, const char *stat, 834 - const char *region, u64 sz) 833 + void drm_fdinfo_print_size(struct drm_printer *p, 834 + const char *prefix, 835 + const char *stat, 836 + const char *region, 837 + u64 sz) 835 838 { 836 839 const char *units[] = {"", " KiB", " MiB"}; 837 840 unsigned u; ··· 845 842 sz = div_u64(sz, SZ_1K); 846 843 } 847 844 848 - drm_printf(p, "drm-%s-%s:\t%llu%s\n", stat, region, sz, units[u]); 845 + drm_printf(p, "%s-%s-%s:\t%llu%s\n", 846 + prefix, stat, region, sz, units[u]); 849 847 } 848 + EXPORT_SYMBOL(drm_fdinfo_print_size); 850 849 851 850 int drm_memory_stats_is_zero(const struct drm_memory_stats *stats) 852 851 { ··· 873 868 enum drm_gem_object_status supported_status, 874 869 const char *region) 875 870 { 876 - print_size(p, "total", region, stats->private + stats->shared); 877 - print_size(p, "shared", region, stats->shared); 871 + const char *prefix = "drm"; 872 + 873 + drm_fdinfo_print_size(p, prefix, "total", region, 874 + stats->private + stats->shared); 875 + drm_fdinfo_print_size(p, prefix, "shared", region, stats->shared); 878 876 879 877 if (supported_status & DRM_GEM_OBJECT_ACTIVE) 880 - print_size(p, "active", region, stats->active); 878 + drm_fdinfo_print_size(p, prefix, "active", region, stats->active); 881 879 882 880 if (supported_status & DRM_GEM_OBJECT_RESIDENT) 883 - print_size(p, "resident", region, stats->resident); 881 + drm_fdinfo_print_size(p, prefix, "resident", region, 882 + stats->resident); 884 883 885 884 if (supported_status & DRM_GEM_OBJECT_PURGEABLE) 886 - print_size(p, "purgeable", region, stats->purgeable); 885 + drm_fdinfo_print_size(p, prefix, "purgeable", region, 886 + stats->purgeable); 887 887 } 888 888 EXPORT_SYMBOL(drm_print_memory_stats); 889 889
+5
include/drm/drm_file.h
··· 495 495 enum drm_gem_object_status; 496 496 497 497 int drm_memory_stats_is_zero(const struct drm_memory_stats *stats); 498 + void drm_fdinfo_print_size(struct drm_printer *p, 499 + const char *prefix, 500 + const char *stat, 501 + const char *region, 502 + u64 sz); 498 503 void drm_print_memory_stats(struct drm_printer *p, 499 504 const struct drm_memory_stats *stats, 500 505 enum drm_gem_object_status supported_status,