[PATCH v4 01/23] iommufd/viommu: Add driver-allocated vDEVICE support

Tian, Kevin kevin.tian at intel.com
Wed May 14 22:42:46 PDT 2025


> From: Nicolin Chen <nicolinc at nvidia.com>
> Sent: Friday, May 9, 2025 11:02 AM
> 
> +
> +#define iommufd_vdevice_alloc(viommu, drv_struct, member)                      \
> +	({                                                                     \
> +		drv_struct *ret;                                               \
> +									       \
> +		static_assert(__same_type(struct iommufd_viommu,
> *viommu));    \
> +		static_assert(__same_type(struct iommufd_vdevice,              \
> +					  ((drv_struct *)NULL)->member));
> \
> +		static_assert(offsetof(drv_struct, member.obj) == 0);          \
> +		ret = (drv_struct *)_iommufd_object_alloc(                     \
> +			viommu->ictx, sizeof(drv_struct),
> IOMMUFD_OBJ_VDEVICE);\
> +		if (!IS_ERR(ret)) {                                            \
> +			ret->member.viommu = viommu;                           \
> +			ret->member.ictx = viommu->ictx;                       \
> +		}                                                              \
> +		ret;                                                           \
> +	})

viommu->ictx is set in patch5, so logically this is better put
after that.

Reviewed-by: Kevin Tian <kevin.tian at intel.com>



More information about the linux-arm-kernel mailing list