]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
iommu/of: Fix pci_request_acs() before enumerating PCI devices
authorXingang Wang <wangxingang5@huawei.com>
Fri, 21 May 2021 03:03:24 +0000 (03:03 +0000)
committerBjorn Helgaas <bhelgaas@google.com>
Fri, 20 Aug 2021 21:13:49 +0000 (16:13 -0500)
When booting with devicetree, pci_request_acs() is called after the
enumeration and initialization of PCI devices, thus ACS is not enabled.

ACS should be enabled when IOMMU is detected for the PCI host bridge, so
check for IOMMU before probe of PCI host and call pci_request_acs() to make
sure ACS will be enabled when enumerating PCI devices.

Fixes: 6bf6c24720d33 ("iommu/of: Request ACS from the PCI core when configuring IOMMU linkage")
Link: https://lore.kernel.org/r/1621566204-37456-1-git-send-email-wangxingang5@huawei.com
Signed-off-by: Xingang Wang <wangxingang5@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Acked-by: Joerg Roedel <jroedel@suse.de>
drivers/iommu/of_iommu.c
drivers/pci/of.c

index 5696314ae69e7d23b5ef7f71382bf95c5bda0bd7..2eacadf6fc084613ac7bc6469e8da80c4b5fb41d 100644 (file)
@@ -137,7 +137,6 @@ const struct iommu_ops *of_iommu_configure(struct device *dev,
                        .np = master_np,
                };
 
-               pci_request_acs();
                err = pci_for_each_dma_alias(to_pci_dev(dev),
                                             of_pci_iommu_init, &info);
        } else {
index a143b02b2dcdf6bd7112da02928f922f6e4a4c09..0f4d9ea3b5a8e45d45597b63d56c0213021d9702 100644 (file)
@@ -590,9 +590,15 @@ static int pci_parse_request_of_pci_ranges(struct device *dev,
 
 int devm_of_pci_bridge_init(struct device *dev, struct pci_host_bridge *bridge)
 {
-       if (!dev->of_node)
+       struct device_node *node = dev->of_node;
+
+       if (!node)
                return 0;
 
+       /* Detect IOMMU and make sure ACS will be enabled */
+       if (of_property_read_bool(node, "iommu-map"))
+               pci_request_acs();
+
        bridge->swizzle_irq = pci_common_swizzle;
        bridge->map_irq = of_irq_parse_and_map_pci;