aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJiang Liu <jiang.liu@linux.intel.com>2014-07-11 02:19:36 -0400
committerJoerg Roedel <jroedel@suse.de>2014-07-23 10:04:47 -0400
commita156ef99e874f3701367cc192aa604bcf8c0a236 (patch)
tree2a2407d0d17ce78f8ed1766127d00724b86fba11
parent162d1b10d4d38065efec690c2b05ee90dfcf170c (diff)
iommu/vt-d: Introduce helper function iova_size() to improve code readability
Signed-off-by: Jiang Liu <jiang.liu@linux.intel.com> Signed-off-by: Joerg Roedel <jroedel@suse.de>
-rw-r--r--drivers/iommu/intel-iommu.c7
-rw-r--r--include/linux/iova.h5
2 files changed, 8 insertions, 4 deletions
diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
index c9e65edaa2ad..cd1ba24c766a 100644
--- a/drivers/iommu/intel-iommu.c
+++ b/drivers/iommu/intel-iommu.c
@@ -3101,10 +3101,10 @@ static void flush_unmaps(void)
3101 /* On real hardware multiple invalidations are expensive */ 3101 /* On real hardware multiple invalidations are expensive */
3102 if (cap_caching_mode(iommu->cap)) 3102 if (cap_caching_mode(iommu->cap))
3103 iommu_flush_iotlb_psi(iommu, domain->id, 3103 iommu_flush_iotlb_psi(iommu, domain->id,
3104 iova->pfn_lo, iova->pfn_hi - iova->pfn_lo + 1, 3104 iova->pfn_lo, iova_size(iova),
3105 !deferred_flush[i].freelist[j], 0); 3105 !deferred_flush[i].freelist[j], 0);
3106 else { 3106 else {
3107 mask = ilog2(mm_to_dma_pfn(iova->pfn_hi - iova->pfn_lo + 1)); 3107 mask = ilog2(mm_to_dma_pfn(iova_size(iova)));
3108 iommu_flush_dev_iotlb(deferred_flush[i].domain[j], 3108 iommu_flush_dev_iotlb(deferred_flush[i].domain[j],
3109 (uint64_t)iova->pfn_lo << PAGE_SHIFT, mask); 3109 (uint64_t)iova->pfn_lo << PAGE_SHIFT, mask);
3110 } 3110 }
@@ -3905,8 +3905,7 @@ static int intel_iommu_memory_notifier(struct notifier_block *nb,
3905 rcu_read_lock(); 3905 rcu_read_lock();
3906 for_each_active_iommu(iommu, drhd) 3906 for_each_active_iommu(iommu, drhd)
3907 iommu_flush_iotlb_psi(iommu, si_domain->id, 3907 iommu_flush_iotlb_psi(iommu, si_domain->id,
3908 iova->pfn_lo, 3908 iova->pfn_lo, iova_size(iova),
3909 iova->pfn_hi - iova->pfn_lo + 1,
3910 !freelist, 0); 3909 !freelist, 0);
3911 rcu_read_unlock(); 3910 rcu_read_unlock();
3912 dma_free_pagelist(freelist); 3911 dma_free_pagelist(freelist);
diff --git a/include/linux/iova.h b/include/linux/iova.h
index 3277f4711349..19e81d5ccb6d 100644
--- a/include/linux/iova.h
+++ b/include/linux/iova.h
@@ -34,6 +34,11 @@ struct iova_domain {
34 unsigned long dma_32bit_pfn; 34 unsigned long dma_32bit_pfn;
35}; 35};
36 36
37static inline unsigned long iova_size(struct iova *iova)
38{
39 return iova->pfn_hi - iova->pfn_lo + 1;
40}
41
37struct iova *alloc_iova_mem(void); 42struct iova *alloc_iova_mem(void);
38void free_iova_mem(struct iova *iova); 43void free_iova_mem(struct iova *iova);
39void free_iova(struct iova_domain *iovad, unsigned long pfn); 44void free_iova(struct iova_domain *iovad, unsigned long pfn);