On Fri, Jul 28, 2023 at 02:55:57PM -0300, Jason Gunthorpe wrote:
On Mon, Jul 24, 2023 at 04:03:57AM -0700, Yi Liu wrote:
- switch (pt_obj->type) {
- case IOMMUFD_OBJ_IOAS:
ioas = container_of(pt_obj, struct iommufd_ioas, obj);
break;
- case IOMMUFD_OBJ_HW_PAGETABLE:
/* pt_id points HWPT only when hwpt_type is !IOMMU_HWPT_TYPE_DEFAULT */
if (cmd->hwpt_type == IOMMU_HWPT_TYPE_DEFAULT) {
rc = -EINVAL;
goto out_put_pt;
}
parent = container_of(pt_obj, struct iommufd_hw_pagetable, obj);
/*
* Cannot allocate user-managed hwpt linking to auto_created
* hwpt. If the parent hwpt is already a user-managed hwpt,
* don't allocate another user-managed hwpt linking to it.
*/
if (parent->auto_domain || parent->parent) {
rc = -EINVAL;
goto out_put_pt;
}
ioas = parent->ioas;
Why do we set ioas here? I would think it should be NULL.
I think it is looking like a mistake to try and re-use iommufd_hw_pagetable_alloc() directly for the nested case. It should not have a IOAS argument, it should not do enforce_cc, or iopt_* functions
So must of the function is removed. Probably better to make a new ioas-less function for the nesting case.
OK.
@Yi, along with the PATCH-6 (IOMMU_RESV_SW_MSI), I will rework on this -- mainly breaking up NESTED hwpt with IOAS.
Thanks Nic