[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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





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


Hello Mykyta

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.



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

Signed-off-by: Mykyta Poturai <mykyta_poturai@xxxxxxxx>
---
  xen/arch/arm/pci/pci-host-rcar.c | 17 ++++++++++++++---
  1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/xen/arch/arm/pci/pci-host-rcar.c b/xen/arch/arm/pci/pci-host-rcar.c
index 5f184d5ebc..87b3ccbc1c 100644
--- a/xen/arch/arm/pci/pci-host-rcar.c
+++ b/xen/arch/arm/pci/pci-host-rcar.c
@@ -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);

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


+ 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...

+    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:
Reviewed-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@xxxxxxxx>


      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




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.