aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/pci/intel-iommu.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/drivers/pci/intel-iommu.c b/drivers/pci/intel-iommu.c
index 22add36fd731..6afe44cb6815 100644
--- a/drivers/pci/intel-iommu.c
+++ b/drivers/pci/intel-iommu.c
@@ -1058,11 +1058,11 @@ static void iommu_flush_dev_iotlb(struct dmar_domain *domain,
1058} 1058}
1059 1059
1060static void iommu_flush_iotlb_psi(struct intel_iommu *iommu, u16 did, 1060static void iommu_flush_iotlb_psi(struct intel_iommu *iommu, u16 did,
1061 u64 addr, unsigned int pages) 1061 unsigned long pfn, unsigned int pages)
1062{ 1062{
1063 unsigned int mask = ilog2(__roundup_pow_of_two(pages)); 1063 unsigned int mask = ilog2(__roundup_pow_of_two(pages));
1064 uint64_t addr = (uint64_t)pfn << VTD_PAGE_SHIFT;
1064 1065
1065 BUG_ON(addr & (~VTD_PAGE_MASK));
1066 BUG_ON(pages == 0); 1066 BUG_ON(pages == 0);
1067 1067
1068 /* 1068 /*
@@ -2494,15 +2494,15 @@ static dma_addr_t __intel_map_single(struct device *hwdev, phys_addr_t paddr,
2494 if (ret) 2494 if (ret)
2495 goto error; 2495 goto error;
2496 2496
2497 start_paddr = (phys_addr_t)iova->pfn_lo << PAGE_SHIFT;
2498
2499 /* it's a non-present to present mapping. Only flush if caching mode */ 2497 /* it's a non-present to present mapping. Only flush if caching mode */
2500 if (cap_caching_mode(iommu->cap)) 2498 if (cap_caching_mode(iommu->cap))
2501 iommu_flush_iotlb_psi(iommu, 0, start_paddr, size); 2499 iommu_flush_iotlb_psi(iommu, 0, mm_to_dma_pfn(iova->pfn_lo), size);
2502 else 2500 else
2503 iommu_flush_write_buffer(iommu); 2501 iommu_flush_write_buffer(iommu);
2504 2502
2505 return start_paddr + (paddr & (~PAGE_MASK)); 2503 start_paddr = (phys_addr_t)iova->pfn_lo << PAGE_SHIFT;
2504 start_paddr += paddr & ~PAGE_MASK;
2505 return start_paddr;
2506 2506
2507error: 2507error:
2508 if (iova) 2508 if (iova)
@@ -2624,8 +2624,7 @@ static void intel_unmap_page(struct device *dev, dma_addr_t dev_addr,
2624 dma_pte_free_pagetable(domain, start_pfn, last_pfn); 2624 dma_pte_free_pagetable(domain, start_pfn, last_pfn);
2625 2625
2626 if (intel_iommu_strict) { 2626 if (intel_iommu_strict) {
2627 iommu_flush_iotlb_psi(iommu, domain->id, 2627 iommu_flush_iotlb_psi(iommu, domain->id, start_pfn,
2628 start_pfn << VTD_PAGE_SHIFT,
2629 last_pfn - start_pfn + 1); 2628 last_pfn - start_pfn + 1);
2630 /* free iova */ 2629 /* free iova */
2631 __free_iova(&domain->iovad, iova); 2630 __free_iova(&domain->iovad, iova);
@@ -2711,8 +2710,7 @@ static void intel_unmap_sg(struct device *hwdev, struct scatterlist *sglist,
2711 /* free page tables */ 2710 /* free page tables */
2712 dma_pte_free_pagetable(domain, start_pfn, last_pfn); 2711 dma_pte_free_pagetable(domain, start_pfn, last_pfn);
2713 2712
2714 iommu_flush_iotlb_psi(iommu, domain->id, 2713 iommu_flush_iotlb_psi(iommu, domain->id, start_pfn,
2715 start_pfn << VTD_PAGE_SHIFT,
2716 (last_pfn - start_pfn + 1)); 2714 (last_pfn - start_pfn + 1));
2717 2715
2718 /* free iova */ 2716 /* free iova */
@@ -2804,8 +2802,7 @@ static int intel_map_sg(struct device *hwdev, struct scatterlist *sglist, int ne
2804 2802
2805 /* it's a non-present to present mapping. Only flush if caching mode */ 2803 /* it's a non-present to present mapping. Only flush if caching mode */
2806 if (cap_caching_mode(iommu->cap)) 2804 if (cap_caching_mode(iommu->cap))
2807 iommu_flush_iotlb_psi(iommu, 0, start_vpfn << VTD_PAGE_SHIFT, 2805 iommu_flush_iotlb_psi(iommu, 0, start_vpfn, offset_pfn);
2808 offset_pfn);
2809 else 2806 else
2810 iommu_flush_write_buffer(iommu); 2807 iommu_flush_write_buffer(iommu);
2811 2808