aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/xen/swiotlb-xen.c5
-rw-r--r--include/trace/events/swiotlb.h46
-rw-r--r--lib/swiotlb.c4
3 files changed, 55 insertions, 0 deletions
diff --git a/drivers/xen/swiotlb-xen.c b/drivers/xen/swiotlb-xen.c
index 1b2277c311d2..b31081007a81 100644
--- a/drivers/xen/swiotlb-xen.c
+++ b/drivers/xen/swiotlb-xen.c
@@ -42,6 +42,9 @@
42#include <xen/page.h> 42#include <xen/page.h>
43#include <xen/xen-ops.h> 43#include <xen/xen-ops.h>
44#include <xen/hvc-console.h> 44#include <xen/hvc-console.h>
45
46#define CREATE_TRACE_POINTS
47#include <trace/events/swiotlb.h>
45/* 48/*
46 * Used to do a quick range check in swiotlb_tbl_unmap_single and 49 * Used to do a quick range check in swiotlb_tbl_unmap_single and
47 * swiotlb_tbl_sync_single_*, to see if the memory was in fact allocated by this 50 * swiotlb_tbl_sync_single_*, to see if the memory was in fact allocated by this
@@ -358,6 +361,8 @@ dma_addr_t xen_swiotlb_map_page(struct device *dev, struct page *page,
358 /* 361 /*
359 * Oh well, have to allocate and map a bounce buffer. 362 * Oh well, have to allocate and map a bounce buffer.
360 */ 363 */
364 trace_swiotlb_bounced(dev, dev_addr, size, swiotlb_force);
365
361 map = swiotlb_tbl_map_single(dev, start_dma_addr, phys, size, dir); 366 map = swiotlb_tbl_map_single(dev, start_dma_addr, phys, size, dir);
362 if (map == SWIOTLB_MAP_ERROR) 367 if (map == SWIOTLB_MAP_ERROR)
363 return DMA_ERROR_CODE; 368 return DMA_ERROR_CODE;
diff --git a/include/trace/events/swiotlb.h b/include/trace/events/swiotlb.h
new file mode 100644
index 000000000000..7ea4c5e7c448
--- /dev/null
+++ b/include/trace/events/swiotlb.h
@@ -0,0 +1,46 @@
1#undef TRACE_SYSTEM
2#define TRACE_SYSTEM swiotlb
3
4#if !defined(_TRACE_SWIOTLB_H) || defined(TRACE_HEADER_MULTI_READ)
5#define _TRACE_SWIOTLB_H
6
7#include <linux/tracepoint.h>
8
9TRACE_EVENT(swiotlb_bounced,
10
11 TP_PROTO(struct device *dev,
12 dma_addr_t dev_addr,
13 size_t size,
14 int swiotlb_force),
15
16 TP_ARGS(dev, dev_addr, size, swiotlb_force),
17
18 TP_STRUCT__entry(
19 __string( dev_name, dev_name(dev) )
20 __field( u64, dma_mask )
21 __field( dma_addr_t, dev_addr )
22 __field( size_t, size )
23 __field( int, swiotlb_force )
24 ),
25
26 TP_fast_assign(
27 __assign_str(dev_name, dev_name(dev));
28 __entry->dma_mask = (dev->dma_mask ? *dev->dma_mask : 0);
29 __entry->dev_addr = dev_addr;
30 __entry->size = size;
31 __entry->swiotlb_force = swiotlb_force;
32 ),
33
34 TP_printk("dev_name: %s dma_mask=%llx dev_addr=%llx "
35 "size=%zu %s",
36 __get_str(dev_name),
37 __entry->dma_mask,
38 (unsigned long long)__entry->dev_addr,
39 __entry->size,
40 __entry->swiotlb_force ? "swiotlb_force" : "" )
41);
42
43#endif /* _TRACE_SWIOTLB_H */
44
45/* This part must be outside protection */
46#include <trace/define_trace.h>
diff --git a/lib/swiotlb.c b/lib/swiotlb.c
index 4e8686c7e5a4..f0d841907da6 100644
--- a/lib/swiotlb.c
+++ b/lib/swiotlb.c
@@ -38,6 +38,8 @@
38#include <linux/bootmem.h> 38#include <linux/bootmem.h>
39#include <linux/iommu-helper.h> 39#include <linux/iommu-helper.h>
40 40
41#include <trace/events/swiotlb.h>
42
41#define OFFSET(val,align) ((unsigned long) \ 43#define OFFSET(val,align) ((unsigned long) \
42 ( (val) & ( (align) - 1))) 44 ( (val) & ( (align) - 1)))
43 45
@@ -726,6 +728,8 @@ dma_addr_t swiotlb_map_page(struct device *dev, struct page *page,
726 if (dma_capable(dev, dev_addr, size) && !swiotlb_force) 728 if (dma_capable(dev, dev_addr, size) && !swiotlb_force)
727 return dev_addr; 729 return dev_addr;
728 730
731 trace_swiotlb_bounced(dev, dev_addr, size, swiotlb_force);
732
729 /* Oh well, have to allocate and map a bounce buffer. */ 733 /* Oh well, have to allocate and map a bounce buffer. */
730 map = map_single(dev, phys, size, dir); 734 map = map_single(dev, phys, size, dir);
731 if (map == SWIOTLB_MAP_ERROR) { 735 if (map == SWIOTLB_MAP_ERROR) {