Skip to content

Commit 3f34f12

Browse files
LuBaolujoergroedel
authored andcommitted
iommu/vt-d: Implement map/unmap_pages() iommu_ops callback
Implement the map_pages() and unmap_pages() callback for the Intel IOMMU driver to allow calls from iommu core to map and unmap multiple pages of the same size in one call. With map/unmap_pages() implemented, the prior map/unmap callbacks are deprecated. Signed-off-by: Lu Baolu <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Joerg Roedel <[email protected]>
1 parent a886d5a commit 3f34f12

File tree

1 file changed

+35
-2
lines changed

1 file changed

+35
-2
lines changed

drivers/iommu/intel/iommu.c

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5065,6 +5065,28 @@ static int intel_iommu_map(struct iommu_domain *domain,
50655065
hpa >> VTD_PAGE_SHIFT, size, prot);
50665066
}
50675067

5068+
static int intel_iommu_map_pages(struct iommu_domain *domain,
5069+
unsigned long iova, phys_addr_t paddr,
5070+
size_t pgsize, size_t pgcount,
5071+
int prot, gfp_t gfp, size_t *mapped)
5072+
{
5073+
unsigned long pgshift = __ffs(pgsize);
5074+
size_t size = pgcount << pgshift;
5075+
int ret;
5076+
5077+
if (pgsize != SZ_4K && pgsize != SZ_2M && pgsize != SZ_1G)
5078+
return -EINVAL;
5079+
5080+
if (!IS_ALIGNED(iova | paddr, pgsize))
5081+
return -EINVAL;
5082+
5083+
ret = intel_iommu_map(domain, iova, paddr, size, prot, gfp);
5084+
if (!ret && mapped)
5085+
*mapped = size;
5086+
5087+
return ret;
5088+
}
5089+
50685090
static size_t intel_iommu_unmap(struct iommu_domain *domain,
50695091
unsigned long iova, size_t size,
50705092
struct iommu_iotlb_gather *gather)
@@ -5094,6 +5116,17 @@ static size_t intel_iommu_unmap(struct iommu_domain *domain,
50945116
return size;
50955117
}
50965118

5119+
static size_t intel_iommu_unmap_pages(struct iommu_domain *domain,
5120+
unsigned long iova,
5121+
size_t pgsize, size_t pgcount,
5122+
struct iommu_iotlb_gather *gather)
5123+
{
5124+
unsigned long pgshift = __ffs(pgsize);
5125+
size_t size = pgcount << pgshift;
5126+
5127+
return intel_iommu_unmap(domain, iova, size, gather);
5128+
}
5129+
50975130
static void intel_iommu_tlb_sync(struct iommu_domain *domain,
50985131
struct iommu_iotlb_gather *gather)
50995132
{
@@ -5591,9 +5624,9 @@ const struct iommu_ops intel_iommu_ops = {
55915624
.aux_attach_dev = intel_iommu_aux_attach_device,
55925625
.aux_detach_dev = intel_iommu_aux_detach_device,
55935626
.aux_get_pasid = intel_iommu_aux_get_pasid,
5594-
.map = intel_iommu_map,
5627+
.map_pages = intel_iommu_map_pages,
5628+
.unmap_pages = intel_iommu_unmap_pages,
55955629
.iotlb_sync_map = intel_iommu_iotlb_sync_map,
5596-
.unmap = intel_iommu_unmap,
55975630
.flush_iotlb_all = intel_flush_iotlb_all,
55985631
.iotlb_sync = intel_iommu_tlb_sync,
55995632
.iova_to_phys = intel_iommu_iova_to_phys,

0 commit comments

Comments
 (0)