From: "Arnd Bergmann" <arnd@arndb.de>
To: "Nathan Chancellor" <nathan@kernel.org>,
"Arnd Bergmann" <arnd@kernel.org>
Cc: Linux-Arch <linux-arch@vger.kernel.org>,
"Richard Henderson" <richard.henderson@linaro.org>,
"Matt Turner" <mattst88@gmail.com>,
"Geert Uytterhoeven" <geert@linux-m68k.org>,
"Greg Ungerer" <gerg@linux-m68k.org>,
"Thomas Bogendoerfer" <tsbogend@alpha.franken.de>,
"James E . J . Bottomley" <James.Bottomley@hansenpartnership.com>,
"Helge Deller" <deller@gmx.de>,
"Madhavan Srinivasan" <maddy@linux.ibm.com>,
"Michael Ellerman" <mpe@ellerman.id.au>,
"Nicholas Piggin" <npiggin@gmail.com>,
"Christophe Leroy" <christophe.leroy@csgroup.eu>,
"Naveen N Rao" <naveen@kernel.org>,
"Yoshinori Sato" <ysato@users.sourceforge.jp>,
"Rich Felker" <dalias@libc.org>,
"John Paul Adrian Glaubitz" <glaubitz@physik.fu-berlin.de>,
"Julian Vetter" <julian@outer-limits.org>,
"Bjorn Helgaas" <bhelgaas@google.com>,
linux-alpha@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org,
linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org,
linux-sh@vger.kernel.org
Subject: Re: [PATCH 5/6] mips: drop GENERIC_IOMAP wrapper
Date: Tue, 18 Mar 2025 22:13:35 +0100 [thread overview]
Message-ID: <5b2779f8-573d-401e-817e-979e02f811d3@app.fastmail.com> (raw)
In-Reply-To: <20250318203906.GA4089579@ax162>
On Tue, Mar 18, 2025, at 21:39, Nathan Chancellor wrote:
> On Sat, Mar 15, 2025 at 11:59:06AM +0100, Arnd Bergmann wrote:
>> From: Arnd Bergmann <arnd@arndb.de>
>> diff --git a/arch/mips/include/asm/io.h b/arch/mips/include/asm/io.h
>> void __ioread64_copy(void *to, const void __iomem *from, size_t count);
>>
>> +#ifdef CONFIG_PCI_DRIVERS_LEGACY
>> +struct pci_dev;
>> +void pci_iounmap(struct pci_dev *dev, void __iomem *addr);
>> +#define pci_iounmap pci_iounmap
>> +#endif
>> +
>> #include <asm-generic/io.h>
>>
>> static inline void *isa_bus_to_virt(unsigned long address)
>> diff --git a/arch/mips/lib/iomap-pci.c b/arch/mips/lib/iomap-pci.c
>> index a9cb28813f0b..2f82c776c6d0 100644
>> --- a/arch/mips/lib/iomap-pci.c
>> +++ b/arch/mips/lib/iomap-pci.c
>> @@ -43,4 +43,13 @@ void __iomem *__pci_ioport_map(struct pci_dev *dev,
>> return (void __iomem *) (ctrl->io_map_base + port);
>> }
>>
>> +void pci_iounmap(struct pci_dev *dev, void __iomem *addr)
>> +{
>> + struct pci_controller *ctrl = dev->bus->sysdata;
>> + void __iomem *base = (void __iomem *)ctrl->io_map_base;
>> +
>> + if (addr < base || addr > (base + resource_size(ctrl->io_resource)))
>> + iounmap(addr);
>> +}
>> +
>> #endif /* CONFIG_PCI_DRIVERS_LEGACY */
>> --
>> 2.39.5
>>
>
> This change as commit 976bf3aec388 ("mips: drop GENERIC_IOMAP wrapper") in
> -next introduces new instances of -Wnull-pointer-arithmetic when building
> certain mips configurations with clang.
>
Thanks for the report, I missed that the generic ioport_map() function
is missing the PCI_IOBASE macro, we should probably remove that from
the asm-generic/io.h header and require architectures to define it
themselves, since the NULL fallback is pretty much always wrong.
There is also a type mismatch between the MIPS
PCI_IOBASE/mips_io_port_base and the one that asm-generic/io.h
expects, so I had to add a couple of extra typecasts, which
makes it rather ugly, but the change below seems to work.
Arnd
diff --git a/arch/mips/include/asm/io.h b/arch/mips/include/asm/io.h
index 1fe56d1870a6..78c6573f91f2 100644
--- a/arch/mips/include/asm/io.h
+++ b/arch/mips/include/asm/io.h
@@ -544,12 +544,16 @@ extern void (*_dma_cache_inv)(unsigned long start, unsigned long size);
void __ioread64_copy(void *to, const void __iomem *from, size_t count);
-#ifdef CONFIG_PCI_DRIVERS_LEGACY
+#if defined(CONFIG_PCI) && defined(CONFIG_PCI_DRIVERS_LEGACY)
struct pci_dev;
void pci_iounmap(struct pci_dev *dev, void __iomem *addr);
#define pci_iounmap pci_iounmap
#endif
+#ifndef PCI_IOBASE
+#define PCI_IOBASE ((void __iomem *)mips_io_port_base)
+#endif
+
#include <asm-generic/io.h>
static inline void *isa_bus_to_virt(unsigned long address)
diff --git a/arch/mips/include/asm/mach-loongson64/spaces.h b/arch/mips/include/asm/mach-loongson64/spaces.h
index ce04e998a37b..dbd26db5f2c5 100644
--- a/arch/mips/include/asm/mach-loongson64/spaces.h
+++ b/arch/mips/include/asm/mach-loongson64/spaces.h
@@ -7,9 +7,10 @@
#endif /* CONFIG_64BIT */
/* Skip 128k to trap NULL pointer dereferences */
-#define PCI_IOBASE _AC(0xc000000000000000 + SZ_128K, UL)
+#define PCI_PORT_BASE _AC(0xc000000000000000 + SZ_128K, UL)
+#define PCI_IOBASE (void __iomem *)PCI_PORT_BASE
#define PCI_IOSIZE SZ_16M
-#define MAP_BASE (PCI_IOBASE + PCI_IOSIZE)
+#define MAP_BASE (PCI_PORT_BASE + PCI_IOSIZE)
#define IO_SPACE_LIMIT (PCI_IOSIZE - 1)
diff --git a/arch/mips/include/asm/mach-ralink/spaces.h b/arch/mips/include/asm/mach-ralink/spaces.h
index a9f0570d0f04..a63d106c89c6 100644
--- a/arch/mips/include/asm/mach-ralink/spaces.h
+++ b/arch/mips/include/asm/mach-ralink/spaces.h
@@ -2,7 +2,7 @@
#ifndef __ASM_MACH_RALINK_SPACES_H_
#define __ASM_MACH_RALINK_SPACES_H_
-#define PCI_IOBASE mips_io_port_base
+#define PCI_IOBASE (void __iomem *)mips_io_port_base
#define PCI_IOSIZE SZ_64K
#define IO_SPACE_LIMIT (PCI_IOSIZE - 1)
diff --git a/arch/mips/loongson64/init.c b/arch/mips/loongson64/init.c
index a35dd7311795..b9f90f33fc9a 100644
--- a/arch/mips/loongson64/init.c
+++ b/arch/mips/loongson64/init.c
@@ -128,7 +128,7 @@ void __init prom_init(void)
}
/* init base address of io space */
- set_io_port_base(PCI_IOBASE);
+ set_io_port_base((unsigned long)PCI_IOBASE);
if (loongson_sysconf.early_config)
loongson_sysconf.early_config();
@@ -178,7 +178,7 @@ static int __init add_legacy_isa_io(struct fwnode_handle *fwnode, resource_size_
return -EINVAL;
}
- vaddr = PCI_IOBASE + range->io_start;
+ vaddr = (unsigned long)PCI_IOBASE + range->io_start;
vmap_page_range(vaddr, vaddr + size, hw_start, pgprot_device(PAGE_KERNEL));
next prev parent reply other threads:[~2025-03-18 21:14 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-15 10:59 [PATCH 0/6] asm-generic: io.h cleanups Arnd Bergmann
2025-03-15 10:59 ` [PATCH 1/6] alpha: stop using asm-generic/iomap.h Arnd Bergmann
2025-03-15 10:59 ` [PATCH 2/6] sh: remove duplicate ioread/iowrite helpers Arnd Bergmann
2025-06-07 12:08 ` John Paul Adrian Glaubitz
2025-06-08 9:39 ` Geert Uytterhoeven
2025-06-08 9:44 ` John Paul Adrian Glaubitz
2025-03-15 10:59 ` [PATCH 3/6] parisc: stop using asm-generic/iomap.h Arnd Bergmann
2025-03-15 10:59 ` [PATCH 4/6] powerpc: asm/io.h: remove split ioread64/iowrite64 helpers Arnd Bergmann
2025-03-17 11:31 ` Michael Ellerman
2025-03-15 10:59 ` [PATCH 5/6] mips: drop GENERIC_IOMAP wrapper Arnd Bergmann
2025-03-18 20:39 ` Nathan Chancellor
2025-03-18 21:13 ` Arnd Bergmann [this message]
2025-03-19 17:30 ` Nathan Chancellor
2025-03-19 18:00 ` Arnd Bergmann
2025-03-15 10:59 ` [PATCH 6/6] m68k/nommu: stop using GENERIC_IOMAP Arnd Bergmann
2025-03-24 1:33 ` Greg Ungerer
2025-03-24 8:02 ` Arnd Bergmann
2025-03-24 13:50 ` Greg Ungerer
2025-03-24 14:40 ` Arnd Bergmann
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=5b2779f8-573d-401e-817e-979e02f811d3@app.fastmail.com \
--to=arnd@arndb.de \
--cc=James.Bottomley@hansenpartnership.com \
--cc=arnd@kernel.org \
--cc=bhelgaas@google.com \
--cc=christophe.leroy@csgroup.eu \
--cc=dalias@libc.org \
--cc=deller@gmx.de \
--cc=geert@linux-m68k.org \
--cc=gerg@linux-m68k.org \
--cc=glaubitz@physik.fu-berlin.de \
--cc=julian@outer-limits.org \
--cc=linux-alpha@vger.kernel.org \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-m68k@lists.linux-m68k.org \
--cc=linux-mips@vger.kernel.org \
--cc=linux-parisc@vger.kernel.org \
--cc=linux-sh@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=maddy@linux.ibm.com \
--cc=mattst88@gmail.com \
--cc=mpe@ellerman.id.au \
--cc=nathan@kernel.org \
--cc=naveen@kernel.org \
--cc=npiggin@gmail.com \
--cc=richard.henderson@linaro.org \
--cc=tsbogend@alpha.franken.de \
--cc=ysato@users.sourceforge.jp \
/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
all inboxes | Powered by JetHome®