mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH RESEND] x86/ioremap: Always incriminate the caller on failure
@ 2026-10-26 14:10 Chris Down
  0 siblings, 0 replies; only message in thread
From: Chris Down @ 2026-10-26 14:10 UTC (permalink / raw)
  To: Dave Hansen
  Cc: Andy Lutomirski, Peter Zijlstra, x86, linux-kernel, kernel-team

On my T14s Gen2, I get the following on startup:

    e1000e 0000:00:1f.6 eth0: Intel(R) PRO/1000 Network Connection
    e1000e 0000:00:1f.6 eth0: MAC: 14, PHY: 12, PBA No: FFFFFF-0FF
    sof-audio-pci-intel-tgl 0000:00:1f.3: warn: FW ABI is more recent than kernel
    ioremap error for 0x930bc000-0x930bd000, requested 0x2, got 0x0
    sof-audio-pci-intel-tgl 0000:00:1f.3: unknown sof_ext_man header type 3 size 0x30
    ucsi_acpi: probe of USBC000:00 failed with error -12

Notice the ioremap error which appears sandwiched between SOF driver
messages. Without more knowledge of the kernel, and due to the
interleaving of printk errors, it's not immediately obvious to the
system administrator where this message comes from (although in this
case tracing confirms that it comes from ucsi_acpi's ->probe, as one
might expect).

To avoid issues with printk interleaving, always incriminate the caller
on ioremap() failure since we have it. While we're here, also change
these from printk(KERN_FOO) to pr_foo(), which we already use elsewhere
in ioremap.c

Signed-off-by: Chris Down <chris@chrisdown.name>
---
Resending this patch from February 2022 that went stale.

Original submission:
https://lore.kernel.org/all/YguzmS7umfiaSSHU@chrisdown.name/

 arch/x86/mm/ioremap.c | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c
index 12c8180ca1ba..2443f4668d0d 100644
--- a/arch/x86/mm/ioremap.c
+++ b/arch/x86/mm/ioremap.c
@@ -201,8 +201,8 @@ __ioremap_caller(resource_size_t phys_addr, unsigned long size,
 		return NULL;
 
 	if (!phys_addr_valid(phys_addr)) {
-		printk(KERN_WARNING "ioremap: invalid physical address %llx\n",
-		       (unsigned long long)phys_addr);
+		pr_warn("%pS: ioremap: invalid physical address %llx\n",
+			caller, (unsigned long long)phys_addr);
 		WARN_ON_ONCE(1);
 		return NULL;
 	}
@@ -213,8 +213,8 @@ __ioremap_caller(resource_size_t phys_addr, unsigned long size,
 	 * Don't allow anybody to remap normal RAM that we're using..
 	 */
 	if (io_desc.flags & IORES_MAP_SYSTEM_RAM) {
-		WARN_ONCE(1, "ioremap on RAM at %pa - %pa\n",
-			  &phys_addr, &last_addr);
+		WARN_ONCE(1, "%pS: ioremap on RAM at %pa - %pa\n",
+			  caller, &phys_addr, &last_addr);
 		return NULL;
 	}
 
@@ -234,17 +234,18 @@ __ioremap_caller(resource_size_t phys_addr, unsigned long size,
 	retval = memtype_reserve(phys_addr, (u64)phys_addr + size,
 						pcm, &new_pcm);
 	if (retval) {
-		printk(KERN_ERR "ioremap memtype_reserve failed %d\n", retval);
+		pr_err("%pS: ioremap memtype_reserve failed %d\n",
+		       caller, retval);
 		return NULL;
 	}
 
 	if (pcm != new_pcm) {
 		if (!is_new_memtype_allowed(phys_addr, size, pcm, new_pcm)) {
-			printk(KERN_ERR
-		"ioremap error for 0x%llx-0x%llx, requested 0x%x, got 0x%x\n",
-				(unsigned long long)phys_addr,
-				(unsigned long long)(phys_addr + size),
-				pcm, new_pcm);
+			pr_err("%pS: ioremap error for 0x%llx-0x%llx, requested 0x%x, got 0x%x\n",
+			       caller,
+			       (unsigned long long)phys_addr,
+			       (unsigned long long)(phys_addr + size),
+			       pcm, new_pcm);
 			goto err_free_memtype;
 		}
 		pcm = new_pcm;
@@ -309,7 +310,7 @@ __ioremap_caller(resource_size_t phys_addr, unsigned long size,
 	 * tree.
 	 */
 	if (iomem_map_sanity_check(unaligned_phys_addr, unaligned_size))
-		pr_warn("caller %pS mapping multiple BARs\n", caller);
+		pr_warn("%pS: mapping multiple BARs\n", caller);
 
 	return ret_addr;
 err_free_area:

base-commit: 29643f6655dcce5bbc43e938fcee1718a63a83a5
-- 
2.54.0


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-10-26 14:10 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-26 14:10 [PATCH RESEND] x86/ioremap: Always incriminate the caller on failure Chris Down

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

all inboxes | Powered by JetHome®