Re: [PATCH V2 02/11] iommufd: Move igroup allocation to a function

From: Jacob Pan

Date: Mon Mar 23 2026 - 18:53:34 EST


Hi Mostafa,

On Sun, 22 Mar 2026 09:41:17 +0000
Mostafa Saleh <smostafa@xxxxxxxxxx> wrote:

> On Thu, Mar 12, 2026 at 08:56:28AM -0700, Jacob Pan wrote:
> > From: Jason Gunthorpe <jgg@xxxxxxxxxx>
> >
> > So it can be reused in the next patch which allows binding to
> > noiommu device.
> >
> > Signed-off-by: Jason Gunthorpe <jgg@xxxxxxxxxx>
> > Signed-off-by: Jacob Pan <jacob.pan@xxxxxxxxxxxxxxxxxxx>
> > ---
> > drivers/iommu/iommufd/device.c | 48
> > +++++++++++++++++++++------------- 1 file changed, 30
> > insertions(+), 18 deletions(-)
> >
> > diff --git a/drivers/iommu/iommufd/device.c
> > b/drivers/iommu/iommufd/device.c index 344d620cdecc..54d73016468f
> > 100644 --- a/drivers/iommu/iommufd/device.c
> > +++ b/drivers/iommu/iommufd/device.c
> > @@ -30,8 +30,9 @@ static void iommufd_group_release(struct kref
> > *kref)
> > WARN_ON(!xa_empty(&igroup->pasid_attach));
> >
> > - xa_cmpxchg(&igroup->ictx->groups,
> > iommu_group_id(igroup->group), igroup,
> > - NULL, GFP_KERNEL);
> > + if (igroup->group)
> > + xa_cmpxchg(&igroup->ictx->groups,
> > iommu_group_id(igroup->group),
> > + igroup, NULL, GFP_KERNEL);
>
> Is that a separate fix or perhaps belongs to the next patch making
> it possible to have NULL groups.
Yes, I agree. NULL groups are not possible here. Should be merged with
the next patch.