Skip to content

Commit d88e61f

Browse files
Christoph Hellwigjoergroedel
authored andcommitted
iommu: Remove the ->map_sg indirection
All iommu drivers use the default_iommu_map_sg implementation, and there is no good reason to ever override it. Just expose it as iommu_map_sg directly and remove the indirection, specially in our post-spectre world where indirect calls are horribly expensive. Signed-off-by: Christoph Hellwig <[email protected]> Signed-off-by: Joerg Roedel <[email protected]>
1 parent 58d1131 commit d88e61f

16 files changed

+5
-31
lines changed

drivers/iommu/amd_iommu.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3192,7 +3192,6 @@ const struct iommu_ops amd_iommu_ops = {
31923192
.detach_dev = amd_iommu_detach_device,
31933193
.map = amd_iommu_map,
31943194
.unmap = amd_iommu_unmap,
3195-
.map_sg = default_iommu_map_sg,
31963195
.iova_to_phys = amd_iommu_iova_to_phys,
31973196
.add_device = amd_iommu_add_device,
31983197
.remove_device = amd_iommu_remove_device,

drivers/iommu/arm-smmu-v3.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1997,7 +1997,6 @@ static struct iommu_ops arm_smmu_ops = {
19971997
.attach_dev = arm_smmu_attach_dev,
19981998
.map = arm_smmu_map,
19991999
.unmap = arm_smmu_unmap,
2000-
.map_sg = default_iommu_map_sg,
20012000
.flush_iotlb_all = arm_smmu_iotlb_sync,
20022001
.iotlb_sync = arm_smmu_iotlb_sync,
20032002
.iova_to_phys = arm_smmu_iova_to_phys,

drivers/iommu/arm-smmu.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1562,7 +1562,6 @@ static struct iommu_ops arm_smmu_ops = {
15621562
.attach_dev = arm_smmu_attach_dev,
15631563
.map = arm_smmu_map,
15641564
.unmap = arm_smmu_unmap,
1565-
.map_sg = default_iommu_map_sg,
15661565
.flush_iotlb_all = arm_smmu_iotlb_sync,
15671566
.iotlb_sync = arm_smmu_iotlb_sync,
15681567
.iova_to_phys = arm_smmu_iova_to_phys,

drivers/iommu/exynos-iommu.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1332,7 +1332,6 @@ static const struct iommu_ops exynos_iommu_ops = {
13321332
.detach_dev = exynos_iommu_detach_device,
13331333
.map = exynos_iommu_map,
13341334
.unmap = exynos_iommu_unmap,
1335-
.map_sg = default_iommu_map_sg,
13361335
.iova_to_phys = exynos_iommu_iova_to_phys,
13371336
.device_group = generic_device_group,
13381337
.add_device = exynos_iommu_add_device,

drivers/iommu/intel-iommu.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5308,7 +5308,6 @@ const struct iommu_ops intel_iommu_ops = {
53085308
.detach_dev = intel_iommu_detach_device,
53095309
.map = intel_iommu_map,
53105310
.unmap = intel_iommu_unmap,
5311-
.map_sg = default_iommu_map_sg,
53125311
.iova_to_phys = intel_iommu_iova_to_phys,
53135312
.add_device = intel_iommu_add_device,
53145313
.remove_device = intel_iommu_remove_device,

drivers/iommu/iommu.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1673,8 +1673,8 @@ size_t iommu_unmap_fast(struct iommu_domain *domain,
16731673
}
16741674
EXPORT_SYMBOL_GPL(iommu_unmap_fast);
16751675

1676-
size_t default_iommu_map_sg(struct iommu_domain *domain, unsigned long iova,
1677-
struct scatterlist *sg, unsigned int nents, int prot)
1676+
size_t iommu_map_sg(struct iommu_domain *domain, unsigned long iova,
1677+
struct scatterlist *sg, unsigned int nents, int prot)
16781678
{
16791679
struct scatterlist *s;
16801680
size_t mapped = 0;
@@ -1714,7 +1714,7 @@ size_t default_iommu_map_sg(struct iommu_domain *domain, unsigned long iova,
17141714
return 0;
17151715

17161716
}
1717-
EXPORT_SYMBOL_GPL(default_iommu_map_sg);
1717+
EXPORT_SYMBOL_GPL(iommu_map_sg);
17181718

17191719
int iommu_domain_window_enable(struct iommu_domain *domain, u32 wnd_nr,
17201720
phys_addr_t paddr, u64 size, int prot)

drivers/iommu/ipmmu-vmsa.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -889,7 +889,6 @@ static const struct iommu_ops ipmmu_ops = {
889889
.unmap = ipmmu_unmap,
890890
.flush_iotlb_all = ipmmu_iotlb_sync,
891891
.iotlb_sync = ipmmu_iotlb_sync,
892-
.map_sg = default_iommu_map_sg,
893892
.iova_to_phys = ipmmu_iova_to_phys,
894893
.add_device = ipmmu_add_device,
895894
.remove_device = ipmmu_remove_device,

drivers/iommu/msm_iommu.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,6 @@ static struct iommu_ops msm_iommu_ops = {
708708
.detach_dev = msm_iommu_detach_dev,
709709
.map = msm_iommu_map,
710710
.unmap = msm_iommu_unmap,
711-
.map_sg = default_iommu_map_sg,
712711
.iova_to_phys = msm_iommu_iova_to_phys,
713712
.add_device = msm_iommu_add_device,
714713
.remove_device = msm_iommu_remove_device,

drivers/iommu/mtk_iommu.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,6 @@ static struct iommu_ops mtk_iommu_ops = {
495495
.detach_dev = mtk_iommu_detach_device,
496496
.map = mtk_iommu_map,
497497
.unmap = mtk_iommu_unmap,
498-
.map_sg = default_iommu_map_sg,
499498
.flush_iotlb_all = mtk_iommu_iotlb_sync,
500499
.iotlb_sync = mtk_iommu_iotlb_sync,
501500
.iova_to_phys = mtk_iommu_iova_to_phys,

drivers/iommu/mtk_iommu_v1.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,6 @@ static struct iommu_ops mtk_iommu_ops = {
531531
.detach_dev = mtk_iommu_detach_device,
532532
.map = mtk_iommu_map,
533533
.unmap = mtk_iommu_unmap,
534-
.map_sg = default_iommu_map_sg,
535534
.iova_to_phys = mtk_iommu_iova_to_phys,
536535
.add_device = mtk_iommu_add_device,
537536
.remove_device = mtk_iommu_remove_device,

drivers/iommu/omap-iommu.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1548,7 +1548,6 @@ static const struct iommu_ops omap_iommu_ops = {
15481548
.detach_dev = omap_iommu_detach_dev,
15491549
.map = omap_iommu_map,
15501550
.unmap = omap_iommu_unmap,
1551-
.map_sg = default_iommu_map_sg,
15521551
.iova_to_phys = omap_iommu_iova_to_phys,
15531552
.add_device = omap_iommu_add_device,
15541553
.remove_device = omap_iommu_remove_device,

drivers/iommu/qcom_iommu.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,6 @@ static const struct iommu_ops qcom_iommu_ops = {
590590
.detach_dev = qcom_iommu_detach_dev,
591591
.map = qcom_iommu_map,
592592
.unmap = qcom_iommu_unmap,
593-
.map_sg = default_iommu_map_sg,
594593
.flush_iotlb_all = qcom_iommu_iotlb_sync,
595594
.iotlb_sync = qcom_iommu_iotlb_sync,
596595
.iova_to_phys = qcom_iommu_iova_to_phys,

drivers/iommu/rockchip-iommu.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1110,7 +1110,6 @@ static const struct iommu_ops rk_iommu_ops = {
11101110
.detach_dev = rk_iommu_detach_device,
11111111
.map = rk_iommu_map,
11121112
.unmap = rk_iommu_unmap,
1113-
.map_sg = default_iommu_map_sg,
11141113
.add_device = rk_iommu_add_device,
11151114
.remove_device = rk_iommu_remove_device,
11161115
.iova_to_phys = rk_iommu_iova_to_phys,

drivers/iommu/tegra-gart.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,6 @@ static const struct iommu_ops gart_iommu_ops = {
377377
.remove_device = gart_iommu_remove_device,
378378
.device_group = generic_device_group,
379379
.map = gart_iommu_map,
380-
.map_sg = default_iommu_map_sg,
381380
.unmap = gart_iommu_unmap,
382381
.iova_to_phys = gart_iommu_iova_to_phys,
383382
.pgsize_bitmap = GART_IOMMU_PGSIZES,

drivers/iommu/tegra-smmu.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -876,7 +876,6 @@ static const struct iommu_ops tegra_smmu_ops = {
876876
.device_group = tegra_smmu_device_group,
877877
.map = tegra_smmu_map,
878878
.unmap = tegra_smmu_unmap,
879-
.map_sg = default_iommu_map_sg,
880879
.iova_to_phys = tegra_smmu_iova_to_phys,
881880
.of_xlate = tegra_smmu_of_xlate,
882881
.pgsize_bitmap = SZ_4K,

include/linux/iommu.h

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,6 @@ struct iommu_resv_region {
166166
* @detach_dev: detach device from an iommu domain
167167
* @map: map a physically contiguous memory region to an iommu domain
168168
* @unmap: unmap a physically contiguous memory region from an iommu domain
169-
* @map_sg: map a scatter-gather list of physically contiguous memory chunks
170-
* to an iommu domain
171169
* @flush_tlb_all: Synchronously flush all hardware TLBs for this domain
172170
* @tlb_range_add: Add a given iova range to the flush queue for this domain
173171
* @tlb_sync: Flush all queued ranges from the hardware TLBs and empty flush
@@ -201,8 +199,6 @@ struct iommu_ops {
201199
phys_addr_t paddr, size_t size, int prot);
202200
size_t (*unmap)(struct iommu_domain *domain, unsigned long iova,
203201
size_t size);
204-
size_t (*map_sg)(struct iommu_domain *domain, unsigned long iova,
205-
struct scatterlist *sg, unsigned int nents, int prot);
206202
void (*flush_iotlb_all)(struct iommu_domain *domain);
207203
void (*iotlb_range_add)(struct iommu_domain *domain,
208204
unsigned long iova, size_t size);
@@ -303,9 +299,8 @@ extern size_t iommu_unmap(struct iommu_domain *domain, unsigned long iova,
303299
size_t size);
304300
extern size_t iommu_unmap_fast(struct iommu_domain *domain,
305301
unsigned long iova, size_t size);
306-
extern size_t default_iommu_map_sg(struct iommu_domain *domain, unsigned long iova,
307-
struct scatterlist *sg,unsigned int nents,
308-
int prot);
302+
extern size_t iommu_map_sg(struct iommu_domain *domain, unsigned long iova,
303+
struct scatterlist *sg,unsigned int nents, int prot);
309304
extern phys_addr_t iommu_iova_to_phys(struct iommu_domain *domain, dma_addr_t iova);
310305
extern void iommu_set_fault_handler(struct iommu_domain *domain,
311306
iommu_fault_handler_t handler, void *token);
@@ -378,13 +373,6 @@ static inline void iommu_tlb_sync(struct iommu_domain *domain)
378373
domain->ops->iotlb_sync(domain);
379374
}
380375

381-
static inline size_t iommu_map_sg(struct iommu_domain *domain,
382-
unsigned long iova, struct scatterlist *sg,
383-
unsigned int nents, int prot)
384-
{
385-
return domain->ops->map_sg(domain, iova, sg, nents, prot);
386-
}
387-
388376
/* PCI device grouping function */
389377
extern struct iommu_group *pci_device_group(struct device *dev);
390378
/* Generic device grouping function */

0 commit comments

Comments
 (0)