iommu/virtio: Add map/unmap_pages() callbacks implementation
Subsystems (2)
RFC 1/1 iommu/virtio: Add map/unmap_pages() callbacks implementation
From: Tina Zhang <[email protected]>
Map/unmap_pags() allows map and unmap multiple pages of the same size in one call, which can improve performance by reducing the numbers of vmexits. With map/unmap_pages() implemented, the prior map/unmap() callbacks are deprecated.
Signed-off-by Tina Zhang <[email protected]>
--- drivers/iommu/virtio-iommu.c | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-)
drivers/iommu/virtio-iommu.c +29 -2
@@ -1006,6 +1006,33 @@ static int viommu_of_xlate(struct device *dev, struct of_phandle_args *args)return iommu_fwspec_add_ids (dev, args->args,1 ); } +static int viommu_map_pages (struct iommu_domain *domain, +unsigned long iova,phys_addr_t paddr, +size_t pgsize,size_t pgcount, +int prot,gfp_t gfp,size_t *mapped) +{ +unsigned long pgshift =__ffs (pgsize); +size_t size = pgcount << pgshift; +int ret; + + ret =viommu_map (domain, iova, paddr, size, prot, gfp); +if (!ret && mapped) + *mapped = size; + +return ret; +} + +static size_t viommu_unmap_pages (struct iommu_domain *domain, +unsigned long iova, +size_t pgsize,size_t pgcount, +struct iommu_iotlb_gather *gather) +{ +unsigned long pgshift =__ffs (pgsize); +size_t size = pgcount << pgshift; + +return viommu_unmap (domain, iova, size, gather); +} +static struct iommu_ops viommu_ops = { .domain_alloc = viommu_domain_alloc, .probe_device = viommu_probe_device,
@@ -1018,8 +1045,8 @@ static struct iommu_ops viommu_ops = { .owner = THIS_MODULE, .default_domain_ops = &(const struct iommu_domain_ops ) { .attach_dev = viommu_attach_dev, - .map = viommu_map, - .unmap = viommu_unmap, + .unmap_pages = viommu_unmap_pages, + .map_pages = viommu_map_pages, .iova_to_phys = viommu_iova_to_phys, .iotlb_sync = viommu_iotlb_sync, .free = viommu_domain_free,
Signature · 6 lines
2.25.1 _______________________________________________ iommu mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/iommu