Messages in this thread | | | From | "Tian, Kevin" <> | Subject | RE: [PATCH v10 04/12] iommu: Add attach/detach_dev_pasid iommu interface | Date | Mon, 25 Jul 2022 07:46:43 +0000 |
| |
> From: Baolu Lu <baolu.lu@linux.intel.com> > Sent: Sunday, July 24, 2022 5:14 PM > > On 2022/7/23 22:11, Jason Gunthorpe wrote: > >> +void iommu_detach_device_pasid(struct iommu_domain *domain, > struct device *dev, > >> + ioasid_t pasid) > >> +{ > >> + struct iommu_group *group = iommu_group_get(dev); > >> + > >> + mutex_lock(&group->mutex); > >> + domain->ops->block_dev_pasid(domain, dev, pasid); > > I still really this OP, it is nonsense to invoke 'block_dev_pasid' on > > a domain, it should be on the iommu ops and it should not take in a > > domain parameter. This is why I prefer we write it as > > > > domain->ops->set_dev_pasid(group->blocking_domain, dev, pasid); > > > > I originally plan to refactor this after both Intel and ARM SMMUv3 > drivers have real blocking domain supports. After revisiting this, it > seems that the only difficulty is how to check whether a domain is a > blocking domain. I am going to use below checking code: > > + /* > + * Detach the domain if a blocking domain is set. Check the > + * right domain type once the IOMMU driver supports a real > + * blocking domain. > + */ > + if (!domain || domain->type == IOMMU_DOMAIN_UNMANAGED) { > > Does this work for you? >
Or you can call __iommu_group_alloc_blocking_domain() in the sva path and then just check whether the domain is equal to group->blocking_domain here.
| |