On 2022-02-14 14:39, Joerg Roedel wrote:
On Mon, Feb 14, 2022 at 09:03:13AM -0400, Jason Gunthorpe wrote:
Groups should disappear into an internal implementation detail, not be
so prominent in the API.
Not going to happen, IOMMU groups are ABI and todays device assignment
code, including user-space, relies on them.
Groups implement and important aspect of hardware IOMMUs that the API
can not abstract away: That there are devices which share the same
request-id.
This is not an issue for devices concerned by iommufd, but for legacy
device assignment it is. The IOMMU-API needs to handle both in a clean
API, even if it means that drivers need to lookup the sub-group of a
device first.
And I don't see how a per-device API can handle both in a device-centric
way. For sure it is not making it 'device centric but operate on groups
under the hood'.
Arguably, iommu_attach_device() could be renamed something like
iommu_attach_group_for_dev(), since that's effectively the semantic that
all the existing API users want anyway (even VFIO at the high level -
the group is the means for the user to assign their GPU/NIC/whatever
device to their process, not the end in itself). That's just a lot more
churn.
It's not that callers should be blind to the entire concept of groups
altogether - they remain a significant reason why iommu_attach_device()
might fail, for one thing - however what callers really shouldn't need
to be bothered with is the exact *implementation* of groups. I do
actually quite like the idea of refining the group abstraction into
isolation groups as a superset of alias groups, but if anything that's a
further argument for not having the guts of the current abstraction
exposed in places that don't need to care - otherwise that would be
liable to be a microcosm of this series in itself: widespread churn vs.
"same name, new meaning" compromises.
Robin.