[PATCH v6 00/25] iommu: Make default_domain's mandatory

Jason Gunthorpe jgg at nvidia.com
Tue Aug 15 03:30:25 AEST 2023


On Mon, Aug 14, 2023 at 04:43:23PM +0800, Baolu Lu wrote:

> > This is on github:https://github.com/jgunthorpe/linux/commits/iommu_all_defdom
> 
> It seems that after this series, all ARM iommu drivers are able to
> support the IDENTITY default domain, hence perhaps we can remove below
> code?

Yes, but this code is still used

> If I remember it correctly, the background of this part of code is
> that some arm drivers didn't support IDENTITY domain, so fall back to
> DMA domain if IDENTITY domain allocation fails.

Not quite..

	if (req_type)
		return __iommu_group_alloc_default_domain(group, req_type);

req_type == 0 can still happen because it depends on what
def_domain_type returns, which is still 0 in alot of cases

	/* The driver gave no guidance on what type to use, try the default */
	dom = __iommu_group_alloc_default_domain(group, iommu_def_domain_type);
	if (dom)
		return dom;

So we try the default which might be IDENTITY/DMA/DMA_FQ - still have
to do this.

	/* Otherwise IDENTITY and DMA_FQ defaults will try DMA */
	if (iommu_def_domain_type == IOMMU_DOMAIN_DMA)
		return NULL;
	dom = __iommu_group_alloc_default_domain(group, IOMMU_DOMAIN_DMA);
	if (!dom)
		return NULL;

	pr_warn("Failed to allocate default IOMMU domain of type %u for group %s - Falling back to IOMMU_DOMAIN_DMA",
		iommu_def_domain_type, group->name);

And this hunk is primarily a fallback in case the DMA_FQ didn't
work. Then we try normal DMA.

That it also protected against not implementing IDENTITY is a side
effect, so I think we have to keep all of this still.

Jason


More information about the Linuxppc-dev mailing list