Commit 4f5c883d authored by Rob Herring's avatar Rob Herring Committed by Lorenzo Pieralisi

PCI: Move setting pci_host_bridge.busnr out of host drivers

Most host drivers only parse the DT bus range to set the root bus number
in pci_host_bridge.busnr. The ones that don't set busnr are buggy in
that they ignore what's in DT. Let's set busnr in pci_scan_root_bus_bridge()
where we already check for the bus resource and remove setting it in
host drivers.

Link: https://lore.kernel.org/r/20200722022514.1283916-12-robh@kernel.orgSigned-off-by: default avatarRob Herring <robh@kernel.org>
Signed-off-by: default avatarLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Acked-by: default avatarBjorn Helgaas <bhelgaas@google.com>
Cc: Jingoo Han <jingoohan1@gmail.com>
Cc: Gustavo Pimentel <gustavo.pimentel@synopsys.com>
Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Cc: Will Deacon <will@kernel.org>
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: Jonathan Hunter <jonathanh@nvidia.com>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Ryder Lee <ryder.lee@mediatek.com>
Cc: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Cc: linux-tegra@vger.kernel.org
Cc: linux-mediatek@lists.infradead.org
Cc: linux-renesas-soc@vger.kernel.org
parent 6176a5f3
...@@ -474,7 +474,6 @@ int dw_pcie_host_init(struct pcie_port *pp) ...@@ -474,7 +474,6 @@ int dw_pcie_host_init(struct pcie_port *pp)
} }
bridge->sysdata = pp; bridge->sysdata = pp;
bridge->busnr = pp->busn->start;
bridge->ops = &dw_pcie_ops; bridge->ops = &dw_pcie_ops;
bridge->map_irq = of_irq_parse_and_map_pci; bridge->map_irq = of_irq_parse_and_map_pci;
bridge->swizzle_irq = pci_common_swizzle; bridge->swizzle_irq = pci_common_swizzle;
......
...@@ -1104,7 +1104,6 @@ static int advk_pcie_probe(struct platform_device *pdev) ...@@ -1104,7 +1104,6 @@ static int advk_pcie_probe(struct platform_device *pdev)
{ {
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
struct advk_pcie *pcie; struct advk_pcie *pcie;
struct resource *bus;
struct pci_host_bridge *bridge; struct pci_host_bridge *bridge;
int ret, irq; int ret, irq;
...@@ -1132,12 +1131,11 @@ static int advk_pcie_probe(struct platform_device *pdev) ...@@ -1132,12 +1131,11 @@ static int advk_pcie_probe(struct platform_device *pdev)
} }
ret = pci_parse_request_of_pci_ranges(dev, &bridge->windows, ret = pci_parse_request_of_pci_ranges(dev, &bridge->windows,
&bridge->dma_ranges, &bus); &bridge->dma_ranges, NULL);
if (ret) { if (ret) {
dev_err(dev, "Failed to parse resources\n"); dev_err(dev, "Failed to parse resources\n");
return ret; return ret;
} }
bridge->busnr = bus->start;
pcie->reset_gpio = devm_gpiod_get_from_of_node(dev, dev->of_node, pcie->reset_gpio = devm_gpiod_get_from_of_node(dev, dev->of_node,
"reset-gpios", 0, "reset-gpios", 0,
......
...@@ -77,7 +77,6 @@ int pci_host_common_probe(struct platform_device *pdev) ...@@ -77,7 +77,6 @@ int pci_host_common_probe(struct platform_device *pdev)
pci_add_flags(PCI_REASSIGN_ALL_BUS); pci_add_flags(PCI_REASSIGN_ALL_BUS);
bridge->sysdata = cfg; bridge->sysdata = cfg;
bridge->busnr = cfg->busr.start;
bridge->ops = (struct pci_ops *)&ops->pci_ops; bridge->ops = (struct pci_ops *)&ops->pci_ops;
bridge->map_irq = of_irq_parse_and_map_pci; bridge->map_irq = of_irq_parse_and_map_pci;
bridge->swizzle_irq = pci_common_swizzle; bridge->swizzle_irq = pci_common_swizzle;
......
...@@ -2668,7 +2668,6 @@ static int tegra_pcie_probe(struct platform_device *pdev) ...@@ -2668,7 +2668,6 @@ static int tegra_pcie_probe(struct platform_device *pdev)
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
struct pci_host_bridge *host; struct pci_host_bridge *host;
struct tegra_pcie *pcie; struct tegra_pcie *pcie;
struct resource *bus;
int err; int err;
host = devm_pci_alloc_host_bridge(dev, sizeof(*pcie)); host = devm_pci_alloc_host_bridge(dev, sizeof(*pcie));
...@@ -2683,7 +2682,7 @@ static int tegra_pcie_probe(struct platform_device *pdev) ...@@ -2683,7 +2682,7 @@ static int tegra_pcie_probe(struct platform_device *pdev)
INIT_LIST_HEAD(&pcie->ports); INIT_LIST_HEAD(&pcie->ports);
pcie->dev = dev; pcie->dev = dev;
err = pci_parse_request_of_pci_ranges(dev, &host->windows, NULL, &bus); err = pci_parse_request_of_pci_ranges(dev, &host->windows, NULL, NULL);
if (err) { if (err) {
dev_err(dev, "Getting bridge resources failed\n"); dev_err(dev, "Getting bridge resources failed\n");
return err; return err;
...@@ -2712,7 +2711,6 @@ static int tegra_pcie_probe(struct platform_device *pdev) ...@@ -2712,7 +2711,6 @@ static int tegra_pcie_probe(struct platform_device *pdev)
goto pm_runtime_put; goto pm_runtime_put;
} }
host->busnr = bus->start;
host->ops = &tegra_pcie_ops; host->ops = &tegra_pcie_ops;
host->map_irq = tegra_pcie_map_irq; host->map_irq = tegra_pcie_map_irq;
host->swizzle_irq = pci_common_swizzle; host->swizzle_irq = pci_common_swizzle;
......
...@@ -584,8 +584,6 @@ static int v3_pci_setup_resource(struct v3_pci *v3, ...@@ -584,8 +584,6 @@ static int v3_pci_setup_resource(struct v3_pci *v3,
} }
break; break;
case IORESOURCE_BUS: case IORESOURCE_BUS:
dev_dbg(dev, "BUS %pR\n", win->res);
host->busnr = win->res->start;
break; break;
default: default:
dev_info(dev, "Unknown resource type %lu\n", dev_info(dev, "Unknown resource type %lu\n",
......
...@@ -209,7 +209,6 @@ struct mtk_pcie_port { ...@@ -209,7 +209,6 @@ struct mtk_pcie_port {
* @mem: non-prefetchable memory resource * @mem: non-prefetchable memory resource
* @ports: pointer to PCIe port information * @ports: pointer to PCIe port information
* @soc: pointer to SoC-dependent operations * @soc: pointer to SoC-dependent operations
* @busnr: root bus number
*/ */
struct mtk_pcie { struct mtk_pcie {
struct device *dev; struct device *dev;
...@@ -218,7 +217,6 @@ struct mtk_pcie { ...@@ -218,7 +217,6 @@ struct mtk_pcie {
struct list_head ports; struct list_head ports;
const struct mtk_pcie_soc *soc; const struct mtk_pcie_soc *soc;
unsigned int busnr;
}; };
static void mtk_pcie_subsys_powerdown(struct mtk_pcie *pcie) static void mtk_pcie_subsys_powerdown(struct mtk_pcie *pcie)
...@@ -1031,16 +1029,13 @@ static int mtk_pcie_setup(struct mtk_pcie *pcie) ...@@ -1031,16 +1029,13 @@ static int mtk_pcie_setup(struct mtk_pcie *pcie)
struct mtk_pcie_port *port, *tmp; struct mtk_pcie_port *port, *tmp;
struct pci_host_bridge *host = pci_host_bridge_from_priv(pcie); struct pci_host_bridge *host = pci_host_bridge_from_priv(pcie);
struct list_head *windows = &host->windows; struct list_head *windows = &host->windows;
struct resource *bus;
int err; int err;
err = pci_parse_request_of_pci_ranges(dev, windows, err = pci_parse_request_of_pci_ranges(dev, windows,
&host->dma_ranges, &bus); &host->dma_ranges, NULL);
if (err) if (err)
return err; return err;
pcie->busnr = bus->start;
for_each_available_child_of_node(node, child) { for_each_available_child_of_node(node, child) {
int slot; int slot;
...@@ -1094,7 +1089,6 @@ static int mtk_pcie_probe(struct platform_device *pdev) ...@@ -1094,7 +1089,6 @@ static int mtk_pcie_probe(struct platform_device *pdev)
if (err) if (err)
return err; return err;
host->busnr = pcie->busnr;
host->ops = pcie->soc->ops; host->ops = pcie->soc->ops;
host->map_irq = of_irq_parse_and_map_pci; host->map_irq = of_irq_parse_and_map_pci;
host->swizzle_irq = pci_common_swizzle; host->swizzle_irq = pci_common_swizzle;
......
...@@ -224,7 +224,6 @@ static int rcar_pcie_setup(struct list_head *resource, ...@@ -224,7 +224,6 @@ static int rcar_pcie_setup(struct list_head *resource,
i++; i++;
break; break;
case IORESOURCE_BUS: case IORESOURCE_BUS:
bridge->busnr = res->start;
break; break;
default: default:
continue; continue;
......
...@@ -3088,6 +3088,7 @@ int pci_scan_root_bus_bridge(struct pci_host_bridge *bridge) ...@@ -3088,6 +3088,7 @@ int pci_scan_root_bus_bridge(struct pci_host_bridge *bridge)
resource_list_for_each_entry(window, &bridge->windows) resource_list_for_each_entry(window, &bridge->windows)
if (window->res->flags & IORESOURCE_BUS) { if (window->res->flags & IORESOURCE_BUS) {
bridge->busnr = window->res->start;
found = true; found = true;
break; break;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment