Re: [PATCH rc v7 3/6] iommu: Fix pasid attach in pci_dev_reset_iommu_prepare/done()

From: Nicolin Chen

Date: Fri Apr 24 2026 - 15:29:18 EST


On Fri, Apr 24, 2026 at 01:49:52PM +0800, Baolu Lu wrote:
> On 4/19/26 07:41, Nicolin Chen wrote:
> > - xa_for_each_start(&group->pasid_array, pasid, entry, 1)
> > - WARN_ON(__iommu_set_group_pasid(
> > - pasid_array_entry_to_domain(entry), group, pasid,
> > - group->blocking_domain));
> > + if (pdev->dev.iommu->max_pasids > 0) {
> > + xa_for_each_start(&group->pasid_array, pasid, entry, 1) {
> > + struct iommu_domain *pasid_dom =
> > + pasid_array_entry_to_domain(entry);
> > +
> > + WARN_ON(pasid_dom->ops->set_dev_pasid(
> > + pasid_dom, &pdev->dev, pasid,
> > + group->blocking_domain));
> > + }
> > + }
> > if (!WARN_ON(group->recovery_cnt == 0))
> > group->recovery_cnt--;
>
> I don’t think this patch fixes a real-world issue though it has the
> "Fixes:" tag. Logically, if pdev->dev.iommu->max_pasids == 0, there
> should be no domains attached to any pasid. Consequently,
> group->pasid_array should be empty, and the xa_for_each loop is just a
> no-op.
>
> I understand this was a result of Sashko's review comments, but I don't
> think it worth a formal fix. I admit I might be overlooking something,
> so please correct me if I am wrong.

The max_pasids check is a small thing, to match other callers.

The fix is replacing __iommu_set_group_pasid() with set_dev_pasid(),
because this path shouldn't change the group-level pasid domains.

Thanks
Nicolin