[PATCH v5 04/19] iommu: Use device fault trace event

From: Jacob Pan
Date: Thu Aug 15 2019 - 16:10:11 EST


From: Jean-Philippe Brucker <jean-philippe.brucker@xxxxxxx>

For performance and debugging purposes, these trace events help
analyzing device faults that interact with IOMMU subsystem.
E.g.
IOMMU:0000:00:0a.0 type=2 reason=0 addr=0x00000000007ff000 pasid=1
group=1 last=0 prot=1

Signed-off-by: Jacob Pan <jacob.jun.pan@xxxxxxxxxxxxxxx>
[JPB: removed invalidate event, that will be added later]
Signed-off-by: Jean-Philippe Brucker <jean-philippe.brucker@xxxxxxx>

Signed-off-by: Jacob Pan <jacob.jun.pan@xxxxxxxxxxxxxxx>
---
drivers/iommu/iommu.c | 2 ++
include/trace/events/iommu.h | 2 +-
2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
index 8f2c7d5..feada31 100644
--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c
@@ -1098,6 +1098,7 @@ int iommu_report_device_fault(struct device *dev, struct iommu_fault_event *evt)
mutex_unlock(&fparam->lock);
kfree(evt_pending);
}
+ trace_dev_fault(dev, &evt->fault);
done_unlock:
mutex_unlock(&param->lock);
return ret;
@@ -1146,6 +1147,7 @@ int iommu_page_response(struct device *dev,
msg->flags = pasid_valid ? IOMMU_PAGE_RESP_PASID_VALID : 0;

ret = domain->ops->page_response(dev, evt, msg);
+ trace_dev_page_response(dev, msg);
list_del(&evt->list);
kfree(evt);
break;
diff --git a/include/trace/events/iommu.h b/include/trace/events/iommu.h
index 767b92c..7a7801b 100644
--- a/include/trace/events/iommu.h
+++ b/include/trace/events/iommu.h
@@ -219,7 +219,7 @@ TRACE_EVENT(dev_fault,

TRACE_EVENT(dev_page_response,

- TP_PROTO(struct device *dev, struct iommu_fault_page_response *msg),
+ TP_PROTO(struct device *dev, struct iommu_page_response *msg),

TP_ARGS(dev, msg),

--
2.7.4