Re: [PATCH v3 01/17] iommu: Add new iommu op to create domains owned by userspace

From: Nicolin Chen
Date: Wed Aug 02 2023 - 22:34:31 EST


On Fri, Jul 28, 2023 at 01:56:05PM -0300, Jason Gunthorpe wrote:
> On Fri, Jul 28, 2023 at 09:37:21AM +0000, Tian, Kevin wrote:
> > > From: Yi Liu <yi.l.liu@xxxxxxxxx>
> > > Sent: Monday, July 24, 2023 7:04 PM
> > >
> > > + * @domain_alloc_user: allocate a user iommu domain corresponding to
> > > the input
> > > + * @hwpt_type that is defined as enum iommu_hwpt_type in the
> > > + * include/uapi/linux/iommufd.h. A returning domain will be
> > > + * set to an IOMMU_DOMAIN_NESTED type, upon valid
> > > @user_data
> > > + * and @parent that is a kernel-managed domain. Otherwise,
> > > + * it will be set to an IOMMU_DOMAIN_UNMANAGED type.
> > > Return
> > > + * ERR_PTR on allocation failure.
> >
> > "If @user_data is valid and @parent points to a kernel-managed domain,
> > the returning domain is set to IOMMU_DOMAIN_NESTED type. Otherwise
> > it is set to IOMMU_DOMAIN_UNMANAGED type."
>
> "If @user_data is valid and @parent points to a kernel-managed domain,
> then the returned domain must be the IOMMU_DOMAIN_NESTED type. Otherwise
> the returned domain is IOMMU_DOMAIN_UNMANAGED."
>
> Notice the detail that this API expects the driver to set the type and
> fully initialize the domain, including the generic iommu_domain
> struct, which is different than alloc_domain.
>
> When we implement this in drivers we should tidy this so all the alloc
> flows fully initialize the domain internally.

Changed to:

+ * @domain_alloc_user: allocate a user iommu domain corresponding to the input
+ * @hwpt_type that is defined as enum iommu_hwpt_type in the
+ * include/uapi/linux/iommufd.h. Different from domain_alloc
+ * it requires iommu driver to fully initialize a new domain
+ * including the generic iommu_domain struct. Upon success,
+ * if the @user_data is valid and the @parent points to a
+ * kernel-managed domain, the type of the new domain must be
+ * IOMMU_DOMAIN_NESTED, otherwise be IOMMU_DOMAIN_UNMANAGED.
+ * Upon failure, ERR_PTR must be returned.

Thanks
Nic