Skip to content

Commit bd111e9

Browse files
rmurphy-armjoergroedel
authored andcommitted
iommu: Retire map/unmap ops
With everyone now implementing the new interfaces, clean up the last remnants of the old map/unmap ops and simplify the calling logic again. Signed-off-by: Robin Murphy <[email protected]> Reviewed-by: Jason Gunthorpe <[email protected]> Link: https://lore.kernel.org/r/d2afdf13b2fbf537713c3ec642dfd49d16dd9e6a.1694525662.git.robin.murphy@arm.com Signed-off-by: Joerg Roedel <[email protected]>
1 parent 39f823d commit bd111e9

File tree

2 files changed

+13
-53
lines changed

2 files changed

+13
-53
lines changed

drivers/iommu/iommu.c

Lines changed: 13 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -2509,30 +2509,6 @@ static size_t iommu_pgsize(struct iommu_domain *domain, unsigned long iova,
25092509
return pgsize;
25102510
}
25112511

2512-
static int __iommu_map_pages(struct iommu_domain *domain, unsigned long iova,
2513-
phys_addr_t paddr, size_t size, int prot,
2514-
gfp_t gfp, size_t *mapped)
2515-
{
2516-
const struct iommu_domain_ops *ops = domain->ops;
2517-
size_t pgsize, count;
2518-
int ret;
2519-
2520-
pgsize = iommu_pgsize(domain, iova, paddr, size, &count);
2521-
2522-
pr_debug("mapping: iova 0x%lx pa %pa pgsize 0x%zx count %zu\n",
2523-
iova, &paddr, pgsize, count);
2524-
2525-
if (ops->map_pages) {
2526-
ret = ops->map_pages(domain, iova, paddr, pgsize, count, prot,
2527-
gfp, mapped);
2528-
} else {
2529-
ret = ops->map(domain, iova, paddr, pgsize, prot, gfp);
2530-
*mapped = ret ? 0 : pgsize;
2531-
}
2532-
2533-
return ret;
2534-
}
2535-
25362512
static int __iommu_map(struct iommu_domain *domain, unsigned long iova,
25372513
phys_addr_t paddr, size_t size, int prot, gfp_t gfp)
25382514
{
@@ -2543,8 +2519,7 @@ static int __iommu_map(struct iommu_domain *domain, unsigned long iova,
25432519
phys_addr_t orig_paddr = paddr;
25442520
int ret = 0;
25452521

2546-
if (unlikely(!(ops->map || ops->map_pages) ||
2547-
domain->pgsize_bitmap == 0UL))
2522+
if (unlikely(!ops->map_pages || domain->pgsize_bitmap == 0UL))
25482523
return -ENODEV;
25492524

25502525
if (unlikely(!(domain->type & __IOMMU_DOMAIN_PAGING)))
@@ -2567,10 +2542,14 @@ static int __iommu_map(struct iommu_domain *domain, unsigned long iova,
25672542
pr_debug("map: iova 0x%lx pa %pa size 0x%zx\n", iova, &paddr, size);
25682543

25692544
while (size) {
2570-
size_t mapped = 0;
2545+
size_t pgsize, count, mapped = 0;
2546+
2547+
pgsize = iommu_pgsize(domain, iova, paddr, size, &count);
25712548

2572-
ret = __iommu_map_pages(domain, iova, paddr, size, prot, gfp,
2573-
&mapped);
2549+
pr_debug("mapping: iova 0x%lx pa %pa pgsize 0x%zx count %zu\n",
2550+
iova, &paddr, pgsize, count);
2551+
ret = ops->map_pages(domain, iova, paddr, pgsize, count, prot,
2552+
gfp, &mapped);
25742553
/*
25752554
* Some pages may have been mapped, even if an error occurred,
25762555
* so we should account for those so they can be unmapped.
@@ -2614,19 +2593,6 @@ int iommu_map(struct iommu_domain *domain, unsigned long iova,
26142593
}
26152594
EXPORT_SYMBOL_GPL(iommu_map);
26162595

2617-
static size_t __iommu_unmap_pages(struct iommu_domain *domain,
2618-
unsigned long iova, size_t size,
2619-
struct iommu_iotlb_gather *iotlb_gather)
2620-
{
2621-
const struct iommu_domain_ops *ops = domain->ops;
2622-
size_t pgsize, count;
2623-
2624-
pgsize = iommu_pgsize(domain, iova, iova, size, &count);
2625-
return ops->unmap_pages ?
2626-
ops->unmap_pages(domain, iova, pgsize, count, iotlb_gather) :
2627-
ops->unmap(domain, iova, pgsize, iotlb_gather);
2628-
}
2629-
26302596
static size_t __iommu_unmap(struct iommu_domain *domain,
26312597
unsigned long iova, size_t size,
26322598
struct iommu_iotlb_gather *iotlb_gather)
@@ -2636,8 +2602,7 @@ static size_t __iommu_unmap(struct iommu_domain *domain,
26362602
unsigned long orig_iova = iova;
26372603
unsigned int min_pagesz;
26382604

2639-
if (unlikely(!(ops->unmap || ops->unmap_pages) ||
2640-
domain->pgsize_bitmap == 0UL))
2605+
if (unlikely(!ops->unmap_pages || domain->pgsize_bitmap == 0UL))
26412606
return 0;
26422607

26432608
if (unlikely(!(domain->type & __IOMMU_DOMAIN_PAGING)))
@@ -2664,9 +2629,10 @@ static size_t __iommu_unmap(struct iommu_domain *domain,
26642629
* or we hit an area that isn't mapped.
26652630
*/
26662631
while (unmapped < size) {
2667-
unmapped_page = __iommu_unmap_pages(domain, iova,
2668-
size - unmapped,
2669-
iotlb_gather);
2632+
size_t pgsize, count;
2633+
2634+
pgsize = iommu_pgsize(domain, iova, iova, size - unmapped, &count);
2635+
unmapped_page = ops->unmap_pages(domain, iova, pgsize, count, iotlb_gather);
26702636
if (!unmapped_page)
26712637
break;
26722638

include/linux/iommu.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -322,10 +322,8 @@ struct iommu_ops {
322322
* * ENODEV - device specific errors, not able to be attached
323323
* * <others> - treated as ENODEV by the caller. Use is discouraged
324324
* @set_dev_pasid: set an iommu domain to a pasid of device
325-
* @map: map a physically contiguous memory region to an iommu domain
326325
* @map_pages: map a physically contiguous set of pages of the same size to
327326
* an iommu domain.
328-
* @unmap: unmap a physically contiguous memory region from an iommu domain
329327
* @unmap_pages: unmap a number of pages of the same size from an iommu domain
330328
* @flush_iotlb_all: Synchronously flush all hardware TLBs for this domain
331329
* @iotlb_sync_map: Sync mappings created recently using @map to the hardware
@@ -344,13 +342,9 @@ struct iommu_domain_ops {
344342
int (*set_dev_pasid)(struct iommu_domain *domain, struct device *dev,
345343
ioasid_t pasid);
346344

347-
int (*map)(struct iommu_domain *domain, unsigned long iova,
348-
phys_addr_t paddr, size_t size, int prot, gfp_t gfp);
349345
int (*map_pages)(struct iommu_domain *domain, unsigned long iova,
350346
phys_addr_t paddr, size_t pgsize, size_t pgcount,
351347
int prot, gfp_t gfp, size_t *mapped);
352-
size_t (*unmap)(struct iommu_domain *domain, unsigned long iova,
353-
size_t size, struct iommu_iotlb_gather *iotlb_gather);
354348
size_t (*unmap_pages)(struct iommu_domain *domain, unsigned long iova,
355349
size_t pgsize, size_t pgcount,
356350
struct iommu_iotlb_gather *iotlb_gather);

0 commit comments

Comments
 (0)