mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [RFC PATCH 0/2] Allow reusing PCI domain numbers in DT
@ 2026-11-02  9:51 Cui Chao
  2026-11-02  9:51 ` [PATCH 1/2] dt-bindings: PCI: Add linux,pci-domain-reuse property Cui Chao
  2026-11-02  9:51 ` [PATCH 2/2] PCI: Allow reusing PCI domain numbers in DT Cui Chao
  0 siblings, 2 replies; 4+ messages in thread
From: Cui Chao @ 2026-11-02  9:51 UTC (permalink / raw)
  To: Will Deacon, Krzysztof Kozlowski, Conor Dooley, Bjorn Helgaas
  Cc: Lorenzo Pieralisi, Krzysztof Wilczyński,
	Manivannan Sadhasivam, Rob Herring, Wang Yinfeng, linux-pci,
	devicetree, linux-arm-kernel, linux-kernel

This series allows multiple PCIe host bridges to reuse the same software
domain number in Device Tree (DT), provided their resources are disjoint.

In mainstream GPU P2P functionality, whether the GPUs participating in
P2P belong to the same PCIe domain is one of the decision criteria. 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.

It should be noted that equality of PCI domains at the software level
is not equivalent to the final P2P decision. The ACPI path directly
returns '_SEG' and does not perform a similar uniqueness check, as
'_SEG' is a purely software concept and allows multiple RCs to use the
same value.

Cui Chao (2):
  dt-bindings: PCI: Add linux,pci-domain-reuse property
  PCI: Allow reusing PCI domain numbers in DT

 .../devicetree/bindings/pci/host-generic-pci.yaml  | 10 ++++++++++
 drivers/pci/pci.c                                  | 14 ++++++++++++--
 2 files changed, 22 insertions(+), 2 deletions(-)

-- 
2.33.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] dt-bindings: PCI: Add linux,pci-domain-reuse property
  2026-11-02  9:51 [RFC PATCH 0/2] Allow reusing PCI domain numbers in DT Cui Chao
@ 2026-11-02  9:51 ` Cui Chao
  2026-11-02 10:00   ` Krzysztof Kozlowski
  2026-11-02  9:51 ` [PATCH 2/2] PCI: Allow reusing PCI domain numbers in DT Cui Chao
  1 sibling, 1 reply; 4+ messages in thread
From: Cui Chao @ 2026-11-02  9:51 UTC (permalink / raw)
  To: Will Deacon, Krzysztof Kozlowski, Conor Dooley, Bjorn Helgaas
  Cc: Lorenzo Pieralisi, Krzysztof Wilczyński,
	Manivannan Sadhasivam, Rob Herring, Wang Yinfeng, linux-pci,
	devicetree, linux-arm-kernel, linux-kernel

Add a new optional boolean property 'linux,pci-domain-reuse' for PCI
host bridges.

By default, the 'linux,pci-domain' property must be unique across all
host bridges. This property allows a host bridge to explicitly opt-out
of this uniqueness check, permitting multiple host bridges to reuse the
same software domain number.

Host bridges reusing the same domain number must have disjoint ECAM,
bus-range, memory, and IO windows so that (domain, bus) tuples remain
globally unique.

Co-developed-by: Wang Yinfeng <wangyinfeng@phytium.com.cn>
Signed-off-by: Wang Yinfeng <wangyinfeng@phytium.com.cn>
Signed-off-by: Cui Chao <cuichao1753@phytium.com.cn>
---
 .../devicetree/bindings/pci/host-generic-pci.yaml      | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/Documentation/devicetree/bindings/pci/host-generic-pci.yaml b/Documentation/devicetree/bindings/pci/host-generic-pci.yaml
index 420d551e9af9..1b439e2f38af 100644
--- a/Documentation/devicetree/bindings/pci/host-generic-pci.yaml
+++ b/Documentation/devicetree/bindings/pci/host-generic-pci.yaml
@@ -114,6 +114,16 @@ properties:
       Requests with Address Type (AT).
     type: boolean
 
+  linux,pci-domain-reuse:
+    description:
+      Boolean indicating that this host bridge is allowed to reuse the same
+      "linux,pci-domain" value as another host bridge on the platform. Host
+      bridges reusing the same domain must have disjoint ECAM, bus-range,
+      memory, and IO windows so that (domain, bus) tuples remain globally
+      unique. A duplicate domain on a host bridge without this property
+      remains an error.
+    type: boolean
+
 required:
   - compatible
   - reg
-- 
2.33.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 2/2] PCI: Allow reusing PCI domain numbers in DT
  2026-11-02  9:51 [RFC PATCH 0/2] Allow reusing PCI domain numbers in DT Cui Chao
  2026-11-02  9:51 ` [PATCH 1/2] dt-bindings: PCI: Add linux,pci-domain-reuse property Cui Chao
@ 2026-11-02  9:51 ` Cui Chao
  1 sibling, 0 replies; 4+ messages in thread
From: Cui Chao @ 2026-11-02  9:51 UTC (permalink / raw)
  To: Will Deacon, Krzysztof Kozlowski, Conor Dooley, Bjorn Helgaas
  Cc: Lorenzo Pieralisi, Krzysztof Wilczyński,
	Manivannan Sadhasivam, Rob Herring, Wang Yinfeng, linux-pci,
	devicetree, linux-arm-kernel, linux-kernel

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@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@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@phytium.com.cn>
Signed-off-by: Wang Yinfeng <wangyinfeng@phytium.com.cn>
Signed-off-by: Cui Chao <cuichao1753@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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] dt-bindings: PCI: Add linux,pci-domain-reuse property
  2026-11-02  9:51 ` [PATCH 1/2] dt-bindings: PCI: Add linux,pci-domain-reuse property Cui Chao
@ 2026-11-02 10:00   ` Krzysztof Kozlowski
  0 siblings, 0 replies; 4+ messages in thread
From: Krzysztof Kozlowski @ 2026-11-02 10:00 UTC (permalink / raw)
  To: Cui Chao, Will Deacon, Krzysztof Kozlowski, Conor Dooley, Bjorn Helgaas
  Cc: Lorenzo Pieralisi, Krzysztof Wilczyński,
	Manivannan Sadhasivam, Rob Herring, Wang Yinfeng, linux-pci,
	devicetree, linux-arm-kernel, linux-kernel

On 02/11/2026 10:51, Cui Chao wrote:
> Add a new optional boolean property 'linux,pci-domain-reuse' for PCI
> host bridges.
> 
> By default, the 'linux,pci-domain' property must be unique across all
> host bridges. This property allows a host bridge to explicitly opt-out
> of this uniqueness check, permitting multiple host bridges to reuse the
> same software domain number.

Why isn't this deducible from the compatibles?

Best regards,
Krzysztof

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-11-02 10:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-02  9:51 [RFC PATCH 0/2] Allow reusing PCI domain numbers in DT Cui Chao
2026-11-02  9:51 ` [PATCH 1/2] dt-bindings: PCI: Add linux,pci-domain-reuse property Cui Chao
2026-11-02 10:00   ` Krzysztof Kozlowski
2026-11-02  9:51 ` [PATCH 2/2] PCI: Allow reusing PCI domain numbers in DT Cui Chao

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®