This is is very useful to finding sources of leaked framebufers.
The fbcon fb is annotated with [fbcon], to give it a better name
than kworker.

Signed-off-by: Maarten Lankhorst <maarten.lankho...@linux.intel.com>
---
 drivers/gpu/drm/drm_fb_helper.c   | 1 +
 drivers/gpu/drm/drm_framebuffer.c | 2 ++
 include/drm/drm_framebuffer.h     | 6 ++++++
 3 files changed, 9 insertions(+)

diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index 04a3a5ce370a..d396d74a7dda 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -1848,6 +1848,7 @@ static int drm_fb_helper_single_fb_probe(struct 
drm_fb_helper *fb_helper,
        if (ret < 0)
                return ret;
 
+       strcpy(fb_helper->fb->comm, "[fbcon]");
        return 0;
 }
 
diff --git a/drivers/gpu/drm/drm_framebuffer.c 
b/drivers/gpu/drm/drm_framebuffer.c
index d63d4c2ac4c8..5a13ff29f4f0 100644
--- a/drivers/gpu/drm/drm_framebuffer.c
+++ b/drivers/gpu/drm/drm_framebuffer.c
@@ -664,6 +664,7 @@ int drm_framebuffer_init(struct drm_device *dev, struct 
drm_framebuffer *fb,
        INIT_LIST_HEAD(&fb->filp_head);
 
        fb->funcs = funcs;
+       strcpy(fb->comm, current->comm);
 
        ret = __drm_mode_object_add(dev, &fb->base, DRM_MODE_OBJECT_FB,
                                    false, drm_framebuffer_free);
@@ -978,6 +979,7 @@ void drm_framebuffer_print_info(struct drm_printer *p, 
unsigned int indent,
        struct drm_format_name_buf format_name;
        unsigned int i;
 
+       drm_printf_indent(p, indent, "allocated by = %s\n", fb->comm);
        drm_printf_indent(p, indent, "refcount=%u\n",
                          drm_framebuffer_read_refcount(fb));
        drm_printf_indent(p, indent, "format=%s\n",
diff --git a/include/drm/drm_framebuffer.h b/include/drm/drm_framebuffer.h
index dccb897951ba..c50502c656e5 100644
--- a/include/drm/drm_framebuffer.h
+++ b/include/drm/drm_framebuffer.h
@@ -121,6 +121,12 @@ struct drm_framebuffer {
         * @base: base modeset object structure, contains the reference count.
         */
        struct drm_mode_object base;
+
+       /**
+        * @comm: Name of the process allocating the fb, used for fb dumping.
+        */
+       char comm[TASK_COMM_LEN];
+
        /**
         * @format: framebuffer format information
         */
-- 
2.15.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Reply via email to