Skip to contentSkip to conversation

drm/framebuffer: Add framebuffer debugfs file

PATCH In review Noralf Trønnes 5 participants 25 messages Nov 7, 2017 – Nov 20, 2017

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

v5 cover drm/framebuffer: Add framebuffer debugfs file

This patchset adds a debugfs file that prints info about the framebuffers.

Changes since version 4:
- Add framebuffer debugfs file: Fix printk formats and add info about indent argument in gem_print_info callback docs (Laurent)
- Turn to_drm_gem_cma_obj() into a macro (Laurent)
- drm_gem_cma_print_info(): Make the cma_obj variable a const since it is derived from the obj variable which is a const.

Changes since version 3:
- Applied patch: drm/gem: Remove trailing whitespace
- Turn drm_printf_indent() into a macro (Ville)
- drm_printf_indent() add overflow marker (Jani)
- Converted arc, hdlcd, tilcdc and removed drm_fb_cma_debugfs_show()

Noralf Trønnes (12):
drm/vma-manager: drm_vma_node_start() constify argument drm/framebuffer: drm_framebuffer_read_refcount() constify argument drm/print: Add drm_printf_indent()
drm/framebuffer: Add framebuffer debugfs file drm/atomic: Use drm_framebuffer_print_info() drm/cma-helper: Turn to_drm_gem_cma_obj() into a macro drm/cma-helper: Add drm_gem_cma_print_info()
drm/arc: Use drm_gem_cma_print_info()
drm/arm/hdlcd: Use drm_gem_cma_print_info()
drm/tilcdc: Use drm_gem_cma_print_info()
drm/tinydrm: Use drm_gem_cma_print_info() drm/cma-helper: Remove drm_fb_cma_debugfs_show()

 drivers/gpu/drm/arc/arcpgu_drv.c     |  2 +-
 drivers/gpu/drm/arm/hdlcd_drv.c      |  2 +-
 drivers/gpu/drm/drm_atomic.c         | 18 ++---------
 drivers/gpu/drm/drm_debugfs.c        |  6 ++++
 drivers/gpu/drm/drm_fb_cma_helper.c  | 37 ----------------------
 drivers/gpu/drm/drm_framebuffer.c    | 59 ++++++++++++++++++++++++++++++++++++
 drivers/gpu/drm/drm_gem.c            | 17 +++++++++++
 drivers/gpu/drm/drm_gem_cma_helper.c | 31 ++++++++-----------
 drivers/gpu/drm/drm_internal.h       |  7 +++++
 drivers/gpu/drm/tilcdc/tilcdc_drv.c  |  2 +-
 drivers/gpu/drm/tinydrm/mipi-dbi.c   |  8 +----
 include/drm/drm_drv.h                | 15 +++++++++
 include/drm/drm_fb_cma_helper.h      |  6 ----
 include/drm/drm_framebuffer.h        |  2 +-
 include/drm/drm_gem_cma_helper.h     | 12 +++-----
 include/drm/drm_print.h              |  8 +++++
 include/drm/drm_vma_manager.h        |  2 +-
 include/drm/tinydrm/tinydrm.h        |  1 +
 18 files changed, 138 insertions(+), 97 deletions(-)

--
2.14.2

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#1 lore raw

PATCH v5 1/12 drm/vma-manager: drm_vma_node_start() constify argument

Constify argument so functions calling into this take a const argument.

---
 include/drm/drm_vma_manager.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/drm/drm_vma_manager.h +1 -1
index d84d52f6d2b1..8758df94e9a0 100644
@@ -152,7 +152,7 @@ static inline void drm_vma_node_reset(struct drm_vma_offset_node *node)
  * Start address of @node for page-based addressing. 0 if the node does not
  * have an offset allocated.
  */
-static inline unsigned long drm_vma_node_start(struct drm_vma_offset_node *node)
+static inline unsigned long drm_vma_node_start(const struct drm_vma_offset_node *node)
 {
 	return node->vm_node.start;
 }
Signature · 6 lines
2.14.2

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#2 lore raw

PATCH v5 2/12 drm/framebuffer: drm_framebuffer_read_refcount() constify argument

In reply to Noralf Trønnes

Constify argument so functions calling into this take a const argument.

---
 include/drm/drm_framebuffer.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/drm/drm_framebuffer.h +1 -1
index b6996ddb19d6..6cce22e1a0f2 100644
@@ -263,7 +263,7 @@ static inline void drm_framebuffer_unreference(struct drm_framebuffer *fb)
  *
  * This functions returns the framebuffer's reference count.
  */
-static inline uint32_t drm_framebuffer_read_refcount(struct drm_framebuffer *fb)
+static inline uint32_t drm_framebuffer_read_refcount(const struct drm_framebuffer *fb)
 {
 	return kref_read(&fb->base.refcount);
 }
Signature · 6 lines
2.14.2

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#3 lore raw

PATCH v5 3/12 drm/print: Add drm_printf_indent()

In reply to Noralf Trønnes

Add drm_printf_indent() that adds tab indentation according to argument. Indentation overflow is marked with an X.

---
 include/drm/drm_print.h | 8 ++++++++
 1 file changed, 8 insertions(+)
include/drm/drm_print.h +8 -0
index 7b9c86a6ca3e..7dbfdebec973 100644
@@ -80,6 +80,14 @@ void __drm_printfn_debug(struct drm_printer *p, struct va_format *vaf);
 __printf(2, 3)
 void drm_printf(struct drm_printer *p, const char *f, ...);
 
