]> rtime.felk.cvut.cz Git - sojka/nv-tegra/linux-3.10.git/commitdiff
tegra/iommu: smmu: Use PCI root device
authorAlex Waterman <alexw@nvidia.com>
Thu, 12 Nov 2015 01:16:38 +0000 (17:16 -0800)
committermobile promotions <svcmobile_promotions@nvidia.com>
Wed, 20 Jan 2016 14:25:20 +0000 (06:25 -0800)
Use the PCI root device for finding the SMMU mapping when the
device to be added is a PCI device.

Bug 200076269

Change-Id: Ief853dbc67dcf689e142038a84807e01f86fdcda
Signed-off-by: Alex Waterman <alexw@nvidia.com>
Reviewed-on: http://git-master/r/831981
(cherry picked from commit 12d2dca04e20387d5e4e0216bb1fff8d09df523c)
Reviewed-on: http://git-master/r/934485
Tested-by: Vidya Sagar <vidyas@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Hayden Du <haydend@nvidia.com>
drivers/iommu/tegra-smmu.c

index 7423f7af7d9bd0fe9ea49bcecaca3ad56a0c8060..016363e49aa092e81d57713befbdbe36e725a900 100644 (file)
@@ -1561,12 +1561,34 @@ static void smmu_iommu_domain_destroy(struct iommu_domain *domain)
        dev_dbg(smmu->dev, "smmu_as@%p\n", as);
 }
 
+/*
+ * Traverse the PCI tree to find the root of the PCI tree. That's the device
+ * that should be used for finding the SMMU mapping.
+ */
+struct device *__get_pci_dev(struct device *dev)
+{
+       struct pci_bus *bus;
+
+       if (!dev_is_pci(dev))
+               return dev;
+
+       bus = to_pci_dev(dev)->bus;
+
+       while (!pci_is_root_bus(bus))
+               bus = bus->parent;
+       return bus->bridge->parent;
+}
+
 static int __smmu_iommu_add_device(struct device *dev, u64 swgids)
 {
        struct dma_iommu_mapping *map;
        int err;
 
-       map = tegra_smmu_of_get_mapping(dev, swgids,
+       /*
+        * If the device is a PCI device we need to use the root of the PCI
+        * tree for looking up the SMMU mapping.
+        */
+       map = tegra_smmu_of_get_mapping(__get_pci_dev(dev), swgids,
                                        &smmu_handle->asprops);
        if (!map) {
                dev_err(dev, "map creation failed!!!\n");