On Tue, Oct 24, 2023 at 02:31:39PM -0300, Jason Gunthorpe wrote: > On Tue, Oct 24, 2023 at 10:28:45AM -0700, Nicolin Chen wrote: > > On Tue, Oct 24, 2023 at 02:18:10PM -0300, Jason Gunthorpe wrote: > > > On Tue, Oct 24, 2023 at 08:06:06AM -0700, Yi Liu wrote: > > > > @@ -195,6 +279,10 @@ int iommufd_hwpt_alloc(struct iommufd_ucmd *ucmd) > > > > if (pt_obj->type == IOMMUFD_OBJ_IOAS) { > > > > struct iommufd_hwpt_paging *hwpt_paging; > > > > > > > > + if (cmd->data_type != IOMMU_HWPT_DATA_NONE) { > > > > + rc = -EINVAL; > > > > + goto out_put_pt; > > > > + } > > > > ioas = container_of(pt_obj, struct iommufd_ioas, obj); > > > > mutex_lock(&ioas->mutex); > > > > hwpt_paging = iommufd_hwpt_paging_alloc(ucmd->ictx, ioas, idev, > > > > > > ?? What is this? > > > > > > Ah something went wrong earlier in "iommu: Pass in parent domain with > > > user_data to domain_alloc_user op" > > > > > > Once we added the user_data we should flow it through to the op > > > always. > > > > Hmm, iommufd_hwpt_paging_alloc doesn't take (or need) user_data, > > but we could pass in a dummy one if that looks better? > > The point is for the user_data to always be available, the driver > needs to check it if it is passed. > > This should all be plumbed to allow drivers to also customize their > paging domains too. We don't have a use case of customizing the paging domains. And our selftest isn't covering this path. Nor the case is supported by the uAPI: 458- * A kernel-managed HWPT will be created with the mappings from the given 459- * IOAS via the @pt_id. The @data_type for this allocation must be set to 460: * IOMMU_HWPT_DATA_NONE. The HWPT can be allocated as a parent HWPT for a 461- * nesting configuration by passing IOMMU_HWPT_ALLOC_NEST_PARENT via @flags. 462- * Also, if we do passing in the data, we'd need to... 280-static struct iommu_domain * 281-mock_domain_alloc_user(struct device *dev, u32 flags, 282- struct iommu_domain *parent, 283: const struct iommu_user_data *user_data) 284-{ 285- struct mock_iommu_domain *mock_parent; 286- struct iommu_hwpt_selftest user_cfg; 287- int rc; 288- 289: if (!user_data) { /* must be mock_domain */ ...change this to if (!parent)... 290- struct mock_dev *mdev = container_of(dev, struct mock_dev, dev); 291- bool has_dirty_flag = flags & IOMMU_HWPT_ALLOC_DIRTY_TRACKING; 292- bool no_dirty_ops = mdev->flags & MOCK_FLAGS_DEVICE_NO_DIRTY; 293- 294- if (parent) 295- return ERR_PTR(-EINVAL); ...and drop this. 296- if (has_dirty_flag && no_dirty_ops) 297- return ERR_PTR(-EOPNOTSUPP); 298- return __mock_domain_alloc_paging(IOMMU_DOMAIN_UNMANAGED, 299- has_dirty_flag); 300- } 301- 302- /* must be mock_domain_nested */ 303: if (user_data->type != IOMMU_HWPT_DATA_SELFTEST) 304- return ERR_PTR(-EOPNOTSUPP); Thanks Nicolin