On 2024/1/3 07:38, Jason Gunthorpe wrote:
On Fri, Dec 15, 2023 at 12:01:19PM +0800, Yi Liu wrote:
I think I misread Yi's narrative: dev_id is a working approach for VMM to convert to a vRID, while he is asking for a better alternative :)
In concept, dev_id works, but in reality we have problem to get a dev_id for a given device in intel iommu driver, hence I'm asking for help here. :)
I think we just need to solve this one way or another.. Even if you use a viommu object you still end up having difficult coupling to iommufd
Some: iommufd_get_dev_id(struct iommufd_ctx *ictx, struct device *dev)
Callable by a driver (using the driver-callable function infrastructure we made for dirty tracking) Is really all that is needed here.
yep, I noticed IOMMUFD_DRIVER was selected by intel iommu driver when IOMMUFD is configed. Maybe such an API could be compiled when IOMMUFD_DRIVER is enabled as well. This does address my concern on making intel iommu driver depending on iommufd. But still need a way to pass in the iommufd_ctx pointer to intel iommu driver, and store it. Hence intel iommu driver could call the above iommufd_get_dev_id(). One possible way is passing it when attaching device to domain and clear it in detach. However, this seems not ideal as iommufd_ctx information should be static between bind_iommufd and unbind. But we don't call into intel iommu driver in the bind and unbind operations. May need to add new iommu op. Any suggestion here?