+/**
+ * drm_printf_indent - Print to a &drm_printer stream with indentation
+ * @printer: DRM printer
+ * @indent: Tab indentation level (max 5)
+ * @fmt: Format string
+ */
+#define drm_printf_indent(printer, indent, fmt, ...) \
+	drm_printf((printer), "%.*s" fmt, (indent), "\t\t\t\t\tX", ##__VA_ARGS__)
 
 /**
  * drm_seq_file_printer - construct a &drm_printer that outputs to &seq_file
Signature · 6 lines
2.14.2

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#4 lore raw

PATCH v5 4/12 drm/framebuffer: Add framebuffer debugfs file

In reply to Noralf Trønnes

Add debugfs file that dumps info about the framebuffers and its planes. Also dump info about any connected gem object(s).

---
 drivers/gpu/drm/drm_debugfs.c     |  6 ++++
 drivers/gpu/drm/drm_framebuffer.c | 59 +++++++++++++++++++++++++++++++++++++++
 drivers/gpu/drm/drm_gem.c         | 17 +++++++++++
 drivers/gpu/drm/drm_internal.h    |  7 +++++
 include/drm/drm_drv.h             | 15 ++++++++++
 5 files changed, 104 insertions(+)
drivers/gpu/drm/drm_debugfs.c +6 -0
index c1807d5754b2..550f29de6c1f 100644
@@ -158,6 +158,12 @@ int drm_debugfs_init(struct drm_minor *minor, int minor_id,
 		}
 	}
 
+	ret = drm_framebuffer_debugfs_init(minor);
+	if (ret) {
+		DRM_ERROR("Failed to create framebuffer debugfs file\n");
+		return ret;
+	}
+
 	if (dev->driver->debugfs_init) {
 		ret = dev->driver->debugfs_init(minor);
 		if (ret) {
drivers/gpu/drm/drm_framebuffer.c +59 -0

69 lines not on this page · raw message

drivers/gpu/drm/drm_gem.c +17 -0
index 4c84b23d37cc..01f8d9481211 100644
@@ -40,6 +40,7 @@
 #include <drm/drmP.h>
 #include <drm/drm_vma_manager.h>
 #include <drm/drm_gem.h>
+#include <drm/drm_print.h>
 #include "drm_internal.h"
 
 /** @file drm_gem.c
@@ -1040,3 +1041,19 @@ int drm_gem_mmap(struct file *filp, struct vm_area_struct *vma)
 	return ret;
 }
 EXPORT_SYMBOL(drm_gem_mmap);
+
+void drm_gem_print_info(struct drm_printer *p, unsigned int indent,
+			const struct drm_gem_object *obj)
+{
+	drm_printf_indent(p, indent, "name=%d\n", obj->name);
+	drm_printf_indent(p, indent, "refcount=%u\n",
+			  kref_read(&obj->refcount));
+	drm_printf_indent(p, indent, "start=%08lx\n",
+			  drm_vma_node_start(&obj->vma_node));
+	drm_printf_indent(p, indent, "size=%zu\n", obj->size);
+	drm_printf_indent(p, indent, "imported=%s\n",
+			  obj->import_attach ? "yes" : "no");
+
+	if (obj->dev->driver->gem_print_info)
+		obj->dev->driver->gem_print_info(p, indent, obj);
+}
drivers/gpu/drm/drm_internal.h +7 -0
index fbc3f308fa19..430ce3fe4f3b 100644
@@ -106,6 +106,8 @@ int drm_gem_open_ioctl(struct drm_device *dev, void *data,
 		       struct drm_file *file_priv);
 void drm_gem_open(struct drm_device *dev, struct drm_file *file_private);
 void drm_gem_release(struct drm_device *dev, struct drm_file *file_private);
+void drm_gem_print_info(struct drm_printer *p, unsigned int indent,
+			const struct drm_gem_object *obj);
 
 /* drm_debugfs.c drm_debugfs_crc.c */
 #if defined(CONFIG_DEBUG_FS)
@@ -173,3 +175,8 @@ int drm_syncobj_reset_ioctl(struct drm_device *dev, void *data,
 			    struct drm_file *file_private);
 int drm_syncobj_signal_ioctl(struct drm_device *dev, void *data,
 			     struct drm_file *file_private);
+
+/* drm_framebuffer.c */
+void drm_framebuffer_print_info(struct drm_printer *p, unsigned int indent,
+				const struct drm_framebuffer *fb);
+int drm_framebuffer_debugfs_init(struct drm_minor *minor);
include/drm/drm_drv.h +15 -0
index 0e90ef24214b..1536e5bddeaf 100644
@@ -39,6 +39,7 @@ struct drm_minor;
 struct dma_buf_attachment;
 struct drm_display_mode;
 struct drm_mode_create_dumb;
+struct drm_printer;
 
 /* driver capabilities and requirements mask */
 #define DRIVER_USE_AGP			0x1
@@ -428,6 +429,20 @@ struct drm_driver {
 	 */
 	void (*gem_close_object) (struct drm_gem_object *, struct drm_file *);
 
+	/**
+	 * @gem_print_info:
+	 *
+	 * If driver subclasses struct &drm_gem_object, it can implement this
+	 * optional hook for printing additional driver specific info.
+	 *
+	 * drm_printf_indent() should be used in the callback passing it the
+	 * indent argument.
+	 *
+	 * This callback is called from drm_gem_print_info().
+	 */
+	void (*gem_print_info)(struct drm_printer *p, unsigned int indent,
+			       const struct drm_gem_object *obj);
+
 	/**
 	 * @gem_create_object: constructor for gem objects
 	 *
Signature · 6 lines
2.14.2

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#5 lore raw

Quoting Noralf Trønnes (2017-11-07 19:13:40)

Quoted 2 lines

Add debugfs file that dumps info about the framebuffers and its planes. Also dump info about any connected gem object(s).

This isn't too hot for non-modesetting drm drivers.

And isn't this growing a midlayer? Calling to the drivers instead of the drivers controlling and calling helpers for the common stuff. -Chris
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#6 lore raw

Den 11.11.2017 19.55, skrev Chris Wilson:

Quoted 7 lines

Quoting Noralf Trønnes (2017-11-07 19:13:40)

Quoted 2 lines

Add debugfs file that dumps info about the framebuffers and its planes. Also dump info about any connected gem object(s).

This isn't too hot for non-modesetting drm drivers.

And isn't this growing a midlayer? Calling to the drivers instead of the drivers controlling and calling helpers for the common stuff.

I really can't say, but Daniel asked me to do it like this:
https://lists.freedesktop.org/archives/dri-devel/2017-October/155245.html

Noralf.

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#7 lore raw

Quoting Noralf Trønnes (2017-11-13 19:54:43)

Quoted 6 lines

Den 11.11.2017 19.55, skrev Chris Wilson:

Quoted 4 lines

Quoting Noralf Trønnes (2017-11-07 19:13:40)

Quoted 2 lines

Add debugfs file that dumps info about the framebuffers and its planes. Also dump info about any connected gem object(s).

This isn't too hot for non-modesetting drm drivers.

Just to be clear; this is currently on fire in i915's CI. As framebuffer-info is installed for vgem and vgem hasn't initialised any of the data structs being inspected...
-Chris
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#8 lore raw

Den 13.11.2017 22.33, skrev Chris Wilson:

Quoted 9 lines

Quoting Noralf Trønnes (2017-11-13 19:54:43)

Quoted 5 lines

Den 11.11.2017 19.55, skrev Chris Wilson:

Quoted 4 lines

Quoting Noralf Trønnes (2017-11-07 19:13:40)

Quoted 2 lines

Add debugfs file that dumps info about the framebuffers and its planes. Also dump info about any connected gem object(s).

This isn't too hot for non-modesetting drm drivers.

Just to be clear; this is currently on fire in i915's CI. As framebuffer-info is installed for vgem and vgem hasn't initialised any of the data structs being inspected...

Ok, so I have broken vgem :-(

drm_framebuffer_info() takes dev->mode_config.fb_lock which hasn't been initialized because vgem doesn't call drm_mode_config_init(). drm_mode_config_init() in addition to initializing various thing also calls drm_mode_create_standard_properties().

Can we call drm_mode_config_init() in vgem or is this a no-go because of the properties? Do you see a solution to this?

Sorry about the fallout.

Noralf.

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#9 lore raw

Quoting Noralf Trønnes (2017-11-13 22:12:06)

Quoted 14 lines

Den 13.11.2017 22.33, skrev Chris Wilson:

Quoted 9 lines

Quoting Noralf Trønnes (2017-11-13 19:54:43)

Quoted 5 lines

Den 11.11.2017 19.55, skrev Chris Wilson:

Quoted 4 lines

Quoting Noralf Trønnes (2017-11-07 19:13:40)

Quoted 2 lines

Add debugfs file that dumps info about the framebuffers and its planes. Also dump info about any connected gem object(s).

This isn't too hot for non-modesetting drm drivers.

Just to be clear; this is currently on fire in i915's CI. As framebuffer-info is installed for vgem and vgem hasn't initialised any of the data structs being inspected...

Ok, so I have broken vgem :-(

Quoted 7 lines

drm_framebuffer_info() takes dev->mode_config.fb_lock which hasn't been initialized because vgem doesn't call drm_mode_config_init(). drm_mode_config_init() in addition to initializing various thing also calls drm_mode_create_standard_properties().

Can we call drm_mode_config_init() in vgem or is this a no-go because of the properties? Do you see a solution to this?

My quick fix idea was a drm_core_check_feature(dev, DRIVER_MODESET) around the drm_framebuffer_debugfs_init().
-Chris
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#10 lore raw

Den 13.11.2017 23.17, skrev Chris Wilson:

Quoted 18 lines

Quoting Noralf Trønnes (2017-11-13 22:12:06)

Quoted 17 lines

Den 13.11.2017 22.33, skrev Chris Wilson:

Quoted 9 lines

Quoting Noralf Trønnes (2017-11-13 19:54:43)

Quoted 5 lines

Den 11.11.2017 19.55, skrev Chris Wilson:

Quoted 4 lines

Quoting Noralf Trønnes (2017-11-07 19:13:40)

Quoted 2 lines

Add debugfs file that dumps info about the framebuffers and its planes. Also dump info about any connected gem object(s).

This isn't too hot for non-modesetting drm drivers.

Just to be clear; this is currently on fire in i915's CI. As framebuffer-info is installed for vgem and vgem hasn't initialised any of the data structs being inspected...

Ok, so I have broken vgem :-(

drm_framebuffer_info() takes dev->mode_config.fb_lock which hasn't been initialized because vgem doesn't call drm_mode_config_init(). drm_mode_config_init() in addition to initializing various thing also calls drm_mode_create_standard_properties().

Quoted 4 lines
Quoted 2 lines

Can we call drm_mode_config_init() in vgem or is this a no-go because of the properties? Do you see a solution to this?

My quick fix idea was a drm_core_check_feature(dev, DRIVER_MODESET) around the drm_framebuffer_debugfs_init().

Ah, yes, thank you!
That sounds like a good idea. I will create a patch.

Noralf.

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#11 lore raw
Quoted 20 lines · Noralf Trønnes

Den 13.11.2017 23.17, skrev Chris Wilson:

Quoted 18 lines

Quoting Noralf Trønnes (2017-11-13 22:12:06)

Quoted 17 lines

Den 13.11.2017 22.33, skrev Chris Wilson:

Quoted 9 lines

Quoting Noralf Trønnes (2017-11-13 19:54:43)

Quoted 5 lines

Den 11.11.2017 19.55, skrev Chris Wilson:

Quoted 4 lines

Quoting Noralf Trønnes (2017-11-07 19:13:40)

Quoted 2 lines

Add debugfs file that dumps info about the framebuffers and its planes. Also dump info about any connected gem object(s).

This isn't too hot for non-modesetting drm drivers.

Just to be clear; this is currently on fire in i915's CI. As framebuffer-info is installed for vgem and vgem hasn't initialised any of the data structs being inspected...

Ok, so I have broken vgem :-(

drm_framebuffer_info() takes dev->mode_config.fb_lock which hasn't been initialized because vgem doesn't call drm_mode_config_init(). drm_mode_config_init() in addition to initializing various thing also calls drm_mode_create_standard_properties().

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

Can we call drm_mode_config_init() in vgem or is this a no-go because of the properties? Do you see a solution to this?

My quick fix idea was a drm_core_check_feature(dev, DRIVER_MODESET) around the drm_framebuffer_debugfs_init().

Ah, yes, thank you!
That sounds like a good idea. I will create a patch.

Yeah we need that check, same way we have it in all the ioctls. Sorry for not spotting this, and yes we need our CI checking dri-devel patches, but just not there yet :-/
-Daniel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#12 lore raw

PATCH v5 5/12 drm/atomic: Use drm_framebuffer_print_info()

In reply to Noralf Trønnes

Use drm_framebuffer_print_info() to print framebuffer info in drm_atomic_plane_print_state(). This will give optional GEM info as well.

---
 drivers/gpu/drm/drm_atomic.c | 18 +++---------------
 1 file changed, 3 insertions(+), 15 deletions(-)
drivers/gpu/drm/drm_atomic.c +3 -15
index fd96c3dad2fb..bf8ca515c958 100644
@@ -33,6 +33,7 @@
 #include <linux/sync_file.h>
 
 #include "drm_crtc_internal.h"
+#include "drm_internal.h"
 
 void __drm_crtc_commit_free(struct kref *kref)
 {
@@ -935,21 +936,8 @@ static void drm_atomic_plane_print_state(struct drm_printer *p,
 	drm_printf(p, "plane[%u]: %s\n", plane->base.id, plane->name);
 	drm_printf(p, "\tcrtc=%s\n", state->crtc ? state->crtc->name : "(null)");
 	drm_printf(p, "\tfb=%u\n", state->fb ? state->fb->base.id : 0);
-	if (state->fb) {
-		struct drm_framebuffer *fb = state->fb;
-		int i, n = fb->format->num_planes;
-		struct drm_format_name_buf format_name;
-
-		drm_printf(p, "\t\tformat=%s\n",
-		              drm_get_format_name(fb->format->format, &format_name));
-		drm_printf(p, "\t\t\tmodifier=0x%llx\n", fb->modifier);
-		drm_printf(p, "\t\tsize=%dx%d\n", fb->width, fb->height);
-		drm_printf(p, "\t\tlayers:\n");
-		for (i = 0; i < n; i++) {
-			drm_printf(p, "\t\t\tpitch[%d]=%u\n", i, fb->pitches[i]);
-			drm_printf(p, "\t\t\toffset[%d]=%u\n", i, fb->offsets[i]);
-		}
-	}
+	if (state->fb)
+		drm_framebuffer_print_info(p, 2, state->fb);
 	drm_printf(p, "\tcrtc-pos=" DRM_RECT_FMT "\n", DRM_RECT_ARG(&dest));
 	drm_printf(p, "\tsrc-pos=" DRM_RECT_FP_FMT "\n", DRM_RECT_FP_ARG(&src));
 	drm_printf(p, "\trotation=%x\n", state->rotation);
Signature · 6 lines
2.14.2

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#13 lore raw

PATCH v5 6/12 drm/cma-helper: Turn to_drm_gem_cma_obj() into a macro

In reply to Noralf Trønnes

This allows the argument to be a const.

The other option was to keep it an inline function and make the argument a const:

static inline struct drm_gem_cma_object * to_drm_gem_cma_obj(const struct drm_gem_object *gem_obj)

{
	return container_of(gem_obj, struct drm_gem_cma_object, base);
}

This will happily return a non-const pointer to the drm_gem_cma_object based on a const pointer to the contained drm_gem_object, thus creating const-safety problems.

There was an attempt to fix the problem in the container_of() macro itself (see https://lkml.org/lkml/2017/5/19/381) but the patch seems to have fallen through the cracks. It would require turning this inline function into a macro.

By making this a macro now, we will benefit from a possible future enhancement of container_of(). We don't loose type checking by doing this, container_of() takes care of that.

---
 include/drm/drm_gem_cma_helper.h | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
include/drm/drm_gem_cma_helper.h +2 -5
index 58a739bf15f1..7a3dcf0cf289 100644
@@ -20,11 +20,8 @@ struct drm_gem_cma_object {
 	void *vaddr;
 };
 
-static inline struct drm_gem_cma_object *
-to_drm_gem_cma_obj(struct drm_gem_object *gem_obj)
-{
-	return container_of(gem_obj, struct drm_gem_cma_object, base);
-}
+#define to_drm_gem_cma_obj(gem_obj) \
+	container_of(gem_obj, struct drm_gem_cma_object, base)
 
 #ifndef CONFIG_MMU
 #define DRM_GEM_CMA_UNMAPPED_AREA_FOPS \
Signature · 6 lines
2.14.2

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Reviewed-by on v5 6/12
#14 lore raw

Re: [PATCH v5 06/12] drm/cma-helper: Turn to_drm_gem_cma_obj() into a macro

Hi Noralf,

Thank you for the patch.

Quoted 20 lines · On Tuesday, 7 November 2017 21:13:42 EET Noralf Trønnes wrote:

This allows the argument to be a const.

The other option was to keep it an inline function and make the argument a const:

static inline struct drm_gem_cma_object * to_drm_gem_cma_obj(const struct drm_gem_object *gem_obj)

{
	return container_of(gem_obj, struct drm_gem_cma_object, base);
}

This will happily return a non-const pointer to the drm_gem_cma_object based on a const pointer to the contained drm_gem_object, thus creating const-safety problems.

There was an attempt to fix the problem in the container_of() macro itself (see https://lkml.org/lkml/2017/5/19/381) but the patch seems to have fallen through the cracks. It would require turning this inline function into a macro.

Quoted 6 lines

By making this a macro now, we will benefit from a possible future enhancement of container_of(). We don't loose type checking by doing this, container_of() takes care of that.

Quoted 22 lines
---
 include/drm/drm_gem_cma_helper.h | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
(quoted diff) +0 -0

b/include/drm/drm_gem_cma_helper.h index 58a739bf15f1..7a3dcf0cf289 100644

include/drm/drm_gem_cma_helper.h +2 -5
@@ -20,11 +20,8 @@ struct drm_gem_cma_object {
 	void *vaddr;
 };
 
-static inline struct drm_gem_cma_object *
-to_drm_gem_cma_obj(struct drm_gem_object *gem_obj)
-{
-	return container_of(gem_obj, struct drm_gem_cma_object, base);
-}
+#define to_drm_gem_cma_obj(gem_obj) \
+	container_of(gem_obj, struct drm_gem_cma_object, base)
 
 #ifndef CONFIG_MMU
 #define DRM_GEM_CMA_UNMAPPED_AREA_FOPS \
Signature · 8 lines
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#15 lore raw

PATCH v5 7/12 drm/cma-helper: Add drm_gem_cma_print_info()

In reply to Noralf Trønnes

Add drm_gem_cma_print_info() for debugfs printing
struct drm_gem_cma_object specific info.

---
 drivers/gpu/drm/drm_gem_cma_helper.c | 19 +++++++++++++++++++
 include/drm/drm_gem_cma_helper.h     |  3 +++
 2 files changed, 22 insertions(+)
drivers/gpu/drm/drm_gem_cma_helper.c +19 -0
index 020e7668dfab..29f7b0fd3ad4 100644
@@ -423,6 +423,25 @@ void drm_gem_cma_describe(struct drm_gem_cma_object *cma_obj,
 EXPORT_SYMBOL_GPL(drm_gem_cma_describe);
 #endif
 
+/**
+ * drm_gem_cma_print_info() - Print &drm_gem_cma_object info for debugfs
+ * @p: DRM printer
+ * @indent: Tab indentation level
+ * @gem: GEM object
+ *
+ * This function can be used as the &drm_driver->gem_print_info callback.
+ * It prints paddr and vaddr for use in e.g. debugfs output.
+ */
+void drm_gem_cma_print_info(struct drm_printer *p, unsigned int indent,
+			    const struct drm_gem_object *obj)
+{
+	const struct drm_gem_cma_object *cma_obj = to_drm_gem_cma_obj(obj);
+
+	drm_printf_indent(p, indent, "paddr=%pad\n", &cma_obj->paddr);
+	drm_printf_indent(p, indent, "vaddr=%p\n", cma_obj->vaddr);
+}
+EXPORT_SYMBOL(drm_gem_cma_print_info);
+
 /**
  * drm_gem_cma_prime_get_sg_table - provide a scatter/gather table of pinned
  *     pages for a CMA GEM object
include/drm/drm_gem_cma_helper.h +3 -0
index 7a3dcf0cf289..40435f3480e5 100644
@@ -91,6 +91,9 @@ unsigned long drm_gem_cma_get_unmapped_area(struct file *filp,
 void drm_gem_cma_describe(struct drm_gem_cma_object *obj, struct seq_file *m);
 #endif
 
+void drm_gem_cma_print_info(struct drm_printer *p, unsigned int indent,
+			    const struct drm_gem_object *obj);
+
 struct sg_table *drm_gem_cma_prime_get_sg_table(struct drm_gem_object *obj);
 struct drm_gem_object *
 drm_gem_cma_prime_import_sg_table(struct drm_device *dev,
Signature · 6 lines
2.14.2

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#16 lore raw

PATCH v5 8/12 drm/arc: Use drm_gem_cma_print_info()

In reply to Noralf Trønnes

There is a new core debugfs file that prints fb/gem info:
<debugfs>/dri/<n>/framebuffer

Use drm_gem_cma_print_info() to provide info to that output instead of using drm_fb_cma_debugfs_show().

---
 drivers/gpu/drm/arc/arcpgu_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/arc/arcpgu_drv.c +1 -1
index 074fd4ea7ece..f067de4e1e82 100644
@@ -155,7 +155,6 @@ static int arcpgu_show_pxlclock(struct seq_file *m, void *arg)
 
 static struct drm_info_list arcpgu_debugfs_list[] = {
 	{ "clocks", arcpgu_show_pxlclock, 0 },
-	{ "fb", drm_fb_cma_debugfs_show, 0 },
 };
 
 static int arcpgu_debugfs_init(struct drm_minor *minor)
@@ -180,6 +179,7 @@ static struct drm_driver arcpgu_drm_driver = {
 	.prime_handle_to_fd = drm_gem_prime_handle_to_fd,
 	.prime_fd_to_handle = drm_gem_prime_fd_to_handle,
 	.gem_free_object_unlocked = drm_gem_cma_free_object,
+	.gem_print_info = drm_gem_cma_print_info,
 	.gem_vm_ops = &drm_gem_cma_vm_ops,
 	.gem_prime_export = drm_gem_prime_export,
 	.gem_prime_import = drm_gem_prime_import,
Signature · 6 lines
2.14.2

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Acked-by on v5 8/12
#17 lore raw

Re: [PATCH v5 08/12] drm/arc: Use drm_gem_cma_print_info()

Hi Noralf,

Quoted 9 lines · Noralf Trønnes

There is a new core debugfs file that prints fb/gem info:
<debugfs>/dri/<n>/framebuffer

Use drm_gem_cma_print_info() to provide info to that output instead of using drm_fb_cma_debugfs_show().

I think I acked the previous version but anyways,

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#18 lore raw

Re: [PATCH v5 08/12] drm/arc: Use drm_gem_cma_print_info()

Den 07.11.2017 20.31, skrev Alexey Brodkin:

Quoted 9 lines

Hi Noralf,

Quoted 6 lines · Noralf Trønnes

There is a new core debugfs file that prints fb/gem info:
<debugfs>/dri/<n>/framebuffer

Use drm_gem_cma_print_info() to provide info to that output instead of using drm_fb_cma_debugfs_show().

Quoted 7 lines
Quoted 3 lines

I think I acked the previous version but anyways,

Indeed you did, but somehow patchwork didn't catch it:
https://patchwork.freedesktop.org/patch/185349/

But the ml did:
https://lists.freedesktop.org/archives/dri-devel/2017-October/156438.html

I use patchwork to respin series because I get all ack/rb applied automatically. Thanks for re-acking :-)

Noralf.

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

author Acked-by Alexey Brodkin
#19 lore raw

Re: [PATCH v5 08/12] drm/arc: Use drm_gem_cma_print_info()

Den 09.11.2017 16.52, skrev Noralf Trønnes:

Quoted 19 lines

Den 07.11.2017 20.31, skrev Alexey Brodkin:

Quoted 9 lines

Hi Noralf,

Quoted 6 lines · Noralf Trønnes

There is a new core debugfs file that prints fb/gem info:
<debugfs>/dri/<n>/framebuffer

Use drm_gem_cma_print_info() to provide info to that output instead of using drm_fb_cma_debugfs_show().

Quoted 7 lines
Quoted 3 lines

I think I acked the previous version but anyways,

Quoted 9 lines

Indeed you did, but somehow patchwork didn't catch it:
https://patchwork.freedesktop.org/patch/185349/

But the ml did:
https://lists.freedesktop.org/archives/dri-devel/2017-October/156438.html

I use patchwork to respin series because I get all ack/rb applied automatically. Thanks for re-acking :-)

Strange, patchwork didn't get your ack this time either:
https://patchwork.freedesktop.org/patch/186972/

I put your ack here so I don't miss it when I apply the patches:

Noralf.

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#20 lore raw

PATCH v5 9/12 drm/arm/hdlcd: Use drm_gem_cma_print_info()

In reply to Noralf Trønnes

There is a new core debugfs file that prints fb/gem info:
<debugfs>/dri/<n>/framebuffer

Use drm_gem_cma_print_info() to provide info to that output instead of using drm_fb_cma_debugfs_show().

---
 drivers/gpu/drm/arm/hdlcd_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/arm/hdlcd_drv.c +1 -1
index 764d0c83710c..59b21bdc0c30 100644
@@ -230,7 +230,6 @@ static int hdlcd_show_pxlclock(struct seq_file *m, void *arg)
 static struct drm_info_list hdlcd_debugfs_list[] = {
 	{ "interrupt_count", hdlcd_show_underrun_count, 0 },
 	{ "clocks", hdlcd_show_pxlclock, 0 },
-	{ "fb", drm_fb_cma_debugfs_show, 0 },
 };
 
 static int hdlcd_debugfs_init(struct drm_minor *minor)
@@ -252,6 +251,7 @@ static struct drm_driver hdlcd_driver = {
 	.irq_postinstall = hdlcd_irq_postinstall,
 	.irq_uninstall = hdlcd_irq_uninstall,
 	.gem_free_object_unlocked = drm_gem_cma_free_object,
+	.gem_print_info = drm_gem_cma_print_info,
 	.gem_vm_ops = &drm_gem_cma_vm_ops,
 	.dumb_create = drm_gem_cma_dumb_create,
 	.prime_handle_to_fd = drm_gem_prime_handle_to_fd,
Signature · 6 lines
2.14.2

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#21 lore raw

PATCH v5 10/12 drm/tilcdc: Use drm_gem_cma_print_info()

In reply to Noralf Trønnes

There is a new core debugfs file that prints fb/gem info:
<debugfs>/dri/<n>/framebuffer

Use drm_gem_cma_print_info() to provide info to that output instead of using drm_fb_cma_debugfs_show().

---
 drivers/gpu/drm/tilcdc/tilcdc_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/tilcdc/tilcdc_drv.c +1 -1
index 72ce063aa0d8..bc4feb3a84b9 100644
@@ -507,7 +507,6 @@ static int tilcdc_mm_show(struct seq_file *m, void *arg)
 static struct drm_info_list tilcdc_debugfs_list[] = {
 		{ "regs", tilcdc_regs_show, 0 },
 		{ "mm",   tilcdc_mm_show,   0 },
-		{ "fb",   drm_fb_cma_debugfs_show, 0 },
 };
 
 static int tilcdc_debugfs_init(struct drm_minor *minor)
@@ -541,6 +540,7 @@ static struct drm_driver tilcdc_driver = {
 	.lastclose          = tilcdc_lastclose,
 	.irq_handler        = tilcdc_irq,
 	.gem_free_object_unlocked = drm_gem_cma_free_object,
+	.gem_print_info     = drm_gem_cma_print_info,
 	.gem_vm_ops         = &drm_gem_cma_vm_ops,
 	.dumb_create        = drm_gem_cma_dumb_create,
 
Signature · 6 lines
2.14.2

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#22 lore raw

PATCH v5 11/12 drm/tinydrm: Use drm_gem_cma_print_info()

In reply to Noralf Trønnes

There is a new core debugfs file that prints fb/gem info:
<debugfs>/dri/<n>/framebuffer

Use drm_gem_cma_print_info() to provide info to that output instead of using drm_fb_cma_debugfs_show().

---
 drivers/gpu/drm/tinydrm/mipi-dbi.c | 8 +-------
 include/drm/tinydrm/tinydrm.h      | 1 +
 2 files changed, 2 insertions(+), 7 deletions(-)
drivers/gpu/drm/tinydrm/mipi-dbi.c +1 -7
index d43e992ab432..347f9b226f26 100644
@@ -961,10 +961,6 @@ static const struct file_operations mipi_dbi_debugfs_command_fops = {
 	.write = mipi_dbi_debugfs_command_write,
 };
 
-static const struct drm_info_list mipi_dbi_debugfs_list[] = {
-	{ "fb",   drm_fb_cma_debugfs_show, 0 },
-};
-
 /**
  * mipi_dbi_debugfs_init - Create debugfs entries
  * @minor: DRM minor
@@ -987,9 +983,7 @@ int mipi_dbi_debugfs_init(struct drm_minor *minor)
 	debugfs_create_file("command", mode, minor->debugfs_root, mipi,
 			    &mipi_dbi_debugfs_command_fops);
 
-	return drm_debugfs_create_files(mipi_dbi_debugfs_list,
-					ARRAY_SIZE(mipi_dbi_debugfs_list),
-					minor->debugfs_root, minor);
+	return 0;
 }
 EXPORT_SYMBOL(mipi_dbi_debugfs_init);
 
include/drm/tinydrm/tinydrm.h +1 -0
index 4774fe3d4273..423828922e5a 100644
@@ -46,6 +46,7 @@ pipe_to_tinydrm(struct drm_simple_display_pipe *pipe)
  */
 #define TINYDRM_GEM_DRIVER_OPS \
 	.gem_free_object	= tinydrm_gem_cma_free_object, \
+	.gem_print_info		= drm_gem_cma_print_info, \
 	.gem_vm_ops		= &drm_gem_cma_vm_ops, \
 	.prime_handle_to_fd	= drm_gem_prime_handle_to_fd, \
 	.prime_fd_to_handle	= drm_gem_prime_fd_to_handle, \
Signature · 6 lines
2.14.2

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#23 lore raw

PATCH v5 12/12 drm/cma-helper: Remove drm_fb_cma_debugfs_show()

In reply to Noralf Trønnes

drm_fb_cma_debugfs_show() and drm_gem_cma_describe() are superseded by drm_framebuffer_debugfs_init() and drm_gem_cma_print_info().

---
 drivers/gpu/drm/drm_fb_cma_helper.c  | 37 ------------------------------------
 drivers/gpu/drm/drm_gem_cma_helper.c | 26 -------------------------
 include/drm/drm_fb_cma_helper.h      |  6 ------
 include/drm/drm_gem_cma_helper.h     |  4 ----
 4 files changed, 73 deletions(-)
drivers/gpu/drm/drm_fb_cma_helper.c +0 -37
index 0e3c14174d08..35b56dfba929 100644
@@ -130,43 +130,6 @@ dma_addr_t drm_fb_cma_get_gem_addr(struct drm_framebuffer *fb,
 }
 EXPORT_SYMBOL_GPL(drm_fb_cma_get_gem_addr);
 
-#ifdef CONFIG_DEBUG_FS
-static void drm_fb_cma_describe(struct drm_framebuffer *fb, struct seq_file *m)
-{
-	int i;
-
-	seq_printf(m, "fb: %dx%d@%4.4s\n", fb->width, fb->height,
-			(char *)&fb->format->format);
-
-	for (i = 0; i < fb->format->num_planes; i++) {
-		seq_printf(m, "   %d: offset=%d pitch=%d, obj: ",
-				i, fb->offsets[i], fb->pitches[i]);
-		drm_gem_cma_describe(drm_fb_cma_get_gem_obj(fb, i), m);
-	}
-}
-
-/**
- * drm_fb_cma_debugfs_show() - Helper to list CMA framebuffer objects
- *			       in debugfs.
- * @m: output file
- * @arg: private data for the callback
- */
-int drm_fb_cma_debugfs_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_framebuffer *fb;
-
-	mutex_lock(&dev->mode_config.fb_lock);
-	drm_for_each_fb(fb, dev)
-		drm_fb_cma_describe(fb, m);
-	mutex_unlock(&dev->mode_config.fb_lock);
-
-	return 0;
-}
-EXPORT_SYMBOL_GPL(drm_fb_cma_debugfs_show);
-#endif
-
 static int drm_fb_cma_mmap(struct fb_info *info, struct vm_area_struct *vma)
 {
 	return dma_mmap_writecombine(info->device, vma, info->screen_base,
drivers/gpu/drm/drm_gem_cma_helper.c +0 -26
index 29f7b0fd3ad4..88ad88719605 100644
@@ -397,32 +397,6 @@ unsigned long drm_gem_cma_get_unmapped_area(struct file *filp,
 EXPORT_SYMBOL_GPL(drm_gem_cma_get_unmapped_area);
 #endif
 
-#ifdef CONFIG_DEBUG_FS
-/**
- * drm_gem_cma_describe - describe a CMA GEM object for debugfs
- * @cma_obj: CMA GEM object
- * @m: debugfs file handle
- *
- * This function can be used to dump a human-readable representation of the
- * CMA GEM object into a synthetic file.
- */
-void drm_gem_cma_describe(struct drm_gem_cma_object *cma_obj,
-			  struct seq_file *m)
-{
-	struct drm_gem_object *obj = &cma_obj->base;
-	uint64_t off;
-
-	off = drm_vma_node_start(&obj->vma_node);
-
-	seq_printf(m, "%2d (%2d) %08llx %pad %p %zu",
-			obj->name, kref_read(&obj->refcount),
-			off, &cma_obj->paddr, cma_obj->vaddr, obj->size);
-
-	seq_printf(m, "\n");
-}
-EXPORT_SYMBOL_GPL(drm_gem_cma_describe);
-#endif
-
 /**
  * drm_gem_cma_print_info() - Print &drm_gem_cma_object info for debugfs
  * @p: DRM printer
include/drm/drm_fb_cma_helper.h +0 -6
index 023f052a5873..a613ff022e6c 100644
@@ -35,11 +35,5 @@ dma_addr_t drm_fb_cma_get_gem_addr(struct drm_framebuffer *fb,
 				   struct drm_plane_state *state,
 				   unsigned int plane);
 
-#ifdef CONFIG_DEBUG_FS
-struct seq_file;
-
-int drm_fb_cma_debugfs_show(struct seq_file *m, void *arg);
-#endif
-
 #endif
 
include/drm/drm_gem_cma_helper.h +0 -4
index 40435f3480e5..76ded75f02cc 100644
@@ -87,10 +87,6 @@ unsigned long drm_gem_cma_get_unmapped_area(struct file *filp,
 					    unsigned long flags);
 #endif
 
-#ifdef CONFIG_DEBUG_FS
-void drm_gem_cma_describe(struct drm_gem_cma_object *obj, struct seq_file *m);
-#endif
-
 void drm_gem_cma_print_info(struct drm_printer *p, unsigned int indent,
 			    const struct drm_gem_object *obj);
 
Signature · 6 lines
2.14.2

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#24 lore raw
In reply to Noralf Trønnes

Den 07.11.2017 20.13, skrev Noralf Trønnes:

Quoted 16 lines

This patchset adds a debugfs file that prints info about the framebuffers.

Changes since version 4:
- Add framebuffer debugfs file: Fix printk formats and add info about indent argument in gem_print_info callback docs (Laurent)
- Turn to_drm_gem_cma_obj() into a macro (Laurent)
- drm_gem_cma_print_info(): Make the cma_obj variable a const since it is derived from the obj variable which is a const.

Changes since version 3:
- Applied patch: drm/gem: Remove trailing whitespace
- Turn drm_printf_indent() into a macro (Ville)
- drm_printf_indent() add overflow marker (Jani)
- Converted arc, hdlcd, tilcdc and removed drm_fb_cma_debugfs_show()

Quoted 13 lines

Noralf Trønnes (12):
drm/vma-manager: drm_vma_node_start() constify argument drm/framebuffer: drm_framebuffer_read_refcount() constify argument drm/print: Add drm_printf_indent()
drm/framebuffer: Add framebuffer debugfs file drm/atomic: Use drm_framebuffer_print_info() drm/cma-helper: Turn to_drm_gem_cma_obj() into a macro drm/cma-helper: Add drm_gem_cma_print_info()
drm/arc: Use drm_gem_cma_print_info()
drm/arm/hdlcd: Use drm_gem_cma_print_info()
drm/tilcdc: Use drm_gem_cma_print_info()
drm/tinydrm: Use drm_gem_cma_print_info() drm/cma-helper: Remove drm_fb_cma_debugfs_show()

Series applied to drm-misc-next.
Thanks for reviewing!

Noralf.

Quoted 20 lines
  drivers/gpu/drm/arc/arcpgu_drv.c     |  2 +-
  drivers/gpu/drm/arm/hdlcd_drv.c      |  2 +-
  drivers/gpu/drm/drm_atomic.c         | 18 ++---------
  drivers/gpu/drm/drm_debugfs.c        |  6 ++++
  drivers/gpu/drm/drm_fb_cma_helper.c  | 37 ----------------------
  drivers/gpu/drm/drm_framebuffer.c    | 59 ++++++++++++++++++++++++++++++++++++
  drivers/gpu/drm/drm_gem.c            | 17 +++++++++++
  drivers/gpu/drm/drm_gem_cma_helper.c | 31 ++++++++-----------
  drivers/gpu/drm/drm_internal.h       |  7 +++++
  drivers/gpu/drm/tilcdc/tilcdc_drv.c  |  2 +-
  drivers/gpu/drm/tinydrm/mipi-dbi.c   |  8 +----
  include/drm/drm_drv.h                | 15 +++++++++
  include/drm/drm_fb_cma_helper.h      |  6 ----
  include/drm/drm_framebuffer.h        |  2 +-
  include/drm/drm_gem_cma_helper.h     | 12 +++-----
  include/drm/drm_print.h              |  8 +++++
  include/drm/drm_vma_manager.h        |  2 +-
  include/drm/tinydrm/tinydrm.h        |  1 +
  18 files changed, 138 insertions(+), 97 deletions(-)
Quoted 3 lines

--
2.14.2

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel