PCI: mvebu: Fix duplicate resource requests
Subsystems (3)
Rob Herring
reviewerPATCH v2 1/1 PCI: mvebu: Fix duplicate resource requests
With commit 669cbc708122 ("PCI: Move DT resource setup into devm_pci_alloc_host_bridge()"), the DT 'ranges' is parsed and populated into resources when the host bridge is allocated. The resources are requested as well, but that happens a 2nd time for the mvebu driver in mvebu_pcie_parse_request_resources(). We should only be requesting the additional resources added in mvebu_pcie_parse_request_resources(). These are not added by default because the use custom properties rather than standard DT address translation.
Also, the bus ranges was also populated by default, so we can remove it from mvebu_pci_host_probe().
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=209729
---
v2:
- Fix copy-n-paste error with ioport_resource
--- drivers/pci/controller/pci-mvebu.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-)
drivers/pci/controller/pci-mvebu.c +10 -13
@@ -960,25 +960,16 @@ static void mvebu_pcie_powerdown(struct mvebu_pcie_port *port) }/* -* We can't use devm_of_pci_get_host_bridge_resources() because we -* need to parse our special DT properties encoding the MEM and IO -* apertures. +* devm_of_pci_get_host_bridge_resources() only sets up translateable resources, +* so we need extra resource setup parsing our special DT properties encoding +* the MEM and IO apertures. */ static int mvebu_pcie_parse_request_resources (struct mvebu_pcie *pcie) {struct device *dev = &pcie->pdev->dev; -struct device_node *np = dev->of_node;struct pci_host_bridge *bridge =pci_host_bridge_from_priv (pcie);int ret; -/* Get the bus range */ - ret =of_pci_parse_bus_range (np, &pcie->busn); -if (ret) { -dev_err (dev,"failed to parse bus-range property: %d\n" , ret); -return ret; - } -pci_add_resource (&bridge->windows, &pcie->busn); -/* Get the PCIe memory aperture */ mvebu_mbus_get_pcie_mem_aperture (&pcie->mem);if (resource_size (&pcie->mem) ==0 ) {
@@ -988,6 +979,9 @@ static int mvebu_pcie_parse_request_resources(struct mvebu_pcie *pcie) pcie->mem.name ="PCI MEM" ;pci_add_resource (&bridge->windows, &pcie->mem); + ret =devm_request_resource (dev, &iomem_resource, &pcie->mem); +if (ret) +return ret;/* Get the PCIe IO aperture */ mvebu_mbus_get_pcie_io_aperture (&pcie->io);
@@ -1001,9 +995,12 @@ static int mvebu_pcie_parse_request_resources(struct mvebu_pcie *pcie) pcie->realio.name ="PCI I/O" ;pci_add_resource (&bridge->windows, &pcie->realio); + ret =devm_request_resource (dev, &ioport_resource, &pcie->realio); +if (ret) +return ret; } -return devm_request_pci_bus_resources (dev, &bridge->windows); +return 0 ; }/*
Signature · 1 line
2.25.1
Quoted 14 lines · Rob Herring
With commit
669cbc708122("PCI: Move DT resource setup intodevm_pci_alloc_host_bridge()"), the DT 'ranges' is parsed and populated into resources when the host bridge is allocated. The resources are requested as well, but that happens a 2nd time for the mvebu driver inmvebu_pcie_parse_request_resources(). We should only be requesting the additional resources added inmvebu_pcie_parse_request_resources(). These are not added by default because the use custom properties rather than standard DT address translation.Also, the bus ranges was also populated by default, so we can remove it from
mvebu_pci_host_probe().Fixes 669cbc708122 ("PCI: Move DT resource setup into devm_pci_alloc_host_bridge()")Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=209729
Quoted 9 lines
Reported-by [email protected]Cc Thomas Petazzoni <[email protected]>Cc Jason Cooper <[email protected]>Cc Lorenzo Pieralisi <[email protected]>Cc Bjorn Helgaas <[email protected]>Cc Russell King <[email protected]>Signed-off-by Rob Herring <[email protected]>
Without this patch, 5.9.1 won't find the eMMC card on Clearfog Base for me, so:
Thanks for the fix,
Jan
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Quoted 23 lines · Rob Herring
With commit
669cbc708122("PCI: Move DT resource setup intodevm_pci_alloc_host_bridge()"), the DT 'ranges' is parsed and populated into resources when the host bridge is allocated. The resources are requested as well, but that happens a 2nd time for the mvebu driver inmvebu_pcie_parse_request_resources(). We should only be requesting the additional resources added inmvebu_pcie_parse_request_resources(). These are not added by default because the use custom properties rather than standard DT address translation.Also, the bus ranges was also populated by default, so we can remove it from
mvebu_pci_host_probe().Fixes 669cbc708122 ("PCI: Move DT resource setup into devm_pci_alloc_host_bridge()")Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=209729
Reported-by [email protected]Cc Thomas Petazzoni <[email protected]>Cc Jason Cooper <[email protected]>Cc Lorenzo Pieralisi <[email protected]>Cc Bjorn Helgaas <[email protected]>Cc Russell King <[email protected]>Signed-off-by Rob Herring <[email protected]>
Quoted 6 lines
---
v2:
- Fix copy-n-paste error withioport_resource--- drivers/pci/controller/pci-mvebu.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-)
Hi Bjorn, strictly speaking, this bug was introduced in v5.9 - it would be good to fix it in one of the upcoming -rc*:
Quoted 60 lines
drivers/pci/controller/pci-mvebu.c +10
-13@@ -960,25 +960,16 @@ static void mvebu_pcie_powerdown(struct mvebu_pcie_port *port) }/* -* We can't use devm_of_pci_get_host_bridge_resources() because we -* need to parse our special DT properties encoding the MEM and IO -* apertures. +* devm_of_pci_get_host_bridge_resources() only sets up translateable resources, +* so we need extra resource setup parsing our special DT properties encoding +* the MEM and IO apertures. */ static int mvebu_pcie_parse_request_resources (struct mvebu_pcie *pcie) {struct device *dev = &pcie->pdev->dev; -struct device_node *np = dev->of_node;struct pci_host_bridge *bridge =pci_host_bridge_from_priv (pcie);int ret; -/* Get the bus range */ - ret =of_pci_parse_bus_range (np, &pcie->busn); -if (ret) { -dev_err (dev,"failed to parse bus-range property: %d\n" , ret); -return ret; - } -pci_add_resource (&bridge->windows, &pcie->busn); -/* Get the PCIe memory aperture */ mvebu_mbus_get_pcie_mem_aperture (&pcie->mem);if (resource_size (&pcie->mem) ==0 ) {@@ -988,6 +979,9 @@ static int mvebu_pcie_parse_request_resources(struct mvebu_pcie *pcie) pcie->mem.name ="PCI MEM" ;pci_add_resource (&bridge->windows, &pcie->mem); + ret =devm_request_resource (dev, &iomem_resource, &pcie->mem); +if (ret) +return ret;/* Get the PCIe IO aperture */ mvebu_mbus_get_pcie_io_aperture (&pcie->io);@@ -1001,9 +995,12 @@ static int mvebu_pcie_parse_request_resources(struct mvebu_pcie *pcie) pcie->realio.name ="PCI I/O" ;pci_add_resource (&bridge->windows, &pcie->realio); + ret =devm_request_resource (dev, &ioport_resource, &pcie->realio); +if (ret) +return ret; } -return devm_request_pci_bus_resources (dev, &bridge->windows); +return 0 ; }/* Signature · 1 line
2.25.1
Quoted 14 lines · Rob Herring
With commit
669cbc708122("PCI: Move DT resource setup intodevm_pci_alloc_host_bridge()"), the DT 'ranges' is parsed and populated into resources when the host bridge is allocated. The resources are requested as well, but that happens a 2nd time for the mvebu driver inmvebu_pcie_parse_request_resources(). We should only be requesting the additional resources added inmvebu_pcie_parse_request_resources(). These are not added by default because the use custom properties rather than standard DT address translation.Also, the bus ranges was also populated by default, so we can remove it from
mvebu_pci_host_probe().Fixes 669cbc708122 ("PCI: Move DT resource setup into devm_pci_alloc_host_bridge()")Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=209729
Quoted 9 lines
Reported-by [email protected]Cc Thomas Petazzoni <[email protected]>Cc Jason Cooper <[email protected]>Cc Lorenzo Pieralisi <[email protected]>Cc Bjorn Helgaas <[email protected]>Cc Russell King <[email protected]>Signed-off-by Rob Herring <[email protected]>
Applied with Jan's tested-by and Lorenzo's ack to for-linus for v5.10, thanks!
Quoted 72 lines
---
v2:
- Fix copy-n-paste error withioport_resource--- drivers/pci/controller/pci-mvebu.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-)drivers/pci/controller/pci-mvebu.c +10
-13@@ -960,25 +960,16 @@ static void mvebu_pcie_powerdown(struct mvebu_pcie_port *port) }/* -* We can't use devm_of_pci_get_host_bridge_resources() because we -* need to parse our special DT properties encoding the MEM and IO -* apertures. +* devm_of_pci_get_host_bridge_resources() only sets up translateable resources, +* so we need extra resource setup parsing our special DT properties encoding +* the MEM and IO apertures. */ static int mvebu_pcie_parse_request_resources (struct mvebu_pcie *pcie) {struct device *dev = &pcie->pdev->dev; -struct device_node *np = dev->of_node;struct pci_host_bridge *bridge =pci_host_bridge_from_priv (pcie);int ret; -/* Get the bus range */ - ret =of_pci_parse_bus_range (np, &pcie->busn); -if (ret) { -dev_err (dev,"failed to parse bus-range property: %d\n" , ret); -return ret; - } -pci_add_resource (&bridge->windows, &pcie->busn); -/* Get the PCIe memory aperture */ mvebu_mbus_get_pcie_mem_aperture (&pcie->mem);if (resource_size (&pcie->mem) ==0 ) {@@ -988,6 +979,9 @@ static int mvebu_pcie_parse_request_resources(struct mvebu_pcie *pcie) pcie->mem.name ="PCI MEM" ;pci_add_resource (&bridge->windows, &pcie->mem); + ret =devm_request_resource (dev, &iomem_resource, &pcie->mem); +if (ret) +return ret;/* Get the PCIe IO aperture */ mvebu_mbus_get_pcie_io_aperture (&pcie->io);@@ -1001,9 +995,12 @@ static int mvebu_pcie_parse_request_resources(struct mvebu_pcie *pcie) pcie->realio.name ="PCI I/O" ;pci_add_resource (&bridge->windows, &pcie->realio); + ret =devm_request_resource (dev, &ioport_resource, &pcie->realio); +if (ret) +return ret; } -return devm_request_pci_bus_resources (dev, &bridge->windows); +return 0 ; }/* Signature · 7 lines
2.25.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel