On Sun, Feb 26, 2023 at 11:13:16AM +0800, Baolu Lu wrote: > On 2/25/23 8:27 AM, Jason Gunthorpe wrote: > > +/** > > + * iommufd_device_attach - Connect a device to an iommu_domain > > + * @idev: device to attach > > + * @pt_id: Input a IOMMUFD_OBJ_IOAS, or IOMMUFD_OBJ_HW_PAGETABLE > > + * Output the IOMMUFD_OBJ_HW_PAGETABLE ID > > "Output the hwpt ID" only happens when the caller input an IOAS object > and an auto domain was selected or created for the device. > > Do I understand it right? Technically it always outputs the hwpt, if a hwpt is in put then the same hwpt is output. > > EXPORT_SYMBOL_NS_GPL(iommufd_device_attach, IOMMUFD); > > +/** > > + * iommufd_device_replace - Change the device's iommu_domain > > + * @idev: device to change > > + * @pt_id: Input a IOMMUFD_OBJ_IOAS, or IOMMUFD_OBJ_HW_PAGETABLE > > + * Output the IOMMUFD_OBJ_HW_PAGETABLE ID > > If my above understanding is correct, then replace will never output a > hwpt id as it only happens after a successful attach. Replace calls iommufd_device_auto_get_domain() which always sets pt_id on success? If a HWPT was passed in then it just leaves it unchanged which is also correct. Jason