diff options
author | Mark Brown <broonie@linaro.org> | 2013-10-07 14:33:53 -0400 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2013-10-07 15:02:01 -0400 |
commit | 56ec1978ff07380bbdc0a942c8779ec9fd9e02ee (patch) | |
tree | 4f9dc2dfc2e4aab1aec8872cea58c56369afaef8 | |
parent | d0e639c9e06d44e713170031fe05fb60ebe680af (diff) |
spi: Provide trace points for message processing
Provide tracepoints for the lifecycle of a message from submission to
completion and for the active time for masters to help with performance
analysis of SPI I/O.
Signed-off-by: Mark Brown <broonie@linaro.org>
-rw-r--r-- | drivers/spi/spi.c | 16 | ||||
-rw-r--r-- | include/trace/events/spi.h | 94 |
2 files changed, 109 insertions, 1 deletions
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 9e039c60c068..8bef0c9a7233 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c | |||
@@ -39,6 +39,9 @@ | |||
39 | #include <linux/ioport.h> | 39 | #include <linux/ioport.h> |
40 | #include <linux/acpi.h> | 40 | #include <linux/acpi.h> |
41 | 41 | ||
42 | #define CREATE_TRACE_POINTS | ||
43 | #include <trace/events/spi.h> | ||
44 | |||
42 | static void spidev_release(struct device *dev) | 45 | static void spidev_release(struct device *dev) |
43 | { | 46 | { |
44 | struct spi_device *spi = to_spi_device(dev); | 47 | struct spi_device *spi = to_spi_device(dev); |
@@ -557,6 +560,7 @@ static void spi_pump_messages(struct kthread_work *work) | |||
557 | pm_runtime_mark_last_busy(master->dev.parent); | 560 | pm_runtime_mark_last_busy(master->dev.parent); |
558 | pm_runtime_put_autosuspend(master->dev.parent); | 561 | pm_runtime_put_autosuspend(master->dev.parent); |
559 | } | 562 | } |
563 | trace_spi_master_idle(master); | ||
560 | return; | 564 | return; |
561 | } | 565 | } |
562 | 566 | ||
@@ -585,6 +589,9 @@ static void spi_pump_messages(struct kthread_work *work) | |||
585 | } | 589 | } |
586 | } | 590 | } |
587 | 591 | ||
592 | if (!was_busy) | ||
593 | trace_spi_master_busy(master); | ||
594 | |||
588 | if (!was_busy && master->prepare_transfer_hardware) { | 595 | if (!was_busy && master->prepare_transfer_hardware) { |
589 | ret = master->prepare_transfer_hardware(master); | 596 | ret = master->prepare_transfer_hardware(master); |
590 | if (ret) { | 597 | if (ret) { |
@@ -597,6 +604,8 @@ static void spi_pump_messages(struct kthread_work *work) | |||
597 | } | 604 | } |
598 | } | 605 | } |
599 | 606 | ||
607 | trace_spi_message_start(master->cur_msg); | ||
608 | |||
600 | ret = master->transfer_one_message(master, master->cur_msg); | 609 | ret = master->transfer_one_message(master, master->cur_msg); |
601 | if (ret) { | 610 | if (ret) { |
602 | dev_err(&master->dev, | 611 | dev_err(&master->dev, |
@@ -689,6 +698,8 @@ void spi_finalize_current_message(struct spi_master *master) | |||
689 | mesg->state = NULL; | 698 | mesg->state = NULL; |
690 | if (mesg->complete) | 699 | if (mesg->complete) |
691 | mesg->complete(mesg->context); | 700 | mesg->complete(mesg->context); |
701 | |||
702 | trace_spi_message_done(mesg); | ||
692 | } | 703 | } |
693 | EXPORT_SYMBOL_GPL(spi_finalize_current_message); | 704 | EXPORT_SYMBOL_GPL(spi_finalize_current_message); |
694 | 705 | ||
@@ -1421,6 +1432,10 @@ static int __spi_async(struct spi_device *spi, struct spi_message *message) | |||
1421 | struct spi_master *master = spi->master; | 1432 | struct spi_master *master = spi->master; |
1422 | struct spi_transfer *xfer; | 1433 | struct spi_transfer *xfer; |
1423 | 1434 | ||
1435 | message->spi = spi; | ||
1436 | |||
1437 | trace_spi_message_submit(message); | ||
1438 | |||
1424 | if (list_empty(&message->transfers)) | 1439 | if (list_empty(&message->transfers)) |
1425 | return -EINVAL; | 1440 | return -EINVAL; |
1426 | if (!message->complete) | 1441 | if (!message->complete) |
@@ -1520,7 +1535,6 @@ static int __spi_async(struct spi_device *spi, struct spi_message *message) | |||
1520 | } | 1535 | } |
1521 | } | 1536 | } |
1522 | 1537 | ||
1523 | message->spi = spi; | ||
1524 | message->status = -EINPROGRESS; | 1538 | message->status = -EINPROGRESS; |
1525 | return master->transfer(spi, message); | 1539 | return master->transfer(spi, message); |
1526 | } | 1540 | } |
diff --git a/include/trace/events/spi.h b/include/trace/events/spi.h new file mode 100644 index 000000000000..a7b09072ce56 --- /dev/null +++ b/include/trace/events/spi.h | |||
@@ -0,0 +1,94 @@ | |||
1 | #undef TRACE_SYSTEM | ||
2 | #define TRACE_SYSTEM spi | ||
3 | |||
4 | #if !defined(_TRACE_SPI_H) || defined(TRACE_HEADER_MULTI_READ) | ||
5 | #define _TRACE_SPI_H | ||
6 | |||
7 | #include <linux/ktime.h> | ||
8 | #include <linux/tracepoint.h> | ||
9 | |||
10 | DECLARE_EVENT_CLASS(spi_master, | ||
11 | |||
12 | TP_PROTO(struct spi_master *master), | ||
13 | |||
14 | TP_ARGS(master), | ||
15 | |||
16 | TP_STRUCT__entry( | ||
17 | __field( int, bus_num ) | ||
18 | ), | ||
19 | |||
20 | TP_fast_assign( | ||
21 | __entry->bus_num = master->bus_num; | ||
22 | ), | ||
23 | |||
24 | TP_printk("spi%d", (int)__entry->bus_num) | ||
25 | |||
26 | ); | ||
27 | |||
28 | DEFINE_EVENT(spi_master, spi_master_idle, | ||
29 | |||
30 | TP_PROTO(struct spi_master *master), | ||
31 | |||
32 | TP_ARGS(master) | ||
33 | |||
34 | ); | ||
35 | |||
36 | DEFINE_EVENT(spi_master, spi_master_busy, | ||
37 | |||
38 | TP_PROTO(struct spi_master *master), | ||
39 | |||
40 | TP_ARGS(master) | ||
41 | |||
42 | ); | ||
43 | |||
44 | DECLARE_EVENT_CLASS(spi_message, | ||
45 | |||
46 | TP_PROTO(struct spi_message *msg), | ||
47 | |||
48 | TP_ARGS(msg), | ||
49 | |||
50 | TP_STRUCT__entry( | ||
51 | __field( int, bus_num ) | ||
52 | __field( int, chip_select ) | ||
53 | __field( struct spi_message *, msg ) | ||
54 | ), | ||
55 | |||
56 | TP_fast_assign( | ||
57 | __entry->bus_num = msg->spi->master->bus_num; | ||
58 | __entry->chip_select = msg->spi->chip_select; | ||
59 | __entry->msg = msg; | ||
60 | ), | ||
61 | |||
62 | TP_printk("spi%d.%d %p", (int)__entry->bus_num, | ||
63 | (int)__entry->chip_select, | ||
64 | (struct spi_message *)__entry->msg) | ||
65 | ); | ||
66 | |||
67 | DEFINE_EVENT(spi_message, spi_message_submit, | ||
68 | |||
69 | TP_PROTO(struct spi_message *msg), | ||
70 | |||
71 | TP_ARGS(msg) | ||
72 | |||
73 | ); | ||
74 | |||
75 | DEFINE_EVENT(spi_message, spi_message_start, | ||
76 | |||
77 | TP_PROTO(struct spi_message *msg), | ||
78 | |||
79 | TP_ARGS(msg) | ||
80 | |||
81 | ); | ||
82 | |||
83 | DEFINE_EVENT(spi_message, spi_message_done, | ||
84 | |||
85 | TP_PROTO(struct spi_message *msg), | ||
86 | |||
87 | TP_ARGS(msg) | ||
88 | |||
89 | ); | ||
90 | |||
91 | #endif /* _TRACE_POWER_H */ | ||
92 | |||
93 | /* This part must be outside protection */ | ||
94 | #include <trace/define_trace.h> | ||