Patchworkβ [3/5] intel-iommu: Use max_pfn to determine whether a device can passthrough

login
register
about
Submitter Alex Williamson
Date 2009-10-26 23:25:09
Message ID <20091026232508.9646.19296.stgit@nehalem.aw>
Download mbox | patch
Permalink /patch/56006/
State Not Applicable
Headers show

Comments

Alex Williamson - 2009-10-26 23:25:09
A dma_mask that's greater than 32-bit does not imply the device
can DMA anywhere in physical memory.

Signed-off-by: Alex Williamson <alex.williamson@hp.com>
---

 drivers/pci/intel-iommu.c |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)


--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/drivers/pci/intel-iommu.c b/drivers/pci/intel-iommu.c
index 40be49a..19f10ae 100644
--- a/drivers/pci/intel-iommu.c
+++ b/drivers/pci/intel-iommu.c
@@ -39,6 +39,7 @@ 
 #include <linux/sysdev.h>
 #include <linux/tboot.h>
 #include <linux/dmi.h>
+#include <linux/bootmem.h>
 #include <asm/cacheflush.h>
 #include <asm/iommu.h>
 #include "pci.h"
@@ -2196,7 +2197,8 @@  static int iommu_should_identity_map(struct pci_dev *pdev, int startup)
 	 * take them out of the 1:1 domain later.
 	 */
 	if (!startup)
-		return pdev->dma_mask > DMA_BIT_MASK(32);
+		return (pdev->dma_mask & (max_pfn << PAGE_SHIFT)) ==
+						(max_pfn << PAGE_SHIFT);
 
 	return 1;
 }
@@ -2537,11 +2539,12 @@  static int iommu_no_mapping(struct device *dev)
 			return 1;
 		else {
 			/*
-			 * 32 bit DMA is removed from si_domain and fall back
-			 * to non-identity mapping.
+			 * Devices that cannot support identity mapping
+			 * are removed from si_domain and fall back to
+			 * non-identity mapping.
 			 */
 			domain_remove_one_dev_info(si_domain, pdev);
-			printk(KERN_INFO "32bit %s uses non-identity mapping\n",
+			printk(KERN_INFO "%s uses non-identity mapping\n",
 			       pci_name(pdev));
 			return 0;
 		}