All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Anholt <eric@anholt.net>
To: dri-devel@lists.freedesktop.org
Cc: linux-kernel@vger.kernel.org,
	Paul Kocialkowski <paul.kocialkowski@bootlin.com>,
	Maxime Ripard <maxime.ripard@bootlin.com>,
	Eric Anholt <eric@anholt.net>
Subject: [PATCH 1/7] drm: Add a helper function for printing a debugfs_regset32.
Date: Wed, 20 Feb 2019 13:03:37 -0800	[thread overview]
Message-ID: <20190220210343.28157-1-eric@anholt.net> (raw)

The debugfs_regset32 is nice to use for reducing boilerplate in
dumping a bunch of regs in debugfs, but we also want to be able to
print to dmesg them at runtime for driver debugging.  drm_printer lets
us format debugfs and the printk the same way.

Signed-off-by: Eric Anholt <eric@anholt.net>
---
 drivers/gpu/drm/drm_print.c | 16 ++++++++++++++++
 include/drm/drm_print.h     |  2 ++
 2 files changed, 18 insertions(+)

diff --git a/drivers/gpu/drm/drm_print.c b/drivers/gpu/drm/drm_print.c
index 0e7fc3e7dfb4..5ecc0f04cd0c 100644
--- a/drivers/gpu/drm/drm_print.c
+++ b/drivers/gpu/drm/drm_print.c
@@ -253,3 +253,19 @@ void drm_err(const char *format, ...)
 	va_end(args);
 }
 EXPORT_SYMBOL(drm_err);
+
+void drm_print_regset32(struct drm_printer *p, struct debugfs_regset32 *regset)
+{
+	int namelen = 0;
+	int i;
+
+	for (i = 0; i < regset->nregs; i++)
+		namelen = max(namelen, (int)strlen(regset->regs[i].name));
+
+	for (i = 0; i < regset->nregs; i++) {
+		drm_printf(p, "%*s = 0x%08x\n",
+			   namelen, regset->regs[i].name,
+			   readl(regset->base + regset->regs[i].offset));
+	}
+}
+EXPORT_SYMBOL(drm_print_regset32);
diff --git a/include/drm/drm_print.h b/include/drm/drm_print.h
index afbc3beef089..3a4247319e63 100644
--- a/include/drm/drm_print.h
+++ b/include/drm/drm_print.h
@@ -30,6 +30,7 @@
 #include <linux/printk.h>
 #include <linux/seq_file.h>
 #include <linux/device.h>
+#include <linux/debugfs.h>
 
 /**
  * DOC: print
@@ -84,6 +85,7 @@ 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, ...);
 void drm_puts(struct drm_printer *p, const char *str);
+void drm_print_regset32(struct drm_printer *p, struct debugfs_regset32 *regset);
 
 __printf(2, 0)
 /**
-- 
2.20.1


             reply	other threads:[~2019-02-20 21:03 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-20 21:03 Eric Anholt [this message]
2019-02-20 21:03 ` [PATCH 2/7] drm/vc4: Use drm_print_regset32() for our debug register dumping Eric Anholt
2019-02-20 21:03   ` Eric Anholt
2019-03-22 10:32   ` Paul Kocialkowski
2019-03-22 10:32     ` Paul Kocialkowski
2019-02-20 21:03 ` [PATCH 3/7] drm/vc4: Use common helpers for debugfs setup by the driver components Eric Anholt
2019-02-20 21:03   ` Eric Anholt
2019-02-20 21:03 ` [PATCH 4/7] drm/vc4: Use drm_printer for the debugfs and runtime bo stats output Eric Anholt
2019-02-20 21:03   ` Eric Anholt
2019-03-22 10:41   ` Paul Kocialkowski
2019-02-20 21:03 ` [PATCH 5/7] drm/vc4: Disable V3D interactions if the v3d component didn't probe Eric Anholt
2019-03-25 13:30   ` Paul Kocialkowski
2019-02-20 21:03 ` [PATCH 6/7] drm/vc4: Add helpers for pm get/put Eric Anholt
2019-02-20 21:03   ` Eric Anholt
2019-03-22 10:48   ` Paul Kocialkowski
2019-02-20 21:03 ` [PATCH 7/7] drm/vc4: Make sure that the v3d ident debugfs has vc4's power on Eric Anholt
2019-03-22 10:43   ` Paul Kocialkowski
2019-02-21  9:37 ` [PATCH 1/7] drm: Add a helper function for printing a debugfs_regset32 Daniel Vetter
2019-02-21  9:37   ` Daniel Vetter
2019-03-25 16:43   ` Eric Anholt
2019-03-22 10:30 ` Paul Kocialkowski
2019-04-01 17:52   ` Eric Anholt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190220210343.28157-1-eric@anholt.net \
    --to=eric@anholt.net \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maxime.ripard@bootlin.com \
    --cc=paul.kocialkowski@bootlin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.