[PATCH 3/5] intel-iommu: Use max_pfn to determine whether a devicecan passthrough

From: Alex Williamson
Date: Mon Oct 26 2009 - 19:29:29 EST


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@xxxxxx>
---

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

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;
}

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/