aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci/intel-iommu.c
diff options
context:
space:
mode:
authorDavid Woodhouse <David.Woodhouse@intel.com>2009-07-04 13:24:27 -0400
committerDavid Woodhouse <David.Woodhouse@intel.com>2009-07-04 14:19:08 -0400
commit6941af2810c6fc970b88f7c0d52ba4e286acbee5 (patch)
tree6b25279e2ab1c2c6062982dcb04bdbddf1eed7d2 /drivers/pci/intel-iommu.c
parent736768325efcbee7b0861d62670d01a54c2d158b (diff)
intel-iommu: Use iommu_should_identity_map() at startup time too.
At boot time, the dma_mask won't have been set on any devices, so we assume that all devices will be 64-bit capable (and thus get a 1:1 map). Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Diffstat (limited to 'drivers/pci/intel-iommu.c')
-rw-r--r--drivers/pci/intel-iommu.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/drivers/pci/intel-iommu.c b/drivers/pci/intel-iommu.c
index fa052dd89913..f9fc4f3bfa3f 100644
--- a/drivers/pci/intel-iommu.c
+++ b/drivers/pci/intel-iommu.c
@@ -2117,6 +2117,17 @@ static int domain_add_dev_info(struct dmar_domain *domain,
2117 return 0; 2117 return 0;
2118} 2118}
2119 2119
2120static int iommu_should_identity_map(struct pci_dev *pdev, int startup)
2121{
2122 if (iommu_identity_mapping == 2)
2123 return IS_GFX_DEVICE(pdev);
2124
2125 if (!startup)
2126 return pdev->dma_mask > DMA_BIT_MASK(32);
2127
2128 return 1;
2129}
2130
2120static int iommu_prepare_static_identity_mapping(void) 2131static int iommu_prepare_static_identity_mapping(void)
2121{ 2132{
2122 struct pci_dev *pdev = NULL; 2133 struct pci_dev *pdev = NULL;
@@ -2127,7 +2138,7 @@ static int iommu_prepare_static_identity_mapping(void)
2127 return -EFAULT; 2138 return -EFAULT;
2128 2139
2129 for_each_pci_dev(pdev) { 2140 for_each_pci_dev(pdev) {
2130 if (iommu_identity_mapping == 1 || IS_GFX_DEVICE(pdev)) { 2141 if (iommu_should_identity_map(pdev, 1)) {
2131 printk(KERN_INFO "IOMMU: identity mapping for device %s\n", 2142 printk(KERN_INFO "IOMMU: identity mapping for device %s\n",
2132 pci_name(pdev)); 2143 pci_name(pdev));
2133 2144
@@ -2448,14 +2459,6 @@ static int iommu_dummy(struct pci_dev *pdev)
2448 return pdev->dev.archdata.iommu == DUMMY_DEVICE_DOMAIN_INFO; 2459 return pdev->dev.archdata.iommu == DUMMY_DEVICE_DOMAIN_INFO;
2449} 2460}
2450 2461
2451static int iommu_should_identity_map(struct pci_dev *pdev)
2452{
2453 if (iommu_identity_mapping == 2)
2454 return IS_GFX_DEVICE(pdev);
2455 else
2456 return pdev->dma_mask > DMA_BIT_MASK(32);
2457}
2458
2459/* Check if the pdev needs to go through non-identity map and unmap process.*/ 2462/* Check if the pdev needs to go through non-identity map and unmap process.*/
2460static int iommu_no_mapping(struct device *dev) 2463static int iommu_no_mapping(struct device *dev)
2461{ 2464{
@@ -2474,7 +2477,7 @@ static int iommu_no_mapping(struct device *dev)
2474 2477
2475 found = identity_mapping(pdev); 2478 found = identity_mapping(pdev);
2476 if (found) { 2479 if (found) {
2477 if (iommu_should_identity_map(pdev)) 2480 if (iommu_should_identity_map(pdev, 0))
2478 return 1; 2481 return 1;
2479 else { 2482 else {
2480 /* 2483 /*
@@ -2491,7 +2494,7 @@ static int iommu_no_mapping(struct device *dev)
2491 * In case of a detached 64 bit DMA device from vm, the device 2494 * In case of a detached 64 bit DMA device from vm, the device
2492 * is put into si_domain for identity mapping. 2495 * is put into si_domain for identity mapping.
2493 */ 2496 */
2494 if (iommu_should_identity_map(pdev)) { 2497 if (iommu_should_identity_map(pdev, 0)) {
2495 int ret; 2498 int ret;
2496 ret = domain_add_dev_info(si_domain, pdev); 2499 ret = domain_add_dev_info(si_domain, pdev);
2497 if (ret) 2500 if (ret)