lkml.org 
[lkml]   [2022]   [Mar]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRE: [PATCH RFC 08/11] iommu: Handle IO page faults directly
Date
> From: Jean-Philippe Brucker <jean-philippe@linaro.org>
> Sent: Monday, March 21, 2022 7:36 PM
>
> On Sun, Mar 20, 2022 at 02:40:27PM +0800, Lu Baolu wrote:
> > diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
> > index c0966fc9b686..4f90b71c6f6e 100644
> > --- a/drivers/iommu/iommu.c
> > +++ b/drivers/iommu/iommu.c
> > @@ -27,6 +27,8 @@
> > #include <linux/cc_platform.h>
> > #include <trace/events/iommu.h>
> >
> > +#include "iommu-sva-lib.h"
> > +
> > static struct kset *iommu_group_kset;
> > static DEFINE_IDA(iommu_group_ida);
> >
> > @@ -1177,10 +1179,9 @@ int iommu_report_device_fault(struct device
> *dev, struct iommu_fault_event *evt)
> > if (!param || !evt)
> > return -EINVAL;
> >
> > - /* we only report device fault if there is a handler registered */
> > mutex_lock(&param->lock);
> > fparam = param->fault_param;
> > - if (!fparam || !fparam->handler) {
> > + if (!fparam) {
> > ret = -EINVAL;
> > goto done_unlock;
> > }
> > @@ -1198,7 +1199,11 @@ int iommu_report_device_fault(struct device
> *dev, struct iommu_fault_event *evt)
> > mutex_unlock(&fparam->lock);
> > }
> >
> > - ret = fparam->handler(&evt->fault, fparam->data);
> > + if (fparam->handler)
> > + ret = fparam->handler(&evt->fault, fparam->data);
> > + else
> > + ret = iommu_queue_iopf(&evt->fault, fparam->data);
> > +
>
> I like the change, but we'll need to consolidate this, because now if the
> driver registers a fault handler it disables IOPF. We could instead
> prevent registration if an IOPF param is present. We could also just merge
> fparam->handler but eventually I'd like to make IOPF fall back to the
> fault handler registered by device driver, in case of invalid page faults.
> I have a couple patches for this but am still missing some bits.
>

Probably we need two different fault reporting interfaces:

iommu_report_device_fault()
iommu_report_domain_fault()

iommu driver knows the type of faults and just calls individual API
accordingly. fallback is also managed by iommu driver if necessary.

Thanks
Kevin

\
 
 \ /
  Last update: 2022-03-22 01:40    [W:0.200 / U:0.100 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site