Re: [PATCH v1 5/8] iommu/amd: Use iommu_attach/detach_device()

From: Jason Gunthorpe
Date: Tue Feb 15 2022 - 09:37:59 EST


On Tue, Feb 15, 2022 at 10:11:01AM +0100, Joerg Roedel wrote:

> > But, then, the requirement is that nobody is using the dma API when we
> > make this change?
>
> That is the tricky part. DMA-API keeps working after the change is made,
> because the new domain is also direct mapped. The new domain just has
> the ability to assign host page-tables to device PASIDs, so that DMA
> requests with a PASID TLP will be remapped.

From, what you've described this is also a good use case for the
replace_group idea..

Using Lu's series we'd:
- Require the group to be in DMA-API mode. We know this is the case
because of how we got here from probe()
- Use the 'replace group's domain' API to switch the group from one
identity translation domain to another identity translation domain
- Rely on the DMA-API refcount to block VFIO/etc instead of checking
for the default domain
- Restore the default domain when all the DMA-API mode drivers unprobe

That is, if Robin's idea to just get the right domain in the first
place doesn't work.

Anyhow, given all this I think this patch is not OK as is.

Thanks,
Jason