On Mon, Oct 21, 2024 at 05:20:10PM -0700, Nicolin Chen wrote:
struct iommufd_viommu_ops {
struct iommufd_vdevice *(*vdevice_alloc)(struct iommufd_viommu *viommu,struct device *dev, u64 id);void (*vdevice_free)(struct iommufd_vdevice *vdev);
...
+#define iommufd_vdevice_alloc(ictx, drv_struct, member) \
({ \static_assert( \__same_type(struct iommufd_vdevice, \((struct drv_struct *)NULL)->member)); \static_assert(offsetof(struct drv_struct, member.obj) == 0); \container_of(_iommufd_object_alloc(ictx, \sizeof(struct drv_struct), \IOMMUFD_OBJ_VDEVICE), \struct drv_struct, member.obj); \})
Per discussion in vIRQ series [1], we might not need to expose struct iommufd_vdevice. So, dropping most of the changes here, and moving iommufd_device to the private header.
[1] https://lore.kernel.org/linux-iommu/ZxlGfgfwrGZGIbeF@Asurada-Nvidia/
Nicolin