When the timeout timer function is added, the callback interface of the timer is actually a soft interrupt response function. When the IOMMU processing response interface is placed in the soft interrupt for processing, using the original mutex lock may cause the kernel calltrace, so it needs to be modified it.
Signed-off-by: Longfang Liu liulongfang@huawei.com --- drivers/iommu/iommu.c | 14 +++++++------- include/linux/iommu.h | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index 7c99d8eb3182..b927a35aefa6 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -1221,7 +1221,7 @@ int iommu_register_device_fault_handler(struct device *dev, } param->fault_param->handler = handler; param->fault_param->data = data; - mutex_init(¶m->fault_param->lock); + spin_lock_init(¶m->fault_param->lock); INIT_LIST_HEAD(¶m->fault_param->faults);
done_unlock: @@ -1306,16 +1306,16 @@ int iommu_report_device_fault(struct device *dev, struct iommu_fault_event *evt) ret = -ENOMEM; goto done_unlock; } - mutex_lock(&fparam->lock); + spin_lock(&fparam->lock); list_add_tail(&evt_pending->list, &fparam->faults); - mutex_unlock(&fparam->lock); + spin_unlock(&fparam->lock); }
ret = fparam->handler(&evt->fault, fparam->data); if (ret && evt_pending) { - mutex_lock(&fparam->lock); + spin_lock(&fparam->lock); list_del(&evt_pending->list); - mutex_unlock(&fparam->lock); + spin_unlock(&fparam->lock); kfree(evt_pending); } done_unlock: @@ -1346,7 +1346,7 @@ int iommu_page_response(struct device *dev, return -EINVAL;
/* Only send response if there is a fault report pending */ - mutex_lock(¶m->fault_param->lock); + spin_lock(¶m->fault_param->lock); if (list_empty(¶m->fault_param->faults)) { dev_warn_ratelimited(dev, "no pending PRQ, drop response\n"); goto done_unlock; @@ -1383,7 +1383,7 @@ int iommu_page_response(struct device *dev, }
done_unlock: - mutex_unlock(¶m->fault_param->lock); + spin_unlock(¶m->fault_param->lock); return ret; } EXPORT_SYMBOL_GPL(iommu_page_response); diff --git a/include/linux/iommu.h b/include/linux/iommu.h index 68d7d304cdb7..0d808ef68704 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -384,7 +384,7 @@ struct iommu_fault_param { iommu_dev_fault_handler_t handler; void *data; struct list_head faults; - struct mutex lock; + spinlock_t lock; };
/**