Message ID | 20230919092523.39286-2-yi.l.liu@intel.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | iommufd support allocating nested parent domain | expand |
> From: Liu, Yi L <yi.l.liu@intel.com> > Sent: Tuesday, September 19, 2023 5:25 PM > > @@ -235,6 +235,13 @@ struct iommu_iotlb_gather { > * use. The information type is one of enum iommu_hw_info_type > defined > * in include/uapi/linux/iommufd.h. > * @domain_alloc: allocate iommu domain Given now we have two @alloc ops it'd be clearer to also update the comment here so the explanation for @domain_alloc_user() is easier to be understood, e.g.: @domain_alloc: allocate and return an iommu domain if success. Otherwise NULL is returned. The domain is not fully initialized until the caller iommu_domain_alloc() returns. > + * @domain_alloc_user: Allocate an iommu domain corresponding to the > input > + * parameters like flags defined as enum > iommufd_ioas_map_flags > + * in include/uapi/linux/iommufd.h. Different from the "to the input parameters as defined in include/uapi/linux/iommufd.h". > + * domain_alloc op, it requires iommu driver to fully > + * initialize a new domain including the generic iommu_domain "Unlike @domain_alloc, it is called only by iommufd and must fully initialize the new domain before return". *domain* here already refers to the generic iommu_domain struct.
On 2023/9/26 13:28, Tian, Kevin wrote: >> From: Liu, Yi L <yi.l.liu@intel.com> >> Sent: Tuesday, September 19, 2023 5:25 PM >> >> @@ -235,6 +235,13 @@ struct iommu_iotlb_gather { >> * use. The information type is one of enum iommu_hw_info_type >> defined >> * in include/uapi/linux/iommufd.h. >> * @domain_alloc: allocate iommu domain > > Given now we have two @alloc ops it'd be clearer to also update the > comment here so the explanation for @domain_alloc_user() is easier > to be understood, e.g.: > > @domain_alloc: allocate and return an iommu domain if success. Otherwise > NULL is returned. The domain is not fully initialized until > the caller iommu_domain_alloc() returns. > >> + * @domain_alloc_user: Allocate an iommu domain corresponding to the >> input >> + * parameters like flags defined as enum >> iommufd_ioas_map_flags >> + * in include/uapi/linux/iommufd.h. Different from the > > "to the input parameters as defined in include/uapi/linux/iommufd.h". > >> + * domain_alloc op, it requires iommu driver to fully >> + * initialize a new domain including the generic iommu_domain > > "Unlike @domain_alloc, it is called only by iommufd and must fully initialize > the new domain before return". > > *domain* here already refers to the generic iommu_domain struct. > above comment well received.
diff --git a/include/linux/iommu.h b/include/linux/iommu.h index c50a769d569a..660dc1931dc9 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -235,6 +235,13 @@ struct iommu_iotlb_gather { * use. The information type is one of enum iommu_hw_info_type defined * in include/uapi/linux/iommufd.h. * @domain_alloc: allocate iommu domain + * @domain_alloc_user: Allocate an iommu domain corresponding to the input + * parameters like flags defined as enum iommufd_ioas_map_flags + * in include/uapi/linux/iommufd.h. Different from the + * domain_alloc op, it requires iommu driver to fully + * initialize a new domain including the generic iommu_domain + * struct. Upon success, a domain is returned. Upon failure, + * ERR_PTR must be returned. * @probe_device: Add device to iommu driver handling * @release_device: Remove device from iommu driver handling * @probe_finalize: Do final setup work after the device is added to an IOMMU @@ -267,6 +274,7 @@ struct iommu_ops { /* Domain allocation and freeing by the iommu driver */ struct iommu_domain *(*domain_alloc)(unsigned iommu_domain_type); + struct iommu_domain *(*domain_alloc_user)(struct device *dev, u32 flags); struct iommu_device *(*probe_device)(struct device *dev); void (*release_device)(struct device *dev); diff --git a/include/uapi/linux/iommufd.h b/include/uapi/linux/iommufd.h index b4ba0c0cbab6..4a7c5c8fdbb4 100644 --- a/include/uapi/linux/iommufd.h +++ b/include/uapi/linux/iommufd.h @@ -347,10 +347,20 @@ struct iommu_vfio_ioas { }; #define IOMMU_VFIO_IOAS _IO(IOMMUFD_TYPE, IOMMUFD_CMD_VFIO_IOAS) +/** + * enum iommufd_hwpt_alloc_flags - Flags for HWPT allocation + * @IOMMU_HWPT_ALLOC_NEST_PARENT: If set, allocate a domain which can serve + * as the parent domain in the nesting + * configuration. + */ +enum iommufd_hwpt_alloc_flags { + IOMMU_HWPT_ALLOC_NEST_PARENT = 1 << 0, +}; + /** * struct iommu_hwpt_alloc - ioctl(IOMMU_HWPT_ALLOC) * @size: sizeof(struct iommu_hwpt_alloc) - * @flags: Must be 0 + * @flags: Combination of enum iommufd_hwpt_alloc_flags * @dev_id: The device to allocate this HWPT for * @pt_id: The IOAS to connect this HWPT to * @out_hwpt_id: The ID of the new HWPT