Re: [PATCH 5/6] iommu: Add Broadcom BCM2712 IOMMU driver

From: Jason Gunthorpe

Date: Sun Jul 12 2026 - 18:11:31 EST


On Sun, Jul 12, 2026 at 10:18:55PM +0100, Daniel Drake wrote:
> +static int bcm2712_iommu_of_xlate(struct device *dev,
> + const struct of_phandle_args *args)
> +{
> + struct platform_device *iommu_dev = of_find_device_by_node(args->np);
> + struct bcm2712_iommu *mmu = platform_get_drvdata(iommu_dev);
> +
> + dev_iommu_priv_set(dev, mmu);
> + return 0;
> +}

Any chance this could work the way that smmuv3 does? I view it as the
more modern example..

> +static int bcm2712_iommu_map_pages(struct iommu_domain *domain,
> + unsigned long iova, phys_addr_t paddr,
> + size_t pgsize, size_t pgcount, int prot,
> + gfp_t gfp, size_t *mapped)
> +{
> + struct bcm2712_iommu_domain *mydomain = to_bcm2712_domain(domain);
> + struct pt_iommu *pt = &mydomain->pt.iommu;
> +
> + return pt->ops->map_range(pt, bcm2712_iova_to_offset(mydomain, iova),
> + paddr, pgsize * pgcount, prot, gfp, mapped);
> +}

These ops should not be present, the iommpt provides the ops directly
through a macro;

> +static const struct iommu_ops bcm2712_iommu_ops = {
> + .identity_domain = &bcm2712_identity_domain,
> + .domain_alloc_paging = bcm2712_iommu_domain_alloc,
> + .probe_device = bcm2712_iommu_probe_device,
> + .device_group = generic_single_device_group,
> + .of_xlate = bcm2712_iommu_of_xlate,
> + .default_domain_ops = &(const struct iommu_domain_ops) {
> + .attach_dev = bcm2712_iommu_attach_dev,
> + .iotlb_sync = bcm2712_iommu_sync,
> + .iotlb_sync_map = bcm2712_iommu_sync_map,
> + .flush_iotlb_all = bcm2712_iommu_sync_all,
> + .free = bcm2712_iommu_domain_free,
> + .map_pages = bcm2712_iommu_map_pages,
> + .unmap_pages = bcm2712_iommu_unmap_pages,
> + .iova_to_phys = bcm2712_iova_to_phys,
> + },

"default_domain_ops" should ideally be split out to a "paging domain
ops" static and set directly during alloc_paging. They are not really
"default" anymore if the driver has unique ops for every domain type.

Then use something like:

IOMMU_PT_DOMAIN_OPS(bcm2712),

To define all the page table related ops automatically.

Any chace the HW can do a blocking_domain, or is the only way to do
that with an empty paging domain?

Jason