From: Xingang Wang Date: Fri, 21 May 2021 03:03:24 +0000 (+0000) Subject: iommu/of: Fix pci_request_acs() before enumerating PCI devices X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=57a4ab1584e6f0a2f8f6075af3986784733909f2;p=users%2Fjedix%2Flinux-maple.git iommu/of: Fix pci_request_acs() before enumerating PCI devices 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 Signed-off-by: Bjorn Helgaas Reviewed-by: Rob Herring Acked-by: Joerg Roedel --- diff --git a/drivers/iommu/of_iommu.c b/drivers/iommu/of_iommu.c index 5696314ae69e7..2eacadf6fc084 100644 --- a/drivers/iommu/of_iommu.c +++ b/drivers/iommu/of_iommu.c @@ -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 { diff --git a/drivers/pci/of.c b/drivers/pci/of.c index a143b02b2dcdf..0f4d9ea3b5a8e 100644 --- a/drivers/pci/of.c +++ b/drivers/pci/of.c @@ -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;