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

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 second 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 they 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
Fixes: 669cbc708122 ("PCI: Move DT resource setup into devm_pci_alloc_host_bridge()")
Link: https://lore.kernel.org/r/20201023145252.2691779-1-robh@kernel.org
Reported-by: vtolkm@googlemail.com
Tested-by: Jan Kundrát <jan.kundrat@cesnet.cz>
Signed-off-by: Rob Herring <robh@kernel.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Cc: Jason Cooper <jason@lakedaemon.net>
Cc: Russell King <linux@armlinux.org.uk>

authored by

Rob Herring and committed by
Bjorn Helgaas
832ea234 9fff3256

+10 -13
+10 -13
drivers/pci/controller/pci-mvebu.c
··· 958 958 } 959 959 960 960 /* 961 - * We can't use devm_of_pci_get_host_bridge_resources() because we 962 - * need to parse our special DT properties encoding the MEM and IO 963 - * apertures. 961 + * devm_of_pci_get_host_bridge_resources() only sets up translateable resources, 962 + * so we need extra resource setup parsing our special DT properties encoding 963 + * the MEM and IO apertures. 964 964 */ 965 965 static int mvebu_pcie_parse_request_resources(struct mvebu_pcie *pcie) 966 966 { 967 967 struct device *dev = &pcie->pdev->dev; 968 - struct device_node *np = dev->of_node; 969 968 struct pci_host_bridge *bridge = pci_host_bridge_from_priv(pcie); 970 969 int ret; 971 - 972 - /* Get the bus range */ 973 - ret = of_pci_parse_bus_range(np, &pcie->busn); 974 - if (ret) { 975 - dev_err(dev, "failed to parse bus-range property: %d\n", ret); 976 - return ret; 977 - } 978 - pci_add_resource(&bridge->windows, &pcie->busn); 979 970 980 971 /* Get the PCIe memory aperture */ 981 972 mvebu_mbus_get_pcie_mem_aperture(&pcie->mem); ··· 977 986 978 987 pcie->mem.name = "PCI MEM"; 979 988 pci_add_resource(&bridge->windows, &pcie->mem); 989 + ret = devm_request_resource(dev, &iomem_resource, &pcie->mem); 990 + if (ret) 991 + return ret; 980 992 981 993 /* Get the PCIe IO aperture */ 982 994 mvebu_mbus_get_pcie_io_aperture(&pcie->io); ··· 993 999 pcie->realio.name = "PCI I/O"; 994 1000 995 1001 pci_add_resource(&bridge->windows, &pcie->realio); 1002 + ret = devm_request_resource(dev, &ioport_resource, &pcie->realio); 1003 + if (ret) 1004 + return ret; 996 1005 } 997 1006 998 - return devm_request_pci_bus_resources(dev, &bridge->windows); 1007 + return 0; 999 1008 } 1000 1009 1001 1010 /*