Re: [PATCH v10 08/12] iommu/sva: Refactoring iommu_sva_bind/unbind_device()
From: Jason Gunthorpe
Date: Mon Jul 25 2022 - 10:46:17 EST
On Mon, Jul 25, 2022 at 10:52:40AM +0100, Jean-Philippe Brucker wrote:
> > The iommu core provides the interface to retrieve attached domain with a
> > {device, pasid} pair. Therefore in the smmuv3 driver, the set_dev_pasid
> > could do like this:
>
> Thanks for the example, yes I can do something like this. I maintain that
> attach+detach is clearer, but as long as it can be made to work, fine by
> me
Except it is not clearer, because there isn't actually a detatch in
our model - many things already got messed up in the non-pasid case
because of this confusing assumption.
We have only a "set" operation and set moves between any two domain
configurations.
You don't need to call attach/detach pairs, just repeated attaches,
which is how the normal path works. detach is called in the legacy
flow for the NULL domain
So, creating a pair invites the wrong idea that they actually are a
pair.
> > The check of "(!domain || domain->type == IOMMU_DOMAIN_UNMANAGED)" looks
> > odd, but could get cleaned up after a real blocking domain is added.
> > Then, we can simply check "domain->type == IOMMU_DOMAIN_BLOCKING".
So this is probably a good reason enough not to do it yet, though it
would be nice to get a proper blocking domain concept in the SMMU
driver to support VFIO, it could be done later.
Jason