Skip to contentSkip to conversation

drm/framebuffer: Add framebuffer debugfs file

PATCH Superseded Noralf Trønnes 4 participants 15 messages Oct 26, 2017 – Oct 30, 2017

Subsystems (2)

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v3 cover drm/framebuffer: Add framebuffer debugfs file

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

This version has a lot of changes since the previous version. The previous version was inspired by drm_fb_cma_debugfs_show(), but this one strictly follows the style of drm_state_info(). This means that the added drm_framebuffer_print_info() could also be used in drm_atomic_plane_print_state(). In order to do that I had to add a way to vary indentation to fit both use cases.

I've also converted the cma helper so I could add the driver callback. If this approach turns out to be the way to go, I'll convert hdlcd and tilcdc as well in the next version so I can remove drm_fb_cma_debugfs_show().

This is how it looks:

$ sudo cat /sys/kernel/debug/dri/0/framebuffer
framebuffer[33]:
        refcount=3
        format=RG16 little-endian (0x36314752)
        modifier=0x0
        size=320x240
        layers:
                size[0]=320x240
                pitch[0]=640
                offset[0]=0
                obj[0]:
                        name=0
                        refcount=1
                        start=00010000
                        size=155648
                        imported=no
                        paddr=0x17c80000
                        vaddr=d7c80000
$ sudo cat /sys/kernel/debug/dri/0/state
plane[28]: plane-0
        crtc=crtc-0
        fb=33
                refcount=3
                format=RG16 little-endian (0x36314752)
                modifier=0x0
                size=320x240
                layers:
                        size[0]=320x240
                        pitch[0]=640
                        offset[0]=0
                        obj[0]:
                                name=0
                                refcount=1
                                start=00010000
                                size=155648
                                imported=no
                                paddr=0x17c80000
                                vaddr=d7c80000
        crtc-pos=320x240+0+0
        src-pos=320.000000x240.000000+0.000000+0.000000
        rotation=1
crtc[29]: crtc-0
<...>

Noralf Trønnes (8):
drm/vma-manager: drm_vma_node_start() constify argument drm/framebuffer: drm_framebuffer_read_refcount() constify argument drm/gem: Remove trailing whitespace
drm/print: Add drm_printf_indent()
drm/framebuffer: Add framebuffer debugfs file drm/atomic: Use drm_framebuffer_print_info() drm/cma-helper: Add drm_gem_cma_print_info() drm/tinydrm: Use drm_gem_cma_print_info()

 drivers/gpu/drm/drm_atomic.c         | 18 ++---------
 drivers/gpu/drm/drm_debugfs.c        |  6 ++++
 drivers/gpu/drm/drm_framebuffer.c    | 59 ++++++++++++++++++++++++++++++++++++
 drivers/gpu/drm/drm_gem.c            | 21 +++++++++++--
 drivers/gpu/drm/drm_gem_cma_helper.c | 19 ++++++++++++
 drivers/gpu/drm/drm_internal.h       |  7 +++++
 drivers/gpu/drm/drm_print.c          | 21 +++++++++++++
 drivers/gpu/drm/tinydrm/mipi-dbi.c   |  8 +----
 include/drm/drm_drv.h                | 11 +++++++
 include/drm/drm_framebuffer.h        |  2 +-
 include/drm/drm_gem_cma_helper.h     |  5 ++-
 include/drm/drm_print.h              |  2 ++
 include/drm/drm_vma_manager.h        |  2 +-
 include/drm/tinydrm/tinydrm.h        |  1 +
 14 files changed, 155 insertions(+), 27 deletions(-)

--
2.14.2

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

#1 lore raw

PATCH v3 1/8 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 v3 2/8 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 v3 3/8 drm/gem: Remove trailing whitespace

In reply to Noralf Trønnes

Remove two trailing spaces.

---
 drivers/gpu/drm/drm_gem.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/drm_gem.c +2 -2
index 55d6182555c7..4c84b23d37cc 100644
@@ -348,7 +348,7 @@ EXPORT_SYMBOL_GPL(drm_gem_dumb_map_offset);
  * @file: drm file-private structure to remove the dumb handle from
  * @dev: corresponding drm_device
  * @handle: the dumb handle to remove
