On Fri, Feb 24, 2023 at 08:27:57PM -0400, Jason Gunthorpe wrote: > +int iommufd_hwpt_alloc(struct iommufd_ucmd *ucmd) > +{ > + struct iommu_hwpt_alloc *cmd = ucmd->cmd; > + struct iommufd_hw_pagetable *hwpt; > + struct iommufd_device *idev; > + struct iommufd_ioas *ioas; > + int rc; > + > + if (cmd->flags) > + return -EOPNOTSUPP; > + > + idev = iommufd_get_device(ucmd, cmd->dev_id); > + if (IS_ERR(idev)) > + return PTR_ERR(idev); > + > + ioas = iommufd_get_ioas(ucmd, cmd->pt_id); > + if (IS_ERR(ioas)) { > + rc = PTR_ERR(idev); PTR_ERR(ioas) > + goto out_put_idev; > + } > + > + mutex_lock(&ioas->mutex); > + hwpt = iommufd_hw_pagetable_alloc(ucmd->ictx, ioas, idev, false); > + mutex_unlock(&ioas->mutex); > + if (IS_ERR(hwpt)) { > + rc = PTR_ERR(idev); PTR_ERR(hwpt) Thanks Nic