[PATCH] iommu/rockchip: Drop global rk_ops in favor of per-device ops
Shawn Lin
shawn.lin at rock-chips.com
Tue Mar 10 02:33:18 PDT 2026
Hi Simon,
在 2026/03/10 星期二 16:48, Simon Xue 写道:
> The driver currently uses a global rk_ops pointer, forcing all IOMMU
> instances to share the same operations. This restricts the driver from
> supporting SoCs that might integrate different versions of IOMMU hardware.
>
> Since the IOMMU framework passes the master device information to
> iommu_paging_domain_alloc(), the global variable is no longer needed.
>
> Fix this by moving rk_ops into struct rk_iommu and struct rk_iommu_domain.
> Initialize it per-device during probe via of_device_get_match_data(),
> and replace all global references with the instance-specific pointers.
>
> Signed-off-by: Simon Xue <xxm at rock-chips.com>
> ---
...
> SPAGE_SIZE, DMA_TO_DEVICE);
> @@ -1212,15 +1215,7 @@ static int rk_iommu_probe(struct platform_device *pdev)
> iommu->num_mmu = 0;
>
> ops = of_device_get_match_data(dev);
Could you remove this one-time-used ops variable and use iommu->rk_ops
directly. The other parts make sense to me.
> - if (!rk_ops)
> - rk_ops = ops;
> -
> - /*
> - * That should not happen unless different versions of the
> - * hardware block are embedded the same SoC
> - */
> - if (WARN_ON(rk_ops != ops))
> - return -EINVAL;
> + iommu->rk_ops = ops;
>
> iommu->bases = devm_kcalloc(dev, num_res, sizeof(*iommu->bases),
> GFP_KERNEL);
> @@ -1286,7 +1281,7 @@ static int rk_iommu_probe(struct platform_device *pdev)
> goto err_pm_disable;
> }
>
> - dma_set_mask_and_coherent(dev, rk_ops->dma_bit_mask);
> + dma_set_mask_and_coherent(dev, iommu->rk_ops->dma_bit_mask);
>
> err = iommu_device_sysfs_add(&iommu->iommu, dev, NULL, dev_name(dev));
> if (err)
>
More information about the Linux-rockchip
mailing list