summaryrefslogtreecommitdiffstats
path: root/drivers/pci
diff options
context:
space:
mode:
authorDavid Woodhouse <David.Woodhouse@intel.com>2009-06-27 20:15:01 +0200
committerDavid Woodhouse <David.Woodhouse@intel.com>2009-06-29 14:26:36 +0200
commit04b18e65dd5a3e544f07f4bcfa8fb52704a1833b (patch)
tree51b6c12b122a1c186c3f8fea3f723c602a4465d7 /drivers/pci
parentintel-iommu: Don't just mask out too-big physical addresses; BUG() instead (diff)
downloadlinux-04b18e65dd5a3e544f07f4bcfa8fb52704a1833b.tar.xz
linux-04b18e65dd5a3e544f07f4bcfa8fb52704a1833b.zip
intel-iommu: Make dma_pte_clear_range() use pfns
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Diffstat (limited to 'drivers/pci')
-rw-r--r--drivers/pci/intel-iommu.c22
1 files changed, 9 insertions, 13 deletions
diff --git a/drivers/pci/intel-iommu.c b/drivers/pci/intel-iommu.c
index ad367f53a2bb..d4217f737159 100644
--- a/drivers/pci/intel-iommu.c
+++ b/drivers/pci/intel-iommu.c
@@ -779,21 +779,17 @@ static void dma_pte_clear_one(struct dmar_domain *domain, unsigned long pfn)
/* clear last level pte, a tlb flush should be followed */
static void dma_pte_clear_range(struct dmar_domain *domain, u64 start, u64 end)
{
- int addr_width = agaw_to_width(domain->agaw);
- int npages;
-
- BUG_ON(start >> addr_width);
- BUG_ON((end-1) >> addr_width);
+ unsigned long start_pfn = IOVA_PFN(start);
+ unsigned long end_pfn = IOVA_PFN(end-1);
+ int addr_width = agaw_to_width(domain->agaw) - VTD_PAGE_SHIFT;
- /* in case it's partial page */
- start &= PAGE_MASK;
- end = PAGE_ALIGN(end);
- npages = (end - start) / VTD_PAGE_SIZE;
+ BUG_ON(addr_width < BITS_PER_LONG && start_pfn >> addr_width);
+ BUG_ON(addr_width < BITS_PER_LONG && end_pfn >> addr_width);
- /* we don't need lock here, nobody else touches the iova range */
- while (npages--) {
- dma_pte_clear_one(domain, start >> VTD_PAGE_SHIFT);
- start += VTD_PAGE_SIZE;
+ /* we don't need lock here; nobody else touches the iova range */
+ while (start_pfn <= end_pfn) {
+ dma_pte_clear_one(domain, start_pfn);
+ start_pfn++;
}
}