RE: [PATCH RFC v3 08/12] iommu/sva: Use attach/detach_pasid_dev in SVA interfaces
From: Tian, Kevin
Date: Tue Apr 12 2022 - 19:45:48 EST
> From: Lu Baolu <baolu.lu@xxxxxxxxxxxxxxx>
> Sent: Tuesday, April 12, 2022 8:53 PM
>
> >
> >> + if (!handle) {
> >> + ret = -ENOMEM;
> >> + goto out_put_ioas;
> >> + }
> >> +
> >> + /* The reference to ioas will be kept until domain free. */
> >> + domain = iommu_sva_alloc_domain(dev, ioas);
> >
> > Shouldn't we first try whether existing domains are compatible to this
> > device?
>
> If we think that here domain represents a hardware pagetable actually
> used by IOMMU for a {device, pasid}, we are able to use per-{device,
> pasid} domain without checking compatibility. Sharing a domain among
> devices under the same IOMMU may be an optimization. That could be done
> in the IOMMU driver just like what vt-d driver is doing for pass-through
> DMA domains.
>
there is only one hardware page table per mm in this case. Multiple domains
are required only due to compatibility reason as Jason/Robin pointed out
in SMMU case. Given all other places create multiple domains per ioas only
upon incompatibility, probably it's more consistent to doing so in this path
too...