Skip to content

Commit 4b86eff

Browse files
claudiubezneaMani-Sadhasivam
authored andcommitted
PCI: rzg3s-host: Use pci_generic_config_write() for the root bus
The Renesas RZ/G3S host controller allows writing to read-only PCIe configuration registers when the RZG3S_PCI_PERM_CFG_HWINIT_EN bit is set in the RZG3S_PCI_PERM register. However, callers of struct pci_ops::write expect the semantics defined by the PCIe specification, meaning that writes to read-only registers must not be allowed. The previous custom struct pci_ops::write implementation for the root bus temporarily enabled write access before calling pci_generic_config_write(). This breaks the expected semantics. Remove the custom implementation and simply use pci_generic_config_write(). Along with this change, the updates of the PCI_PRIMARY_BUS, PCI_SECONDARY_BUS, and PCI_SUBORDINATE_BUS registers were moved so that they no longer depends on the RZG3S_PCI_PERM_CFG_HWINIT_EN bit in the RZG3S_PCI_PERM_CFG register, since these registers are R/W. Fixes: 7ef502f ("PCI: Add Renesas RZ/G3S host controller driver") Suggested-by: Bjorn Helgaas <helgaas@kernel.org> Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com> Signed-off-by: Manivannan Sadhasivam <mani@kernel.org> Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Link: https://patch.msgid.link/20251217111510.138848-2-claudiu.beznea.uj@bp.renesas.com
1 parent 8f0b4cc commit 4b86eff

1 file changed

Lines changed: 4 additions & 23 deletions

File tree

drivers/pci/controller/pcie-rzg3s-host.c

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -439,28 +439,9 @@ static void __iomem *rzg3s_pcie_root_map_bus(struct pci_bus *bus,
439439
return host->pcie + where;
440440
}
441441

442-
/* Serialized by 'pci_lock' */
443-
static int rzg3s_pcie_root_write(struct pci_bus *bus, unsigned int devfn,
444-
int where, int size, u32 val)
445-
{
446-
struct rzg3s_pcie_host *host = bus->sysdata;
447-
int ret;
448-
449-
/* Enable access control to the CFGU */
450-
writel_relaxed(RZG3S_PCI_PERM_CFG_HWINIT_EN,
451-
host->axi + RZG3S_PCI_PERM);
452-
453-
ret = pci_generic_config_write(bus, devfn, where, size, val);
454-
455-
/* Disable access control to the CFGU */
456-
writel_relaxed(0, host->axi + RZG3S_PCI_PERM);
457-
458-
return ret;
459-
}
460-
461442
static struct pci_ops rzg3s_pcie_root_ops = {
462443
.read = pci_generic_config_read,
463-
.write = rzg3s_pcie_root_write,
444+
.write = pci_generic_config_write,
464445
.map_bus = rzg3s_pcie_root_map_bus,
465446
};
466447

@@ -1065,14 +1046,14 @@ static int rzg3s_pcie_config_init(struct rzg3s_pcie_host *host)
10651046
writel_relaxed(0xffffffff, host->pcie + RZG3S_PCI_CFG_BARMSK00L);
10661047
writel_relaxed(0xffffffff, host->pcie + RZG3S_PCI_CFG_BARMSK00U);
10671048

1049+
/* Disable access control to the CFGU */
1050+
writel_relaxed(0, host->axi + RZG3S_PCI_PERM);
1051+
10681052
/* Update bus info */
10691053
writeb_relaxed(primary_bus, host->pcie + PCI_PRIMARY_BUS);
10701054
writeb_relaxed(secondary_bus, host->pcie + PCI_SECONDARY_BUS);
10711055
writeb_relaxed(subordinate_bus, host->pcie + PCI_SUBORDINATE_BUS);
10721056

1073-
/* Disable access control to the CFGU */
1074-
writel_relaxed(0, host->axi + RZG3S_PCI_PERM);
1075-
10761057
return 0;
10771058
}
10781059

0 commit comments

Comments
 (0)