iommu: Add iommu_fault class event to iommu trace
cover iommu: Add iommu_fault class event to iommu trace
This patch set adds iommu_fault class event to iommu trace. iommu_fault class event can be enabled to trigger when an iommu fault occurs. This trace event is intended to be called to report the fault information. Trace information includes driver name, device name, iova, and flags.
iommu_fault:report_fault
This patch set depends on the previous patch set that added iommu tracing feature. Reference:
http://www.kernelhub.org/?msg=313155&p=2
http://www.kernelhub.org/?msg=313156&p=2
Shuah Khan (2):
iommu: Add iommu_fault class event to iommu trace
iommu: Change iommu driver to call report_fault trace event
drivers/iommu/iommu-traces.c | 3 +++ include/linux/iommu.h | 2 ++ include/trace/events/iommu.h | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 38 insertions(+)
Signature · 1 line
1.7.10.4
PATCH 1/2 iommu: Add iommu_fault class event to iommu trace
Add iommu_fault class event can be enabled to trigger when an iommu fault occurs. This trace event is intended to be called to report the fault information. Trace information includes driver name, device name, iova, and flags.
iommu_fault:report_fault
--- drivers/iommu/iommu-traces.c | 3 +++ include/trace/events/iommu.h | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+)
drivers/iommu/iommu-traces.c +3 -0
@@ -22,3 +22,6 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(detach_device_from_domain);/* iommu_map_unmap */ EXPORT_TRACEPOINT_SYMBOL_GPL (map);EXPORT_TRACEPOINT_SYMBOL_GPL (unmap); + +/* iommu_fault */ +EXPORT_TRACEPOINT_SYMBOL_GPL (report_fault);
include/trace/events/iommu.h +33 -0
@@ -123,6 +123,39 @@ DEFINE_EVENT_PRINT(iommu_map_unmap, unmap, __entry->iova, __entry->size ) ); + +DECLARE_EVENT_CLASS (iommu_fault, + + TP_PROTO(struct device *dev, unsigned long iova, int flags), + +TP_ARGS (dev, iova, flags), + +TP_STRUCT__entry ( + __string(device, dev_name(dev)) + __string(driver, dev_driver_string(dev)) + __field(u64, iova) +__field (int, flags) + ), + +TP_fast_assign ( + __assign_str(device, dev_name(dev)); + __assign_str(driver, dev_driver_string(dev)); + __entry->iova = iova; + __entry->flags = flags; + ), + +TP_printk ("IOMMU:%s %s iova=0x%016llx flags=0x%04x" , +__get_str (driver),__get_str (device), + __entry->iova, __entry->flags + ) +); + +DEFINE_EVENT (iommu_fault, report_fault, + + TP_PROTO(struct device *dev, unsigned long iova, int flags), + +TP_ARGS (dev, iova, flags) +);#endif /* _TRACE_IOMMU_H */ /* This part must be outside protection */
Signature · 1 line
1.7.10.4
PATCH 2/2 iommu: Change iommu driver to call report_fault trace event
In reply to Shuah KhanChange iommu driver report_iommu_fault() to call report_fault trace event. This iommu_fault class event can be enabled to trigger when an iommu fault occurs. Trace information includes driver name, device name, iova, and flags.
Testing:
Added trace calls to iommu_prepare_identity_map() for testing some of the conditions that are hard to trigger. Here is the trace from the testing:
swapper/0-1 [003] .... 1.926331: report_fault: IOMMU:pci 0000:00:1d.0 iova=0x00000000cadc6000 flags=0x0001
--- include/linux/iommu.h | 2 ++ 1 file changed, 2 insertions(+)
include/linux/iommu.h +2 -0
@@ -22,6 +22,7 @@#include <linux/errno.h> #include <linux/err.h> #include <linux/types.h> +#include <trace/events/iommu.h> #define IOMMU_READ (1)#define IOMMU_WRITE (2)
@@ -211,6 +212,7 @@ static inline int report_iommu_fault(struct iommu_domain *domain, ret = domain->handler (domain, dev, iova, flags, domain->handler_token); +trace_report_fault (dev, iova, flags);return ret; }
Signature · 1 line
1.7.10.4
Joerg Roedel
maintainerinclude/trace/events/iommu.h DEFINE_EVENT_PRINT(iommu_map_unmap, unmap, · line 158
Quoted 6 lines · Shuah Khan
include/trace/events/iommu.h +6
-0+DEFINE_EVENT (iommu_fault, report_fault, + + TP_PROTO(struct device *dev, unsigned long iova, int flags), + +TP_ARGS (dev, iova, flags) +);
I am not entirely happy with the naming. It is better to name the class iommu_error and the page-fault event io_page_fault. This makes it more clear what kind of fault it is.
Joerg
Quoted 13 lines · Joerg Roedel
include/trace/events/iommu.h DEFINE_EVENT_PRINT(iommu_map_unmap, unmap, · line 158
Quoted 6 lines · Shuah Khan
include/trace/events/iommu.h +6
-0+DEFINE_EVENT (iommu_fault, report_fault, + + TP_PROTO(struct device *dev, unsigned long iova, int flags), + +TP_ARGS (dev, iova, flags) +);I am not entirely happy with the naming. It is better to name the class
iommu_errorand the page-fault eventio_page_fault. This makes it more clear what kind of fault it is.
Quoted 3 lines
Joerg
Joerg,
Yes, iommu_error and io_page_fault sounds better. I will rename and send the updated patch.
-- Shuah
Signature · 4 lines
Shuah Khan Senior Linux Kernel Developer - Open Source Group Samsung Research America(Silicon Valley) [email protected] | (970) 672-0658