Skip to contentSkip to conversation

Add R-Car Gen5 PCI host support

PATCH In review Mykyta Poturai 3 participants 6 messages Nov 16 – Nov 17 Arm/RISC-V/Renesas architecture

lore
Share & tools
lore
#1 lore raw

PATCH 1/2 pci/rcar: Rename PCI host rcar4 to rcar

In reply to Mykyta Poturai

Gen5 mostly reuses the same DesignWare integration and register layout as Gen4, so one driver covers both. Drop the generation number from the file and symbol names.

---
 MAINTAINERS                                   |  2 +-
 xen/arch/arm/pci/Makefile                     |  2 +-
 .../pci/{pci-host-rcar4.c => pci-host-rcar.c} | 32 +++++++++----------
 .../pci/{pci-host-rcar4.h => pci-host-rcar.h} |  6 ++--
 xen/drivers/passthrough/arm/ipmmu-vmsa.c      |  2 +-
 5 files changed, 22 insertions(+), 22 deletions(-)
 rename xen/arch/arm/pci/{pci-host-rcar4.c => pci-host-rcar.c} (88%)
 rename xen/arch/arm/pci/{pci-host-rcar4.h => pci-host-rcar.h} (88%)
MAINTAINERS +1 -1
index b804434d52..68b47adf81 100644
@@ -504,7 +504,7 @@ T:	git https://xenbits.xenproject.org/git-http/qemu-xen.git
 RCAR PCI
 M:	Mykyta Poturai <[email protected]>
 S:	Supported
-F:	xen/arch/arm/pci/pci-host-rcar4.c
+F:	xen/arch/arm/pci/pci-host-rcar.c
 
 REMUS
 S:	Orphan
xen/arch/arm/pci/Makefile +1 -1
index ca6135e282..431a91c46d 100644
@@ -5,4 +5,4 @@ obj-y += pci-host-common.o
 obj-y += ecam.o
 obj-y += pci-host-zynqmp.o
 obj-y += pci-designware.o
-obj-y += pci-host-rcar4.o
+obj-y += pci-host-rcar.o
xen/arch/arm/pci/pci-host-rcar.c renamed from xen/arch/arm/pci/pci-host-rcar4.c +16 -16
similarity index 88%
rename from xen/arch/arm/pci/pci-host-rcar4.c
rename to xen/arch/arm/pci/pci-host-rcar.c
index e1e8eb0ee1..5f184d5ebc 100644
@@ -13,9 +13,9 @@
 #include <asm/pci.h>
 
 #include "pci-designware.h"
-#include "pci-host-rcar4.h"
+#include "pci-host-rcar.h"
 
-#define RCAR4_DWC_VERSION       0x520A
+#define RCAR_DWC_VERSION     0x520A
 
 /* PCIE BDF-OSID assignment */
 #define CNVID(n)             (0x700 + ((n) * 4))
