Re: [PATCH v5 08/14] iommufd/viommu: Add iommufd_viommu_report_event helper

From: Jason Gunthorpe
Date: Fri Jan 10 2025 - 09:54:16 EST


On Fri, Jan 10, 2025 at 07:12:46AM +0000, Tian, Kevin wrote:

> > + 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?

Indeed, it might make sense to protect this with

if (IS_ENABLED(CONFIG_IOMMUFD_TEST))

As a compiled out assertion

Or drop it

We shouldn't have unnecessary argument validation on fast paths,
!viommu should go too.

Jason