diff options
author | David Woodhouse <David.Woodhouse@intel.com> | 2014-03-09 18:24:46 -0400 |
---|---|---|
committer | David Woodhouse <David.Woodhouse@intel.com> | 2014-03-24 10:07:51 -0400 |
commit | e1f167f3fd69d794b570fc4d3159191568ff9b70 (patch) | |
tree | 1254e730ba12f1a42c80c25b3ff57a54b10ffaf9 | |
parent | 156baca8d31e1aced2c8a14262637aef1ab416b9 (diff) |
iommu/vt-d: Make domain_context_mapp{ed,ing}() take struct device
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
-rw-r--r-- | drivers/iommu/intel-iommu.c | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c index cfc5eef81b82..949aa29dba8b 100644 --- a/drivers/iommu/intel-iommu.c +++ b/drivers/iommu/intel-iommu.c | |||
@@ -1840,24 +1840,25 @@ static int domain_context_mapping_one(struct dmar_domain *domain, | |||
1840 | } | 1840 | } |
1841 | 1841 | ||
1842 | static int | 1842 | static int |
1843 | domain_context_mapping(struct dmar_domain *domain, struct pci_dev *pdev, | 1843 | domain_context_mapping(struct dmar_domain *domain, struct device *dev, |
1844 | int translation) | 1844 | int translation) |
1845 | { | 1845 | { |
1846 | int ret; | 1846 | int ret; |
1847 | struct pci_dev *tmp, *parent; | 1847 | struct pci_dev *pdev, *tmp, *parent; |
1848 | struct intel_iommu *iommu; | 1848 | struct intel_iommu *iommu; |
1849 | u8 bus, devfn; | 1849 | u8 bus, devfn; |
1850 | 1850 | ||
1851 | iommu = device_to_iommu(&pdev->dev, &bus, &devfn); | 1851 | iommu = device_to_iommu(dev, &bus, &devfn); |
1852 | if (!iommu) | 1852 | if (!iommu) |
1853 | return -ENODEV; | 1853 | return -ENODEV; |
1854 | 1854 | ||
1855 | ret = domain_context_mapping_one(domain, iommu, bus, devfn, | 1855 | ret = domain_context_mapping_one(domain, iommu, bus, devfn, |
1856 | translation); | 1856 | translation); |
1857 | if (ret) | 1857 | if (ret || !dev_is_pci(dev)) |
1858 | return ret; | 1858 | return ret; |
1859 | 1859 | ||
1860 | /* dependent device mapping */ | 1860 | /* dependent device mapping */ |
1861 | pdev = to_pci_dev(dev); | ||
1861 | tmp = pci_find_upstream_pcie_bridge(pdev); | 1862 | tmp = pci_find_upstream_pcie_bridge(pdev); |
1862 | if (!tmp) | 1863 | if (!tmp) |
1863 | return 0; | 1864 | return 0; |
@@ -1882,21 +1883,23 @@ domain_context_mapping(struct dmar_domain *domain, struct pci_dev *pdev, | |||
1882 | translation); | 1883 | translation); |
1883 | } | 1884 | } |
1884 | 1885 | ||
1885 | static int domain_context_mapped(struct pci_dev *pdev) | 1886 | static int domain_context_mapped(struct device *dev) |
1886 | { | 1887 | { |
1887 | int ret; | 1888 | int ret; |
1888 | struct pci_dev *tmp, *parent; | 1889 | struct pci_dev *pdev, *tmp, *parent; |
1889 | struct intel_iommu *iommu; | 1890 | struct intel_iommu *iommu; |
1890 | u8 bus, devfn; | 1891 | u8 bus, devfn; |
1891 | 1892 | ||
1892 | iommu = device_to_iommu(&pdev->dev, &bus, &devfn); | 1893 | iommu = device_to_iommu(dev, &bus, &devfn); |
1893 | if (!iommu) | 1894 | if (!iommu) |
1894 | return -ENODEV; | 1895 | return -ENODEV; |
1895 | 1896 | ||
1896 | ret = device_context_mapped(iommu, bus, devfn); | 1897 | ret = device_context_mapped(iommu, bus, devfn); |
1897 | if (!ret) | 1898 | if (!ret || !dev_is_pci(dev)) |
1898 | return ret; | 1899 | return ret; |
1900 | |||
1899 | /* dependent device mapping */ | 1901 | /* dependent device mapping */ |
1902 | pdev = to_pci_dev(dev); | ||
1900 | tmp = pci_find_upstream_pcie_bridge(pdev); | 1903 | tmp = pci_find_upstream_pcie_bridge(pdev); |
1901 | if (!tmp) | 1904 | if (!tmp) |
1902 | return ret; | 1905 | return ret; |
@@ -2361,7 +2364,7 @@ static int iommu_prepare_identity_map(struct pci_dev *pdev, | |||
2361 | goto error; | 2364 | goto error; |
2362 | 2365 | ||
2363 | /* context entry init */ | 2366 | /* context entry init */ |
2364 | ret = domain_context_mapping(domain, pdev, CONTEXT_TT_MULTI_LEVEL); | 2367 | ret = domain_context_mapping(domain, &pdev->dev, CONTEXT_TT_MULTI_LEVEL); |
2365 | if (ret) | 2368 | if (ret) |
2366 | goto error; | 2369 | goto error; |
2367 | 2370 | ||
@@ -2485,7 +2488,7 @@ static int domain_add_dev_info(struct dmar_domain *domain, | |||
2485 | if (ndomain != domain) | 2488 | if (ndomain != domain) |
2486 | return -EBUSY; | 2489 | return -EBUSY; |
2487 | 2490 | ||
2488 | ret = domain_context_mapping(domain, pdev, translation); | 2491 | ret = domain_context_mapping(domain, &pdev->dev, translation); |
2489 | if (ret) { | 2492 | if (ret) { |
2490 | domain_remove_one_dev_info(domain, pdev); | 2493 | domain_remove_one_dev_info(domain, pdev); |
2491 | return ret; | 2494 | return ret; |
@@ -2870,8 +2873,8 @@ static struct dmar_domain *__get_valid_domain_for_dev(struct pci_dev *pdev) | |||
2870 | } | 2873 | } |
2871 | 2874 | ||
2872 | /* make sure context mapping is ok */ | 2875 | /* make sure context mapping is ok */ |
2873 | if (unlikely(!domain_context_mapped(pdev))) { | 2876 | if (unlikely(!domain_context_mapped(&pdev->dev))) { |
2874 | ret = domain_context_mapping(domain, pdev, | 2877 | ret = domain_context_mapping(domain, &pdev->dev, |
2875 | CONTEXT_TT_MULTI_LEVEL); | 2878 | CONTEXT_TT_MULTI_LEVEL); |
2876 | if (ret) { | 2879 | if (ret) { |
2877 | printk(KERN_ERR | 2880 | printk(KERN_ERR |
@@ -4159,7 +4162,7 @@ static int intel_iommu_attach_device(struct iommu_domain *domain, | |||
4159 | u8 bus, devfn; | 4162 | u8 bus, devfn; |
4160 | 4163 | ||
4161 | /* normally pdev is not mapped */ | 4164 | /* normally pdev is not mapped */ |
4162 | if (unlikely(domain_context_mapped(pdev))) { | 4165 | if (unlikely(domain_context_mapped(&pdev->dev))) { |
4163 | struct dmar_domain *old_domain; | 4166 | struct dmar_domain *old_domain; |
4164 | 4167 | ||
4165 | old_domain = find_domain(dev); | 4168 | old_domain = find_domain(dev); |