Re: [PATCH 1/1] iommu/vt-d: Fix missed device TLB cache tag

From: Jason Gunthorpe
Date: Fri Jun 21 2024 - 08:58:46 EST


On Fri, Jun 21, 2024 at 09:44:27AM +0800, Baolu Lu wrote:

> Enabling/Disabling ATS on domain attach seems like a feasible approach.
> The ATS requirement information (required/disallowed/neutral) could be
> included as an opt-in option in the domain attach path. This likely
> applies to PASID attachments and VF/PF devices. The iommu driver
> maintains the per-device ATS refcount and enables it for the first
> request and disables it after the last one. The attachment fails
> accordingly if the hardware capability doesn't match the domain attach
> requirement.

Yes. if we do this the core code would have to take some
responsibility to manage ATS and PASID needs together. It is a bit
tricky potentially, but probably better than having drivers repeat the
same logic.

But it probably does require the drivers actually implement hitless
replace. I'd imagin a core driven flow is something like:

- Install an identity domain without ATS
- Decide we want a SVA pasid
- Replace the identiy domain with the same identity domain and ATS
- Install the SVA pasid

(assuming we want some policy like only enable ATS when needed)

> Perhaps we could further include PRI as a domain attach option,
> indicating that the domain requires IOPF functionality. This would allow
> us to simplify the SVA and IOMMUFD by hiding device and IOMMU details
> within the IOMMU driver.

This is my desire, if the domain has a fault handler then the driver
should just make PRI work on attach or fail attach.

None of the weird feature stuff is needed. We are getting closer, I
think the SVA enable stuff is almost all NO-OP'd.

Jason