mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH] driver: add CONFIG_DEBUG_PROBES
Date: Mon, 28 Jun 2021 09:03:45 +0200	[thread overview]
Message-ID: <20210628070345.13838-1-a.fatoum@pengutronix.de> (raw)

CONFIG_DEBUG_INITCALLS can be very useful to roughly pinpoint what
causes barebox to hang. With deep probe, most probes run at the same
initcall level making the debug option much less useful.

Add a new CONFIG_DEBUG_PROBES that will instead log whenever a probe is
invoked. The text's horizontal alignment is increased with each
recursive probe making the option suitable for debugging some deep probe
issues as well.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 common/Kconfig        |  4 ++++
 drivers/base/driver.c | 17 +++++++++++++++--
 2 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/common/Kconfig b/common/Kconfig
index a2aa0b2568de..05e4bdbba132 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -1497,6 +1497,10 @@ config DEBUG_INITCALLS
 	help
 	  If enabled this will print initcall traces.
 
+config DEBUG_PROBES
+	bool "Trace driver probes"
+	help
+	  If enabled this will print driver probe traces.
 
 config PBL_BREAK
 	bool "Execute software break on pbl start"
diff --git a/drivers/base/driver.c b/drivers/base/driver.c
index c2ab9d308e91..c6a8aef879af 100644
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -36,6 +36,12 @@
 #include <pinctrl.h>
 #include <linux/clk/clk-conf.h>
 
+#ifdef CONFIG_DEBUG_PROBES
+#define pr_report_probe		pr_info
+#else
+#define pr_report_probe		pr_debug
+#endif
+
 LIST_HEAD(device_list);
 EXPORT_SYMBOL(device_list);
 
@@ -82,8 +88,13 @@ int get_free_deviceid(const char *name_template)
 
 int device_probe(struct device_d *dev)
 {
+	static int depth = 0;
 	int ret;
 
+	depth++;
+
+	pr_report_probe("%*sprobe-> %s\n", depth, "", dev_name(dev));
+
 	pinctrl_select_state_default(dev);
 	of_clk_set_defaults(dev->device_node, false);
 
@@ -91,7 +102,7 @@ int device_probe(struct device_d *dev)
 
 	ret = dev->bus->probe(dev);
 	if (ret == 0)
-		return 0;
+		goto out;
 
 	if (ret == -EPROBE_DEFER) {
 		list_del(&dev->active);
@@ -105,7 +116,7 @@ int device_probe(struct device_d *dev)
 			dev_err(dev, "probe deferred\n");
 		else
 			dev_dbg(dev, "probe deferred\n");
-		return ret;
+		goto out;
 	}
 
 	list_del(&dev->active);
@@ -116,6 +127,8 @@ int device_probe(struct device_d *dev)
 	else
 		dev_err(dev, "probe failed: %s\n", strerror(-ret));
 
+out:
+	depth--;
 	return ret;
 }
 
-- 
2.30.2


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


             reply	other threads:[~2021-06-28  7:06 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-28  7:03 Ahmad Fatoum [this message]
2021-06-28 20:37 ` Sascha Hauer
2021-06-29  6:39   ` Ahmad Fatoum

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=20210628070345.13838-1-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox