mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] resource: add CONFIG_DEBUG_RESOURCES option
@ 2024-07-22 17:06 Ahmad Fatoum
  2024-07-24  8:14 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Ahmad Fatoum @ 2024-07-22 17:06 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

Whether a resource conflict is indeed a problem depends on how the user
handles it. Most users will propagate an -EBUSY error, but some will
gracefully handle it and move on.

We thus can't just warn unconditionally about conflicts in __request_region.
It's still useful to enable warnings there though while debugging, so
let's add a Kconfig option that enables these debugging prints.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 common/Kconfig.debug |  8 ++++++++
 common/resource.c    | 17 ++++++++++-------
 2 files changed, 18 insertions(+), 7 deletions(-)

diff --git a/common/Kconfig.debug b/common/Kconfig.debug
index 5d245de23c07..989f3ccc2a20 100644
--- a/common/Kconfig.debug
+++ b/common/Kconfig.debug
@@ -99,6 +99,14 @@ config DEBUG_LIST
 
 	  If unsure, say N.
 
+config DEBUG_RESOURCES
+	bool "Debug resource reservation"
+	help
+	  Enable this to bump verbosity of the resource reservation code
+	  from debug log level to info.
+
+	  If unsure, say N.
+
 config PBL_BREAK
 	bool "Execute software break on pbl start"
 	depends on ARM && (!CPU_32v4T && !ARCH_TEGRA)
diff --git a/common/resource.c b/common/resource.c
index 76f19de4942f..436a0488ddf0 100644
--- a/common/resource.c
+++ b/common/resource.c
@@ -13,6 +13,12 @@
 #include <linux/resource_ext.h>
 #include <asm/io.h>
 
+#ifdef CONFIG_DEBUG_RESOURCES
+#define res_dbg(args...)	pr_info(args)
+#else
+#define res_dbg(args...)	pr_debug(args)
+#endif
+
 static int init_resource(struct resource *res, const char *name)
 {
 	INIT_LIST_HEAD(&res->children);
@@ -35,8 +41,7 @@ struct resource *__request_region(struct resource *parent,
 	struct resource *r, *new;
 
 	if (end < start) {
-		debug("%s: request region 0x%08llx:0x%08llx: end < start\n",
-				__func__,
+		res_dbg("request region(0x%08llx:0x%08llx): end < start\n",
 				(unsigned long long)start,
 				(unsigned long long)end);
 		return ERR_PTR(-EINVAL);
@@ -44,8 +49,7 @@ struct resource *__request_region(struct resource *parent,
 
 	/* outside parent resource? */
 	if (start < parent->start || end > parent->end) {
-		debug("%s: 0x%08llx:0x%08llx outside parent resource 0x%08llx:0x%08llx\n",
-				__func__,
+		res_dbg("request region(0x%08llx:0x%08llx): outside parent resource 0x%08llx:0x%08llx\n",
 				(unsigned long long)start,
 				(unsigned long long)end,
 				(unsigned long long)parent->start,
@@ -62,8 +66,7 @@ struct resource *__request_region(struct resource *parent,
 			goto ok;
 		if (start > r->end)
 			continue;
-		debug("%s: 0x%08llx:0x%08llx (%s) conflicts with 0x%08llx:0x%08llx (%s)\n",
-				__func__,
+		res_dbg("request region(0x%08llx:0x%08llx): %s conflicts with 0x%08llx:0x%08llx (%s)\n",
 				(unsigned long long)start,
 				(unsigned long long)end,
 				name,
@@ -74,7 +77,7 @@ struct resource *__request_region(struct resource *parent,
 	}
 
 ok:
-	debug("%s ok: 0x%08llx:0x%08llx flags=0x%x\n", __func__,
+	res_dbg("request region(0x%08llx:0x%08llx): success flags=0x%x\n",
 			(unsigned long long)start,
 			(unsigned long long)end, flags);
 
-- 
2.39.2




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

* Re: [PATCH] resource: add CONFIG_DEBUG_RESOURCES option
  2024-07-22 17:06 [PATCH] resource: add CONFIG_DEBUG_RESOURCES option Ahmad Fatoum
@ 2024-07-24  8:14 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2024-07-24  8:14 UTC (permalink / raw)
  To: barebox, Ahmad Fatoum


On Mon, 22 Jul 2024 19:06:41 +0200, Ahmad Fatoum wrote:
> Whether a resource conflict is indeed a problem depends on how the user
> handles it. Most users will propagate an -EBUSY error, but some will
> gracefully handle it and move on.
> 
> We thus can't just warn unconditionally about conflicts in __request_region.
> It's still useful to enable warnings there though while debugging, so
> let's add a Kconfig option that enables these debugging prints.
> 
> [...]

Applied, thanks!

[1/1] resource: add CONFIG_DEBUG_RESOURCES option
      https://git.pengutronix.de/cgit/barebox/commit/?id=aafcfb061c98 (link may not be stable)

Best regards,
-- 
Sascha Hauer <s.hauer@pengutronix.de>




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

end of thread, other threads:[~2024-07-24  8:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-07-22 17:06 [PATCH] resource: add CONFIG_DEBUG_RESOURCES option Ahmad Fatoum
2024-07-24  8:14 ` Sascha Hauer

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