]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
PCI: dwc: Move iATU detection earlier
authorHou Zhiqiang <Zhiqiang.Hou@nxp.com>
Tue, 13 Apr 2021 14:22:19 +0000 (17:22 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 12 May 2021 06:37:39 +0000 (08:37 +0200)
commit 8bcca26585585ae4b44d25d30f351ad0afa4976b upstream.

dw_pcie_ep_init() depends on the detected iATU region numbers to allocate
the in/outbound window management bitmap.  It fails after 281f1f99cf3a
("PCI: dwc: Detect number of iATU windows").

Move the iATU region detection into a new function, move the detection to
the very beginning of dw_pcie_host_init() and dw_pcie_ep_init().  Also
remove it from the dw_pcie_setup(), since it's more like a software
initialization step than hardware setup.

Link: https://lore.kernel.org/r/20210125044803.4310-1-Zhiqiang.Hou@nxp.com
Link: https://lore.kernel.org/linux-pci/20210407131255.702054-1-dmitry.baryshkov@linaro.org
Link: https://lore.kernel.org/r/20210413142219.2301430-1-dmitry.baryshkov@linaro.org
Fixes: 281f1f99cf3a ("PCI: dwc: Detect number of iATU windows")
Tested-by: Kunihiko Hayashi <hayashi.kunihiko@socionext.com>
Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>
Tested-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Hou Zhiqiang <Zhiqiang.Hou@nxp.com>
[DB: moved dw_pcie_iatu_detect to happen after host_init callback]
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Cc: stable@vger.kernel.org # v5.11+
Cc: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/pci/controller/dwc/pcie-designware-ep.c
drivers/pci/controller/dwc/pcie-designware-host.c
drivers/pci/controller/dwc/pcie-designware.c
drivers/pci/controller/dwc/pcie-designware.h

index bcd1cd9ba8c80b20073ec23883939240f42bcc7d..fcf935bf6f5e2aa87881e555fb88772255f24ce5 100644 (file)
@@ -707,6 +707,8 @@ int dw_pcie_ep_init(struct dw_pcie_ep *ep)
                }
        }
 
+       dw_pcie_iatu_detect(pci);
+
        res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "addr_space");
        if (!res)
                return -EINVAL;
index 8a84c005f32bdc6edac1638efb028108e32050d7..e14e6d8661d3f08f82e4f7ff722c8f05e80de337 100644 (file)
@@ -421,6 +421,7 @@ int dw_pcie_host_init(struct pcie_port *pp)
                if (ret)
                        goto err_free_msi;
        }
+       dw_pcie_iatu_detect(pci);
 
        dw_pcie_setup_rc(pp);
        dw_pcie_msi_init(pp);
index 645fa18923751db2477956522d49d9120edeeb16..6d709dbd9deb88e7a5edbd1bae4418915cb02038 100644 (file)
@@ -610,11 +610,9 @@ static void dw_pcie_iatu_detect_regions(struct dw_pcie *pci)
        pci->num_ob_windows = ob;
 }
 
-void dw_pcie_setup(struct dw_pcie *pci)
+void dw_pcie_iatu_detect(struct dw_pcie *pci)
 {
-       u32 val;
        struct device *dev = pci->dev;
-       struct device_node *np = dev->of_node;
        struct platform_device *pdev = to_platform_device(dev);
 
        if (pci->version >= 0x480A || (!pci->version &&
@@ -643,6 +641,13 @@ void dw_pcie_setup(struct dw_pcie *pci)
 
        dev_info(pci->dev, "Detected iATU regions: %u outbound, %u inbound",
                 pci->num_ob_windows, pci->num_ib_windows);
+}
+
+void dw_pcie_setup(struct dw_pcie *pci)
+{
+       u32 val;
+       struct device *dev = pci->dev;
+       struct device_node *np = dev->of_node;
 
        if (pci->link_gen > 0)
                dw_pcie_link_set_max_speed(pci, pci->link_gen);
index 0207840756c47fc0fae42175b3729df0f2afde38..ba27494602ac816da92a8ba6fbf72ebeee1f8b48 100644 (file)
@@ -304,6 +304,7 @@ int dw_pcie_prog_inbound_atu(struct dw_pcie *pci, u8 func_no, int index,
 void dw_pcie_disable_atu(struct dw_pcie *pci, int index,
                         enum dw_pcie_region_type type);
 void dw_pcie_setup(struct dw_pcie *pci);
+void dw_pcie_iatu_detect(struct dw_pcie *pci);
 
 static inline void dw_pcie_writel_dbi(struct dw_pcie *pci, u32 reg, u32 val)
 {