On Tue, Oct 10, 2023 at 01:58:44PM -0300, Jason Gunthorpe wrote: > On Thu, Sep 21, 2023 at 12:51:22AM -0700, Yi Liu wrote: > > diff --git a/include/linux/iommu.h b/include/linux/iommu.h > > index 660dc1931dc9..12e12e5563e6 100644 > > --- a/include/linux/iommu.h > > +++ b/include/linux/iommu.h > > @@ -14,6 +14,7 @@ > > #include <linux/err.h> > > #include <linux/of.h> > > #include <uapi/linux/iommu.h> > > +#include <uapi/linux/iommufd.h> > > Oh we should definately avoid doing that! > > Maybe this is a good moment to start a new header file exclusively for > iommu drivers and core subsystem to include? > > include/linux/iommu-driver.h > > ? > > Put iommu_copy_user_data() and struct iommu_user_data in there > > Avoid this include in this file. By looking closer, it seems that we included the uapi header for: + struct iommu_domain *(*domain_alloc_user)(struct device *dev, u32 flags, + enum iommu_hwpt_data_type data_type, + struct iommu_domain *parent, + const struct iommu_user_data *user_data); So we could drop the include, and instead add this next to structs: +enum iommu_hwpt_data_type; Then it's not that necessary to have a new header? We could mark a section of "driver exclusively functions" in iommu.h, I think. > > #define IOMMU_READ (1 << 0) > > #define IOMMU_WRITE (1 << 1) > > @@ -227,6 +228,41 @@ struct iommu_iotlb_gather { > > bool queued; > > }; > > > > +/** > > + * struct iommu_user_data - iommu driver specific user space data info > > + * @uptr: Pointer to the user buffer for copy_from_user() > > + * @len: The length of the user buffer in bytes > > + * > > + * A user space data is an uAPI that is defined in include/uapi/linux/iommufd.h > > + * Both @uptr and @len should be just copied from an iommufd core uAPI structure > > + */ > > +struct iommu_user_data { > > + void __user *uptr; > > + size_t len; > > +}; > > Put the "hwpt_type" in here and just call it type Ah, then domain_alloc_user can omit the enum iommu_hwpt_data_type. Thanks! Nic