- * 
+ *
  * This implements the &drm_driver.dumb_destroy kms driver callback for drivers
  * which use gem to manage their backing storage.
  */
@@ -365,7 +365,7 @@ EXPORT_SYMBOL(drm_gem_dumb_destroy);
  * @file_priv: drm file-private structure to register the handle for
  * @obj: object to register
  * @handlep: pointer to return the created handle to the caller
- * 
+ *
  * This expects the &drm_device.object_name_lock to be held already and will
  * drop it before returning. Used to avoid races in establishing new handles
  * when importing an object from either an flink name or a dma-buf.
Signature · 6 lines
2.14.2

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Reviewed-by on v3 3/8
#4 lore raw

Re: [PATCH v3 3/8] drm/gem: Remove trailing whitespace

Quoted 3 lines · Noralf Trønnes

Remove two trailing spaces.

Patches 1-3 are

Quoted 28 lines
---
 drivers/gpu/drm/drm_gem.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/drm_gem.c +2 -2
index 55d6182555c7..4c84b23d37cc 100644
@@ -348,7 +348,7 @@ EXPORT_SYMBOL_GPL(drm_gem_dumb_map_offset);
  * @file: drm file-private structure to remove the dumb handle from
  * @dev: corresponding drm_device
  * @handle: the dumb handle to remove
- * 
+ *
  * This implements the &drm_driver.dumb_destroy kms driver callback for drivers
  * which use gem to manage their backing storage.
  */
@@ -365,7 +365,7 @@ EXPORT_SYMBOL(drm_gem_dumb_destroy);
  * @file_priv: drm file-private structure to register the handle for
  * @obj: object to register
  * @handlep: pointer to return the created handle to the caller
- * 
+ *
  * This expects the &drm_device.object_name_lock to be held already and will
  * drop it before returning. Used to avoid races in establishing new handles
  * when importing an object from either an flink name or a dma-buf.
Signature · 1 line
2.14.2
Signature · 6 lines
Ville Syrjälä
Intel OTC
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#5 lore raw

PATCH v3 4/8 drm/print: Add drm_printf_indent()

In reply to Noralf Trønnes

Add drm_printf_indent() that adds tab indentation according to argument.

---
 drivers/gpu/drm/drm_print.c | 21 +++++++++++++++++++++
 include/drm/drm_print.h     |  2 ++
 2 files changed, 23 insertions(+)
drivers/gpu/drm/drm_print.c +21 -0
index 0b3bf476dc4b..dac3ee98b30f 100644
@@ -64,6 +64,27 @@ void drm_printf(struct drm_printer *p, const char *f, ...)
 }
 EXPORT_SYMBOL(drm_printf);
 
+/**
+ * drm_printf_indent - print to a &drm_printer stream with indentation
+ * @p: the &drm_printer
+ * @i: indentation
+ * @f: format string
+ */
+void drm_printf_indent(struct drm_printer *p, unsigned int i, const char *f, ...)
+{
+	struct va_format vaf;
+	va_list args;
+
+	drm_printf(p, "%.*s", i, "\t\t\t\t\t\t\t\t\t\t");
+
+	va_start(args, f);
+	vaf.fmt = f;
+	vaf.va = &args;
+	p->printfn(p, &vaf);
+	va_end(args);
+}
+EXPORT_SYMBOL(drm_printf_indent);
+
 #define DRM_PRINTK_FMT "[" DRM_NAME ":%s]%s %pV"
 
 void drm_dev_printk(const struct device *dev, const char *level,
include/drm/drm_print.h +2 -0
index 7b9c86a6ca3e..73dcd16eca49 100644
@@ -79,6 +79,8 @@ 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, ...);
+__printf(3, 4)
+void drm_printf_indent(struct drm_printer *p, unsigned int i, const char *f, ...);
 
 
 /**
Signature · 6 lines
2.14.2

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

Re: [PATCH v3 4/8] drm/print: Add drm_printf_indent()

Quoted 26 lines · Noralf Trønnes

Add drm_printf_indent() that adds tab indentation according to argument.

---
 drivers/gpu/drm/drm_print.c | 21 +++++++++++++++++++++
 include/drm/drm_print.h     |  2 ++
 2 files changed, 23 insertions(+)
drivers/gpu/drm/drm_print.c +10 -0
index 0b3bf476dc4b..dac3ee98b30f 100644
@@ -64,6 +64,27 @@ void drm_printf(struct drm_printer *p, const char *f, ...)
 }
 EXPORT_SYMBOL(drm_printf);
 
+/**
+ * drm_printf_indent - print to a &drm_printer stream with indentation
+ * @p: the &drm_printer
+ * @i: indentation
+ * @f: format string
+ */
+void drm_printf_indent(struct drm_printer *p, unsigned int i, const char *f, ...)
+{
+	struct va_format vaf;
+	va_list args;

drivers/gpu/drm/drm_print.c void drm_printf(struct drm_printer *p, const char *f, ...) · line 86

Quoted 10 lines
drivers/gpu/drm/drm_print.c +10 -0
+
+	drm_printf(p, "%.*s", i, "\t\t\t\t\t\t\t\t\t\t");
+
+	va_start(args, f);
+	vaf.fmt = f;
+	vaf.va = &args;
+	p->printfn(p, &vaf);
+	va_end(args);
+}
+EXPORT_SYMBOL(drm_printf_indent);

