Skip to content

Commit eff0306

Browse files
PCI: meson: Fix parsing the DBI register region
First of all, the driver was parsing the 'dbi' register region as 'elbi'. This was due to DT mistakenly passing 'dbi' as 'elbi'. Since the DT is now fixed to supply 'dbi' region, this driver can rely on the DWC core driver to parse and map it. However, to support the old DTs, if the 'elbi' region is found in DT, parse and map the region as both 'dw_pcie::elbi_base' as 'dw_pcie::dbi_base'. This will allow the driver to work with both broken and fixed DTs. Also, skip parsing the 'elbi' region in DWC core if 'pci->elbi_base' was already populated. Fixes: 9c0ef6d ("PCI: amlogic: Add the Amlogic Meson PCIe controller driver") Fixes: c96992a ("PCI: dwc: Add support for ELBI resource mapping") Reported-by: Linnaea Lavia <linnaea-von-lavia@live.com> Closes: https://lore.kernel.org/linux-pci/DM4PR05MB102707B8CDF84D776C39F22F2C7F0A@DM4PR05MB10270.namprd05.prod.outlook.com/ Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com> Signed-off-by: Manivannan Sadhasivam <mani@kernel.org> Tested-by: Neil Armstrong <neil.armstrong@linaro.org> # on Bananapi-M2S Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org> Cc: stable@vger.kernel.org # 6.2 Link: https://patch.msgid.link/20251101-pci-meson-fix-v1-3-c50dcc56ed6a@oss.qualcomm.com
1 parent 4813dea commit eff0306

2 files changed

Lines changed: 22 additions & 8 deletions

File tree

drivers/pci/controller/dwc/pci-meson.c

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,22 @@ static int meson_pcie_get_mems(struct platform_device *pdev,
108108
struct meson_pcie *mp)
109109
{
110110
struct dw_pcie *pci = &mp->pci;
111+
struct resource *res;
111112

112-
pci->dbi_base = devm_platform_ioremap_resource_byname(pdev, "elbi");
113-
if (IS_ERR(pci->dbi_base))
114-
return PTR_ERR(pci->dbi_base);
113+
/*
114+
* For the broken DTs that supply 'dbi' as 'elbi', parse the 'elbi'
115+
* region and assign it to both 'pci->elbi_base' and 'pci->dbi_space' so
116+
* that the DWC core can skip parsing both regions.
117+
*/
118+
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "elbi");
119+
if (res) {
120+
pci->elbi_base = devm_pci_remap_cfg_resource(pci->dev, res);
121+
if (IS_ERR(pci->elbi_base))
122+
return PTR_ERR(pci->elbi_base);
123+
124+
pci->dbi_base = pci->elbi_base;
125+
pci->dbi_phys_addr = res->start;
126+
}
115127

116128
mp->cfg_base = devm_platform_ioremap_resource_byname(pdev, "cfg");
117129
if (IS_ERR(mp->cfg_base))

drivers/pci/controller/dwc/pcie-designware.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -168,11 +168,13 @@ int dw_pcie_get_resources(struct dw_pcie *pci)
168168
}
169169

170170
/* ELBI is an optional resource */
171-
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "elbi");
172-
if (res) {
173-
pci->elbi_base = devm_ioremap_resource(pci->dev, res);
174-
if (IS_ERR(pci->elbi_base))
175-
return PTR_ERR(pci->elbi_base);
171+
if (!pci->elbi_base) {
172+
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "elbi");
173+
if (res) {
174+
pci->elbi_base = devm_ioremap_resource(pci->dev, res);
175+
if (IS_ERR(pci->elbi_base))
176+
return PTR_ERR(pci->elbi_base);
177+
}
176178
}
177179

178180
/* LLDD is supposed to manually switch the clocks and resets state */

0 commit comments

Comments
 (0)