On Mon, Jun 02, 2025 at 10:41:05PM -0700, Nicolin Chen wrote: > I found that the size_viommu or size_hw_queue might not work using > a static macro as that RDMA one does: > > - The size in vIOMMU case is type dependent. E.g. smmuv3 driver > uses one iommu_ops to support two types: vSMMU and vCMDQ Maybe they can just be max()'d? > 1) Define a get_viommu_size(unsigned int type) op: use a similar > macro in the driver function to return with: > > #define VIOMMU_STRUCT_SIZE(ib_struct, drv_struct, member) \ > (sizeof(drv_struct) + \ > BUILD_BUG_ON_ZERO(offsetof(drv_struct, member)) + \ > BUILD_BUG_ON_ZERO(!__same_type(((drv_struct *)NULL)->member, \ > ib_struct))) > > if (type == SMMU) > return VIOMMU_STRUCT_SIZE( > struct arm_vsmmu, struct iommufd_viommu, core); > return 0; I guess this is best? > 2) Let core allocate with sizeof(struct iommufd_viommu), then let > driver krealloc during the viommu_init op call: No.. memmoving things like locks doesn't work. Jason