Messages in this thread | | | Date | Wed, 13 Apr 2022 19:57:33 +0800 | From | Lu Baolu <> | Subject | Re: [PATCH RFC v3 08/12] iommu/sva: Use attach/detach_pasid_dev in SVA interfaces |
| |
On 2022/4/13 7:36, Tian, Kevin wrote: >> From: Lu Baolu <baolu.lu@linux.intel.com> >> 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...
Sharing domain for compatible devices is valuable when the domain supports map/unmap operations. That can reduce the number of map/unmap calls and the resulting synchronization of IOTLB. But for SVA case, it's a dumb domain which only provides attach/detach operations.
A similar case could be found on pass-through DMA domains. The iommu core allocates a default domain for each group although all the domains represent a same page table for the compatible devices. The VT-d driver optimizes this by exporting a static identity domain.
Anyway, I am open for this. I can add a compatible domain list if most of you like that way. :-)
Best regards, baolu
| |