RE: [PATCH v5 08/14] iommufd/viommu: Add iommufd_viommu_report_event helper
From: Tian, Kevin
Date: Fri Jan 10 2025 - 02:13:45 EST
> From: Nicolin Chen <nicolinc@xxxxxxxxxx>
> Sent: Wednesday, January 8, 2025 1:10 AM
>
> +/*
> + * Typically called in driver's threaded IRQ handler.
> + * The @type and @event_data must be defined in
> include/uapi/linux/iommufd.h
> + */
> +int iommufd_viommu_report_event(struct iommufd_viommu *viommu,
> + enum iommu_veventq_type type, void
> *event_data,
> + size_t data_len)
> +{
> + struct iommufd_veventq *veventq;
> + struct iommufd_vevent *vevent;
> + int rc = 0;
> +
> + if (!viommu)
> + return -ENODEV;
> + if (WARN_ON_ONCE(!viommu->ops || !viommu->ops-
> >supports_veventq ||
> + !viommu->ops->supports_veventq(type)))
> + return -EOPNOTSUPP;
Hmm the driver knows which type is supported by itself before
calling this helper. Why bother having the helper calling into
the driver again to verify?