Skip to contentSkip to conversation

Convert drivers to the new debugfs device-centered functions

PATCH In review Maíra Canal 2 participants 9 messages Jan 9, 2023

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

v2 cover Convert drivers to the new debugfs device-centered functions

The commit 1c9cacbea880 ("drm/debugfs: create device-centered debugfs functions") introduced new device-centered debugfs functions, which center the debugfs files management on the drm_device instead of drm_minor. Therefore, this patchset converts 6 drivers to this new debugfs device-centered structure as it was already performed on the vc4 (f2ede40e46e8), v3d (c0dda238e264), and vkms (03d2673bb757) drivers.

Best Regards,
- Maíra Canal

---
v1 -> v2: https://lore.kernel.org/dri-devel/[email protected]/T/

- Drop some of the #ifdef guards and mark the potentially unused functions as __maybe_unused (Daniel Vetter).
- Fix pl111 compilation error when CONFIG_DEBUG_FS=n (kernel test robot).

Maíra Canal (7):
drm/etnaviv: use new debugfs device-centered functions drm/pl111: use new debugfs device-centered functions drm/arc: use new debugfs device-centered functions drm/virtio: use new debugfs device-centered functions drm/omap: use new debugfs device-centered functions drm/qxl: remove unused debugfs structure drm/qxl: use new debugfs device-centered functions

 drivers/gpu/drm/etnaviv/etnaviv_drv.c    | 29 ++++++-------
 drivers/gpu/drm/omapdrm/omap_debugfs.c   | 29 +++++--------
 drivers/gpu/drm/omapdrm/omap_drv.c       |  7 +--
 drivers/gpu/drm/omapdrm/omap_drv.h       |  2 +-
 drivers/gpu/drm/pl111/Makefile           |  4 +-
 drivers/gpu/drm/pl111/pl111_debugfs.c    | 17 +++-----
 drivers/gpu/drm/pl111/pl111_drm.h        |  2 +-
 drivers/gpu/drm/pl111/pl111_drv.c        |  6 +--
 drivers/gpu/drm/qxl/qxl_debugfs.c        | 55 +++++-------------------
 drivers/gpu/drm/qxl/qxl_drv.c            |  5 +--
 drivers/gpu/drm/qxl/qxl_drv.h            | 22 +---------
 drivers/gpu/drm/tiny/arcpgu.c            | 24 +++--------
 drivers/gpu/drm/virtio/virtgpu_debugfs.c | 17 +++-----
 drivers/gpu/drm/virtio/virtgpu_drv.c     |  5 +--
 drivers/gpu/drm/virtio/virtgpu_drv.h     |  2 +-
 15 files changed, 65 insertions(+), 161 deletions(-)
Signature · 1 line
2.39.0
#1 lore raw

PATCH v2 1/7 drm/etnaviv: use new debugfs device-centered functions

Replace the use of drm_debugfs_create_files() with the new drm_debugfs_add_files() function, which centers the debugfs files management on the drm_device instead of drm_minor. Moreover, remove the debugfs_init hook and add the debugfs files directly on etnaviv_bind(), before drm_dev_register().

---
 drivers/gpu/drm/etnaviv/etnaviv_drv.c | 29 +++++++++++----------------
 1 file changed, 12 insertions(+), 17 deletions(-)
drivers/gpu/drm/etnaviv/etnaviv_drv.c +12 -17
index 1d2b4fb4bcf8..2b265460672e 100644
@@ -191,22 +191,22 @@ static int etnaviv_ring_show(struct etnaviv_gpu *gpu, struct seq_file *m)
 
 static int show_unlocked(struct seq_file *m, void *arg)
 {
-	struct drm_info_node *node = (struct drm_info_node *) m->private;
-	struct drm_device *dev = node->minor->dev;
+	struct drm_debugfs_entry *entry = m->private;
+	struct drm_device *dev = entry->dev;
 	int (*show)(struct drm_device *dev, struct seq_file *m) =
-			node->info_ent->data;
+			entry->file.data;
 
 	return show(dev, m);
 }
 
 static int show_each_gpu(struct seq_file *m, void *arg)
 {
-	struct drm_info_node *node = (struct drm_info_node *) m->private;
-	struct drm_device *dev = node->minor->dev;
+	struct drm_debugfs_entry *entry = m->private;
+	struct drm_device *dev = entry->dev;
 	struct etnaviv_drm_private *priv = dev->dev_private;
 	struct etnaviv_gpu *gpu;
 	int (*show)(struct etnaviv_gpu *gpu, struct seq_file *m) =
-			node->info_ent->data;
+			entry->file.data;
 	unsigned int i;
 	int ret = 0;
 
@@ -223,20 +223,13 @@ static int show_each_gpu(struct seq_file *m, void *arg)
 	return ret;
 }
 