The double printf() is rather unfortunate. Sadly I don't think there's any proper way to manipulate a va_list to avoid that.

Hmm. Would it work if we simply make it a macro? Eg.

#define drm_printf_indent(printer, indent, fmt, ...) \
	drm_printf((printer), "%.*s" fmt, (indent), "\t\t\t", ##__VA_ARGS__)

The "\t\t\t..." thing is also rather off putting, but I guess it's the best we can do if we want to keep it to one printf(). And maybe we should have a check in there to make sure we have enought tabs in the string to satisfy the indent level, or we just clamp the indent level silently to something reasonable?

Oh, seeing the \t now reminds me that tabs won't necesarily get printed out properly. At least I've seen fbcon just printing some weird blobs instead of tabs. Not sure if it's just a matter of having a crappy font or what. That said, the state dump code is using tabs already, so I guess this wouldn't make it worse at least.

Quoted 19 lines
drivers/gpu/drm/drm_print.c +1 -0
+
 #define DRM_PRINTK_FMT "[" DRM_NAME ":%s]%s %pV"
 
 void drm_dev_printk(const struct device *dev, const char *level,
include/drm/drm_print.h +2 -0
index 7b9c86a6ca3e..73dcd16eca49 100644
@@ -79,6 +79,8 @@ 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, ...);
+__printf(3, 4)
+void drm_printf_indent(struct drm_printer *p, unsigned int i, const char *f, ...);
 
 
 /**
Signature · 1 line
2.14.2
Signature · 6 lines
Ville Syrjälä
Intel OTC
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#7 lore raw

Re: [PATCH v3 4/8] drm/print: Add drm_printf_indent()

Den 26.10.2017 19.49, skrev Ville Syrjälä:

Quoted 40 lines · Noralf Trønnes
Quoted 26 lines

Add drm_printf_indent() that adds tab indentation according to argument.

---
  drivers/gpu/drm/drm_print.c | 21 +++++++++++++++++++++
  include/drm/drm_print.h     |  2 ++
  2 files changed, 23 insertions(+)
drivers/gpu/drm/drm_print.c +10 -0
index 0b3bf476dc4b..dac3ee98b30f 100644
@@ -64,6 +64,27 @@ void drm_printf(struct drm_printer *p, const char *f, ...)
  }
  EXPORT_SYMBOL(drm_printf);
 
+/**
+ * drm_printf_indent - print to a &drm_printer stream with indentation
+ * @p: the &drm_printer
+ * @i: indentation
+ * @f: format string
+ */
+void drm_printf_indent(struct drm_printer *p, unsigned int i, const char *f, ...)
+{
+	struct va_format vaf;
+	va_list args;

drivers/gpu/drm/drm_print.c void drm_printf(struct drm_printer *p, const char *f, ...) · line 86

Quoted 10 lines
drivers/gpu/drm/drm_print.c +10 -0
+
+	drm_printf(p, "%.*s", i, "\t\t\t\t\t\t\t\t\t\t");
+
+	va_start(args, f);
+	vaf.fmt = f;
+	vaf.va = &args;
+	p->printfn(p, &vaf);
+	va_end(args);
+}
+EXPORT_SYMBOL(drm_printf_indent);

The double printf() is rather unfortunate. Sadly I don't think there's any proper way to manipulate a va_list to avoid that.

Quoted 4 lines

Hmm. Would it work if we simply make it a macro? Eg.

#define drm_printf_indent(printer, indent, fmt, ...) \
	drm_printf((printer), "%.*s" fmt, (indent), "\t\t\t", ##__VA_ARGS__)

The macro worked fine and it looks like a better solution to me.

Quoted 5 lines

The "\t\t\t..." thing is also rather off putting, but I guess it's the best we can do if we want to keep it to one printf(). And maybe we should have a check in there to make sure we have enought tabs in the string to satisfy the indent level, or we just clamp the indent level silently to something reasonable?

I put 10 tabs in my suggestion, which should be enough and I think it's OK to just silently fail to do more. If 10 isn't enough it's easy to add more for the developer that hits the limit.

Noralf.

Quoted 22 lines

Oh, seeing the \t now reminds me that tabs won't necesarily get printed out properly. At least I've seen fbcon just printing some weird blobs instead of tabs. Not sure if it's just a matter of having a crappy font or what. That said, the state dump code is using tabs already, so I guess this wouldn't make it worse at least.

Quoted 16 lines
drivers/gpu/drm/drm_print.c +1 -0
+
  #define DRM_PRINTK_FMT "[" DRM_NAME ":%s]%s %pV"
 
  void drm_dev_printk(const struct device *dev, const char *level,
include/drm/drm_print.h +2 -0
index 7b9c86a6ca3e..73dcd16eca49 100644
@@ -79,6 +79,8 @@ 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, ...);
+__printf(3, 4)
+void drm_printf_indent(struct drm_printer *p, unsigned int i, const char *f, ...);
 
 
Quoted 3 lines
Quoted 3 lines
include/drm/drm_print.h +0 -0
  /**
Signature · 1 line
2.14.2

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

#8 lore raw

Re: [PATCH v3 4/8] drm/print: Add drm_printf_indent()

Quoted 42 lines · Noralf Trønnes

Den 26.10.2017 19.49, skrev Ville Syrjälä:

Quoted 40 lines · Noralf Trønnes
Quoted 26 lines

Add drm_printf_indent() that adds tab indentation according to argument.

---
  drivers/gpu/drm/drm_print.c | 21 +++++++++++++++++++++
  include/drm/drm_print.h     |  2 ++
  2 files changed, 23 insertions(+)
drivers/gpu/drm/drm_print.c +10 -0
index 0b3bf476dc4b..dac3ee98b30f 100644
@@ -64,6 +64,27 @@ void drm_printf(struct drm_printer *p, const char *f, ...)
  }
  EXPORT_SYMBOL(drm_printf);
 
+/**
+ * drm_printf_indent - print to a &drm_printer stream with indentation
+ * @p: the &drm_printer
+ * @i: indentation
+ * @f: format string
+ */
+void drm_printf_indent(struct drm_printer *p, unsigned int i, const char *f, ...)
+{
+	struct va_format vaf;
+	va_list args;

drivers/gpu/drm/drm_print.c void drm_printf(struct drm_printer *p, const char *f, ...) · line 86

Quoted 10 lines
drivers/gpu/drm/drm_print.c +10 -0
+
+	drm_printf(p, "%.*s", i, "\t\t\t\t\t\t\t\t\t\t");
+
+	va_start(args, f);
+	vaf.fmt = f;
+	vaf.va = &args;
+	p->printfn(p, &vaf);
+	va_end(args);
+}
+EXPORT_SYMBOL(drm_printf_indent);

The double printf() is rather unfortunate. Sadly I don't think there's any proper way to manipulate a va_list to avoid that.

Quoted 6 lines
Quoted 4 lines

Hmm. Would it work if we simply make it a macro? Eg.

#define drm_printf_indent(printer, indent, fmt, ...) \
	drm_printf((printer), "%.*s" fmt, (indent), "\t\t\t", ##__VA_ARGS__)

The macro worked fine and it looks like a better solution to me.

Only downside is that it bloats every format string. But as long as there aren't a huge number of useless callers we should be fine.

Quoted 10 lines
Quoted 6 lines

The "\t\t\t..." thing is also rather off putting, but I guess it's the best we can do if we want to keep it to one printf(). And maybe we should have a check in there to make sure we have enought tabs in the string to satisfy the indent level, or we just clamp the indent level silently to something reasonable?

I put 10 tabs in my suggestion, which should be enough and I think it's OK to just silently fail to do more. If 10 isn't enough it's easy to add more for the developer that hits the limit.

10 is probably even overkill. I'd say if you have to go past four or so then there's alredy a bigger problem in the code ;)

Quoted 28 lines

Noralf.

Quoted 25 lines

Oh, seeing the \t now reminds me that tabs won't necesarily get printed out properly. At least I've seen fbcon just printing some weird blobs instead of tabs. Not sure if it's just a matter of having a crappy font or what. That said, the state dump code is using tabs already, so I guess this wouldn't make it worse at least.

Quoted 19 lines
drivers/gpu/drm/drm_print.c +1 -0
+
  #define DRM_PRINTK_FMT "[" DRM_NAME ":%s]%s %pV"
 
  void drm_dev_printk(const struct device *dev, const char *level,
include/drm/drm_print.h +2 -0
index 7b9c86a6ca3e..73dcd16eca49 100644
@@ -79,6 +79,8 @@ 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, ...);
+__printf(3, 4)
+void drm_printf_indent(struct drm_printer *p, unsigned int i, const char *f, ...);
 
 
  /**
Signature · 1 line
2.14.2
Signature · 6 lines
Ville Syrjälä
Intel OTC
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#9 lore raw

Re: [PATCH v3 4/8] drm/print: Add drm_printf_indent()

Quoted 60 lines · Ville Syrjälä
Quoted 42 lines · Noralf Trønnes

Den 26.10.2017 19.49, skrev Ville Syrjälä:

Quoted 40 lines · Noralf Trønnes
Quoted 26 lines

Add drm_printf_indent() that adds tab indentation according to argument.

---
  drivers/gpu/drm/drm_print.c | 21 +++++++++++++++++++++
  include/drm/drm_print.h     |  2 ++
  2 files changed, 23 insertions(+)
drivers/gpu/drm/drm_print.c +10 -0
index 0b3bf476dc4b..dac3ee98b30f 100644
@@ -64,6 +64,27 @@ void drm_printf(struct drm_printer *p, const char *f, ...)
  }
  EXPORT_SYMBOL(drm_printf);
 
+/**
+ * drm_printf_indent - print to a &drm_printer stream with indentation
+ * @p: the &drm_printer
+ * @i: indentation
+ * @f: format string
+ */
+void drm_printf_indent(struct drm_printer *p, unsigned int i, const char *f, ...)
+{
+	struct va_format vaf;
+	va_list args;

drivers/gpu/drm/drm_print.c void drm_printf(struct drm_printer *p, const char *f, ...) · line 86

Quoted 10 lines
drivers/gpu/drm/drm_print.c +10 -0
+
+	drm_printf(p, "%.*s", i, "\t\t\t\t\t\t\t\t\t\t");
+
+	va_start(args, f);
+	vaf.fmt = f;
+	vaf.va = &args;
+	p->printfn(p, &vaf);
+	va_end(args);
+}
+EXPORT_SYMBOL(drm_printf_indent);

The double printf() is rather unfortunate. Sadly I don't think there's any proper way to manipulate a va_list to avoid that.

Quoted 6 lines
Quoted 4 lines

Hmm. Would it work if we simply make it a macro? Eg.

#define drm_printf_indent(printer, indent, fmt, ...) \
	drm_printf((printer), "%.*s" fmt, (indent), "\t\t\t", ##__VA_ARGS__)

The macro worked fine and it looks like a better solution to me.

Only downside is that it bloats every format string. But as long as there aren't a huge number of useless callers we should be fine.

Quoted 7 lines
Quoted 6 lines

The "\t\t\t..." thing is also rather off putting, but I guess it's the best we can do if we want to keep it to one printf(). And maybe we should have a check in there to make sure we have enought tabs in the string to satisfy the indent level, or we just clamp the indent level silently to something reasonable?

Quoted 6 lines
Quoted 3 lines

I put 10 tabs in my suggestion, which should be enough and I think it's OK to just silently fail to do more. If 10 isn't enough it's easy to add more for the developer that hits the limit.

10 is probably even overkill. I'd say if you have to go past four or so then there's alredy a bigger problem in the code ;)

Just put some non-tab character at the end of the tab string? Dunno, + or * or something, just to draw attention to it instead of just silently failing to indent.

Overall I think this is a neat way to do indents.

BR,
Jani.

Quoted 29 lines
Quoted 29 lines

Noralf.

Quoted 25 lines

Oh, seeing the \t now reminds me that tabs won't necesarily get printed out properly. At least I've seen fbcon just printing some weird blobs instead of tabs. Not sure if it's just a matter of having a crappy font or what. That said, the state dump code is using tabs already, so I guess this wouldn't make it worse at least.

Quoted 19 lines
drivers/gpu/drm/drm_print.c +1 -0
+
  #define DRM_PRINTK_FMT "[" DRM_NAME ":%s]%s %pV"
 
  void drm_dev_printk(const struct device *dev, const char *level,
include/drm/drm_print.h +2 -0
index 7b9c86a6ca3e..73dcd16eca49 100644
@@ -79,6 +79,8 @@ 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, ...);
+__printf(3, 4)
+void drm_printf_indent(struct drm_printer *p, unsigned int i, const char *f, ...);
 
 
  /**
Signature · 1 line
2.14.2
Signature · 5 lines
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#10 lore raw

PATCH v3 5/8 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             | 11 ++++++++
 5 files changed, 100 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..152bd6210dde 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=%d\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 +11 -0
index 0e90ef24214b..434de999c3ba 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,16 @@ 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.
+	 * See 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
#11 lore raw

PATCH v3 6/8 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 6c9c4a8e09af..6d626355ba4e 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)
 {
@@ -934,21 +935,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
#12 lore raw

PATCH v3 7/8 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     |  5 ++++-
 2 files changed, 23 insertions(+), 1 deletion(-)
drivers/gpu/drm/drm_gem_cma_helper.c +19 -0
index 020e7668dfab..89dc7f04fae6 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)
+{
+	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 +4 -1
index 58a739bf15f1..bc47e6eba271 100644
@@ -21,7 +21,7 @@ struct drm_gem_cma_object {
 };
 
 static inline struct drm_gem_cma_object *
-to_drm_gem_cma_obj(struct drm_gem_object *gem_obj)
+to_drm_gem_cma_obj(const struct drm_gem_object *gem_obj)
 {
 	return container_of(gem_obj, struct drm_gem_cma_object, base);
 }
@@ -94,6 +94,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
#13 lore raw

PATCH v3 8/8 drm/tinydrm: Use drm_gem_cma_print_info()

In reply to Noralf Trønnes

Use drm_gem_cma_print_info() instead of drm_fb_cma_debugfs_show() to print framebuffer/gem info to debugfs. The debugfs file is now:
<debugfs>/dri/<n>/framebuffer

---
 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
Reviewed-by on v3 8/8
#14 lore raw

Re: [PATCH v3 8/8] drm/tinydrm: Use drm_gem_cma_print_info()

Quoted 41 lines · Noralf Trønnes

Use drm_gem_cma_print_info() instead of drm_fb_cma_debugfs_show() to print framebuffer/gem info to debugfs. The debugfs file is now:
<debugfs>/dri/<n>/framebuffer

---
 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 +0 -0
index 4774fe3d4273..423828922e5a 100644

include/drm/tinydrm/tinydrm.h pipe_to_tinydrm(struct drm_simple_display_pipe *pipe) · line 52

Quoted 7 lines
include/drm/tinydrm/tinydrm.h +1 -0
@@ -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, \

I think a DRM_GEM_CMA_DRIVER_OPS like we have for FOPS might be nice eventually. But probably better to go through with all the other refactoring. For patches 4-8 (since Ville reviewed the first 3 already):

Quoted 7 lines
Signature · 6 lines
2.14.2

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
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