lkml.org 
[lkml]   [2022]   [Mar]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [PATCH RFC 08/11] iommu: Handle IO page faults directly
    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.

    Thanks,
    Jean

    > if (ret && evt_pending) {
    > mutex_lock(&fparam->lock);
    > list_del(&evt_pending->list);
    > --
    > 2.25.1
    >

    \
     
     \ /
      Last update: 2022-03-21 12:36    [W:12.465 / U:0.016 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site