Re: [PATCH 04/12] iommufd: Pass parent hwpt and user_data to iommufd_hw_pagetable_alloc()

From: Jason Gunthorpe
Date: Fri Mar 10 2023 - 12:50:03 EST


On Fri, Mar 10, 2023 at 10:10:56AM +0800, Baolu Lu wrote:
> > @@ -54,14 +58,20 @@ int iommufd_hw_pagetable_enforce_cc(struct iommufd_hw_pagetable *hwpt)
> > */
> > struct iommufd_hw_pagetable *
> > iommufd_hw_pagetable_alloc(struct iommufd_ctx *ictx, struct iommufd_ioas *ioas,
> > - struct iommufd_device *idev, bool immediate_attach)
> > + struct iommufd_device *idev,
> > + struct iommufd_hw_pagetable *parent,
> > + void *user_data, bool immediate_attach)
> > {
> > const struct iommu_ops *ops = dev_iommu_ops(idev->dev);
> > + struct iommu_domain *parent_domain = NULL;
> > struct iommufd_hw_pagetable *hwpt;
> > int rc;
> > lockdep_assert_held(&ioas->mutex);
> > + if (parent && !ops->domain_alloc_user)
> > + return ERR_PTR(-EOPNOTSUPP);
>
> My understanding here is that we are checking whether domain_alloc_user
> is required. It seems that as long as the caller inputs a valid
> user_data or parent, domain_alloc_user is required. If so,
>
> if ((user_data || parent) && !ops->domain_alloc_user)
> return ERR_PTR(-EOPNOTSUPP);

Yes

Jason