forked from Minki/linux
iommu: Add event tracing feature to iommu
Add tracing feature to iommu to report various iommu events. Classes iommu_group, iommu_device, and iommu_map_unmap are defined. iommu_group class events can be enabled to trigger when devices get added to and removed from an iommu group. Trace information includes iommu group id and device name. iommu:add_device_to_group iommu:remove_device_from_group iommu_device class events can be enabled to trigger when devices are attached to and detached from a domain. Trace information includes device name. iommu:attach_device_to_domain iommu:detach_device_from_domain iommu_map_unmap class events can be enabled to trigger when iommu map and unmap iommu ops. Trace information includes iova, physical address (map event only), and size. iommu:map iommu:unmap Signed-off-by: Shuah Khan <shuah.kh@samsung.com> Signed-off-by: Joerg Roedel <joro@8bytes.org>
This commit is contained in:
parent
4a10c2ac2f
commit
7f6db17172
@ -1,4 +1,5 @@
|
||||
obj-$(CONFIG_IOMMU_API) += iommu.o
|
||||
obj-$(CONFIG_IOMMU_API) += iommu-traces.o
|
||||
obj-$(CONFIG_OF_IOMMU) += of_iommu.o
|
||||
obj-$(CONFIG_MSM_IOMMU) += msm_iommu.o msm_iommu_dev.o
|
||||
obj-$(CONFIG_AMD_IOMMU) += amd_iommu.o amd_iommu_init.o
|
||||
|
24
drivers/iommu/iommu-traces.c
Normal file
24
drivers/iommu/iommu-traces.c
Normal file
@ -0,0 +1,24 @@
|
||||
/*
|
||||
* iommu trace points
|
||||
*
|
||||
* Copyright (C) 2013 Shuah Khan <shuah.kh@samsung.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#include <linux/string.h>
|
||||
#include <linux/types.h>
|
||||
|
||||
#define CREATE_TRACE_POINTS
|
||||
#include <trace/events/iommu.h>
|
||||
|
||||
/* iommu_group_event */
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(add_device_to_group);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(remove_device_from_group);
|
||||
|
||||
/* iommu_device_event */
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(attach_device_to_domain);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(detach_device_from_domain);
|
||||
|
||||
/* iommu_map_unmap */
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(map);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(unmap);
|
@ -29,6 +29,7 @@
|
||||
#include <linux/idr.h>
|
||||
#include <linux/notifier.h>
|
||||
#include <linux/err.h>
|
||||
#include <trace/events/iommu.h>
|
||||
|
||||
static struct kset *iommu_group_kset;
|
||||
static struct ida iommu_group_ida;
|
||||
|
129
include/trace/events/iommu.h
Normal file
129
include/trace/events/iommu.h
Normal file
@ -0,0 +1,129 @@
|
||||
/*
|
||||
* iommu trace points
|
||||
*
|
||||
* Copyright (C) 2013 Shuah Khan <shuah.kh@samsung.com>
|
||||
*
|
||||
*/
|
||||
#undef TRACE_SYSTEM
|
||||
#define TRACE_SYSTEM iommu
|
||||
|
||||
#if !defined(_TRACE_IOMMU_H) || defined(TRACE_HEADER_MULTI_READ)
|
||||
#define _TRACE_IOMMU_H
|
||||
|
||||
#include <linux/tracepoint.h>
|
||||
#include <linux/pci.h>
|
||||
|
||||
struct device;
|
||||
|
||||
DECLARE_EVENT_CLASS(iommu_group_event,
|
||||
|
||||
TP_PROTO(int group_id, struct device *dev),
|
||||
|
||||
TP_ARGS(group_id, dev),
|
||||
|
||||
TP_STRUCT__entry(
|
||||
__field(int, gid)
|
||||
__string(device, dev_name(dev))
|
||||
),
|
||||
|
||||
TP_fast_assign(
|
||||
__entry->gid = group_id;
|
||||
__assign_str(device, dev_name(dev));
|
||||
),
|
||||
|
||||
TP_printk("IOMMU: groupID=%d device=%s",
|
||||
__entry->gid, __get_str(device)
|
||||
)
|
||||
);
|
||||
|
||||
DEFINE_EVENT(iommu_group_event, add_device_to_group,
|
||||
|
||||
TP_PROTO(int group_id, struct device *dev),
|
||||
|
||||
TP_ARGS(group_id, dev)
|
||||
|
||||
);
|
||||
|
||||
DEFINE_EVENT(iommu_group_event, remove_device_from_group,
|
||||
|
||||
TP_PROTO(int group_id, struct device *dev),
|
||||
|
||||
TP_ARGS(group_id, dev)
|
||||
);
|
||||
|
||||
DECLARE_EVENT_CLASS(iommu_device_event,
|
||||
|
||||
TP_PROTO(struct device *dev),
|
||||
|
||||
TP_ARGS(dev),
|
||||
|
||||
TP_STRUCT__entry(
|
||||
__string(device, dev_name(dev))
|
||||
),
|
||||
|
||||
TP_fast_assign(
|
||||
__assign_str(device, dev_name(dev));
|
||||
),
|
||||
|
||||
TP_printk("IOMMU: device=%s", __get_str(device)
|
||||
)
|
||||
);
|
||||
|
||||
DEFINE_EVENT(iommu_device_event, attach_device_to_domain,
|
||||
|
||||
TP_PROTO(struct device *dev),
|
||||
|
||||
TP_ARGS(dev)
|
||||
);
|
||||
|
||||
DEFINE_EVENT(iommu_device_event, detach_device_from_domain,
|
||||
|
||||
TP_PROTO(struct device *dev),
|
||||
|
||||
TP_ARGS(dev)
|
||||
);
|
||||
|
||||
DECLARE_EVENT_CLASS(iommu_map_unmap,
|
||||
|
||||
TP_PROTO(unsigned long iova, phys_addr_t paddr, size_t size),
|
||||
|
||||
TP_ARGS(iova, paddr, size),
|
||||
|
||||
TP_STRUCT__entry(
|
||||
__field(u64, iova)
|
||||
__field(u64, paddr)
|
||||
__field(int, size)
|
||||
),
|
||||
|
||||
TP_fast_assign(
|
||||
__entry->iova = iova;
|
||||
__entry->paddr = paddr;
|
||||
__entry->size = size;
|
||||
),
|
||||
|
||||
TP_printk("IOMMU: iova=0x%016llx paddr=0x%016llx size=0x%x",
|
||||
__entry->iova, __entry->paddr, __entry->size
|
||||
)
|
||||
);
|
||||
|
||||
DEFINE_EVENT(iommu_map_unmap, map,
|
||||
|
||||
TP_PROTO(unsigned long iova, phys_addr_t paddr, size_t size),
|
||||
|
||||
TP_ARGS(iova, paddr, size)
|
||||
);
|
||||
|
||||
DEFINE_EVENT_PRINT(iommu_map_unmap, unmap,
|
||||
|
||||
TP_PROTO(unsigned long iova, phys_addr_t paddr, size_t size),
|
||||
|
||||
TP_ARGS(iova, paddr, size),
|
||||
|
||||
TP_printk("IOMMU: iova=0x%016llx size=0x%x",
|
||||
__entry->iova, __entry->size
|
||||
)
|
||||
);
|
||||
#endif /* _TRACE_IOMMU_H */
|
||||
|
||||
/* This part must be outside protection */
|
||||
#include <trace/define_trace.h>
|
Loading…
Reference in New Issue
Block a user