Skip to content

Commit 526e21a

Browse files
committed
firewire: ohci: add tracepoints event for data of Self-ID DMA
In 1394 OHCI, the SelfIDComplete event occurs when the hardware has finished transmitting all of the self ID packets received during the bus initialization process to the host memory by DMA. This commit adds a tracepoints event for this event to trace the timing and packet data of Self-ID DMA. It is the part of following tracepoints events helpful to debug some events at bus reset; e.g. the issue addressed at a commit d0b06dc ("firewire: core: use long bus reset on gap count error")[1]: * firewire_ohci:irqs * firewire_ohci:self_id_complete * firewire:bus_reset_handle * firewire:self_id_sequence They would be also helpful in the problem about invocation timing of hardIRQ and process (workqueue) contexts. We can often see this kind of problem with -rt kernel[2]. [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=d0b06dc48fb1 [2] https://lore.kernel.org/linux-rt-users/YAwPoaUZ1gTD5y+k@hmbx/ Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Takashi Sakamoto <[email protected]>
1 parent 4a13617 commit 526e21a

File tree

2 files changed

+64
-1
lines changed

2 files changed

+64
-1
lines changed

drivers/firewire/ohci.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@
4545

4646
#include <trace/events/firewire.h>
4747

48+
static u32 cond_le32_to_cpu(__le32 value, bool has_be_header_quirk);
49+
4850
#define CREATE_TRACE_POINTS
4951
#include <trace/events/firewire_ohci.h>
5052

@@ -2208,8 +2210,15 @@ static irqreturn_t irq_handler(int irq, void *data)
22082210
if (event & OHCI1394_busReset)
22092211
reg_write(ohci, OHCI1394_IntMaskClear, OHCI1394_busReset);
22102212

2211-
if (event & OHCI1394_selfIDComplete)
2213+
if (event & OHCI1394_selfIDComplete) {
2214+
if (trace_self_id_complete_enabled()) {
2215+
u32 reg = reg_read(ohci, OHCI1394_SelfIDCount);
2216+
2217+
trace_self_id_complete(ohci->card.index, reg, ohci->self_id,
2218+
has_be_header_quirk(ohci));
2219+
}
22122220
queue_work(selfid_workqueue, &ohci->bus_reset_work);
2221+
}
22132222

22142223
if (event & OHCI1394_RQPkt)
22152224
tasklet_schedule(&ohci->ar_request_ctx.tasklet);

include/trace/events/firewire_ohci.h

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
#include <linux/tracepoint.h>
1111

12+
// Some macros and helper functions are defined in 'drivers/firewire/ohci.c'.
13+
1214
TRACE_EVENT(irqs,
1315
TP_PROTO(unsigned int card_index, u32 events),
1416
TP_ARGS(card_index, events),
@@ -42,6 +44,58 @@ TRACE_EVENT(irqs,
4244
)
4345
);
4446

47+
#define QUADLET_SIZE 4
48+
49+
#define SELF_ID_COUNT_IS_ERROR(reg) \
50+
(!!(((reg) & OHCI1394_SelfIDCount_selfIDError_MASK) >> OHCI1394_SelfIDCount_selfIDError_SHIFT))
51+
52+
#define SELF_ID_COUNT_GET_GENERATION(reg) \
53+
(((reg) & OHCI1394_SelfIDCount_selfIDGeneration_MASK) >> OHCI1394_SelfIDCount_selfIDGeneration_SHIFT)
54+
55+
#define SELF_ID_RECEIVE_Q0_GET_GENERATION(quadlet) \
56+
(((quadlet) & OHCI1394_SELF_ID_RECEIVE_Q0_GENERATION_MASK) >> OHCI1394_SELF_ID_RECEIVE_Q0_GENERATION_SHIFT)
57+
58+
#define SELF_ID_RECEIVE_Q0_GET_TIMESTAMP(quadlet) \
59+
(((quadlet) & OHCI1394_SELF_ID_RECEIVE_Q0_TIMESTAMP_MASK) >> OHCI1394_SELF_ID_RECEIVE_Q0_TIMESTAMP_SHIFT)
60+
61+
TRACE_EVENT(self_id_complete,
62+
TP_PROTO(unsigned int card_index, u32 reg, const __le32 *self_id_receive, bool has_be_header_quirk),
63+
TP_ARGS(card_index, reg, self_id_receive, has_be_header_quirk),
64+
TP_STRUCT__entry(
65+
__field(u8, card_index)
66+
__field(u32, reg)
67+
__dynamic_array(u32, self_id_receive, ohci1394_self_id_count_get_size(reg))
68+
),
69+
TP_fast_assign(
70+
__entry->card_index = card_index;
71+
__entry->reg = reg;
72+
{
73+
u32 *ptr = __get_dynamic_array(self_id_receive);
74+
int i;
75+
76+
for (i = 0; i < __get_dynamic_array_len(self_id_receive) / QUADLET_SIZE; ++i)
77+
ptr[i] = cond_le32_to_cpu(self_id_receive[i], has_be_header_quirk);
78+
}
79+
),
80+
TP_printk(
81+
"card_index=%u is_error=%s generation_at_bus_reset=%u generation_at_completion=%u timestamp=0x%04x packet_data=%s",
82+
__entry->card_index,
83+
SELF_ID_COUNT_IS_ERROR(__entry->reg) ? "true" : "false",
84+
SELF_ID_COUNT_GET_GENERATION(__entry->reg),
85+
SELF_ID_RECEIVE_Q0_GET_GENERATION(((const u32 *)__get_dynamic_array(self_id_receive))[0]),
86+
SELF_ID_RECEIVE_Q0_GET_TIMESTAMP(((const u32 *)__get_dynamic_array(self_id_receive))[0]),
87+
__print_array(((const u32 *)__get_dynamic_array(self_id_receive)) + 1,
88+
(__get_dynamic_array_len(self_id_receive) / QUADLET_SIZE) - 1, QUADLET_SIZE)
89+
)
90+
);
91+
92+
#undef SELF_ID_COUNT_IS_ERROR
93+
#undef SELF_ID_COUNT_GET_GENERATION
94+
#undef SELF_ID_RECEIVE_Q0_GET_GENERATION
95+
#undef SELF_ID_RECEIVE_Q0_GET_TIMESTAMP
96+
97+
#undef QUADLET_SIZE
98+
4599
#endif // _FIREWIRE_OHCI_TRACE_EVENT_H
46100

47101
#include <trace/define_trace.h>

0 commit comments

Comments
 (0)