Remove ops.pgsize_bitmap
Subsystems (22)
Jason Gunthorpe
maintainerv2 cover Remove ops.pgsize_bitmap
Now that all drivers are using domain_alloc_paging() and dev is never NULL, we can have all drivers correctly set domain.pgsize_bitmap during their allocation function.
There are a few oddities that have accumulated here over past changes:
- Some drivers always set domain.pgsize_bitmap during their domain_alloc_paging() call but still provide a value in ops. This is dead code, delete it.
- Some drivers calculate a system global pgsize_bitmap in the ops, but it is now trivial to use the per-instance value instead. In several cases this is dead code, delete it. This also allows constifying the ops in these drivers as a hardening measure
- Some drivers have a fixed pgsize_bitmap, put it next to setting up the geometry in their domain_alloc_paging() functions.
- Finally a few drivers still use ops because they have a delayed finalize operation. Set the constant pgsize_bitmap in the domain_alloc_paging().
Then remove ops.pgsize_bitmap.
This is based on iommu next, and must go after the virtio domain_alloc_paging() conversion.
v2:
- Rebase on v6.16-rc1
v1: https://patch.msgid.link/r/[email protected]
Jason Gunthorpe (7):
qiommu/arm-smmu-v3: Remove iommu_ops pgsize_bitmap iommu/arm-smmu: Remove iommu_ops pgsize_bitmap
iommu: Remove ops.pgsize_bitmap from drivers that don't use it
iommu: Remove iommu_ops pgsize_bitmap from simple drivers iommu/mtk: Remove iommu_ops pgsize_bitmap iommu/qcom: Remove iommu_ops pgsize_bitmap
iommu: Remove ops->pgsize_bitmap
drivers/iommu/apple-dart.c | 1 - drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 10 ++-------- drivers/iommu/arm/arm-smmu/arm-smmu.c | 12 +++++------- drivers/iommu/arm/arm-smmu/qcom_iommu.c | 6 ++---- drivers/iommu/exynos-iommu.c | 3 ++- drivers/iommu/intel/iommu.c | 1 - drivers/iommu/iommu.c | 7 ------- drivers/iommu/iommufd/selftest.c | 1 - drivers/iommu/ipmmu-vmsa.c | 4 ++-- drivers/iommu/mtk_iommu.c | 9 +++------ drivers/iommu/mtk_iommu_v1.c | 3 ++- drivers/iommu/omap-iommu.c | 3 ++- drivers/iommu/riscv/iommu.c | 1 - drivers/iommu/rockchip-iommu.c | 3 ++- drivers/iommu/s390-iommu.c | 2 +- drivers/iommu/sprd-iommu.c | 3 ++- drivers/iommu/sun50i-iommu.c | 3 ++- drivers/iommu/tegra-smmu.c | 3 ++- drivers/iommu/virtio-iommu.c | 6 ++---- include/linux/iommu.h | 2 -- 20 files changed, 31 insertions(+), 52 deletions(-)
base-commit: 19272b37aa4f83ca52bdf9c16d5d81bdd1354494
Signature · 1 line
2.43.0
Jason Gunthorpe
maintainerPATCH v2 1/7 qiommu/arm-smmu-v3: Remove iommu_ops pgsize_bitmap
The driver never reads this value, arm_smmu_domain_finalise() always sets domain.pgsize_bitmap to pgtbl_cfg, which comes from the per-smmu calculated value.
Remove the ops version entirely, the related dead code and make arm_smmu_ops const.
--- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +2 -8
@@ -38,7 +38,7 @@ module_param(disable_msipolling, bool, 0444);MODULE_PARM_DESC (disable_msipolling,"Disable MSI-based polling for CMD_SYNC completion." ); -static struct iommu_ops arm_smmu_ops; +static const struct iommu_ops arm_smmu_ops;static struct iommu_dirty_ops arm_smmu_dirty_ops;enum arm_smmu_msi_index {
@@ -3674,7 +3674,7 @@ static int arm_smmu_def_domain_type(struct device *dev)return 0 ; } -static struct iommu_ops arm_smmu_ops = { +static const struct iommu_ops arm_smmu_ops = { .identity_domain = &arm_smmu_identity_domain, .blocked_domain = &arm_smmu_blocked_domain, .capable = arm_smmu_capable,
@@ -3690,7 +3690,6 @@ static struct iommu_ops arm_smmu_ops = { .def_domain_type = arm_smmu_def_domain_type, .viommu_alloc = arm_vsmmu_alloc, .user_pasid_table = 1, - .pgsize_bitmap = -1UL, /* Restricted during device attach */ .owner = THIS_MODULE, .default_domain_ops = &(const struct iommu_domain_ops ) { .attach_dev = arm_smmu_attach_dev,
@@ -4504,11 +4503,6 @@ static int arm_smmu_device_hw_probe(struct arm_smmu_device *smmu) smmu->oas =48 ; } -if (arm_smmu_ops.pgsize_bitmap ==-1UL ) - arm_smmu_ops.pgsize_bitmap = smmu->pgsize_bitmap; -else - arm_smmu_ops.pgsize_bitmap |= smmu->pgsize_bitmap; -/* Set the DMA mask for our table walker */ if (dma_set_mask_and_coherent (smmu->dev,DMA_BIT_MASK (smmu->oas))) dev_warn(smmu->dev,
Signature · 1 line
2.43.0
Re: [PATCH v2 1/7] qiommu/arm-smmu-v3: Remove iommu_ops pgsize_bitmap
Quoted 10 lines · Jason Gunthorpe
The driver never reads this value,
arm_smmu_domain_finalise()always sets domain.pgsize_bitmap topgtbl_cfg, which comes from the per-smmu calculated value.Remove the ops version entirely, the related dead code and make
arm_smmu_opsconst.Reviewed-by Kevin Tian <[email protected]>Acked-by Will Deacon <[email protected]>Signed-off-by Jason Gunthorpe <[email protected]>
Is "qiommu" a typo in the subject?
Jason Gunthorpe
maintainerRe: [PATCH v2 1/7] qiommu/arm-smmu-v3: Remove iommu_ops pgsize_bitmap
Quoted 8 lines · Nicolin Chen
Quoted 7 lines · Jason Gunthorpe
The driver never reads this value,
arm_smmu_domain_finalise()always sets domain.pgsize_bitmap topgtbl_cfg, which comes from the per-smmu calculated value.Remove the ops version entirely, the related dead code and make
arm_smmu_opsconst.
Quoted 7 lines
Quoted 3 lines
Reviewed-by Kevin Tian <[email protected]>Acked-by Will Deacon <[email protected]>Signed-off-by Jason Gunthorpe <[email protected]>Reviewed-by Nicolin Chen <[email protected]>Is "qiommu" a typo in the subject?
Yeah
Thanks,
Jason
Jason Gunthorpe
maintainerPATCH v2 2/7 iommu/arm-smmu: Remove iommu_ops pgsize_bitmap
In reply to Jason GunthorpeThe driver never reads this value, arm_smmu_init_domain_context() always sets domain.pgsize_bitmap to smmu->pgsize_bitmap, the per-instance value.
Remove the ops version entirely, the related dead code and make arm_smmu_ops const.
Since this driver does not yet finalize the domain under arm_smmu_domain_alloc_paging() add a page size initialization to alloc so the page size is still setup prior to attach.
--- drivers/iommu/arm/arm-smmu/arm-smmu.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)
drivers/iommu/arm/arm-smmu/arm-smmu.c +5 -7
@@ -109,7 +109,7 @@ static struct arm_smmu_domain *to_smmu_domain(struct iommu_domain *dom) }static struct platform_driver arm_smmu_driver; -static struct iommu_ops arm_smmu_ops; +static const struct iommu_ops arm_smmu_ops;#ifdef CONFIG_ARM_SMMU_LEGACY_DT_BINDINGS static struct device_node *dev_get_dev_node (struct device *dev)
@@ -919,6 +919,8 @@ static void arm_smmu_destroy_domain_context(struct arm_smmu_domain *smmu_domain)static struct iommu_domain *arm_smmu_domain_alloc_paging (struct device *dev) {struct arm_smmu_domain *smmu_domain; +struct arm_smmu_master_cfg *cfg =dev_iommu_priv_get (dev); +struct arm_smmu_device *smmu = cfg->smmu;/* * Allocate the domain and initialise some of its data structures.
@@ -931,6 +933,7 @@ static struct iommu_domain *arm_smmu_domain_alloc_paging(struct device *dev)mutex_init (&smmu_domain->init_mutex);spin_lock_init (&smmu_domain->cb_lock); + smmu_domain->domain.pgsize_bitmap = smmu->pgsize_bitmap;return &smmu_domain->domain; }
@@ -1627,7 +1630,7 @@ static int arm_smmu_def_domain_type(struct device *dev)return 0 ; } -static struct iommu_ops arm_smmu_ops = { +static const struct iommu_ops arm_smmu_ops = { .identity_domain = &arm_smmu_identity_domain, .blocked_domain = &arm_smmu_blocked_domain, .capable = arm_smmu_capable,
@@ -1639,7 +1642,6 @@ static struct iommu_ops arm_smmu_ops = { .of_xlate = arm_smmu_of_xlate, .get_resv_regions = arm_smmu_get_resv_regions, .def_domain_type = arm_smmu_def_domain_type, - .pgsize_bitmap = -1UL, /* Restricted during device attach */ .owner = THIS_MODULE, .default_domain_ops = &(const struct iommu_domain_ops ) { .attach_dev = arm_smmu_attach_dev,
@@ -1919,10 +1921,6 @@ static int arm_smmu_device_cfg_probe(struct arm_smmu_device *smmu)if (smmu->features &ARM_SMMU_FEAT_FMT_AARCH64_64K ) smmu->pgsize_bitmap |=SZ_64K |SZ_512M ; -if (arm_smmu_ops.pgsize_bitmap ==-1UL ) - arm_smmu_ops.pgsize_bitmap = smmu->pgsize_bitmap; -else - arm_smmu_ops.pgsize_bitmap |= smmu->pgsize_bitmap;dev_notice (smmu->dev,"\tSupported page sizes: 0x%08lx\n" , smmu->pgsize_bitmap);
Signature · 1 line
2.43.0
Jason Gunthorpe
maintainerPATCH v2 3/7 iommu: Remove ops.pgsize_bitmap from drivers that don't use it
In reply to Jason GunthorpeThese drivers all set the domain->pgsize_bitmap in their domain_alloc_paging() functions, so the ops value is never used. Delete it.
--- drivers/iommu/apple-dart.c | 1 - drivers/iommu/intel/iommu.c | 1 - drivers/iommu/iommufd/selftest.c | 1 - drivers/iommu/riscv/iommu.c | 1 - drivers/iommu/virtio-iommu.c | 6 ++---- 5 files changed, 2 insertions(+), 8 deletions(-)
drivers/iommu/apple-dart.c +0 -1
@@ -991,7 +991,6 @@ static const struct iommu_ops apple_dart_iommu_ops = { .of_xlate = apple_dart_of_xlate, .def_domain_type = apple_dart_def_domain_type, .get_resv_regions = apple_dart_get_resv_regions, - .pgsize_bitmap = -1UL, /* Restricted during dart probe */ .owner = THIS_MODULE, .default_domain_ops = &(const struct iommu_domain_ops ) { .attach_dev = apple_dart_attach_dev_paging,
drivers/iommu/intel/iommu.c +0 -1
@@ -4365,7 +4365,6 @@ const struct iommu_ops intel_iommu_ops = { .device_group = intel_iommu_device_group, .is_attach_deferred = intel_iommu_is_attach_deferred, .def_domain_type = device_def_domain_type, - .pgsize_bitmap = SZ_4K, .page_response = intel_iommu_page_response, .default_domain_ops = &(const struct iommu_domain_ops ) { .attach_dev = intel_iommu_attach_device,
drivers/iommu/iommufd/selftest.c +0 -1
@@ -801,7 +801,6 @@ static const struct iommu_ops mock_ops = { .default_domain = &mock_blocking_domain, .blocked_domain = &mock_blocking_domain, .owner = THIS_MODULE, - .pgsize_bitmap = MOCK_IO_PAGE_SIZE, .hw_info = mock_domain_hw_info, .domain_alloc_paging_flags = mock_domain_alloc_paging_flags, .domain_alloc_nested = mock_domain_alloc_nested,
drivers/iommu/riscv/iommu.c +0 -1
@@ -1533,7 +1533,6 @@ static void riscv_iommu_release_device(struct device *dev) }static const struct iommu_ops riscv_iommu_ops = { - .pgsize_bitmap =SZ_4K , .of_xlate = riscv_iommu_of_xlate, .identity_domain = &riscv_iommu_identity_domain, .blocked_domain = &riscv_iommu_blocking_domain,
drivers/iommu/virtio-iommu.c +2 -4
@@ -998,7 +998,7 @@ static void viommu_get_resv_regions(struct device *dev, struct list_head *head)iommu_dma_get_resv_regions (dev, head); } -static struct iommu_ops viommu_ops; +static const struct iommu_ops viommu_ops;static struct virtio_driver virtio_iommu_drv;static int viommu_match_node (struct device *dev,const void *data)
@@ -1086,7 +1086,7 @@ static bool viommu_capable(struct device *dev, enum iommu_cap cap) } } -static struct iommu_ops viommu_ops = { +static const struct iommu_ops viommu_ops = { .capable = viommu_capable, .domain_alloc_identity = viommu_domain_alloc_identity, .domain_alloc_paging = viommu_domain_alloc_paging,
@@ -1217,8 +1217,6 @@ static int viommu_probe(struct virtio_device *vdev) viommu->first_domain++; } - viommu_ops.pgsize_bitmap = viommu->pgsize_bitmap; -virtio_device_ready (vdev);/* Populate the event queue with buffers */
Signature · 1 line
2.43.0
Jason Gunthorpe
maintainerPATCH v2 4/7 iommu: Remove iommu_ops pgsize_bitmap from simple drivers
In reply to Jason GunthorpeThese drivers just have a constant value for their page size, move it into their domain_alloc_paging function before setting up the geometry.
--- drivers/iommu/exynos-iommu.c | 3 ++- drivers/iommu/ipmmu-vmsa.c | 4 ++-- drivers/iommu/mtk_iommu_v1.c | 3 ++- drivers/iommu/omap-iommu.c | 3 ++- drivers/iommu/rockchip-iommu.c | 3 ++- drivers/iommu/s390-iommu.c | 2 +- drivers/iommu/sprd-iommu.c | 3 ++- drivers/iommu/sun50i-iommu.c | 3 ++- drivers/iommu/tegra-smmu.c | 3 ++- 9 files changed, 17 insertions(+), 10 deletions(-)
drivers/iommu/exynos-iommu.c +2 -1
@@ -925,6 +925,8 @@ static struct iommu_domain *exynos_iommu_domain_alloc_paging(struct device *dev)spin_lock_init (&domain->pgtablelock);INIT_LIST_HEAD (&domain->clients); + domain->domain.pgsize_bitmap =SECT_SIZE |LPAGE_SIZE |SPAGE_SIZE ; + domain->domain.geometry.aperture_start =0 ; domain->domain.geometry.aperture_end = ~0UL ; domain->domain.geometry.force_aperture = true;
@@ -1477,7 +1479,6 @@ static const struct iommu_ops exynos_iommu_ops = { .device_group = generic_device_group, .probe_device = exynos_iommu_probe_device, .release_device = exynos_iommu_release_device, - .pgsize_bitmap = SECT_SIZE | LPAGE_SIZE | SPAGE_SIZE, .of_xlate = exynos_iommu_of_xlate, .default_domain_ops = &(const struct iommu_domain_ops ) { .attach_dev = exynos_iommu_attach_device,
drivers/iommu/ipmmu-vmsa.c +2 -2
@@ -430,7 +430,7 @@ static int ipmmu_domain_init_context(struct ipmmu_vmsa_domain *domain)* non-secure mode. */ domain->cfg.quirks =IO_PGTABLE_QUIRK_ARM_NS ; - domain->cfg.pgsize_bitmap =SZ_1G |SZ_2M |SZ_4K ; + domain->cfg.pgsize_bitmap = domain->io_domain.pgsize_bitmap; domain->cfg.ias =32 ; domain->cfg.oas =40 ; domain->cfg.tlb = &ipmmu_flush_ops;
@@ -571,6 +571,7 @@ static struct iommu_domain *ipmmu_domain_alloc_paging(struct device *dev)return NULL ;mutex_init (&domain->mutex); + domain->io_domain.pgsize_bitmap =SZ_1G |SZ_2M |SZ_4K ;return &domain->io_domain; }
@@ -882,7 +883,6 @@ static const struct iommu_ops ipmmu_ops = {*/ .device_group = IS_ENABLED(CONFIG_ARM) && !IS_ENABLED(CONFIG_IOMMU_DMA) ? generic_device_group : generic_single_device_group, - .pgsize_bitmap = SZ_1G | SZ_2M | SZ_4K, .of_xlate = ipmmu_of_xlate, .default_domain_ops = &(const struct iommu_domain_ops ) { .attach_dev = ipmmu_attach_device,
drivers/iommu/mtk_iommu_v1.c +2 -1
@@ -288,6 +288,8 @@ static struct iommu_domain *mtk_iommu_v1_domain_alloc_paging(struct device *dev)if (!dom)return NULL ; + dom->domain.pgsize_bitmap =MT2701_IOMMU_PAGE_SIZE ; +return &dom->domain; }
@@ -582,7 +584,6 @@ static const struct iommu_ops mtk_iommu_v1_ops = { .probe_finalize = mtk_iommu_v1_probe_finalize, .release_device = mtk_iommu_v1_release_device, .device_group = generic_device_group, - .pgsize_bitmap = MT2701_IOMMU_PAGE_SIZE, .owner = THIS_MODULE, .default_domain_ops = &(const struct iommu_domain_ops ) { .attach_dev = mtk_iommu_v1_attach_device,
drivers/iommu/omap-iommu.c +2 -1
@@ -1584,6 +1584,8 @@ static struct iommu_domain *omap_iommu_domain_alloc_paging(struct device *dev)spin_lock_init (&omap_domain->lock); + omap_domain->domain.pgsize_bitmap =OMAP_IOMMU_PGSIZES ; + omap_domain->domain.geometry.aperture_start =0 ; omap_domain->domain.geometry.aperture_end = (1ULL <<32 ) -1 ; omap_domain->domain.geometry.force_aperture = true;
@@ -1735,7 +1737,6 @@ static const struct iommu_ops omap_iommu_ops = { .release_device = omap_iommu_release_device, .device_group = generic_single_device_group, .of_xlate = omap_iommu_of_xlate, - .pgsize_bitmap = OMAP_IOMMU_PGSIZES, .default_domain_ops = &(const struct iommu_domain_ops ) { .attach_dev = omap_iommu_attach_dev, .map_pages = omap_iommu_map,
drivers/iommu/rockchip-iommu.c +2 -1
@@ -1081,6 +1081,8 @@ static struct iommu_domain *rk_iommu_domain_alloc_paging(struct device *dev)spin_lock_init (&rk_domain->dt_lock);INIT_LIST_HEAD (&rk_domain->iommus); + rk_domain->domain.pgsize_bitmap =RK_IOMMU_PGSIZE_BITMAP ; + rk_domain->domain.geometry.aperture_start =0 ; rk_domain->domain.geometry.aperture_end =DMA_BIT_MASK (32 ); rk_domain->domain.geometry.force_aperture = true;
@@ -1171,7 +1173,6 @@ static const struct iommu_ops rk_iommu_ops = { .probe_device = rk_iommu_probe_device, .release_device = rk_iommu_release_device, .device_group = generic_single_device_group, - .pgsize_bitmap = RK_IOMMU_PGSIZE_BITMAP, .of_xlate = rk_iommu_of_xlate, .default_domain_ops = &(const struct iommu_domain_ops ) { .attach_dev = rk_iommu_attach_device,
drivers/iommu/s390-iommu.c +1 -1
@@ -557,6 +557,7 @@ static struct iommu_domain *s390_domain_alloc_paging(struct device *dev) } zdev->end_dma = zdev->start_dma + aperture_size -1 ; + s390_domain->domain.pgsize_bitmap =SZ_4K ; s390_domain->domain.geometry.force_aperture = true; s390_domain->domain.geometry.aperture_start =0 ; s390_domain->domain.geometry.aperture_end =max_tbl_size (s390_domain);
@@ -1158,7 +1159,6 @@ static struct iommu_domain blocking_domain = { .domain_alloc_paging = s390_domain_alloc_paging, \ .probe_device = s390_iommu_probe_device, \ .device_group = generic_device_group, \ - .pgsize_bitmap = SZ_4K, \ .get_resv_regions = s390_iommu_get_resv_regions, \ .default_domain_ops = &(const struct iommu_domain_ops ) { \ .attach_dev = s390_iommu_attach_device, \
drivers/iommu/sprd-iommu.c +2 -1
@@ -143,6 +143,8 @@ static struct iommu_domain *sprd_iommu_domain_alloc_paging(struct device *dev)spin_lock_init (&dom->pgtlock); + dom->domain.pgsize_bitmap =SPRD_IOMMU_PAGE_SIZE ; + dom->domain.geometry.aperture_start =0 ; dom->domain.geometry.aperture_end =SZ_256M -1 ; dom->domain.geometry.force_aperture = true;
@@ -410,7 +412,6 @@ static const struct iommu_ops sprd_iommu_ops = { .probe_device = sprd_iommu_probe_device, .device_group = generic_single_device_group, .of_xlate = sprd_iommu_of_xlate, - .pgsize_bitmap = SPRD_IOMMU_PAGE_SIZE, .owner = THIS_MODULE, .default_domain_ops = &(const struct iommu_domain_ops ) { .attach_dev = sprd_iommu_attach_device,
drivers/iommu/sun50i-iommu.c +2 -1
@@ -697,6 +697,8 @@ sun50i_iommu_domain_alloc_paging(struct device *dev)refcount_set (&sun50i_domain->refcnt,1 ); + sun50i_domain->domain.pgsize_bitmap =SZ_4K ; + sun50i_domain->domain.geometry.aperture_start =0 ; sun50i_domain->domain.geometry.aperture_end =DMA_BIT_MASK (32 ); sun50i_domain->domain.geometry.force_aperture = true;
@@ -842,7 +844,6 @@ static int sun50i_iommu_of_xlate(struct device *dev,static const struct iommu_ops sun50i_iommu_ops = { .identity_domain = &sun50i_iommu_identity_domain, - .pgsize_bitmap =SZ_4K , .device_group = generic_single_device_group, .domain_alloc_paging = sun50i_iommu_domain_alloc_paging, .of_xlate = sun50i_iommu_of_xlate,
drivers/iommu/tegra-smmu.c +2 -1
@@ -318,6 +318,8 @@ static struct iommu_domain *tegra_smmu_domain_alloc_paging(struct device *dev)spin_lock_init (&as->lock); + as->domain.pgsize_bitmap =SZ_4K ; +/* setup aperture */ as->domain.geometry.aperture_start =0 ; as->domain.geometry.aperture_end =0xffffffff ;
@@ -1002,7 +1004,6 @@ static const struct iommu_ops tegra_smmu_ops = { .probe_device = tegra_smmu_probe_device, .device_group = tegra_smmu_device_group, .of_xlate = tegra_smmu_of_xlate, - .pgsize_bitmap = SZ_4K, .default_domain_ops = &(const struct iommu_domain_ops ) { .attach_dev = tegra_smmu_attach_dev, .map_pages = tegra_smmu_map,
Signature · 1 line
2.43.0
Re: [PATCH v2 4/7] iommu: Remove iommu_ops pgsize_bitmap from simple drivers
Quoted 7 lines · Jason Gunthorpe
These drivers just have a constant value for their page size, move it into their
domain_alloc_pagingfunction before setting up the geometry.Reviewed-by Kevin Tian <[email protected]>Signed-off-by Jason Gunthorpe <[email protected]>
Quoted 9 lines
--- drivers/iommu/exynos-iommu.c | 3 ++- drivers/iommu/ipmmu-vmsa.c | 4 ++-- drivers/iommu/mtk_iommu_v1.c | 3 ++- drivers/iommu/omap-iommu.c | 3 ++- drivers/iommu/rockchip-iommu.c | 3 ++- drivers/iommu/s390-iommu.c | 2 +- drivers/iommu/sprd-iommu.c | 3 ++- drivers/iommu/sun50i-iommu.c | 3 ++-
Re: [PATCH v2 4/7] iommu: Remove iommu_ops pgsize_bitmap from simple drivers
In reply to Jason GunthorpeOn Mon, Jun 09, 2025 at 05:41:28PM -0300, Jason Gunthorpe wrote:
[...]
Quoted 14 lines
drivers/iommu/tegra-smmu.c +2
-0@@ -318,6 +318,8 @@ static struct iommu_domain *tegra_smmu_domain_alloc_paging(struct device *dev)spin_lock_init (&as->lock); + as->domain.pgsize_bitmap =SZ_4K ; +/* setup aperture */ as->domain.geometry.aperture_start =0 ; as->domain.geometry.aperture_end =0xffffffff ;
drivers/iommu/tegra-smmu.c static const struct iommu_ops tegra_smmu_ops = { · line 1009
Quoted 7 lines
drivers/iommu/tegra-smmu.c +0
-1@@ -1002,7 +1004,6 @@ static const struct iommu_ops tegra_smmu_ops = { .probe_device = tegra_smmu_probe_device, .device_group = tegra_smmu_device_group, .of_xlate = tegra_smmu_of_xlate, - .pgsize_bitmap = SZ_4K, .default_domain_ops = &(const struct iommu_domain_ops ) { .attach_dev = tegra_smmu_attach_dev, .map_pages = tegra_smmu_map,
Re: [PATCH v2 4/7] iommu: Remove iommu_ops pgsize_bitmap from simple drivers
In reply to Jason GunthorpeIl 09/06/25 22:41, Jason Gunthorpe ha scritto:
Quoted 6 lines
These drivers just have a constant value for their page size, move it into their
domain_alloc_pagingfunction before setting up the geometry.Reviewed-by Kevin Tian <[email protected]>Signed-off-by Jason Gunthorpe <[email protected]>
For MediaTek:
Re: [PATCH v2 4/7] iommu: Remove iommu_ops pgsize_bitmap from simple drivers
In reply to Jason GunthorpeQuoted 8 lines · Jason Gunthorpe
These drivers just have a constant value for their page size, move it into their
domain_alloc_pagingfunction before setting up the geometry.Reviewed-by Kevin Tian <[email protected]>Signed-off-by Jason Gunthorpe <[email protected]>--- drivers/iommu/exynos-iommu.c | 3 ++-
Quoted 199 lines
drivers/iommu/ipmmu-vmsa.c | 4 ++-- drivers/iommu/mtk_iommu_v1.c | 3 ++- drivers/iommu/omap-iommu.c | 3 ++- drivers/iommu/rockchip-iommu.c | 3 ++- drivers/iommu/s390-iommu.c | 2 +- drivers/iommu/sprd-iommu.c | 3 ++- drivers/iommu/sun50i-iommu.c | 3 ++- drivers/iommu/tegra-smmu.c | 3 ++- 9 files changed, 17 insertions(+), 10 deletions(-)drivers/iommu/exynos-iommu.c +2
-1@@ -925,6 +925,8 @@ static struct iommu_domain *exynos_iommu_domain_alloc_paging(struct device *dev)spin_lock_init (&domain->pgtablelock);INIT_LIST_HEAD (&domain->clients); + domain->domain.pgsize_bitmap =SECT_SIZE |LPAGE_SIZE |SPAGE_SIZE ; + domain->domain.geometry.aperture_start =0 ; domain->domain.geometry.aperture_end = ~0UL ; domain->domain.geometry.force_aperture = true;@@ -1477,7 +1479,6 @@ static const struct iommu_ops exynos_iommu_ops = { .device_group = generic_device_group, .probe_device = exynos_iommu_probe_device, .release_device = exynos_iommu_release_device, - .pgsize_bitmap = SECT_SIZE | LPAGE_SIZE | SPAGE_SIZE, .of_xlate = exynos_iommu_of_xlate, .default_domain_ops = &(const struct iommu_domain_ops ) { .attach_dev = exynos_iommu_attach_device,drivers/iommu/ipmmu-vmsa.c +2
-2@@ -430,7 +430,7 @@ static int ipmmu_domain_init_context(struct ipmmu_vmsa_domain *domain)* non-secure mode. */ domain->cfg.quirks =IO_PGTABLE_QUIRK_ARM_NS ; - domain->cfg.pgsize_bitmap =SZ_1G |SZ_2M |SZ_4K ; + domain->cfg.pgsize_bitmap = domain->io_domain.pgsize_bitmap; domain->cfg.ias =32 ; domain->cfg.oas =40 ; domain->cfg.tlb = &ipmmu_flush_ops;@@ -571,6 +571,7 @@ static struct iommu_domain *ipmmu_domain_alloc_paging(struct device *dev)return NULL ;mutex_init (&domain->mutex); + domain->io_domain.pgsize_bitmap =SZ_1G |SZ_2M |SZ_4K ;return &domain->io_domain; }@@ -882,7 +883,6 @@ static const struct iommu_ops ipmmu_ops = {*/ .device_group = IS_ENABLED(CONFIG_ARM) && !IS_ENABLED(CONFIG_IOMMU_DMA) ? generic_device_group : generic_single_device_group, - .pgsize_bitmap = SZ_1G | SZ_2M | SZ_4K, .of_xlate = ipmmu_of_xlate, .default_domain_ops = &(const struct iommu_domain_ops ) { .attach_dev = ipmmu_attach_device,drivers/iommu/mtk_iommu_v1.c +2
-1@@ -288,6 +288,8 @@ static struct iommu_domain *mtk_iommu_v1_domain_alloc_paging(struct device *dev)if (!dom)return NULL ; + dom->domain.pgsize_bitmap =MT2701_IOMMU_PAGE_SIZE ; +return &dom->domain; }@@ -582,7 +584,6 @@ static const struct iommu_ops mtk_iommu_v1_ops = { .probe_finalize = mtk_iommu_v1_probe_finalize, .release_device = mtk_iommu_v1_release_device, .device_group = generic_device_group, - .pgsize_bitmap = MT2701_IOMMU_PAGE_SIZE, .owner = THIS_MODULE, .default_domain_ops = &(const struct iommu_domain_ops ) { .attach_dev = mtk_iommu_v1_attach_device,drivers/iommu/omap-iommu.c +2
-1@@ -1584,6 +1584,8 @@ static struct iommu_domain *omap_iommu_domain_alloc_paging(struct device *dev)spin_lock_init (&omap_domain->lock); + omap_domain->domain.pgsize_bitmap =OMAP_IOMMU_PGSIZES ; + omap_domain->domain.geometry.aperture_start =0 ; omap_domain->domain.geometry.aperture_end = (1ULL <<32 ) -1 ; omap_domain->domain.geometry.force_aperture = true;@@ -1735,7 +1737,6 @@ static const struct iommu_ops omap_iommu_ops = { .release_device = omap_iommu_release_device, .device_group = generic_single_device_group, .of_xlate = omap_iommu_of_xlate, - .pgsize_bitmap = OMAP_IOMMU_PGSIZES, .default_domain_ops = &(const struct iommu_domain_ops ) { .attach_dev = omap_iommu_attach_dev, .map_pages = omap_iommu_map,drivers/iommu/rockchip-iommu.c +2
-1@@ -1081,6 +1081,8 @@ static struct iommu_domain *rk_iommu_domain_alloc_paging(struct device *dev)spin_lock_init (&rk_domain->dt_lock);INIT_LIST_HEAD (&rk_domain->iommus); + rk_domain->domain.pgsize_bitmap =RK_IOMMU_PGSIZE_BITMAP ; + rk_domain->domain.geometry.aperture_start =0 ; rk_domain->domain.geometry.aperture_end =DMA_BIT_MASK (32 ); rk_domain->domain.geometry.force_aperture = true;@@ -1171,7 +1173,6 @@ static const struct iommu_ops rk_iommu_ops = { .probe_device = rk_iommu_probe_device, .release_device = rk_iommu_release_device, .device_group = generic_single_device_group, - .pgsize_bitmap = RK_IOMMU_PGSIZE_BITMAP, .of_xlate = rk_iommu_of_xlate, .default_domain_ops = &(const struct iommu_domain_ops ) { .attach_dev = rk_iommu_attach_device,drivers/iommu/s390-iommu.c +1
-1@@ -557,6 +557,7 @@ static struct iommu_domain *s390_domain_alloc_paging(struct device *dev) } zdev->end_dma = zdev->start_dma + aperture_size -1 ; + s390_domain->domain.pgsize_bitmap =SZ_4K ; s390_domain->domain.geometry.force_aperture = true; s390_domain->domain.geometry.aperture_start =0 ; s390_domain->domain.geometry.aperture_end =max_tbl_size (s390_domain);@@ -1158,7 +1159,6 @@ static struct iommu_domain blocking_domain = { .domain_alloc_paging = s390_domain_alloc_paging, \ .probe_device = s390_iommu_probe_device, \ .device_group = generic_device_group, \ - .pgsize_bitmap = SZ_4K, \ .get_resv_regions = s390_iommu_get_resv_regions, \ .default_domain_ops = &(const struct iommu_domain_ops ) { \ .attach_dev = s390_iommu_attach_device, \drivers/iommu/sprd-iommu.c +2
-1@@ -143,6 +143,8 @@ static struct iommu_domain *sprd_iommu_domain_alloc_paging(struct device *dev)spin_lock_init (&dom->pgtlock); + dom->domain.pgsize_bitmap =SPRD_IOMMU_PAGE_SIZE ; + dom->domain.geometry.aperture_start =0 ; dom->domain.geometry.aperture_end =SZ_256M -1 ; dom->domain.geometry.force_aperture = true;@@ -410,7 +412,6 @@ static const struct iommu_ops sprd_iommu_ops = { .probe_device = sprd_iommu_probe_device, .device_group = generic_single_device_group, .of_xlate = sprd_iommu_of_xlate, - .pgsize_bitmap = SPRD_IOMMU_PAGE_SIZE, .owner = THIS_MODULE, .default_domain_ops = &(const struct iommu_domain_ops ) { .attach_dev = sprd_iommu_attach_device,drivers/iommu/sun50i-iommu.c +2
-1@@ -697,6 +697,8 @@ sun50i_iommu_domain_alloc_paging(struct device *dev)refcount_set (&sun50i_domain->refcnt,1 ); + sun50i_domain->domain.pgsize_bitmap =SZ_4K ; + sun50i_domain->domain.geometry.aperture_start =0 ; sun50i_domain->domain.geometry.aperture_end =DMA_BIT_MASK (32 ); sun50i_domain->domain.geometry.force_aperture = true;@@ -842,7 +844,6 @@ static int sun50i_iommu_of_xlate(struct device *dev,static const struct iommu_ops sun50i_iommu_ops = { .identity_domain = &sun50i_iommu_identity_domain, - .pgsize_bitmap =SZ_4K , .device_group = generic_single_device_group, .domain_alloc_paging = sun50i_iommu_domain_alloc_paging, .of_xlate = sun50i_iommu_of_xlate,drivers/iommu/tegra-smmu.c +2
-0@@ -318,6 +318,8 @@ static struct iommu_domain *tegra_smmu_domain_alloc_paging(struct device *dev)spin_lock_init (&as->lock); + as->domain.pgsize_bitmap =SZ_4K ; +/* setup aperture */ as->domain.geometry.aperture_start =0 ; as->domain.geometry.aperture_end =0xffffffff ;
drivers/iommu/tegra-smmu.c static const struct iommu_ops tegra_smmu_ops = { · line 1009
Quoted 7 lines
drivers/iommu/tegra-smmu.c +0
-1@@ -1002,7 +1004,6 @@ static const struct iommu_ops tegra_smmu_ops = { .probe_device = tegra_smmu_probe_device, .device_group = tegra_smmu_device_group, .of_xlate = tegra_smmu_of_xlate, - .pgsize_bitmap = SZ_4K, .default_domain_ops = &(const struct iommu_domain_ops ) { .attach_dev = tegra_smmu_attach_dev, .map_pages = tegra_smmu_map,
Best regards
Signature · 2 lines
Marek Szyprowski, PhD Samsung R&D Institute Poland
Jason Gunthorpe
maintainerPATCH v2 5/7 iommu/mtk: Remove iommu_ops pgsize_bitmap
In reply to Jason GunthorpeThis driver just uses a constant, put it in domain_alloc_paging and use the domain's value instead of ops during finalise.
--- drivers/iommu/mtk_iommu.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/iommu/mtk_iommu.c +3 -6
@@ -648,7 +648,7 @@ static int mtk_iommu_domain_finalise(struct mtk_iommu_domain *dom,if (share_dom) { dom->iop = share_dom->iop; dom->cfg = share_dom->cfg; - dom->domain.pgsize_bitmap = share_dom->cfg.pgsize_bitmap; + dom->domain.pgsize_bitmap = share_dom->domain.pgsize_bitmap; goto update_iova_region; }
@@ -656,7 +656,7 @@ static int mtk_iommu_domain_finalise(struct mtk_iommu_domain *dom, .quirks = IO_PGTABLE_QUIRK_ARM_NS | IO_PGTABLE_QUIRK_NO_PERMS | IO_PGTABLE_QUIRK_ARM_MTK_EXT, - .pgsize_bitmap = mtk_iommu_ops.pgsize_bitmap, + .pgsize_bitmap = dom->domain.pgsize_bitmap, .ias = MTK_IOMMU_HAS_FLAG(data->plat_data, IOVA_34_EN) ? 34 : 32, .iommu_dev = data->dev, };
@@ -675,9 +675,6 @@ static int mtk_iommu_domain_finalise(struct mtk_iommu_domain *dom,return -ENOMEM ; } -/* Update our support page sizes bitmap */ - dom->domain.pgsize_bitmap = dom->cfg.pgsize_bitmap; - data->share_dom = dom; update_iova_region:
@@ -697,6 +694,7 @@ static struct iommu_domain *mtk_iommu_domain_alloc_paging(struct device *dev)if (!dom)return NULL ;mutex_init (&dom->mutex); + dom->domain.pgsize_bitmap =SZ_4K |SZ_64K |SZ_1M |SZ_16M ;return &dom->domain; }
@@ -1019,7 +1017,6 @@ static const struct iommu_ops mtk_iommu_ops = { .device_group = mtk_iommu_device_group, .of_xlate = mtk_iommu_of_xlate, .get_resv_regions = mtk_iommu_get_resv_regions, - .pgsize_bitmap = SZ_4K | SZ_64K | SZ_1M | SZ_16M, .owner = THIS_MODULE, .default_domain_ops = &(const struct iommu_domain_ops ) { .attach_dev = mtk_iommu_attach_device,
Signature · 1 line
2.43.0
Re: [PATCH v2 5/7] iommu/mtk: Remove iommu_ops pgsize_bitmap
Il 09/06/25 22:41, Jason Gunthorpe ha scritto:
Quoted 5 lines
This driver just uses a constant, put it in
domain_alloc_pagingand use the domain's value instead of ops during finalise.Reviewed-by Kevin Tian <[email protected]>Signed-off-by Jason Gunthorpe <[email protected]>
Jason Gunthorpe
maintainerPATCH v2 6/7 iommu/qcom: Remove iommu_ops pgsize_bitmap
In reply to Jason GunthorpeThis driver just uses a constant, put it in domain_alloc_paging and use the domain's value instead of ops during init_domain.
--- drivers/iommu/arm/arm-smmu/qcom_iommu.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/iommu/arm/arm-smmu/qcom_iommu.c +2 -4
@@ -229,7 +229,7 @@ static int qcom_iommu_init_domain(struct iommu_domain *domain, goto out_unlock; pgtbl_cfg = (struct io_pgtable_cfg ) { - .pgsize_bitmap = qcom_iommu_ops.pgsize_bitmap, + .pgsize_bitmap = domain->pgsize_bitmap, .ias =32 , .oas =40 , .tlb = &qcom_flush_ops,
@@ -246,8 +246,6 @@ static int qcom_iommu_init_domain(struct iommu_domain *domain, goto out_clear_iommu; } -/* Update the domain's page sizes to reflect the page table format */ - domain->pgsize_bitmap = pgtbl_cfg.pgsize_bitmap; domain->geometry.aperture_end = (1ULL << pgtbl_cfg.ias) -1 ; domain->geometry.force_aperture = true;
@@ -337,6 +335,7 @@ static struct iommu_domain *qcom_iommu_domain_alloc_paging(struct device *dev)mutex_init (&qcom_domain->init_mutex);spin_lock_init (&qcom_domain->pgtbl_lock); + qcom_domain->domain.pgsize_bitmap =SZ_4K |SZ_64K |SZ_1M |SZ_16M ;return &qcom_domain->domain; }
@@ -598,7 +597,6 @@ static const struct iommu_ops qcom_iommu_ops = { .probe_device = qcom_iommu_probe_device, .device_group = generic_device_group, .of_xlate = qcom_iommu_of_xlate, - .pgsize_bitmap = SZ_4K | SZ_64K | SZ_1M | SZ_16M, .default_domain_ops = &(const struct iommu_domain_ops ) { .attach_dev = qcom_iommu_attach_dev, .map_pages = qcom_iommu_map,
Signature · 1 line
2.43.0
Jason Gunthorpe
maintainerPATCH v2 7/7 iommu: Remove ops->pgsize_bitmap
In reply to Jason GunthorpeNo driver uses it now, remove the core code.
--- drivers/iommu/iommu.c | 7 ------- include/linux/iommu.h | 2 -- 2 files changed, 9 deletions(-)
drivers/iommu/iommu.c +0 -7
@@ -2002,13 +2002,6 @@ static void iommu_domain_init(struct iommu_domain *domain, unsigned int type, domain->owner = ops;if (!domain->ops) domain->ops = ops->default_domain_ops; - -/* -* If not already set, assume all sizes by default; the driver -* may override this later -*/ -if (!domain->pgsize_bitmap) - domain->pgsize_bitmap = ops->pgsize_bitmap; } static struct iommu_domain *
include/linux/iommu.h +0 -2
@@ -604,7 +604,6 @@ iommu_copy_struct_from_full_user_array(void *kdst, size_t kdst_entry_size,* It is required to call iommufd_viommu_alloc() helper for * a bundled allocation of the core and the driver structures, * using the given @ictx pointer. -* @pgsize_bitmap: bitmap of all possible supported page sizes * @owner: Driver module providing these ops * @identity_domain: An always available, always attachable identity * translation.
@@ -659,7 +658,6 @@ struct iommu_ops { struct iommufd_ctx *ictx, unsigned int viommu_type);const struct iommu_domain_ops *default_domain_ops; -unsigned long pgsize_bitmap;struct module *owner;struct iommu_domain *identity_domain;struct iommu_domain *blocked_domain;
Signature · 1 line
2.43.0
Joerg Roedel
maintainerRe: [PATCH v2 7/7] iommu: Remove ops->pgsize_bitmap
Hi Jason,
Quoted 1 line · Jason Gunthorpe
No driver uses it now, remove the core code.
That is actually not true, the MSM driver still uses it, and this patch breaks my arm32 compile tests. Please send a fix for this driver so that I can put it on-top.
Regards,
Joerg
Jason Gunthorpe
maintainerRe: [PATCH v2 7/7] iommu: Remove ops->pgsize_bitmap
Quoted 8 lines · Joerg Roedel
Hi Jason,
Quoted 1 line · Jason Gunthorpe
No driver uses it now, remove the core code.
That is actually not true, the MSM driver still uses it, and this patch breaks my arm32 compile tests. Please send a fix for this driver so that I can put it on-top.
I'm really surprised the build bot didn't catch this, I'm sure it ran on this series. I notice msm is not in the arm32 defconfig, maybe that is why.
Jason
Quoted 22 lines · Jason Gunthorpe
Now that all drivers are using
domain_alloc_paging()and dev is never NULL, we can have all drivers correctly set domain.pgsize_bitmap during their allocation function.There are a few oddities that have accumulated here over past changes:
- Some drivers always set domain.pgsize_bitmap during their
domain_alloc_paging()call but still provide a value in ops. This is dead code, delete it.- Some drivers calculate a system global
pgsize_bitmapin the ops, but it is now trivial to use the per-instance value instead. In several cases this is dead code, delete it. This also allows constifying the ops in these drivers as a hardening measure- Some drivers have a fixed
pgsize_bitmap, put it next to setting up the geometry in theirdomain_alloc_paging()functions.- Finally a few drivers still use ops because they have a delayed finalize operation. Set the constant
pgsize_bitmapin thedomain_alloc_paging().
Quoted 7 lines
Then remove ops.pgsize_bitmap.
This is based on iommu next, and must go after the virtio
domain_alloc_paging()conversion.v2:
- Rebase on v6.16-rc1
Sanity tests with SMMUv3 look good.
Quoted 8 lines
Jason Gunthorpe (7):
qiommu/arm-smmu-v3: Removeiommu_opspgsize_bitmapiommu/arm-smmu: Removeiommu_opspgsize_bitmap
iommu: Remove ops.pgsize_bitmap from drivers that don't use it
iommu: Removeiommu_opspgsize_bitmapfrom simple drivers iommu/mtk: Removeiommu_opspgsize_bitmapiommu/qcom: Removeiommu_opspgsize_bitmap
iommu: Removeops->pgsize_bitmap
Applied, thanks Jason.