-static struct drm_info_list etnaviv_debugfs_list[] = {
+static struct drm_debugfs_info etnaviv_debugfs_list[] = {
 		{"gpu", show_each_gpu, 0, etnaviv_gpu_debugfs},
 		{"gem", show_unlocked, 0, etnaviv_gem_show},
 		{ "mm", show_unlocked, 0, etnaviv_mm_show },
 		{"mmu", show_each_gpu, 0, etnaviv_mmu_show},
 		{"ring", show_each_gpu, 0, etnaviv_ring_show},
 };
-
-static void etnaviv_debugfs_init(struct drm_minor *minor)
-{
-	drm_debugfs_create_files(etnaviv_debugfs_list,
-				 ARRAY_SIZE(etnaviv_debugfs_list),
-				 minor->debugfs_root, minor);
-}
 #endif
 
 /*
@@ -478,9 +471,6 @@ static const struct drm_driver etnaviv_drm_driver = {
 	.prime_fd_to_handle = drm_gem_prime_fd_to_handle,
 	.gem_prime_import_sg_table = etnaviv_gem_prime_import_sg_table,
 	.gem_prime_mmap     = drm_gem_prime_mmap,
-#ifdef CONFIG_DEBUG_FS
-	.debugfs_init       = etnaviv_debugfs_init,
-#endif
 	.ioctls             = etnaviv_ioctls,
 	.num_ioctls         = DRM_ETNAVIV_NUM_IOCTLS,
 	.fops               = &fops,
@@ -534,6 +524,11 @@ static int etnaviv_bind(struct device *dev)
 
 	load_gpu(drm);
 
+#ifdef CONFIG_DEBUG_FS
+	drm_debugfs_add_files(drm, etnaviv_debugfs_list,
+			      ARRAY_SIZE(etnaviv_debugfs_list));
+#endif
+
 	ret = drm_dev_register(drm, 0);
 	if (ret)
 		goto out_unbind;
Signature · 1 line
2.39.0
#2 lore raw

PATCH v2 2/7 drm/pl111: use new debugfs device-centered functions

In reply to Maíra Canal

Replace the use of drm_debugfs_create_files() with the new drm_debugfs_add_file() function, which centers the debugfs files management on the drm_device instead of drm_minor. Moreover, remove the debugfs_init hook and add the debugfs files directly on pl111_amba_probe(), before drm_dev_register().

---
 drivers/gpu/drm/pl111/Makefile        |  4 ++--
 drivers/gpu/drm/pl111/pl111_debugfs.c | 17 +++++------------
 drivers/gpu/drm/pl111/pl111_drm.h     |  2 +-
 drivers/gpu/drm/pl111/pl111_drv.c     |  6 ++----
 4 files changed, 10 insertions(+), 19 deletions(-)
drivers/gpu/drm/pl111/Makefile +2 -2
index 67d430d433e0..8e4d53fdf314 100644
@@ -1,9 +1,9 @@
 # SPDX-License-Identifier: GPL-2.0
 pl111_drm-y +=	pl111_display.o \
 		pl111_versatile.o \
-		pl111_drv.o
+		pl111_drv.o \
+		pl111_debugfs.o
 
 pl111_drm-$(CONFIG_ARCH_NOMADIK) += pl111_nomadik.o
-pl111_drm-$(CONFIG_DEBUG_FS) += pl111_debugfs.o
 
 obj-$(CONFIG_DRM_PL111) += pl111_drm.o
drivers/gpu/drm/pl111/pl111_debugfs.c +5 -12
index 6744fa16f464..d7cda31ceb2a 100644
@@ -30,10 +30,10 @@ static const struct {
 	REGDEF(CLCD_PL111_LCUR),
 };
 
-static int pl111_debugfs_regs(struct seq_file *m, void *unused)
+static int __maybe_unused pl111_debugfs_regs(struct seq_file *m, void *unused)
 {
-	struct drm_info_node *node = (struct drm_info_node *)m->private;
-	struct drm_device *dev = node->minor->dev;
+	struct drm_debugfs_entry *entry = m->private;
+	struct drm_device *dev = entry->dev;
 	struct pl111_drm_dev_private *priv = dev->dev_private;
 	int i;
 
@@ -46,14 +46,7 @@ static int pl111_debugfs_regs(struct seq_file *m, void *unused)
 	return 0;
 }
 
-static const struct drm_info_list pl111_debugfs_list[] = {
-	{"regs", pl111_debugfs_regs, 0},
-};
-
-void
-pl111_debugfs_init(struct drm_minor *minor)
+void pl111_debugfs_init(struct drm_device *drm)
 {
-	drm_debugfs_create_files(pl111_debugfs_list,
-				 ARRAY_SIZE(pl111_debugfs_list),
-				 minor->debugfs_root, minor);
+	drm_debugfs_add_file(drm, "regs", pl111_debugfs_regs, NULL);
 }
drivers/gpu/drm/pl111/pl111_drm.h +1 -1
index 2a46b5bd8576..7fe74be917f1 100644
@@ -157,6 +157,6 @@ struct pl111_drm_dev_private {
 
 int pl111_display_init(struct drm_device *dev);
 irqreturn_t pl111_irq(int irq, void *data);
-void pl111_debugfs_init(struct drm_minor *minor);
+void pl111_debugfs_init(struct drm_device *drm);
 
 #endif /* _PL111_DRM_H_ */
drivers/gpu/drm/pl111/pl111_drv.c +2 -4
index 00deba0b7271..c031eb4abc0d 100644
@@ -228,10 +228,6 @@ static const struct drm_driver pl111_drm_driver = {
 	.prime_fd_to_handle = drm_gem_prime_fd_to_handle,
 	.gem_prime_import_sg_table = pl111_gem_import_sg_table,
 	.gem_prime_mmap = drm_gem_prime_mmap,
-
-#if defined(CONFIG_DEBUG_FS)
-	.debugfs_init = pl111_debugfs_init,
-#endif
 };
 
 static int pl111_amba_probe(struct amba_device *amba_dev,
@@ -304,6 +300,8 @@ static int pl111_amba_probe(struct amba_device *amba_dev,
 	if (ret != 0)
 		goto dev_put;
 
+	pl111_debugfs_init(drm);
+
 	ret = drm_dev_register(drm, 0);
 	if (ret < 0)
 		goto dev_put;
Signature · 1 line
2.39.0
#3 lore raw

PATCH v2 3/7 drm/arc: use new debugfs device-centered functions

In reply to Maíra Canal

Replace the use of drm_debugfs_create_files() with the new drm_debugfs_add_file() function, which centers the debugfs files management on the drm_device instead of drm_minor. Moreover, remove the debugfs_init hook and add the debugfs files directly on arcpgu_probe(), before drm_dev_register().

---
 drivers/gpu/drm/tiny/arcpgu.c | 24 +++++-------------------
 1 file changed, 5 insertions(+), 19 deletions(-)
drivers/gpu/drm/tiny/arcpgu.c +5 -19
index 611bbee15071..88ceaf8c869c 100644
@@ -335,11 +335,10 @@ static int arcpgu_unload(struct drm_device *drm)
 	return 0;
 }
 
-#ifdef CONFIG_DEBUG_FS
-static int arcpgu_show_pxlclock(struct seq_file *m, void *arg)
+static int __maybe_unused arcpgu_show_pxlclock(struct seq_file *m, void *arg)
 {
-	struct drm_info_node *node = (struct drm_info_node *)m->private;
-	struct drm_device *drm = node->minor->dev;
+	struct drm_debugfs_entry *entry = m->private;
+	struct drm_device *drm = entry->dev;
 	struct arcpgu_drm_private *arcpgu = dev_to_arcpgu(drm);
 	unsigned long clkrate = clk_get_rate(arcpgu->clk);
 	unsigned long mode_clock = arcpgu->pipe.crtc.mode.crtc_clock * 1000;
@@ -349,18 +348,6 @@ static int arcpgu_show_pxlclock(struct seq_file *m, void *arg)
 	return 0;
 }
 
-static struct drm_info_list arcpgu_debugfs_list[] = {
-	{ "clocks", arcpgu_show_pxlclock, 0 },
-};
-
-static void arcpgu_debugfs_init(struct drm_minor *minor)
-{
-	drm_debugfs_create_files(arcpgu_debugfs_list,
-				 ARRAY_SIZE(arcpgu_debugfs_list),
-				 minor->debugfs_root, minor);
-}
-#endif
-
 static const struct drm_driver arcpgu_drm_driver = {
 	.driver_features = DRIVER_MODESET | DRIVER_GEM | DRIVER_ATOMIC,
 	.name = "arcpgu",
@@ -371,9 +358,6 @@ static const struct drm_driver arcpgu_drm_driver = {
 	.patchlevel = 0,
 	.fops = &arcpgu_drm_ops,
 	DRM_GEM_DMA_DRIVER_OPS,
-#ifdef CONFIG_DEBUG_FS
-	.debugfs_init = arcpgu_debugfs_init,
-#endif
 };
 
 static int arcpgu_probe(struct platform_device *pdev)
@@ -390,6 +374,8 @@ static int arcpgu_probe(struct platform_device *pdev)
 	if (ret)
 		return ret;
 
+	drm_debugfs_add_file(&arcpgu->drm, "clocks", arcpgu_show_pxlclock, NULL);
+
 	ret = drm_dev_register(&arcpgu->drm, 0);
 	if (ret)
 		goto err_unload;
Signature · 1 line
2.39.0
Acked-by on v2 3/7
#4 lore raw

Re: [PATCH v2 3/7] drm/arc: use new debugfs device-centered functions

Hi Maíra,

Quoted 11 lines

Replace the use of drm_debugfs_create_files() with the new drm_debugfs_add_file() function, which centers the debugfs files management on the drm_device instead of drm_minor. Moreover, remove the debugfs_init hook and add the debugfs files directly on arcpgu_probe(), before drm_dev_register().

---
 drivers/gpu/drm/tiny/arcpgu.c | 24 +++++-------------------

 1 file changed, 5 insertions(+), 19 deletions(-)

Thanks for taking care of ARC PGU driver and

#5 lore raw

PATCH v2 4/7 drm/virtio: use new debugfs device-centered functions

In reply to Maíra Canal

Replace the use of drm_debugfs_create_files() with the new drm_debugfs_add_files() function, which centers the debugfs files management on the drm_device instead of drm_minor. Moreover, remove the debugfs_init hook and add the debugfs files directly on virtio_gpu_probe(), before drm_dev_register().

---
 drivers/gpu/drm/virtio/virtgpu_debugfs.c | 17 +++++++----------
 drivers/gpu/drm/virtio/virtgpu_drv.c     |  5 ++---
 drivers/gpu/drm/virtio/virtgpu_drv.h     |  2 +-
 3 files changed, 10 insertions(+), 14 deletions(-)
drivers/gpu/drm/virtio/virtgpu_debugfs.c +7 -10
index 853dd9aa397e..91c81b7429cc 100644
@@ -68,8 +68,8 @@ static int virtio_gpu_features(struct seq_file *m, void *data)
 static int
 virtio_gpu_debugfs_irq_info(struct seq_file *m, void *data)
 {
-	struct drm_info_node *node = (struct drm_info_node *) m->private;
-	struct virtio_gpu_device *vgdev = node->minor->dev->dev_private;
+	struct drm_debugfs_entry *entry = m->private;
+	struct virtio_gpu_device *vgdev = entry->dev->dev_private;
 
 	seq_printf(m, "fence %llu %lld\n",
 		   (u64)atomic64_read(&vgdev->fence_drv.last_fence_id),
@@ -80,8 +80,8 @@ virtio_gpu_debugfs_irq_info(struct seq_file *m, void *data)
 static int
 virtio_gpu_debugfs_host_visible_mm(struct seq_file *m, void *data)
 {
-	struct drm_info_node *node = (struct drm_info_node *)m->private;
-	struct virtio_gpu_device *vgdev = node->minor->dev->dev_private;
+	struct drm_debugfs_entry *entry = m->private;
+	struct virtio_gpu_device *vgdev = entry->dev->dev_private;
 	struct drm_printer p;
 
 	if (!vgdev->has_host_visible) {
@@ -94,7 +94,7 @@ virtio_gpu_debugfs_host_visible_mm(struct seq_file *m, void *data)
 	return 0;
 }
 
-static struct drm_info_list virtio_gpu_debugfs_list[] = {
+static struct drm_debugfs_info virtio_gpu_debugfs_list[] = {
 	{ "virtio-gpu-features", virtio_gpu_features },
 	{ "virtio-gpu-irq-fence", virtio_gpu_debugfs_irq_info, 0, NULL },
 	{ "virtio-gpu-host-visible-mm", virtio_gpu_debugfs_host_visible_mm },
@@ -102,10 +102,7 @@ static struct drm_info_list virtio_gpu_debugfs_list[] = {
 
 #define VIRTIO_GPU_DEBUGFS_ENTRIES ARRAY_SIZE(virtio_gpu_debugfs_list)
 
-void
-virtio_gpu_debugfs_init(struct drm_minor *minor)
+void virtio_gpu_debugfs_init(struct drm_device *drm)
 {
-	drm_debugfs_create_files(virtio_gpu_debugfs_list,
-				 VIRTIO_GPU_DEBUGFS_ENTRIES,
-				 minor->debugfs_root, minor);
+	drm_debugfs_add_files(drm, virtio_gpu_debugfs_list, VIRTIO_GPU_DEBUGFS_ENTRIES);
 }
drivers/gpu/drm/virtio/virtgpu_drv.c +2 -3
index ae97b98750b6..83aa77e5893b 100644
@@ -98,6 +98,8 @@ static int virtio_gpu_probe(struct virtio_device *vdev)
 	if (ret)
 		goto err_free;
 
+	virtio_gpu_debugfs_init(dev);
+
 	ret = drm_dev_register(dev, 0);
 	if (ret)
 		goto err_deinit;
@@ -179,9 +181,6 @@ static const struct drm_driver driver = {
 	.dumb_create = virtio_gpu_mode_dumb_create,
 	.dumb_map_offset = virtio_gpu_mode_dumb_mmap,
 
-#if defined(CONFIG_DEBUG_FS)
-	.debugfs_init = virtio_gpu_debugfs_init,
-#endif
 	.prime_handle_to_fd = drm_gem_prime_handle_to_fd,
 	.prime_fd_to_handle = drm_gem_prime_fd_to_handle,
 	.gem_prime_mmap = drm_gem_prime_mmap,
drivers/gpu/drm/virtio/virtgpu_drv.h +1 -1
index af6ffb696086..fe90f0959063 100644
@@ -472,7 +472,7 @@ struct drm_gem_object *virtgpu_gem_prime_import_sg_table(
 	struct sg_table *sgt);
 
 /* virtgpu_debugfs.c */
-void virtio_gpu_debugfs_init(struct drm_minor *minor);
+void virtio_gpu_debugfs_init(struct drm_device *drm);
 
 /* virtgpu_vram.c */
 bool virtio_gpu_is_vram(struct virtio_gpu_object *bo);
Signature · 1 line
2.39.0
#6 lore raw

PATCH v2 5/7 drm/omap: use new debugfs device-centered functions

In reply to Maíra Canal

Replace the use of drm_debugfs_create_files() with the new drm_debugfs_add_files() function, which centers the debugfs files management on the drm_device instead of drm_minor. Moreover, remove the debugfs_init hook and add the debugfs files directly on omapdrm_init(), before drm_dev_register().

---
 drivers/gpu/drm/omapdrm/omap_debugfs.c | 29 +++++++++-----------------
 drivers/gpu/drm/omapdrm/omap_drv.c     |  7 ++++---
 drivers/gpu/drm/omapdrm/omap_drv.h     |  2 +-
 3 files changed, 15 insertions(+), 23 deletions(-)
drivers/gpu/drm/omapdrm/omap_debugfs.c +10 -19
index bfb2ccb40bd1..491aa74eb2ec 100644
@@ -19,8 +19,8 @@
 
 static int gem_show(struct seq_file *m, void *arg)
 {
-	struct drm_info_node *node = (struct drm_info_node *) m->private;
-	struct drm_device *dev = node->minor->dev;
+	struct drm_debugfs_entry *entry = m->private;
+	struct drm_device *dev = entry->dev;
 	struct omap_drm_private *priv = dev->dev_private;
 
 	seq_printf(m, "All Objects:\n");
@@ -33,8 +33,8 @@ static int gem_show(struct seq_file *m, void *arg)
 
 static int mm_show(struct seq_file *m, void *arg)
 {
-	struct drm_info_node *node = (struct drm_info_node *) m->private;
-	struct drm_device *dev = node->minor->dev;
+	struct drm_debugfs_entry *entry = m->private;
+	struct drm_device *dev = entry->dev;
 	struct drm_printer p = drm_seq_file_printer(m);
 
 	drm_mm_print(&dev->vma_offset_manager->vm_addr_space_mm, &p);
@@ -45,8 +45,8 @@ static int mm_show(struct seq_file *m, void *arg)
 #ifdef CONFIG_DRM_FBDEV_EMULATION
 static int fb_show(struct seq_file *m, void *arg)
 {
-	struct drm_info_node *node = (struct drm_info_node *) m->private;
-	struct drm_device *dev = node->minor->dev;
+	struct drm_debugfs_entry *entry = m->private;
+	struct drm_device *dev = entry->dev;
 	struct omap_drm_private *priv = dev->dev_private;
 	struct drm_framebuffer *fb;
 
@@ -68,7 +68,7 @@ static int fb_show(struct seq_file *m, void *arg)
 #endif
 
 /* list of debufs files that are applicable to all devices */
-static struct drm_info_list omap_debugfs_list[] = {
+static struct drm_debugfs_info omap_debugfs_list[] = {
 	{"gem", gem_show, 0},
 	{"mm", mm_show, 0},
 #ifdef CONFIG_DRM_FBDEV_EMULATION
@@ -76,21 +76,12 @@ static struct drm_info_list omap_debugfs_list[] = {
 #endif
 };
 
-/* list of debugfs files that are specific to devices with dmm/tiler */
-static struct drm_info_list omap_dmm_debugfs_list[] = {
-	{"tiler_map", tiler_map_show, 0},
-};
-
-void omap_debugfs_init(struct drm_minor *minor)
+void omap_debugfs_init(struct drm_device *drm)
 {
-	drm_debugfs_create_files(omap_debugfs_list,
-				 ARRAY_SIZE(omap_debugfs_list),
-				 minor->debugfs_root, minor);
+	drm_debugfs_add_files(drm, omap_debugfs_list, ARRAY_SIZE(omap_debugfs_list));
 
 	if (dmm_is_available())
-		drm_debugfs_create_files(omap_dmm_debugfs_list,
-					 ARRAY_SIZE(omap_dmm_debugfs_list),
-					 minor->debugfs_root, minor);
+		drm_debugfs_add_file(drm, "tiler_map", tiler_map_show, NULL);
 }
 
 #endif
drivers/gpu/drm/omapdrm/omap_drv.c +4 -3
index 699ed814e021..0565401e767f 100644
@@ -653,9 +653,6 @@ static const struct drm_driver omap_drm_driver = {
 		DRIVER_ATOMIC | DRIVER_RENDER,
 	.open = dev_open,
 	.lastclose = drm_fb_helper_lastclose,
-#ifdef CONFIG_DEBUG_FS
-	.debugfs_init = omap_debugfs_init,
-#endif
 	.prime_handle_to_fd = drm_gem_prime_handle_to_fd,
 	.prime_fd_to_handle = drm_gem_prime_fd_to_handle,
 	.gem_prime_import = omap_gem_prime_import,
@@ -743,6 +740,10 @@ static int omapdrm_init(struct omap_drm_private *priv, struct device *dev)
 
 	omap_fbdev_init(ddev);
 
+#ifdef CONFIG_DEBUG_FS
+	omap_debugfs_init(ddev);
+#endif
+
 	drm_kms_helper_poll_init(ddev);
 
 	/*
drivers/gpu/drm/omapdrm/omap_drv.h +1 -1
index 825960fd3ea9..1e0d9e10cd6b 100644
@@ -103,7 +103,7 @@ struct omap_drm_private {
 };
 
 
-void omap_debugfs_init(struct drm_minor *minor);
+void omap_debugfs_init(struct drm_device *drm);
 
 struct omap_global_state * __must_check omap_get_global_state(struct drm_atomic_state *s);
 
Signature · 1 line
2.39.0
#7 lore raw

PATCH v2 6/7 drm/qxl: remove unused debugfs structure

In reply to Maíra Canal

The current debugfs structure was introduced at commit f64122c1f6ad ("drm: add new QXL driver. (v1.4)") and it was never used by the driver. Considering the addition of more device-centered functions to the DRM core, remove the current debugfs structure.

---
 drivers/gpu/drm/qxl/qxl_debugfs.c | 29 -----------------------------
 drivers/gpu/drm/qxl/qxl_drv.h     | 20 --------------------
 2 files changed, 49 deletions(-)
drivers/gpu/drm/qxl/qxl_debugfs.c +0 -29
index 2d9ed3b94574..bdfce1a8f006 100644
@@ -95,32 +95,3 @@ qxl_debugfs_init(struct drm_minor *minor)
 	qxl_ttm_debugfs_init(dev);
 #endif
 }
-
-void qxl_debugfs_add_files(struct qxl_device *qdev,
-			   struct drm_info_list *files,
-			   unsigned int nfiles)
-{
-	unsigned int i;
-
-	for (i = 0; i < qdev->debugfs_count; i++) {
-		if (qdev->debugfs[i].files == files) {
-			/* Already registered */
-			return;
-		}
-	}
-
-	i = qdev->debugfs_count + 1;
-	if (i > QXL_DEBUGFS_MAX_COMPONENTS) {
-		DRM_ERROR("Reached maximum number of debugfs components.\n");
-		DRM_ERROR("Report so we increase QXL_DEBUGFS_MAX_COMPONENTS.\n");
-		return;
-	}
-	qdev->debugfs[qdev->debugfs_count].files = files;
-	qdev->debugfs[qdev->debugfs_count].num_files = nfiles;
-	qdev->debugfs_count = i;
-#if defined(CONFIG_DEBUG_FS)
-	drm_debugfs_create_files(files, nfiles,
-				 qdev->ddev.primary->debugfs_root,
-				 qdev->ddev.primary);
-#endif
-}
drivers/gpu/drm/qxl/qxl_drv.h +0 -20
index ea993d7162e8..0868d5d2a839 100644
@@ -60,8 +60,6 @@ struct iosys_map;
 #define DRIVER_MINOR 1
 #define DRIVER_PATCHLEVEL 0
 
-#define QXL_DEBUGFS_MAX_COMPONENTS		32
-
 extern int qxl_num_crtc;
 
 #define QXL_INTERRUPT_MASK (\
@@ -165,14 +163,6 @@ struct qxl_drm_image {
 	struct list_head chunk_list;
 };
 
-/*
- * Debugfs
- */
-struct qxl_debugfs {
-	struct drm_info_list	*files;
-	unsigned int num_files;
-};
-
 struct qxl_device {
 	struct drm_device ddev;
 
@@ -228,10 +218,6 @@ struct qxl_device {
 	wait_queue_head_t io_cmd_event;
 	struct work_struct client_monitors_config_work;
 
-	/* debugfs */
-	struct qxl_debugfs	debugfs[QXL_DEBUGFS_MAX_COMPONENTS];
-	unsigned int debugfs_count;
-
 	struct mutex		update_area_mutex;
 
 	struct idr	surf_id_idr;
@@ -256,8 +242,6 @@ struct qxl_device {
 
 #define to_qxl(dev) container_of(dev, struct qxl_device, ddev)
 
-int qxl_debugfs_fence_init(struct qxl_device *rdev);
-
 int qxl_device_init(struct qxl_device *qdev, struct pci_dev *pdev);
 void qxl_device_fini(struct qxl_device *qdev);
 
@@ -430,10 +414,6 @@ void qxl_gem_prime_vunmap(struct drm_gem_object *obj,
 /* qxl_irq.c */
 int qxl_irq_init(struct qxl_device *qdev);
 
-void qxl_debugfs_add_files(struct qxl_device *qdev,
-			   struct drm_info_list *files,
-			   unsigned int nfiles);
-
 int qxl_surface_id_alloc(struct qxl_device *qdev,
 			 struct qxl_bo *surf);
 void qxl_surface_id_dealloc(struct qxl_device *qdev,
Signature · 1 line
2.39.0
#8 lore raw

PATCH v2 7/7 drm/qxl: use new debugfs device-centered functions

In reply to Maíra Canal

Replace the use of drm_debugfs_create_files() with the new drm_debugfs_add_files() function, which centers the debugfs files management on the drm_device instead of drm_minor. Moreover, remove the debugfs_init hook and add the debugfs files directly on qxl_pci_probe(), before drm_dev_register().

---
 drivers/gpu/drm/qxl/qxl_debugfs.c | 26 ++++++++++----------------
 drivers/gpu/drm/qxl/qxl_drv.c     |  5 ++---
 drivers/gpu/drm/qxl/qxl_drv.h     |  2 +-
 3 files changed, 13 insertions(+), 20 deletions(-)
drivers/gpu/drm/qxl/qxl_debugfs.c +10 -16
index bdfce1a8f006..c33f1f37dca0 100644
@@ -34,12 +34,11 @@
 #include "qxl_drv.h"
 #include "qxl_object.h"
 
-#if defined(CONFIG_DEBUG_FS)
-static int
+static int __maybe_unused
 qxl_debugfs_irq_received(struct seq_file *m, void *data)
 {
-	struct drm_info_node *node = (struct drm_info_node *) m->private;
-	struct qxl_device *qdev = to_qxl(node->minor->dev);
+	struct drm_debugfs_entry *entry = m->private;
+	struct qxl_device *qdev = to_qxl(entry->dev);
 
 	seq_printf(m, "%d\n", atomic_read(&qdev->irq_received));
 	seq_printf(m, "%d\n", atomic_read(&qdev->irq_received_display));
@@ -49,11 +48,11 @@ qxl_debugfs_irq_received(struct seq_file *m, void *data)
 	return 0;
 }
 
-static int
+static int __maybe_unused
 qxl_debugfs_buffers_info(struct seq_file *m, void *data)
 {
-	struct drm_info_node *node = (struct drm_info_node *) m->private;
-	struct qxl_device *qdev = to_qxl(node->minor->dev);
+	struct drm_debugfs_entry *entry = m->private;
+	struct qxl_device *qdev = to_qxl(entry->dev);
 	struct qxl_bo *bo;
 
 	list_for_each_entry(bo, &qdev->gem.objects, list) {
@@ -76,22 +75,17 @@ qxl_debugfs_buffers_info(struct seq_file *m, void *data)
 	return 0;
 }
 
-static struct drm_info_list qxl_debugfs_list[] = {
+static struct drm_debugfs_info qxl_debugfs_list[] = {
 	{ "irq_received", qxl_debugfs_irq_received, 0, NULL },
 	{ "qxl_buffers", qxl_debugfs_buffers_info, 0, NULL },
 };
 #define QXL_DEBUGFS_ENTRIES ARRAY_SIZE(qxl_debugfs_list)
-#endif
 
-void
-qxl_debugfs_init(struct drm_minor *minor)
+void qxl_debugfs_init(struct drm_device *drm)
 {
-#if defined(CONFIG_DEBUG_FS)
-	struct qxl_device *dev = to_qxl(minor->dev);
+	struct qxl_device *dev = to_qxl(drm);
 
-	drm_debugfs_create_files(qxl_debugfs_list, QXL_DEBUGFS_ENTRIES,
-				 minor->debugfs_root, minor);
+	drm_debugfs_add_files(drm, qxl_debugfs_list, QXL_DEBUGFS_ENTRIES);
 
 	qxl_ttm_debugfs_init(dev);
-#endif
 }
drivers/gpu/drm/qxl/qxl_drv.c +2 -3
index a3b83f89e061..3ae2db78f671 100644
@@ -116,6 +116,8 @@ qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 	if (ret)
 		goto unload;
 
+	qxl_debugfs_init(&qdev->ddev);
+
 	drm_kms_helper_poll_init(&qdev->ddev);
 
 	/* Complete initialization. */
@@ -287,9 +289,6 @@ static struct drm_driver qxl_driver = {
 
 	.dumb_create = qxl_mode_dumb_create,
 	.dumb_map_offset = drm_gem_ttm_dumb_map_offset,
-#if defined(CONFIG_DEBUG_FS)
-	.debugfs_init = qxl_debugfs_init,
-#endif
 	.prime_handle_to_fd = drm_gem_prime_handle_to_fd,
 	.prime_fd_to_handle = drm_gem_prime_fd_to_handle,
 	.gem_prime_import_sg_table = qxl_gem_prime_import_sg_table,
drivers/gpu/drm/qxl/qxl_drv.h +1 -1
index 0868d5d2a839..cb84a3bebcec 100644
@@ -397,7 +397,7 @@ int qxl_garbage_collect(struct qxl_device *qdev);
 
 /* debugfs */
 
-void qxl_debugfs_init(struct drm_minor *minor);
+void qxl_debugfs_init(struct drm_device *drm);
 void qxl_ttm_debugfs_init(struct qxl_device *qdev);
 
 /* qxl_prime.c */
Signature · 1 line
2.39.0