From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH] resource: add CONFIG_DEBUG_RESOURCES option
Date: Mon, 22 Jul 2024 19:06:41 +0200 [thread overview]
Message-ID: <20240722170641.3868698-1-a.fatoum@pengutronix.de> (raw)
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
next reply other threads:[~2024-07-22 17:07 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-22 17:06 Ahmad Fatoum [this message]
2024-07-24 8:14 ` Sascha Hauer
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=20240722170641.3868698-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