[PATCH 2/2] PCI: Allow reusing PCI domain numbers in DT
Cui Chao
cuichao1753 at phytium.com.cn
Mon Nov 2 01:51:50 PST 2026
In the existing DT path, a uniqueness constraint is imposed on the PCI
domains of multiple PCIe nodes, which prevents devices under different
PCIe RCs from reusing the same software domain number.
Add support for the 'linux,pci-domain-reuse' DT property. For a PCI
node that declares this property, it is allowed to reuse the same
'linux,pci-domain' number with other nodes. For a PCI node that does
not declare this property, the original uniqueness check remains in
place.
Reasonable resource partitioning does not affect the global uniqueness
of devices. When domains are the same, as long as the physical
resources of two PCIe nodes (RCs), such as ECAM, bus ranges, mem32,
mem64, and IO, do not overlap, (domain, bus) remains globally unique,
and the BDFs of all devices are also globally unique.
Device tree example:
Each RC node participating in reuse declares 'linux,pci-domain-reuse';
whether the same number is actually reused is determined by the
'linux,pci-domain' value. In the example, the ECAM, bus-range, and
ranges of the two RCs do not overlap.
pcie0: pcie at 10000000 {
...
linux,pci-domain = <0>;
linux,pci-domain-reuse;
bus-range = <0x00 0x7f>;
ranges = <0x01000000 0x00000000 0x00100000 0x00000000
0x10000000 0x00000000 0x00100000
0x02000000 0x00000000 0x20000000 0x00000000
0x20000000 0x00000000 0x10000000
0x43000000 0x00000200 0x00000000 0x00000200
0x00000000 0x00000100 0x00000000>;
...
};
pcie1: pcie at 20000000 {
...
linux,pci-domain = <0>;
linux,pci-domain-reuse;
bus-range = <0x80 0xff>;
ranges = <0x01000000 0x00000000 0x00200000 0x00000000
0x10100000 0x00000000 0x00100000
0x02000000 0x00000000 0x30000000 0x00000000
0x30000000 0x00000000 0x10000000
0x43000000 0x00000300 0x00000000 0x00000300
0x00000000 0x00000100 0x00000000>;
...
};
Co-developed-by: Wang Yinfeng <wangyinfeng at phytium.com.cn>
Signed-off-by: Wang Yinfeng <wangyinfeng at phytium.com.cn>
Signed-off-by: Cui Chao <cuichao1753 at phytium.com.cn>
---
drivers/pci/pci.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 7c6f2aba8144..245ffb9d2f74 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -6801,13 +6801,19 @@ static int of_pci_bus_find_domain_nr(struct device *parent)
/*
* If domain is in DT, allocate it in static IDA. This
* prevents duplicate static allocations in case of errors
- * in DT.
+ * in DT. Platform that legitimately reuse a domain number
+ * across host bridges (disjoint ECAM/bus/memory/IO) opt out
+ * of this check with "linux,pci-domain-reuse".
*/
domain_nr = of_get_pci_domain_nr(parent->of_node);
- if (domain_nr >= 0)
+ if (domain_nr >= 0) {
+ if (of_property_read_bool(parent->of_node,
+ "linux,pci-domain-reuse"))
+ return domain_nr;
return ida_alloc_range(&pci_domain_nr_static_ida,
domain_nr, domain_nr,
GFP_KERNEL);
+ }
}
/*
@@ -6824,6 +6830,10 @@ static void of_pci_bus_release_domain_nr(struct device *parent, int domain_nr)
if (domain_nr < 0)
return;
+ /* Reusers never acquire the static slot, so never release it */
+ if (of_property_read_bool(parent->of_node, "linux,pci-domain-reuse"))
+ return;
+
/* Release domain from IDA where it was allocated. */
if (parent && of_get_pci_domain_nr(parent->of_node) == domain_nr)
ida_free(&pci_domain_nr_static_ida, domain_nr);
--
2.33.0
More information about the linux-arm-kernel
mailing list