Re: [PATCH 3/3] iommu: Allow drivers to say if they use report_iommu_fault()

Jason Gunthorpe
2025-10-23T14:54:39Z

On Thu, Oct 23, 2025 at 12:24:01PM +0100, Robin Murphy wrote:
> On 2025-10-22 6:12 pm, Jason Gunthorpe wrote:
> > report_iommu_fault() is an older API that has been superseded by
> > iommu_report_device_fault() which is capable to support PRI.
> >
> > Only two external drivers consume this, drivers/remoteproc and
> > drivers/gpu/drm/msm. Ideally they would move over to the new APIs, but for
> > now protect against accidentally mix and matching the wrong components.
> >
> > The iommu drivers support either the old iommu_set_fault_handler() via the
> > driver calling report_iommu_fault(), or they are newer server focused
> > drivers that call iommu_report_device_fault().
> >
> > Include a flag in the domain_ops if it calls report_iommu_fault() and
> > block iommu_set_fault_handler() on iommu's that can't support it.
>
> This isn't a domain operation though; depending on how you look at it,
> supporting a legacy fault_handler is either a capability of the IOMMU driver
> (that would be reachable via domain->owner->capable) or a property of the
> iommu_domain itself that the drivers can set at allocation time (basically
> this same patch just with the lines in slightly different places).

That's right, the issue is:

void iommu_set_fault_handler(struct iommu_domain *domain,
iommu_fault_handler_t handler,
void *token)

We can't get to the iommu instance starting from a domain pointer

Do you think we should change the above signature to include a
struct device *?

Jason