mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] driver: add CONFIG_DEBUG_PROBES
@ 2021-06-28  7:03 Ahmad Fatoum
  2021-06-28 20:37 ` Sascha Hauer
  0 siblings, 1 reply; 3+ messages in thread
From: Ahmad Fatoum @ 2021-06-28  7:03 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-06-29  6:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-28  7:03 [PATCH] driver: add CONFIG_DEBUG_PROBES Ahmad Fatoum
2021-06-28 20:37 ` Sascha Hauer
2021-06-29  6:39   ` Ahmad Fatoum

mail archive of the barebox mailing list

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://lore.barebox.org/barebox/0 barebox/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 barebox barebox/ https://lore.barebox.org/barebox \
		barebox@lists.infradead.org barebox@lists.infradead.org
	public-inbox-index barebox

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git