PCI: dwc: Drop support for config space in 'ranges'
authorRob Herring <robh@kernel.org>
Tue, 15 Dec 2020 19:41:49 +0000 (13:41 -0600)
committerBjorn Helgaas <bhelgaas@google.com>
Wed, 24 Feb 2021 17:09:50 +0000 (11:09 -0600)
Since commit a0fd361db8e5 ("PCI: dwc: Move "dbi", "dbi2", and
"addr_space" resource setup into common code"), the code
setting dbi_base when the config space is defined in 'ranges' property
instead of 'reg' is dead code as dbi_base is never NULL.

Rather than fix this, let's just drop the code. Using ranges has been
deprecated since 2014. The only platforms using this were exynos5440,
i.MX6 and Spear13xx. Exynos5440 is dead and has been removed. i.MX6 and
Spear13xx had PCIe support added just before this was deprecated and
were fixed within a kernel release or 2.

Link: https://lore.kernel.org/r/20201215194149.86831-1-robh@kernel.org
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Rob Herring <robh@kernel.org>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
drivers/pci/controller/dwc/pcie-designware-host.c

index 8a84c00..bcb5bd7 100644 (file)
@@ -305,8 +305,13 @@ int dw_pcie_host_init(struct pcie_port *pp)
        if (cfg_res) {
                pp->cfg0_size = resource_size(cfg_res);
                pp->cfg0_base = cfg_res->start;
-       } else if (!pp->va_cfg0_base) {
+
+               pp->va_cfg0_base = devm_pci_remap_cfg_resource(dev, cfg_res);
+               if (IS_ERR(pp->va_cfg0_base))
+                       return PTR_ERR(pp->va_cfg0_base);
+       } else {
                dev_err(dev, "Missing *config* reg space\n");
+               return -ENODEV;
        }
 
        if (!pci->dbi_base) {
@@ -322,38 +327,12 @@ int dw_pcie_host_init(struct pcie_port *pp)
 
        pp->bridge = bridge;
 
-       /* Get the I/O and memory ranges from DT */
-       resource_list_for_each_entry(win, &bridge->windows) {
-               switch (resource_type(win->res)) {
-               case IORESOURCE_IO:
-                       pp->io_size = resource_size(win->res);
-                       pp->io_bus_addr = win->res->start - win->offset;
-                       pp->io_base = pci_pio_to_address(win->res->start);
-                       break;
-               case 0:
-                       dev_err(dev, "Missing *config* reg space\n");
-                       pp->cfg0_size = resource_size(win->res);
-                       pp->cfg0_base = win->res->start;
-                       if (!pci->dbi_base) {
-                               pci->dbi_base = devm_pci_remap_cfgspace(dev,
-                                                               pp->cfg0_base,
-                                                               pp->cfg0_size);
-                               if (!pci->dbi_base) {
-                                       dev_err(dev, "Error with ioremap\n");
-                                       return -ENOMEM;
-                               }
-                       }
-                       break;
-               }
-       }
-
-       if (!pp->va_cfg0_base) {
-               pp->va_cfg0_base = devm_pci_remap_cfgspace(dev,
-                                       pp->cfg0_base, pp->cfg0_size);
-               if (!pp->va_cfg0_base) {
-                       dev_err(dev, "Error with ioremap in function\n");
-                       return -ENOMEM;
-               }
+       /* Get the I/O range from DT */
+       win = resource_list_first_type(&bridge->windows, IORESOURCE_IO);
+       if (win) {
+               pp->io_size = resource_size(win->res);
+               pp->io_bus_addr = win->res->start - win->offset;
+               pp->io_base = pci_pio_to_address(win->res->start);
        }
 
        if (pci->link_gen < 1)