Message ID | 20241104132033.14027-4-yi.l.liu@intel.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | Support attaching PASID to the blocked_domain | expand |
On Mon, Nov 04, 2024 at 05:20:29AM -0800, Yi Liu wrote: > The iommu drivers are on the way to detach pasid by attaching to the blocked > domain. However, this cannot be done in one shot. During the transition, iommu > core would select between the remove_dev_pasid op and the blocked domain. > > Suggested-by: Kevin Tian <kevin.tian@intel.com> > Suggested-by: Jason Gunthorpe <jgg@nvidia.com> > Signed-off-by: Yi Liu <yi.l.liu@intel.com> > --- > drivers/iommu/iommu.c | 16 ++++++++++++++-- > 1 file changed, 14 insertions(+), 2 deletions(-) Reviewed-by: Jason Gunthorpe <jgg@nvidia.com> Jason
On 11/4/2024 6:50 PM, Yi Liu wrote: > The iommu drivers are on the way to detach pasid by attaching to the blocked > domain. However, this cannot be done in one shot. During the transition, iommu > core would select between the remove_dev_pasid op and the blocked domain. > > Suggested-by: Kevin Tian <kevin.tian@intel.com> > Suggested-by: Jason Gunthorpe <jgg@nvidia.com> > Signed-off-by: Yi Liu <yi.l.liu@intel.com> Reviewed-by: Vasant Hegde <vasant.hegde@amd.com> -Vasant
> From: Liu, Yi L <yi.l.liu@intel.com> > Sent: Monday, November 4, 2024 9:20 PM > > @@ -3404,8 +3404,18 @@ static void iommu_remove_dev_pasid(struct > device *dev, ioasid_t pasid, > struct iommu_domain *domain) > { > const struct iommu_ops *ops = dev_iommu_ops(dev); > + struct iommu_domain *blocked_domain = ops->blocked_domain; > + int ret = 1; > + > + if (blocked_domain && blocked_domain->ops->set_dev_pasid) { > + ret = blocked_domain->ops->set_dev_pasid(blocked_domain, > + dev, pasid, domain); > + } else if (ops->remove_dev_pasid) { > + ops->remove_dev_pasid(dev, pasid, domain); > + ret = 0; > + } > given ops->remove_dev_pasid is already checked at attach time here could just call it w/o further check. Reviewed-by: Kevin Tian <kevin.tian@intel.com>
On 2024/11/7 17:35, Tian, Kevin wrote: >> From: Liu, Yi L <yi.l.liu@intel.com> >> Sent: Monday, November 4, 2024 9:20 PM >> >> @@ -3404,8 +3404,18 @@ static void iommu_remove_dev_pasid(struct >> device *dev, ioasid_t pasid, >> struct iommu_domain *domain) >> { >> const struct iommu_ops *ops = dev_iommu_ops(dev); >> + struct iommu_domain *blocked_domain = ops->blocked_domain; >> + int ret = 1; >> + >> + if (blocked_domain && blocked_domain->ops->set_dev_pasid) { >> + ret = blocked_domain->ops->set_dev_pasid(blocked_domain, >> + dev, pasid, domain); >> + } else if (ops->remove_dev_pasid) { >> + ops->remove_dev_pasid(dev, pasid, domain); >> + ret = 0; >> + } >> > > given ops->remove_dev_pasid is already checked at attach time > here could just call it w/o further check. yep. A driver does not pass that check should not get here at all. So either should be valid. > Reviewed-by: Kevin Tian <kevin.tian@intel.com>
diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index 21320578d801..e8b2850cc61f 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -3404,8 +3404,18 @@ static void iommu_remove_dev_pasid(struct device *dev, ioasid_t pasid, struct iommu_domain *domain) { const struct iommu_ops *ops = dev_iommu_ops(dev); + struct iommu_domain *blocked_domain = ops->blocked_domain; + int ret = 1; + + if (blocked_domain && blocked_domain->ops->set_dev_pasid) { + ret = blocked_domain->ops->set_dev_pasid(blocked_domain, + dev, pasid, domain); + } else if (ops->remove_dev_pasid) { + ops->remove_dev_pasid(dev, pasid, domain); + ret = 0; + } - ops->remove_dev_pasid(dev, pasid, domain); + WARN_ON(ret); } static int __iommu_set_group_pasid(struct iommu_domain *domain, @@ -3464,7 +3474,9 @@ int iommu_attach_device_pasid(struct iommu_domain *domain, int ret; if (!domain->ops->set_dev_pasid || - !ops->remove_dev_pasid) + (!ops->remove_dev_pasid && + (!ops->blocked_domain || + !ops->blocked_domain->ops->set_dev_pasid))) return -EOPNOTSUPP; if (!group)
The iommu drivers are on the way to detach pasid by attaching to the blocked domain. However, this cannot be done in one shot. During the transition, iommu core would select between the remove_dev_pasid op and the blocked domain. Suggested-by: Kevin Tian <kevin.tian@intel.com> Suggested-by: Jason Gunthorpe <jgg@nvidia.com> Signed-off-by: Yi Liu <yi.l.liu@intel.com> --- drivers/iommu/iommu.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)