* [PATCH 0/2] MIPS: Loongson2ef: Use pcibios_align_resource() to block io range
@ 2026-01-31 21:32 Rong Zhang
2026-01-31 21:32 ` [PATCH 1/2] MIPS: Loongson2ef: Register PCI controller in early stage Rong Zhang
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Rong Zhang @ 2026-01-31 21:32 UTC (permalink / raw)
To: Jiaxun Yang, Thomas Bogendoerfer
Cc: Rong Zhang, Rong Zhang, Ilpo Järvinen, linux-mips,
linux-kernel
Loongson2ef reserves io range below 0x4000 (LOONGSON_PCI_IO_START) while
ISA-mode only IDE controller on the south bridge still has a hard
dependency on ISA IO ports.
The reservation was done by lifting loongson_pci_io_resource.start onto
0x4000. Prior to commit ae81aad5c2e1 ("MIPS: PCI: Use
pci_enable_resources()"), the arch specific pcibios_enable_resources()
did not check if the resources were claimed, which diverges from what
PCI core checks, effectively hiding the fact that IDE IO resources were
not properly within the resource tree. After starting to use
pcibios_enable_resources() from PCI core, enabling IDE controller fails:
pata_cs5536 0000:00:0e.2: BAR 0 [io 0x01f0-0x01f7]: not claimed; can't enable device
pata_cs5536 0000:00:0e.2: probe with driver pata_cs5536 failed with error -22
MIPS PCI code already has support for enforcing lower bounds using
PCIBIOS_MIN_IO in pcibios_align_resource() without altering the IO
window start address itself. Register PCI controller in plat_mem_setup()
instead of arch_initcall() to make it the root of other resources (e.g.,
i8259) and prevent resource conflicts. Then, make Loongson2ef PCI code
use PCIBIOS_MIN_IO too.
Rong Zhang (2):
MIPS: Loongson2ef: Register PCI controller in early stage
MIPS: Loongson2ef: Use pcibios_align_resource() to block io range
.../include/asm/mach-loongson2ef/loongson.h | 6 ++++++
arch/mips/loongson2ef/common/pci.c | 18 +++++++++++-------
arch/mips/loongson2ef/common/setup.c | 1 +
3 files changed, 18 insertions(+), 7 deletions(-)
base-commit: ad9a728a3388dc5f66eab6b7135e0154249e9403
--
2.51.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/2] MIPS: Loongson2ef: Register PCI controller in early stage
2026-01-31 21:32 [PATCH 0/2] MIPS: Loongson2ef: Use pcibios_align_resource() to block io range Rong Zhang
@ 2026-01-31 21:32 ` Rong Zhang
2026-01-31 21:32 ` [PATCH 2/2] MIPS: Loongson2ef: Use pcibios_align_resource() to block io range Rong Zhang
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Rong Zhang @ 2026-01-31 21:32 UTC (permalink / raw)
To: Jiaxun Yang, Thomas Bogendoerfer
Cc: Rong Zhang, Rong Zhang, Ilpo Järvinen, linux-mips,
linux-kernel, stable, Beiyan Yun, Yao Zi
We are about to set loongson_pci_io_resource.start to 0 and adopt
PCIBIOS_MIN_IO. As the first step, PCI controller needs to be registered
in early stage to make it the root of other resources (e.g., i8259) and
prevent resource conflicts.
Register it in plat_mem_setup() instead of arch_initcall().
Fixes: ae81aad5c2e1 ("MIPS: PCI: Use pci_enable_resources()")
Cc: stable@vger.kernel.org
Tested-by: Beiyan Yun <root@infi.wang>
Tested-by: Yao Zi <me@ziyao.cc>
Signed-off-by: Rong Zhang <rongrong@oss.cipunited.com>
---
arch/mips/include/asm/mach-loongson2ef/loongson.h | 6 ++++++
arch/mips/loongson2ef/common/pci.c | 7 +------
arch/mips/loongson2ef/common/setup.c | 1 +
3 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/arch/mips/include/asm/mach-loongson2ef/loongson.h b/arch/mips/include/asm/mach-loongson2ef/loongson.h
index 4a098fb102325..0e586787eb87a 100644
--- a/arch/mips/include/asm/mach-loongson2ef/loongson.h
+++ b/arch/mips/include/asm/mach-loongson2ef/loongson.h
@@ -324,4 +324,10 @@ extern unsigned long _loongson_addrwincfg_base;
#endif /* ! CONFIG_CPU_SUPPORTS_ADDRWINCFG */
+#ifdef CONFIG_PCI
+void loongson2ef_pcibios_init(void);
+#else
+static inline void loongson2ef_pcibios_init(void) { }
+#endif
+
#endif /* __ASM_MACH_LOONGSON2EF_LOONGSON_H */
diff --git a/arch/mips/loongson2ef/common/pci.c b/arch/mips/loongson2ef/common/pci.c
index 7d9ea51e8c01e..55524f9a7b96b 100644
--- a/arch/mips/loongson2ef/common/pci.c
+++ b/arch/mips/loongson2ef/common/pci.c
@@ -73,15 +73,10 @@ static void __init setup_pcimap(void)
#endif
}
-static int __init pcibios_init(void)
+void __init loongson2ef_pcibios_init(void)
{
setup_pcimap();
loongson_pci_controller.io_map_base = mips_io_port_base;
register_pci_controller(&loongson_pci_controller);
-
-
- return 0;
}
-
-arch_initcall(pcibios_init);
diff --git a/arch/mips/loongson2ef/common/setup.c b/arch/mips/loongson2ef/common/setup.c
index 4fd27f4f90edb..a639e35acce59 100644
--- a/arch/mips/loongson2ef/common/setup.c
+++ b/arch/mips/loongson2ef/common/setup.c
@@ -27,4 +27,5 @@ EXPORT_SYMBOL(__wbflush);
void __init plat_mem_setup(void)
{
+ loongson2ef_pcibios_init();
}
--
2.51.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] MIPS: Loongson2ef: Use pcibios_align_resource() to block io range
2026-01-31 21:32 [PATCH 0/2] MIPS: Loongson2ef: Use pcibios_align_resource() to block io range Rong Zhang
2026-01-31 21:32 ` [PATCH 1/2] MIPS: Loongson2ef: Register PCI controller in early stage Rong Zhang
@ 2026-01-31 21:32 ` Rong Zhang
2026-01-31 21:41 ` [PATCH 0/2] " Jiaxun Yang
2026-02-05 9:05 ` Thomas Bogendoerfer
3 siblings, 0 replies; 5+ messages in thread
From: Rong Zhang @ 2026-01-31 21:32 UTC (permalink / raw)
To: Jiaxun Yang, Thomas Bogendoerfer
Cc: Rong Zhang, Rong Zhang, Ilpo Järvinen, linux-mips,
linux-kernel, stable, Beiyan Yun, Yao Zi
Loongson2ef reserves io range below 0x4000 (LOONGSON_PCI_IO_START) while
ISA-mode only IDE controller on the south bridge still has a hard
dependency on ISA IO ports.
The reservation was done by lifting loongson_pci_io_resource.start onto
0x4000. Prior to commit ae81aad5c2e1 ("MIPS: PCI: Use
pci_enable_resources()"), the arch specific pcibios_enable_resources()
did not check if the resources were claimed, which diverges from what
PCI core checks, effectively hiding the fact that IDE IO resources were
not properly within the resource tree. After starting to use
pcibios_enable_resources() from PCI core, enabling IDE controller fails:
pata_cs5536 0000:00:0e.2: BAR 0 [io 0x01f0-0x01f7]: not claimed; can't enable device
pata_cs5536 0000:00:0e.2: probe with driver pata_cs5536 failed with error -22
MIPS PCI code already has support for enforcing lower bounds using
PCIBIOS_MIN_IO in pcibios_align_resource() without altering the IO
window start address itself. Make Loongson2ef PCI code use
PCIBIOS_MIN_IO too.
Fixes: ae81aad5c2e1 ("MIPS: PCI: Use pci_enable_resources()")
Cc: stable@vger.kernel.org
Tested-by: Beiyan Yun <root@infi.wang>
Tested-by: Yao Zi <me@ziyao.cc>
Signed-off-by: Rong Zhang <rongrong@oss.cipunited.com>
---
arch/mips/loongson2ef/common/pci.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/arch/mips/loongson2ef/common/pci.c b/arch/mips/loongson2ef/common/pci.c
index 55524f9a7b96b..0f11392104bfd 100644
--- a/arch/mips/loongson2ef/common/pci.c
+++ b/arch/mips/loongson2ef/common/pci.c
@@ -17,7 +17,7 @@ static struct resource loongson_pci_mem_resource = {
static struct resource loongson_pci_io_resource = {
.name = "pci io space",
- .start = LOONGSON_PCI_IO_START,
+ .start = 0x00000000UL, /* See loongson2ef_pcibios_init(). */
.end = IO_SPACE_LIMIT,
.flags = IORESOURCE_IO,
};
@@ -77,6 +77,15 @@ void __init loongson2ef_pcibios_init(void)
{
setup_pcimap();
+ /*
+ * ISA-mode only IDE controllers have a hard dependency on ISA IO ports.
+ *
+ * Claim them by setting PCI IO space to start at 0x00000000, and set
+ * PCIBIOS_MIN_IO to prevent non-legacy PCI devices from touching
+ * reserved regions.
+ */
+ PCIBIOS_MIN_IO = LOONGSON_PCI_IO_START;
+
loongson_pci_controller.io_map_base = mips_io_port_base;
register_pci_controller(&loongson_pci_controller);
}
--
2.51.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 0/2] MIPS: Loongson2ef: Use pcibios_align_resource() to block io range
2026-01-31 21:32 [PATCH 0/2] MIPS: Loongson2ef: Use pcibios_align_resource() to block io range Rong Zhang
2026-01-31 21:32 ` [PATCH 1/2] MIPS: Loongson2ef: Register PCI controller in early stage Rong Zhang
2026-01-31 21:32 ` [PATCH 2/2] MIPS: Loongson2ef: Use pcibios_align_resource() to block io range Rong Zhang
@ 2026-01-31 21:41 ` Jiaxun Yang
2026-02-05 9:05 ` Thomas Bogendoerfer
3 siblings, 0 replies; 5+ messages in thread
From: Jiaxun Yang @ 2026-01-31 21:41 UTC (permalink / raw)
To: Rong Zhang, Thomas Bogendoerfer
Cc: Rong Zhang, Ilpo Järvinen, linux-mips@vger.kernel.org,
linux-kernel
On Sat, 31 Jan 2026, at 9:32 PM, Rong Zhang wrote:
> Loongson2ef reserves io range below 0x4000 (LOONGSON_PCI_IO_START) while
> ISA-mode only IDE controller on the south bridge still has a hard
> dependency on ISA IO ports.
>
> The reservation was done by lifting loongson_pci_io_resource.start onto
> 0x4000. Prior to commit ae81aad5c2e1 ("MIPS: PCI: Use
> pci_enable_resources()"), the arch specific pcibios_enable_resources()
> did not check if the resources were claimed, which diverges from what
> PCI core checks, effectively hiding the fact that IDE IO resources were
> not properly within the resource tree. After starting to use
> pcibios_enable_resources() from PCI core, enabling IDE controller fails:
>
> pata_cs5536 0000:00:0e.2: BAR 0 [io 0x01f0-0x01f7]: not claimed;
> can't enable device
> pata_cs5536 0000:00:0e.2: probe with driver pata_cs5536 failed with
> error -22
>
> MIPS PCI code already has support for enforcing lower bounds using
> PCIBIOS_MIN_IO in pcibios_align_resource() without altering the IO
> window start address itself. Register PCI controller in plat_mem_setup()
> instead of arch_initcall() to make it the root of other resources (e.g.,
> i8259) and prevent resource conflicts. Then, make Loongson2ef PCI code
> use PCIBIOS_MIN_IO too.
>
> Rong Zhang (2):
> MIPS: Loongson2ef: Register PCI controller in early stage
> MIPS: Loongson2ef: Use pcibios_align_resource() to block io range
Acked-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
>
> .../include/asm/mach-loongson2ef/loongson.h | 6 ++++++
> arch/mips/loongson2ef/common/pci.c | 18 +++++++++++-------
> arch/mips/loongson2ef/common/setup.c | 1 +
> 3 files changed, 18 insertions(+), 7 deletions(-)
>
>
> base-commit: ad9a728a3388dc5f66eab6b7135e0154249e9403
> --
> 2.51.0
--
- Jiaxun
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 0/2] MIPS: Loongson2ef: Use pcibios_align_resource() to block io range
2026-01-31 21:32 [PATCH 0/2] MIPS: Loongson2ef: Use pcibios_align_resource() to block io range Rong Zhang
` (2 preceding siblings ...)
2026-01-31 21:41 ` [PATCH 0/2] " Jiaxun Yang
@ 2026-02-05 9:05 ` Thomas Bogendoerfer
3 siblings, 0 replies; 5+ messages in thread
From: Thomas Bogendoerfer @ 2026-02-05 9:05 UTC (permalink / raw)
To: Rong Zhang
Cc: Jiaxun Yang, Rong Zhang, Ilpo Järvinen, linux-mips,
linux-kernel
On Sun, Feb 01, 2026 at 05:32:57AM +0800, Rong Zhang wrote:
> Loongson2ef reserves io range below 0x4000 (LOONGSON_PCI_IO_START) while
> ISA-mode only IDE controller on the south bridge still has a hard
> dependency on ISA IO ports.
>
> The reservation was done by lifting loongson_pci_io_resource.start onto
> 0x4000. Prior to commit ae81aad5c2e1 ("MIPS: PCI: Use
> pci_enable_resources()"), the arch specific pcibios_enable_resources()
> did not check if the resources were claimed, which diverges from what
> PCI core checks, effectively hiding the fact that IDE IO resources were
> not properly within the resource tree. After starting to use
> pcibios_enable_resources() from PCI core, enabling IDE controller fails:
>
> pata_cs5536 0000:00:0e.2: BAR 0 [io 0x01f0-0x01f7]: not claimed; can't enable device
> pata_cs5536 0000:00:0e.2: probe with driver pata_cs5536 failed with error -22
>
> MIPS PCI code already has support for enforcing lower bounds using
> PCIBIOS_MIN_IO in pcibios_align_resource() without altering the IO
> window start address itself. Register PCI controller in plat_mem_setup()
> instead of arch_initcall() to make it the root of other resources (e.g.,
> i8259) and prevent resource conflicts. Then, make Loongson2ef PCI code
> use PCIBIOS_MIN_IO too.
>
> Rong Zhang (2):
> MIPS: Loongson2ef: Register PCI controller in early stage
> MIPS: Loongson2ef: Use pcibios_align_resource() to block io range
>
> .../include/asm/mach-loongson2ef/loongson.h | 6 ++++++
> arch/mips/loongson2ef/common/pci.c | 18 +++++++++++-------
> arch/mips/loongson2ef/common/setup.c | 1 +
> 3 files changed, 18 insertions(+), 7 deletions(-)
>
>
> base-commit: ad9a728a3388dc5f66eab6b7135e0154249e9403
> --
> 2.51.0
series applied to mips-next
Thomas.
--
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea. [ RFC1925, 2.3 ]
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-02-05 9:06 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-31 21:32 [PATCH 0/2] MIPS: Loongson2ef: Use pcibios_align_resource() to block io range Rong Zhang
2026-01-31 21:32 ` [PATCH 1/2] MIPS: Loongson2ef: Register PCI controller in early stage Rong Zhang
2026-01-31 21:32 ` [PATCH 2/2] MIPS: Loongson2ef: Use pcibios_align_resource() to block io range Rong Zhang
2026-01-31 21:41 ` [PATCH 0/2] " Jiaxun Yang
2026-02-05 9:05 ` Thomas Bogendoerfer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox