From: Baolu Lu <baolu.lu@xxxxxxxxxxxxxxx>
Sent: Sunday, July 24, 2022 5:14 PM
On 2022/7/23 22:11, Jason Gunthorpe wrote:
struct device *dev,+void iommu_detach_device_pasid(struct iommu_domain *domain,
+ ioasid_t pasid)I still really this OP, it is nonsense to invoke 'block_dev_pasid' on
+{
+ struct iommu_group *group = iommu_group_get(dev);
+
+ mutex_lock(&group->mutex);
+ domain->ops->block_dev_pasid(domain, dev, pasid);
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.