]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
iommu: Remove iommu_ops pgsize_bitmap from simple drivers
authorJason Gunthorpe <jgg@nvidia.com>
Mon, 9 Jun 2025 20:41:28 +0000 (17:41 -0300)
committerJoerg Roedel <joerg.roedel@amd.com>
Fri, 27 Jun 2025 06:55:57 +0000 (08:55 +0200)
These drivers just have a constant value for their page size, move it
into their domain_alloc_paging function before setting up the geometry.

Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Acked-by: Niklas Schnelle <schnelle@linux.ibm.com> # for s390-iommu.c
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Acked-by: Marek Szyprowski <m.szyprowski@samsung.com> # for exynos-iommu.c
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Acked-by: Thierry Reding <treding@nvidia.com>
Acked-by: Chen-Yu Tsai <wens@csie.org> # sun50i-iommu.c
Tested-by: Nicolin Chen <nicolinc@nvidia.com>
Link: https://lore.kernel.org/r/4-v2-68a2e1ba507c+1fb-iommu_rm_ops_pgsize_jgg@nvidia.com
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
drivers/iommu/exynos-iommu.c
drivers/iommu/ipmmu-vmsa.c
drivers/iommu/mtk_iommu_v1.c
drivers/iommu/omap-iommu.c
drivers/iommu/rockchip-iommu.c
drivers/iommu/s390-iommu.c
drivers/iommu/sprd-iommu.c
drivers/iommu/sun50i-iommu.c
drivers/iommu/tegra-smmu.c

index fcb6a0f7c08275083065e5e311f190a85dd1f5f4..b62a8f35c3e8516ead6a41f92dc7c8dc057986a8 100644 (file)
@@ -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,
index 90341b24a811559876d973a7663c724dd5ac9e30..ffa892f6571406f92b5c05635da167d0c84e0db1 100644 (file)
@@ -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,
index 66824982e05fbfdda224276ad41b90f9d5f9ca4e..496cfe37243ac270bc4826f3e63d75ccfeffdb78 100644 (file)
@@ -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,
index 3c62337f43c67720a15b67e8b610da7886f6f39c..21c218976143ef949eaee17c94748deef275efe2 100644 (file)
@@ -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,
index 22f74ba33a0e388a4f9d2ad7928e12c3e049a8da..f4a5ad096343ab125a2e6e7b1852ea157a487c4e 100644 (file)
@@ -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,
index 433b59f435302bdcb1fbe045cfb79b1d08d41581..9c80d61deb2c0bba4fae59129323cc90f998693d 100644 (file)
@@ -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, \
index 941d1f361c8cda5a9175f073d77cbacdd60f4146..c7ca1d8a0b153037cb22700948bf9b3bf9510518 100644 (file)
@@ -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,
index 76c9620af4bba898483032d735686eb8442ac2d2..de10b569d9a9403a6476d63b256dbc52489d4bf0 100644 (file)
@@ -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,
index e58fe9d8b9e77e221291a86e60e640b65397d5e8..36cdd5fbab0779f9344d14d31c28f54429da5608 100644 (file)
@@ -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,