Re: [PATCH rc v7 5/6] iommu: Fix ATS invalidation timeouts during __iommu_remove_group_pasid()

From: Nicolin Chen

Date: Fri Apr 24 2026 - 15:40:10 EST


On Fri, Apr 24, 2026 at 02:23:17PM +0800, Baolu Lu wrote:
> On 4/19/26 07:41, Nicolin Chen wrote:
> > @@ -3554,7 +3554,8 @@ static void __iommu_remove_group_pasid(struct iommu_group *group,
> > struct group_device *device;
> > for_each_group_device(group, device) {
> > - if (device->dev->iommu->max_pasids > 0)
> > + /* Device might be already detached for a device recovery */
> > + if (!device->blocked && device->dev->iommu->max_pasids > 0)
> > iommu_remove_dev_pasid(device->dev, pasid, domain);
> > }
> > }
>
> If that is the case, why not add the same logic to the set_group_pasid
> path? For example:
>
> diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
> index 61c12ba78206..42a979ee0ced 100644
> --- a/drivers/iommu/iommu.c
> +++ b/drivers/iommu/iommu.c
> @@ -3532,7 +3532,7 @@ static int __iommu_set_group_pasid(struct iommu_domain
> *domain,
> int ret;
>
> for_each_group_device(group, device) {
> - if (device->dev->iommu->max_pasids > 0) {
> + if (!device->blocked && device->dev->iommu->max_pasids > 0)
> {
> ret = domain->ops->set_dev_pasid(domain,
> device->dev,
> pasid, old);

Because the policy is to reject concurrent RID/PASID attachments
on the group if any of its gdevs is resetting.

So callers of __iommu_set_group_pasid() check group->recovery_cnt
and reject with -EBUSY.

__iommu_remove_group_pasid() is exempted, because detach() cannot
fail. And it's okay to bypass a resetting gdev since it's already
detached.

Nicolin