Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 d0b06dc48fb1 ("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/20240702222034.1378764-6-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>

+64 -1
+10 -1
drivers/firewire/ohci.c
··· 45 45 46 46 #include <trace/events/firewire.h> 47 47 48 + static u32 cond_le32_to_cpu(__le32 value, bool has_be_header_quirk); 49 + 48 50 #define CREATE_TRACE_POINTS 49 51 #include <trace/events/firewire_ohci.h> 50 52 ··· 2210 2208 if (event & OHCI1394_busReset) 2211 2209 reg_write(ohci, OHCI1394_IntMaskClear, OHCI1394_busReset); 2212 2210 2213 - if (event & OHCI1394_selfIDComplete) 2211 + if (event & OHCI1394_selfIDComplete) { 2212 + if (trace_self_id_complete_enabled()) { 2213 + u32 reg = reg_read(ohci, OHCI1394_SelfIDCount); 2214 + 2215 + trace_self_id_complete(ohci->card.index, reg, ohci->self_id, 2216 + has_be_header_quirk(ohci)); 2217 + } 2214 2218 queue_work(selfid_workqueue, &ohci->bus_reset_work); 2219 + } 2215 2220 2216 2221 if (event & OHCI1394_RQPkt) 2217 2222 tasklet_schedule(&ohci->ar_request_ctx.tasklet);
+54
include/trace/events/firewire_ohci.h
··· 9 9 10 10 #include <linux/tracepoint.h> 11 11 12 + // Some macros and helper functions are defined in 'drivers/firewire/ohci.c'. 13 + 12 14 TRACE_EVENT(irqs, 13 15 TP_PROTO(unsigned int card_index, u32 events), 14 16 TP_ARGS(card_index, events), ··· 43 41 ) 44 42 ) 45 43 ); 44 + 45 + #define QUADLET_SIZE 4 46 + 47 + #define SELF_ID_COUNT_IS_ERROR(reg) \ 48 + (!!(((reg) & OHCI1394_SelfIDCount_selfIDError_MASK) >> OHCI1394_SelfIDCount_selfIDError_SHIFT)) 49 + 50 + #define SELF_ID_COUNT_GET_GENERATION(reg) \ 51 + (((reg) & OHCI1394_SelfIDCount_selfIDGeneration_MASK) >> OHCI1394_SelfIDCount_selfIDGeneration_SHIFT) 52 + 53 + #define SELF_ID_RECEIVE_Q0_GET_GENERATION(quadlet) \ 54 + (((quadlet) & OHCI1394_SELF_ID_RECEIVE_Q0_GENERATION_MASK) >> OHCI1394_SELF_ID_RECEIVE_Q0_GENERATION_SHIFT) 55 + 56 + #define SELF_ID_RECEIVE_Q0_GET_TIMESTAMP(quadlet) \ 57 + (((quadlet) & OHCI1394_SELF_ID_RECEIVE_Q0_TIMESTAMP_MASK) >> OHCI1394_SELF_ID_RECEIVE_Q0_TIMESTAMP_SHIFT) 58 + 59 + TRACE_EVENT(self_id_complete, 60 + TP_PROTO(unsigned int card_index, u32 reg, const __le32 *self_id_receive, bool has_be_header_quirk), 61 + TP_ARGS(card_index, reg, self_id_receive, has_be_header_quirk), 62 + TP_STRUCT__entry( 63 + __field(u8, card_index) 64 + __field(u32, reg) 65 + __dynamic_array(u32, self_id_receive, ohci1394_self_id_count_get_size(reg)) 66 + ), 67 + TP_fast_assign( 68 + __entry->card_index = card_index; 69 + __entry->reg = reg; 70 + { 71 + u32 *ptr = __get_dynamic_array(self_id_receive); 72 + int i; 73 + 74 + for (i = 0; i < __get_dynamic_array_len(self_id_receive) / QUADLET_SIZE; ++i) 75 + ptr[i] = cond_le32_to_cpu(self_id_receive[i], has_be_header_quirk); 76 + } 77 + ), 78 + TP_printk( 79 + "card_index=%u is_error=%s generation_at_bus_reset=%u generation_at_completion=%u timestamp=0x%04x packet_data=%s", 80 + __entry->card_index, 81 + SELF_ID_COUNT_IS_ERROR(__entry->reg) ? "true" : "false", 82 + SELF_ID_COUNT_GET_GENERATION(__entry->reg), 83 + SELF_ID_RECEIVE_Q0_GET_GENERATION(((const u32 *)__get_dynamic_array(self_id_receive))[0]), 84 + SELF_ID_RECEIVE_Q0_GET_TIMESTAMP(((const u32 *)__get_dynamic_array(self_id_receive))[0]), 85 + __print_array(((const u32 *)__get_dynamic_array(self_id_receive)) + 1, 86 + (__get_dynamic_array_len(self_id_receive) / QUADLET_SIZE) - 1, QUADLET_SIZE) 87 + ) 88 + ); 89 + 90 + #undef SELF_ID_COUNT_IS_ERROR 91 + #undef SELF_ID_COUNT_GET_GENERATION 92 + #undef SELF_ID_RECEIVE_Q0_GET_GENERATION 93 + #undef SELF_ID_RECEIVE_Q0_GET_TIMESTAMP 94 + 95 + #undef QUADLET_SIZE 46 96 47 97 #endif // _FIREWIRE_OHCI_TRACE_EVENT_H 48 98