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

* Re: [PATCH] driver: add CONFIG_DEBUG_PROBES
  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
  0 siblings, 1 reply; 3+ messages in thread
From: Sascha Hauer @ 2021-06-28 20:37 UTC (permalink / raw)
  To: Ahmad Fatoum; +Cc: barebox

On Mon, Jun 28, 2021 at 09:03:45AM +0200, Ahmad Fatoum wrote:
> 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(-)

Nice. I applied with one change I hope you're ok with:

> +	depth++;
> +
> +	pr_report_probe("%*sprobe-> %s\n", depth, "", dev_name(dev));

I changed the indentation to 4 here.

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

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


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

* Re: [PATCH] driver: add CONFIG_DEBUG_PROBES
  2021-06-28 20:37 ` Sascha Hauer
@ 2021-06-29  6:39   ` Ahmad Fatoum
  0 siblings, 0 replies; 3+ messages in thread
From: Ahmad Fatoum @ 2021-06-29  6:39 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

On 28.06.21 22:37, Sascha Hauer wrote:
> On Mon, Jun 28, 2021 at 09:03:45AM +0200, Ahmad Fatoum wrote:
>> 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(-)
> 
> Nice. I applied with one change I hope you're ok with:
> 
>> +	depth++;
>> +
>> +	pr_report_probe("%*sprobe-> %s\n", depth, "", dev_name(dev));
> 
> I changed the indentation to 4 here.

Fine by me.

Cheers,
Ahmad

> 
> Sascha
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox