aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/iommu
diff options
context:
space:
mode:
authorDavid Woodhouse <David.Woodhouse@intel.com>2014-03-09 15:52:30 -0400
committerDavid Woodhouse <David.Woodhouse@intel.com>2014-03-24 10:06:37 -0400
commit64ae892bfee37c0f982710363c39474218028e33 (patch)
tree714ec12bc5244167c4904f6f6b35af749c6dac9d /drivers/iommu
parent0bcb3e28c3c9b06a3ffab6238c517acdc851e625 (diff)
iommu/vt-d: Pass iommu to domain_context_mapping_one() and iommu_support_dev_iotlb()
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Diffstat (limited to 'drivers/iommu')
-rw-r--r--drivers/iommu/intel-iommu.c35
1 files changed, 17 insertions, 18 deletions
diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
index dc84147cd5c9..1c43a7b3008a 100644
--- a/drivers/iommu/intel-iommu.c
+++ b/drivers/iommu/intel-iommu.c
@@ -1240,13 +1240,13 @@ static void __iommu_flush_iotlb(struct intel_iommu *iommu, u16 did,
1240 (unsigned long long)DMA_TLB_IAIG(val)); 1240 (unsigned long long)DMA_TLB_IAIG(val));
1241} 1241}
1242 1242
1243static struct device_domain_info *iommu_support_dev_iotlb( 1243static struct device_domain_info *
1244 struct dmar_domain *domain, int segment, u8 bus, u8 devfn) 1244iommu_support_dev_iotlb (struct dmar_domain *domain, struct intel_iommu *iommu,
1245 u8 bus, u8 devfn)
1245{ 1246{
1246 int found = 0; 1247 int found = 0;
1247 unsigned long flags; 1248 unsigned long flags;
1248 struct device_domain_info *info; 1249 struct device_domain_info *info;
1249 struct intel_iommu *iommu = device_to_iommu(segment, bus, devfn);
1250 struct pci_dev *pdev; 1250 struct pci_dev *pdev;
1251 1251
1252 if (!ecap_dev_iotlb_support(iommu->ecap)) 1252 if (!ecap_dev_iotlb_support(iommu->ecap))
@@ -1700,12 +1700,12 @@ static void domain_exit(struct dmar_domain *domain)
1700 free_domain_mem(domain); 1700 free_domain_mem(domain);
1701} 1701}
1702 1702
1703static int domain_context_mapping_one(struct dmar_domain *domain, int segment, 1703static int domain_context_mapping_one(struct dmar_domain *domain,
1704 u8 bus, u8 devfn, int translation) 1704 struct intel_iommu *iommu,
1705 u8 bus, u8 devfn, int translation)
1705{ 1706{
1706 struct context_entry *context; 1707 struct context_entry *context;
1707 unsigned long flags; 1708 unsigned long flags;
1708 struct intel_iommu *iommu;
1709 struct dma_pte *pgd; 1709 struct dma_pte *pgd;
1710 unsigned long num; 1710 unsigned long num;
1711 unsigned long ndomains; 1711 unsigned long ndomains;
@@ -1720,10 +1720,6 @@ static int domain_context_mapping_one(struct dmar_domain *domain, int segment,
1720 BUG_ON(translation != CONTEXT_TT_PASS_THROUGH && 1720 BUG_ON(translation != CONTEXT_TT_PASS_THROUGH &&
1721 translation != CONTEXT_TT_MULTI_LEVEL); 1721 translation != CONTEXT_TT_MULTI_LEVEL);
1722 1722
1723 iommu = device_to_iommu(segment, bus, devfn);
1724 if (!iommu)
1725 return -ENODEV;
1726
1727 context = device_to_context_entry(iommu, bus, devfn); 1723 context = device_to_context_entry(iommu, bus, devfn);
1728 if (!context) 1724 if (!context)
1729 return -ENOMEM; 1725 return -ENOMEM;
@@ -1781,7 +1777,7 @@ static int domain_context_mapping_one(struct dmar_domain *domain, int segment,
1781 context_set_domain_id(context, id); 1777 context_set_domain_id(context, id);
1782 1778
1783 if (translation != CONTEXT_TT_PASS_THROUGH) { 1779 if (translation != CONTEXT_TT_PASS_THROUGH) {
1784 info = iommu_support_dev_iotlb(domain, segment, bus, devfn); 1780 info = iommu_support_dev_iotlb(domain, iommu, bus, devfn);
1785 translation = info ? CONTEXT_TT_DEV_IOTLB : 1781 translation = info ? CONTEXT_TT_DEV_IOTLB :
1786 CONTEXT_TT_MULTI_LEVEL; 1782 CONTEXT_TT_MULTI_LEVEL;
1787 } 1783 }
@@ -1836,8 +1832,14 @@ domain_context_mapping(struct dmar_domain *domain, struct pci_dev *pdev,
1836{ 1832{
1837 int ret; 1833 int ret;
1838 struct pci_dev *tmp, *parent; 1834 struct pci_dev *tmp, *parent;
1835 struct intel_iommu *iommu;
1836
1837 iommu = device_to_iommu(pci_domain_nr(pdev->bus), pdev->bus->number,
1838 pdev->devfn);
1839 if (!iommu)
1840 return -ENODEV;
1839 1841
1840 ret = domain_context_mapping_one(domain, pci_domain_nr(pdev->bus), 1842 ret = domain_context_mapping_one(domain, iommu,
1841 pdev->bus->number, pdev->devfn, 1843 pdev->bus->number, pdev->devfn,
1842 translation); 1844 translation);
1843 if (ret) 1845 if (ret)
@@ -1850,8 +1852,7 @@ domain_context_mapping(struct dmar_domain *domain, struct pci_dev *pdev,
1850 /* Secondary interface's bus number and devfn 0 */ 1852 /* Secondary interface's bus number and devfn 0 */
1851 parent = pdev->bus->self; 1853 parent = pdev->bus->self;
1852 while (parent != tmp) { 1854 while (parent != tmp) {
1853 ret = domain_context_mapping_one(domain, 1855 ret = domain_context_mapping_one(domain, iommu,
1854 pci_domain_nr(parent->bus),
1855 parent->bus->number, 1856 parent->bus->number,
1856 parent->devfn, translation); 1857 parent->devfn, translation);
1857 if (ret) 1858 if (ret)
@@ -1859,13 +1860,11 @@ domain_context_mapping(struct dmar_domain *domain, struct pci_dev *pdev,
1859 parent = parent->bus->self; 1860 parent = parent->bus->self;
1860 } 1861 }
1861 if (pci_is_pcie(tmp)) /* this is a PCIe-to-PCI bridge */ 1862 if (pci_is_pcie(tmp)) /* this is a PCIe-to-PCI bridge */
1862 return domain_context_mapping_one(domain, 1863 return domain_context_mapping_one(domain, iommu,
1863 pci_domain_nr(tmp->subordinate),
1864 tmp->subordinate->number, 0, 1864 tmp->subordinate->number, 0,
1865 translation); 1865 translation);
1866 else /* this is a legacy PCI bridge */ 1866 else /* this is a legacy PCI bridge */
1867 return domain_context_mapping_one(domain, 1867 return domain_context_mapping_one(domain, iommu,
1868 pci_domain_nr(tmp->bus),
1869 tmp->bus->number, 1868 tmp->bus->number,
1870 tmp->devfn, 1869 tmp->devfn,
1871 translation); 1870 translation);