[PATCH v2 5/8] drm/gem-fb-helper: Add drm_gem_fb_debugfs_show()

Noralf Trønnes noralf at tronnes.org
Sun Oct 15 16:30:39 UTC 2017


Add drm_gem_fb_debugfs_show() function to provide a debugfs
representation of the framebuffer and GEM object(s).

Signed-off-by: Noralf Trønnes <noralf at tronnes.org>
---
 drivers/gpu/drm/drm_gem_framebuffer_helper.c | 45 ++++++++++++++++++++++++++++
 include/drm/drm_gem_framebuffer_helper.h     |  6 ++++
 2 files changed, 51 insertions(+)

diff --git a/drivers/gpu/drm/drm_gem_framebuffer_helper.c b/drivers/gpu/drm/drm_gem_framebuffer_helper.c
index aa8cb9bfa499..18fdcc29427a 100644
--- a/drivers/gpu/drm/drm_gem_framebuffer_helper.c
+++ b/drivers/gpu/drm/drm_gem_framebuffer_helper.c
@@ -265,6 +265,51 @@ int drm_gem_fb_prepare_fb(struct drm_plane *plane,
 }
 EXPORT_SYMBOL_GPL(drm_gem_fb_prepare_fb);
 
+#ifdef CONFIG_DEBUG_FS
+static void drm_gem_fb_describe(struct drm_framebuffer *fb, struct seq_file *m)
+{
+	struct drm_gem_object *obj;
+	unsigned int i;
+
+	seq_printf(m, "[FB:%d] %dx%d@%4.4s\n", fb->base.id, fb->width,
+		   fb->height, (char *)&fb->format->format);
+
+	for (i = 0; i < fb->format->num_planes; i++) {
+		obj = fb->obj[i];
+		seq_printf(m, "\t%u: offset=%d pitch=%d, GEM: name=%d",
+			   i, fb->offsets[i], fb->pitches[i], obj->name);
+		seq_printf(m, " refcount=%d start=%08lx size=%zu%s\n",
+			   kref_read(&obj->refcount),
+			   drm_vma_node_start(&obj->vma_node), obj->size,
+			   obj->import_attach ? " (imported)" : "");
+	}
+}
+
+/**
+ * drm_gem_fb_debugfs_show() - Helper to list GEM backed framebuffer objects
+ *                             in debugfs.
+ * @m: Output file
+ * @arg: Private data for the callback
+ *
+ * This function gives a debugfs representation of the framebuffers with their
+ * backing GEM objects. See drm_debugfs_create_files() for more info.
+ */
+int drm_gem_fb_debugfs_show(struct seq_file *m, void *arg)
+{
+	struct drm_info_node *node = m->private;
+	struct drm_device *dev = node->minor->dev;
+	struct drm_framebuffer *fb;
+
+	mutex_lock(&dev->mode_config.fb_lock);
+	drm_for_each_fb(fb, dev)
+		drm_gem_fb_describe(fb, m);
+	mutex_unlock(&dev->mode_config.fb_lock);
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(drm_gem_fb_debugfs_show);
+#endif
+
 /**
  * drm_gem_fbdev_fb_create - Create a GEM backed &drm_framebuffer for fbdev
  *                           emulation
diff --git a/include/drm/drm_gem_framebuffer_helper.h b/include/drm/drm_gem_framebuffer_helper.h
index 5ca7cdc3f527..1bb73d961aba 100644
--- a/include/drm/drm_gem_framebuffer_helper.h
+++ b/include/drm/drm_gem_framebuffer_helper.h
@@ -28,6 +28,12 @@ drm_gem_fb_create(struct drm_device *dev, struct drm_file *file,
 int drm_gem_fb_prepare_fb(struct drm_plane *plane,
 			  struct drm_plane_state *state);
 
+#ifdef CONFIG_DEBUG_FS
+struct seq_file;
+
+int drm_gem_fb_debugfs_show(struct seq_file *m, void *arg);
+#endif
+
 struct drm_framebuffer *
 drm_gem_fbdev_fb_create(struct drm_device *dev,
 			struct drm_fb_helper_surface_size *sizes,
-- 
2.14.2



More information about the dri-devel mailing list