@@ -51,20 +51,20 @@ struct rcar4_pcie_priv {
  *   "config": child's configuration space
  *   "atu"   : iATU registers for DWC version 4.80 or later
  */
-static int __init rcar4_cfg_reg_index(struct dt_device_node *np)
+static int __init rcar_cfg_reg_index(struct dt_device_node *np)
 {
     return dt_property_match_string(np, "reg-names", "dbi");
 }
 
-static int __init rcar4_child_cfg_reg_index(struct dt_device_node *np)
+static int __init rcar_child_cfg_reg_index(struct dt_device_node *np)
 {
     return dt_property_match_string(np, "reg-names", "config");
 }
 
 /* ECAM ops */
-static const struct pci_ecam_ops rcar4_pcie_ops = {
+static const struct pci_ecam_ops rcar_pcie_ops = {
     .bus_shift  = 20,
-    .cfg_reg_index = rcar4_cfg_reg_index,
+    .cfg_reg_index = rcar_cfg_reg_index,
     .pci_ops    = {
         .map_bus                = pci_ecam_map_bus,
         .read                   = pci_generic_config_read,
@@ -74,9 +74,9 @@ static const struct pci_ecam_ops rcar4_pcie_ops = {
     }
 };
 
-static const struct pci_ecam_ops rcar4_pcie_child_ops = {
+static const struct pci_ecam_ops rcar_pcie_child_ops = {
     .bus_shift  = 20,
-    .cfg_reg_index = rcar4_child_cfg_reg_index,
+    .cfg_reg_index = rcar_child_cfg_reg_index,
     .pci_ops    = {
         .map_bus                = dw_pcie_child_map_bus,
         .read                   = dw_pcie_child_config_read,
@@ -86,7 +86,7 @@ static const struct pci_ecam_ops rcar4_pcie_child_ops = {
     }
 };
 
-static const struct dt_device_match __initconstrel rcar4_pcie_dt_match[] = {
+static const struct dt_device_match __initconstrel rcar_pcie_dt_match[] = {
     { .compatible = "renesas,r8a779f0-pcie" },
     { .compatible = "renesas,r8a779g0-pcie" },
     {},
@@ -179,8 +179,8 @@ void rcar4_pcie_bdf_msk_set(struct pci_host_bridge *bridge, unsigned int reg_id,
     rcar4_pcie_writel_app(priv, CNVIDMSK(reg_id), val);
 }
 
-static int __init pci_host_rcar4_probe(struct dt_device_node *dev,
-                                       const void *data)
+static int __init pci_host_rcar_probe(struct dt_device_node *dev,
+                                      const void *data)
 {
     struct pci_host_bridge *bridge;
     paddr_t app_phys_addr;
@@ -191,8 +191,8 @@ static int __init pci_host_rcar4_probe(struct dt_device_node *dev,
     if ( !priv )
         return -ENOMEM;
 
-    bridge = dw_pcie_host_probe(dev, data, &rcar4_pcie_ops,
-                                &rcar4_pcie_child_ops);
+    bridge = dw_pcie_host_probe(dev, data, &rcar_pcie_ops,
+                                &rcar_pcie_child_ops);
 
     app_idx = dt_property_match_string(dev, "reg-names", "app");
     if ( app_idx < 0 )
@@ -219,7 +219,7 @@ static int __init pci_host_rcar4_probe(struct dt_device_node *dev,
            app_phys_addr + app_size - 1);
 
     dw_pcie_set_priv(bridge, priv);
-    dw_pcie_set_version(bridge, RCAR4_DWC_VERSION);
+    dw_pcie_set_version(bridge, RCAR_DWC_VERSION);
 
     return 0;
 err:
@@ -228,8 +228,8 @@ err:
 }
 
 DT_DEVICE_START(pci_gen, "PCI HOST R-CAR GEN4", DEVICE_PCI_HOSTBRIDGE)
-.dt_match = rcar4_pcie_dt_match,
-.init = pci_host_rcar4_probe,
+.dt_match = rcar_pcie_dt_match,
+.init = pci_host_rcar_probe,
 DT_DEVICE_END
 
 /*
xen/arch/arm/pci/pci-host-rcar.h renamed from xen/arch/arm/pci/pci-host-rcar4.h +3 -3
similarity index 88%
rename from xen/arch/arm/pci/pci-host-rcar4.h
rename to xen/arch/arm/pci/pci-host-rcar.h
index 31ef9d2d40..ffd49e3c1c 100644
@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0-only */
-#ifndef __PCI_HOST_RCAR4_H__
-#define __PCI_HOST_RCAR4_H__
+#ifndef __PCI_HOST_RCAR_H__
+#define __PCI_HOST_RCAR_H__
 
 #include <asm/pci.h>
 
@@ -17,4 +17,4 @@ void rcar4_pcie_osid_reg_free(struct pci_host_bridge *bridge,
 int rcar4_pcie_osid_regs_init(struct pci_host_bridge *bridge);
 #endif
 
-#endif /* __PCI_HOST_RCAR4_H__ */
+#endif /* __PCI_HOST_RCAR_H__ */
xen/drivers/passthrough/arm/ipmmu-vmsa.c +1 -1
index 0648f9b407..bfb9df238a 100644
@@ -51,7 +51,7 @@
 #include <asm/device.h>
 #include <asm/io.h>
 #include <asm/iommu_fwspec.h>
-#include "../arch/arm/pci/pci-host-rcar4.h"
+#include "../arch/arm/pci/pci-host-rcar.h"
 
 #define dev_name(dev) dt_node_full_name(dev_to_dt(dev))
 
Signature · 1 line
2.56.1
#0 lore raw

cover Add R-Car Gen5 PCI host support

Add R-Car Gen5 PCI host support to the existing Gen4 driver. Gen5 uses the same DesignWare integration and register layout, so one driver covers both.

Drop the generation number from the driver file and static symbols. Keep the rcar4_ prefix on the exported OSID helpers, as the BDF-to-OSID registers only exist on Gen4.

Add the "renesas,rcar-gen5-pcie6" compatible and skip the "app" register range on Gen5, as the hardware does not have it.

Mykyta Poturai (2):
pci/rcar: Rename PCI host rcar4 to rcar
pci/rcar: Add support for Gen5 PCI host

 MAINTAINERS                                   |  2 +-
 xen/arch/arm/pci/Makefile                     |  2 +-
 .../pci/{pci-host-rcar4.c => pci-host-rcar.c} | 49 ++++++++++++-------
 .../pci/{pci-host-rcar4.h => pci-host-rcar.h} |  6 +--
 xen/drivers/passthrough/arm/ipmmu-vmsa.c      |  2 +-
 5 files changed, 36 insertions(+), 25 deletions(-)
 rename xen/arch/arm/pci/{pci-host-rcar4.c => pci-host-rcar.c} (81%)
 rename xen/arch/arm/pci/{pci-host-rcar4.h => pci-host-rcar.h} (88%)
Signature · 1 line
2.56.1
#3 lore raw

PATCH 2/2 pci/rcar: Add support for Gen5 PCI host

Add support for Renesas R-Car Gen5 PCI host controller. This includes updating the device tree match table to recognize the new compatible string "renesas,rcar-gen5-pcie6" and ensuring that the OSID registers are only initialized when they are supported by the hardware.

Gen5 hosts do not expose the "app" register range, so only look it up on Gen4.

---
 xen/arch/arm/pci/pci-host-rcar.c | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)
xen/arch/arm/pci/pci-host-rcar.c +14 -3
index 5f184d5ebc..87b3ccbc1c 100644
@@ -17,6 +17,9 @@
 
 #define RCAR_DWC_VERSION     0x520A
 
+#define RCAR_GEN4    4
+#define RCAR_GEN5    5
+
 /* PCIE BDF-OSID assignment */
 #define CNVID(n)             (0x700 + ((n) * 4))
 #define CNVID_CNV_EN         (1U << 31)
@@ -87,8 +90,9 @@ static const struct pci_ecam_ops rcar_pcie_child_ops = {
 };
 
 static const struct dt_device_match __initconstrel rcar_pcie_dt_match[] = {
-    { .compatible = "renesas,r8a779f0-pcie" },
-    { .compatible = "renesas,r8a779g0-pcie" },
+    { .compatible = "renesas,r8a779f0-pcie", .data = (void *)RCAR_GEN4 },
+    { .compatible = "renesas,r8a779g0-pcie", .data = (void *)RCAR_GEN4 },
+    { .compatible = "renesas,rcar-gen5-pcie6", .data = (void *)RCAR_GEN5 },
     {},
 };
 
@@ -182,6 +186,7 @@ void rcar4_pcie_bdf_msk_set(struct pci_host_bridge *bridge, unsigned int reg_id,
 static int __init pci_host_rcar_probe(struct dt_device_node *dev,
                                       const void *data)
 {
+    const struct dt_device_match *match;
     struct pci_host_bridge *bridge;
     paddr_t app_phys_addr;
     paddr_t app_size;
@@ -194,6 +199,11 @@ static int __init pci_host_rcar_probe(struct dt_device_node *dev,
     bridge = dw_pcie_host_probe(dev, data, &rcar_pcie_ops,
                                 &rcar_pcie_child_ops);
 
+    match = dt_match_node(rcar_pcie_dt_match, dev);
+    ASSERT(match);
+    if ( match->data != (void *)RCAR_GEN4 )
+        goto skip_app;
+
     app_idx = dt_property_match_string(dev, "reg-names", "app");
     if ( app_idx < 0 )
     {
@@ -218,6 +228,7 @@ static int __init pci_host_rcar_probe(struct dt_device_node *dev,
     printk("APP at [mem 0x%" PRIpaddr "-0x%" PRIpaddr "]\n", app_phys_addr,
            app_phys_addr + app_size - 1);
 
+skip_app:
     dw_pcie_set_priv(bridge, priv);
     dw_pcie_set_version(bridge, RCAR_DWC_VERSION);
 
@@ -227,7 +238,7 @@ err:
     return ret;
 }
 
-DT_DEVICE_START(pci_gen, "PCI HOST R-CAR GEN4", DEVICE_PCI_HOSTBRIDGE)
+DT_DEVICE_START(pci_gen, "PCI HOST R-CAR GEN4/GEN5", DEVICE_PCI_HOSTBRIDGE)
 .dt_match = rcar_pcie_dt_match,
 .init = pci_host_rcar_probe,
 DT_DEVICE_END
Signature · 1 line
2.56.1
#5 lore raw
In reply to Mykyta Poturai

Hello Mykyta,

Quoted 15 lines · Mykyta Poturai

Add R-Car Gen5 PCI host support to the existing Gen4 driver. Gen5 uses the same DesignWare integration and register layout, so one driver covers both.

Drop the generation number from the driver file and static symbols. Keep the rcar4_ prefix on the exported OSID helpers, as the BDF-to-OSID registers only exist on Gen4.

Add the "renesas,rcar-gen5-pcie6" compatible and skip the "app" register range on Gen5, as the hardware does not have it.

Mykyta Poturai (2):
pci/rcar: Rename PCI host rcar4 to rcar
pci/rcar: Add support for Gen5 PCI host

Quoted 9 lines
  MAINTAINERS                                   |  2 +-
  xen/arch/arm/pci/Makefile                     |  2 +-
  .../pci/{pci-host-rcar4.c => pci-host-rcar.c} | 49 ++++++++++++-------
  .../pci/{pci-host-rcar4.h => pci-host-rcar.h} |  6 +--
  xen/drivers/passthrough/arm/ipmmu-vmsa.c      |  2 +-
  5 files changed, 36 insertions(+), 25 deletions(-)

rename xen/arch/arm/pci/{pci-host-rcar4.c => pci-host-rcar.c} (81%) rename xen/arch/arm/pci/{pci-host-rcar4.h => pci-host-rcar.h} (88%)

Could you also please add item in CHANGELOG.md if v2 will be needed?

Thanks in advance.

~ Oleksii

Reviewed-by on v1 2/2
#4 lore raw

Re: [PATCH v1 2/2] pci/rcar: Add support for Gen5 PCI host

In reply to Mykyta Poturai

16.11.2026 10:40, Mykyta Poturai пишет:

Hello Mykyta

Quoted 4 lines

Add support for Renesas R-Car Gen5 PCI host controller. This includes updating the device tree match table to recognize the new compatible string "renesas,rcar-gen5-pcie6" and ensuring that the OSID registers are only initialized when they are supported by the hardware.

NIT: It is not entirely precise, the code only skips the app range lookup and ioremap on Gen5. Nothing guards OSID initialisation. That is harmless, because only the IPMMU driver uses it and Gen5 uses SMMUv3.

Quoted 44 lines

Gen5 hosts do not expose the "app" register range, so only look it up on Gen4.

---
  xen/arch/arm/pci/pci-host-rcar.c | 17 ++++++++++++++---
  1 file changed, 14 insertions(+), 3 deletions(-)
xen/arch/arm/pci/pci-host-rcar.c +7 -2
index 5f184d5ebc..87b3ccbc1c 100644
@@ -17,6 +17,9 @@
 
  #define RCAR_DWC_VERSION     0x520A
 
+#define RCAR_GEN4    4
+#define RCAR_GEN5    5
+
  /* PCIE BDF-OSID assignment */
  #define CNVID(n)             (0x700 + ((n) * 4))
  #define CNVID_CNV_EN         (1U << 31)
@@ -87,8 +90,9 @@ static const struct pci_ecam_ops rcar_pcie_child_ops = {
  };
 
  static const struct dt_device_match __initconstrel rcar_pcie_dt_match[] = {
-    { .compatible = "renesas,r8a779f0-pcie" },
-    { .compatible = "renesas,r8a779g0-pcie" },
+    { .compatible = "renesas,r8a779f0-pcie", .data = (void *)RCAR_GEN4 },
+    { .compatible = "renesas,r8a779g0-pcie", .data = (void *)RCAR_GEN4 },
+    { .compatible = "renesas,rcar-gen5-pcie6", .data = (void *)RCAR_GEN5 },
      {},
  };
 
@@ -182,6 +186,7 @@ void rcar4_pcie_bdf_msk_set(struct pci_host_bridge *bridge, unsigned int reg_id,
  static int __init pci_host_rcar_probe(struct dt_device_node *dev,
                                        const void *data)
  {
+    const struct dt_device_match *match;
      struct pci_host_bridge *bridge;
      paddr_t app_phys_addr;
      paddr_t app_size;

xen/arch/arm/pci/pci-host-rcar.c static int __init pci_host_rcar_probe(struct dt_device_node *dev, · line 200

Quoted 2 lines
xen/arch/arm/pci/pci-host-rcar.c +0 -0
@@ -194,6 +199,11 @@ static int __init pci_host_rcar_probe(struct dt_device_node *dev,
      bridge = dw_pcie_host_probe(dev, data, &rcar_pcie_ops,
                                  &rcar_pcie_child_ops);

Remark: The result of dw_pcie_host_probe() is not checked. On failure it returns an ERR_PTR ...

xen/arch/arm/pci/pci-host-rcar.c static int __init pci_host_rcar_probe(struct dt_device_node *dev, · line 203

Quoted 3 lines
xen/arch/arm/pci/pci-host-rcar.c +2 -0
+    match = dt_match_node(rcar_pcie_dt_match, dev);
+    ASSERT(match);

NIT: To be honest, I am not entirely sure why this assert is here. I assume it was copied from existing code. As far as I understand, dt_match_node() cannot fail here, because the device was already matched to reach the probe...

xen/arch/arm/pci/pci-host-rcar.c static int __init pci_host_rcar_probe(struct dt_device_node *dev, · line 232

Quoted 12 lines
xen/arch/arm/pci/pci-host-rcar.c +4 -0
+    if ( match->data != (void *)RCAR_GEN4 )
+        goto skip_app;
+
      app_idx = dt_property_match_string(dev, "reg-names", "app");
      if ( app_idx < 0 )
      {
@@ -218,6 +228,7 @@ static int __init pci_host_rcar_probe(struct dt_device_node *dev,
      printk("APP at [mem 0x%" PRIpaddr "-0x%" PRIpaddr "]\n", app_phys_addr,
             app_phys_addr + app_size - 1);
 
+skip_app:
      dw_pcie_set_priv(bridge, priv);

... which dw_pcie_set_priv() then dereferences. This is pre-existing,
so maybe better to fix it in prereq commit.

As for the current commit:

Quoted 11 lines
xen/arch/arm/pci/pci-host-rcar.c +1 -1
      dw_pcie_set_version(bridge, RCAR_DWC_VERSION);
 
@@ -227,7 +238,7 @@ err:
      return ret;
  }
 
-DT_DEVICE_START(pci_gen, "PCI HOST R-CAR GEN4", DEVICE_PCI_HOSTBRIDGE)
+DT_DEVICE_START(pci_gen, "PCI HOST R-CAR GEN4/GEN5", DEVICE_PCI_HOSTBRIDGE)
  .dt_match = rcar_pcie_dt_match,
  .init = pci_host_rcar_probe,
  DT_DEVICE_END
Reviewed-by on v1 1/2
#2 lore raw

Re: [PATCH v1 1/2] pci/rcar: Rename PCI host rcar4 to rcar

In reply to Mykyta Poturai

16.11.2026 10:40, Mykyta Poturai пишет:

Hello Mykyta

Quoted 3 lines

Gen5 mostly reuses the same DesignWare integration and register layout as Gen4, so one driver covers both. Drop the generation number from the file and symbol names.

NIT: But rcar4_pcie_osid_*, rcar4_pcie_bdf_msk_set, struct rcar4_pcie_priv, etc keep the generation number. Yes, the reason (the registers exist only on Gen4) is mentioned in cover letter, but this will not be committed to git history. I would add a sentence in the patch description.

Quoted 17 lines
---
  MAINTAINERS                                   |  2 +-
  xen/arch/arm/pci/Makefile                     |  2 +-
  .../pci/{pci-host-rcar4.c => pci-host-rcar.c} | 32 +++++++++----------
  .../pci/{pci-host-rcar4.h => pci-host-rcar.h} |  6 ++--
  xen/drivers/passthrough/arm/ipmmu-vmsa.c      |  2 +-
  5 files changed, 22 insertions(+), 22 deletions(-)

rename xen/arch/arm/pci/{pci-host-rcar4.c => pci-host-rcar.c} (88%) rename xen/arch/arm/pci/{pci-host-rcar4.h => pci-host-rcar.h} (88%)

MAINTAINERS +0 -0
index b804434d52..68b47adf81 100644

MAINTAINERS T: git https://xenbits.xenproject.org/git-http/qemu-xen.git · line 507

Quoted 5 lines
MAINTAINERS +1 -1
@@ -504,7 +504,7 @@ T:	git https://xenbits.xenproject.org/git-http/qemu-xen.git
  RCAR PCI
  M:	Mykyta Poturai <[email protected]>
  S:	Supported
-F:	xen/arch/arm/pci/pci-host-rcar4.c
+F:	xen/arch/arm/pci/pci-host-rcar.c

Remark: pci-host-rcar.h is not covered by the RCAR PCI entry. Yes, this is pre-existing and not caused by the rename, I thought the line was edited anyway, so it would be a cheap addition.

I did not find any issues with current patch.

Quoted 1 line

...

[snip]