All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] arm/pci-designware: Make config space iATU index configurable
@ 2026-12-02  9:53 Mykyta Poturai
  2026-12-03 11:38 ` Orzel, Michal
  0 siblings, 1 reply; 3+ messages in thread
From: Mykyta Poturai @ 2026-12-02  9:53 UTC (permalink / raw)
  To: xen-devel@lists.xenproject.org
  Cc: Mykyta Poturai, Andrew Cooper, Anthony PERARD, Michal Orzel,
	Jan Beulich, Julien Grall, Roger Pau Monné,
	Stefano Stabellini, Bertrand Marquis, Volodymyr Babchuk,
	Hildebrand, Stewart

Xen programs outbound iATU window 1 for child bus config space
accesses, following the pre-5.11 Linux layout. Since Linux commit
9f9e59a48095 ("PCI: dwc: Support multiple ATU memory regions") the
hardware domain uses window 0 for config space and windows 1 and up
for MEM ranges, so every config access from Xen overwrites the first
MEM window.

Add the "pci-dw-cfg-atu" command line option to select the window and
default it to 0 to match current Linux. Older kernels need
pci-dw-cfg-atu=1.

Signed-off-by: Mykyta Poturai <mykyta_poturai@epam.com>
---
 docs/misc/xen-command-line.pandoc | 10 ++++++++++
 xen/arch/arm/pci/pci-designware.c | 12 ++++++++----
 xen/arch/arm/pci/pci-designware.h |  1 -
 3 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/docs/misc/xen-command-line.pandoc b/docs/misc/xen-command-line.pandoc
index a6f08463d1..ccc8f849dd 100644
--- a/docs/misc/xen-command-line.pandoc
+++ b/docs/misc/xen-command-line.pandoc
@@ -2077,6 +2077,16 @@ behavior.**
   In its negative form, allows to suppress certain quirk workarounds, in case
   they cause issues.
 
+### pci-dw-cfg-atu (arm)
+> `= <integer>`
+
+> Default: `0`
+
+Outbound iATU window used by Xen for config space accesses on DesignWare PCIe
+host bridges.  It must not clash with the windows programmed by the hardware
+domain.  Linux 5.11 and later use window 0 for config space, older versions
+use window 1.
+
 ### pci-phantom
 > `=[<seg>:]<bus>:<device>,<stride>`
 
diff --git a/xen/arch/arm/pci/pci-designware.c b/xen/arch/arm/pci/pci-designware.c
index 902da19e8c..13cb585096 100644
--- a/xen/arch/arm/pci/pci-designware.c
+++ b/xen/arch/arm/pci/pci-designware.c
@@ -8,6 +8,7 @@
  */
 
 #include <xen/delay.h>
+#include <xen/param.h>
 #include <asm/io.h>
 
 #include "pci-designware.h"
@@ -27,6 +28,10 @@
  */
 #define lower_32_bits(n) ((uint32_t)((n) & 0xffffffffU))
 
+/* Linux >= 5.11 uses outbound window 0 for config space, older ones use 1. */
+static unsigned int __ro_after_init cfg_atu_index;
+integer_param("pci-dw-cfg-atu", cfg_atu_index);
+
 static int dw_pcie_read(void __iomem *addr, unsigned int len, uint32_t *val)
 {
     if ( !IS_ALIGNED((uintptr_t)addr, len) )
@@ -282,8 +287,7 @@ void __iomem *dw_pcie_child_map_bus(struct pci_host_bridge *bridge,
              PCIE_ATU_FUNC(PCI_FUNC(sbdf.devfn));
 
     /* FIXME: Parent is the root bus, so use PCIE_ATU_TYPE_CFG0. */
-    ret = dw_pcie_prog_outbound_atu(bridge, PCIE_ATU_REGION_INDEX1,
-                                    PCIE_ATU_TYPE_CFG0,
+    ret = dw_pcie_prog_outbound_atu(bridge, cfg_atu_index, PCIE_ATU_TYPE_CFG0,
                                     bridge->child_cfg->phys_addr, busdev,
                                     bridge->child_cfg->size);
     if ( ret )
@@ -313,7 +317,7 @@ int dw_pcie_child_config_read(struct pci_host_bridge *bridge, pci_sbdf_t sbdf,
 
     ret = pci_generic_config_read(bridge, sbdf, reg, len, value);
     if ( !ret && (priv->num_viewport <= 2) )
-        ret = dw_pcie_prog_outbound_atu(bridge, PCIE_ATU_REGION_INDEX1,
+        ret = dw_pcie_prog_outbound_atu(bridge, cfg_atu_index,
                                         PCIE_ATU_TYPE_IO,
                                         bridge->child_cfg->phys_addr, 0,
                                         bridge->child_cfg->size);
@@ -329,7 +333,7 @@ int dw_pcie_child_config_write(struct pci_host_bridge *bridge, pci_sbdf_t sbdf,
 
     ret = pci_generic_config_write(bridge, sbdf, reg, len, value);
     if ( !ret && (priv->num_viewport <= 2) )
-        ret = dw_pcie_prog_outbound_atu(bridge, PCIE_ATU_REGION_INDEX1,
+        ret = dw_pcie_prog_outbound_atu(bridge, cfg_atu_index,
                                         PCIE_ATU_TYPE_IO,
                                         bridge->child_cfg->phys_addr, 0,
                                         bridge->child_cfg->size);
diff --git a/xen/arch/arm/pci/pci-designware.h b/xen/arch/arm/pci/pci-designware.h
index bd93dab6f2..6dfe27d7e4 100644
--- a/xen/arch/arm/pci/pci-designware.h
+++ b/xen/arch/arm/pci/pci-designware.h
@@ -25,7 +25,6 @@
 #define PCIE_ATU_UPPER_TARGET           0x91C
 #define PCIE_ATU_UPPER_LIMIT            0x924
 
-#define PCIE_ATU_REGION_INDEX1  0x1
 #define PCIE_ATU_TYPE_IO        0x2
 #define PCIE_ATU_TYPE_CFG0      0x4
 

---
base-commit: abc47aca98fa87e9fdebd0e9f7fbbbaa482056fb
change-id: 20261202-pci-dw-cfg-atu-0117d18b4630

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

end of thread, other threads:[~2026-12-04  8:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-02  9:53 [PATCH] arm/pci-designware: Make config space iATU index configurable Mykyta Poturai
2026-12-03 11:38 ` Orzel, Michal
2026-12-04  8:29   ` Mykyta Poturai

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.