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

ALSA: firewire-lib: extend tracepoints event including CYCLE_TIME of 1394 OHCI

A commit baa914cd81f5 ("firewire: add kernel API to access CYCLE_TIME
register") allow unit drivers to read CYCLE_TIME of 1394 OHCI controller.
The value expresses monotonic time with 42.195 Mhz resolution and wrapping
around every 128 seconds. The controller uses the time to govern
isochronous cycle.

This commit extends tracepoints event including the value so that event
parser can compute gap between current isochronous cycle and the latest
isochronous cycle in which packet is processed (in IR context) or scheduled
(in IT context). It loses backward compatibility to former format of the
tracepoints event.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20230109213231.138223-1-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>

authored by

Takashi Sakamoto and committed by
Takashi Iwai
fef4e61b f0117128

+21 -9
+6 -3
sound/firewire/amdtp-stream-trace.h
··· 14 14 #include <linux/tracepoint.h> 15 15 16 16 TRACE_EVENT(amdtp_packet, 17 - TP_PROTO(const struct amdtp_stream *s, u32 cycles, const __be32 *cip_header, unsigned int payload_length, unsigned int data_blocks, unsigned int data_block_counter, unsigned int packet_index, unsigned int index), 18 - TP_ARGS(s, cycles, cip_header, payload_length, data_blocks, data_block_counter, packet_index, index), 17 + TP_PROTO(const struct amdtp_stream *s, u32 cycles, const __be32 *cip_header, unsigned int payload_length, unsigned int data_blocks, unsigned int data_block_counter, unsigned int packet_index, unsigned int index, u32 curr_cycle_time), 18 + TP_ARGS(s, cycles, cip_header, payload_length, data_blocks, data_block_counter, packet_index, index, curr_cycle_time), 19 19 TP_STRUCT__entry( 20 + __field(unsigned int, cycle_time) 20 21 __field(unsigned int, second) 21 22 __field(unsigned int, cycle) 22 23 __field(int, channel) ··· 32 31 __field(unsigned int, index) 33 32 ), 34 33 TP_fast_assign( 34 + __entry->cycle_time = curr_cycle_time; 35 35 __entry->second = cycles / CYCLES_PER_SECOND; 36 36 __entry->cycle = cycles % CYCLES_PER_SECOND; 37 37 __entry->channel = s->context->channel; ··· 55 53 __entry->index = index; 56 54 ), 57 55 TP_printk( 58 - "%02u %04u %04x %04x %02d %03u %02u %03u %02u %01u %02u %s", 56 + "%08x %02u %04u %04x %04x %02d %03u %02u %03u %02u %01u %02u %s", 57 + __entry->cycle_time, 59 58 __entry->second, 60 59 __entry->cycle, 61 60 __entry->src,
+15 -6
sound/firewire/amdtp-stream.c
··· 674 674 struct fw_iso_packet *params, unsigned int header_length, 675 675 unsigned int data_blocks, 676 676 unsigned int data_block_counter, 677 - unsigned int syt, unsigned int index) 677 + unsigned int syt, unsigned int index, u32 curr_cycle_time) 678 678 { 679 679 unsigned int payload_length; 680 680 __be32 *cip_header; ··· 691 691 } 692 692 693 693 trace_amdtp_packet(s, cycle, cip_header, payload_length + header_length, data_blocks, 694 - data_block_counter, s->packet_index, index); 694 + data_block_counter, s->packet_index, index, curr_cycle_time); 695 695 } 696 696 697 697 static int check_cip_header(struct amdtp_stream *s, const __be32 *buf, ··· 793 793 const __be32 *ctx_header, 794 794 unsigned int *data_blocks, 795 795 unsigned int *data_block_counter, 796 - unsigned int *syt, unsigned int packet_index, unsigned int index) 796 + unsigned int *syt, unsigned int packet_index, unsigned int index, 797 + u32 curr_cycle_time) 797 798 { 798 799 unsigned int payload_length; 799 800 const __be32 *cip_header; ··· 839 838 } 840 839 841 840 trace_amdtp_packet(s, cycle, cip_header, payload_length, *data_blocks, 842 - *data_block_counter, packet_index, index); 841 + *data_block_counter, packet_index, index, curr_cycle_time); 843 842 844 843 return 0; 845 844 } ··· 890 889 unsigned int dbc = s->data_block_counter; 891 890 unsigned int packet_index = s->packet_index; 892 891 unsigned int queue_size = s->queue_size; 892 + u32 curr_cycle_time; 893 893 int i; 894 894 int err; 895 + 896 + if (trace_amdtp_packet_enabled()) 897 + (void)fw_card_read_cycle_time(fw_parent_device(s->unit)->card, &curr_cycle_time); 895 898 896 899 *desc_count = 0; 897 900 for (i = 0; i < packet_count; ++i) { ··· 941 936 } 942 937 943 938 err = parse_ir_ctx_header(s, cycle, ctx_header, &data_blocks, &dbc, &syt, 944 - packet_index, i); 939 + packet_index, i, curr_cycle_time); 945 940 if (err < 0) 946 941 return err; 947 942 ··· 1055 1050 struct pkt_desc *desc = s->packet_descs_cursor; 1056 1051 unsigned int pkt_header_length; 1057 1052 unsigned int packets; 1053 + u32 curr_cycle_time; 1058 1054 bool need_hw_irq; 1059 1055 int i; 1060 1056 ··· 1084 1078 need_hw_irq = false; 1085 1079 } 1086 1080 1081 + if (trace_amdtp_packet_enabled()) 1082 + (void)fw_card_read_cycle_time(fw_parent_device(s->unit)->card, &curr_cycle_time); 1083 + 1087 1084 for (i = 0; i < packets; ++i) { 1088 1085 struct { 1089 1086 struct fw_iso_packet params; ··· 1096 1087 1097 1088 build_it_pkt_header(s, desc->cycle, &template.params, pkt_header_length, 1098 1089 desc->data_blocks, desc->data_block_counter, 1099 - desc->syt, i); 1090 + desc->syt, i, curr_cycle_time); 1100 1091 1101 1092 if (s == s->domain->irq_target) { 1102 1093 event_count += desc->data_blocks;