Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

PCI: dwc: Move iATU detection earlier

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>

authored by

Hou Zhiqiang and committed by
Lorenzo Pieralisi
8bcca265 7d499169

+12 -3
+2
drivers/pci/controller/dwc/pcie-designware-ep.c
··· 705 705 } 706 706 } 707 707 708 + dw_pcie_iatu_detect(pci); 709 + 708 710 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "addr_space"); 709 711 if (!res) 710 712 return -EINVAL;
+1
drivers/pci/controller/dwc/pcie-designware-host.c
··· 398 398 if (ret) 399 399 goto err_free_msi; 400 400 } 401 + dw_pcie_iatu_detect(pci); 401 402 402 403 dw_pcie_setup_rc(pp); 403 404
+8 -3
drivers/pci/controller/dwc/pcie-designware.c
··· 660 660 pci->num_ob_windows = ob; 661 661 } 662 662 663 - void dw_pcie_setup(struct dw_pcie *pci) 663 + void dw_pcie_iatu_detect(struct dw_pcie *pci) 664 664 { 665 - u32 val; 666 665 struct device *dev = pci->dev; 667 - struct device_node *np = dev->of_node; 668 666 struct platform_device *pdev = to_platform_device(dev); 669 667 670 668 if (pci->version >= 0x480A || (!pci->version && ··· 691 693 692 694 dev_info(pci->dev, "Detected iATU regions: %u outbound, %u inbound", 693 695 pci->num_ob_windows, pci->num_ib_windows); 696 + } 697 + 698 + void dw_pcie_setup(struct dw_pcie *pci) 699 + { 700 + u32 val; 701 + struct device *dev = pci->dev; 702 + struct device_node *np = dev->of_node; 694 703 695 704 if (pci->link_gen > 0) 696 705 dw_pcie_link_set_max_speed(pci, pci->link_gen);
+1
drivers/pci/controller/dwc/pcie-designware.h
··· 306 306 void dw_pcie_disable_atu(struct dw_pcie *pci, int index, 307 307 enum dw_pcie_region_type type); 308 308 void dw_pcie_setup(struct dw_pcie *pci); 309 + void dw_pcie_iatu_detect(struct dw_pcie *pci); 309 310 310 311 static inline void dw_pcie_writel_dbi(struct dw_pcie *pci, u32 reg, u32 val) 311 312 {