Skip to content

Commit 814b431

Browse files
takaswietiwai
authored andcommitted
ALSA: firewire-lib: fix amdtp_packet tracepoints event for packet_index field
The snd_firewire_lib:amdtp_packet tracepoints event includes index of packet processed in a context handling. However in IR context, it is not calculated as expected. Cc: <[email protected]> Fixes: 753e717 ("ALSA: firewire-lib: use packet descriptor for IR context") Signed-off-by: Takashi Sakamoto <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
1 parent 1be4f21 commit 814b431

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

sound/firewire/amdtp-stream-trace.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
#include <linux/tracepoint.h>
1515

1616
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 index),
18-
TP_ARGS(s, cycles, cip_header, payload_length, data_blocks, data_block_counter, 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),
18+
TP_ARGS(s, cycles, cip_header, payload_length, data_blocks, data_block_counter, packet_index, index),
1919
TP_STRUCT__entry(
2020
__field(unsigned int, second)
2121
__field(unsigned int, cycle)
@@ -48,7 +48,7 @@ TRACE_EVENT(amdtp_packet,
4848
__entry->payload_quadlets = payload_length / sizeof(__be32);
4949
__entry->data_blocks = data_blocks;
5050
__entry->data_block_counter = data_block_counter,
51-
__entry->packet_index = s->packet_index;
51+
__entry->packet_index = packet_index;
5252
__entry->irq = !!in_interrupt();
5353
__entry->index = index;
5454
),

sound/firewire/amdtp-stream.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ static void build_it_pkt_header(struct amdtp_stream *s, unsigned int cycle,
526526
}
527527

528528
trace_amdtp_packet(s, cycle, cip_header, payload_length, data_blocks,
529-
data_block_counter, index);
529+
data_block_counter, s->packet_index, index);
530530
}
531531

532532
static int check_cip_header(struct amdtp_stream *s, const __be32 *buf,
@@ -630,7 +630,7 @@ static int parse_ir_ctx_header(struct amdtp_stream *s, unsigned int cycle,
630630
unsigned int *payload_length,
631631
unsigned int *data_blocks,
632632
unsigned int *data_block_counter,
633-
unsigned int *syt, unsigned int index)
633+
unsigned int *syt, unsigned int packet_index, unsigned int index)
634634
{
635635
const __be32 *cip_header;
636636
unsigned int cip_header_size;
@@ -668,7 +668,7 @@ static int parse_ir_ctx_header(struct amdtp_stream *s, unsigned int cycle,
668668
}
669669

670670
trace_amdtp_packet(s, cycle, cip_header, *payload_length, *data_blocks,
671-
*data_block_counter, index);
671+
*data_block_counter, packet_index, index);
672672

673673
return err;
674674
}
@@ -707,12 +707,13 @@ static int generate_device_pkt_descs(struct amdtp_stream *s,
707707
unsigned int packets)
708708
{
709709
unsigned int dbc = s->data_block_counter;
710+
unsigned int packet_index = s->packet_index;
711+
unsigned int queue_size = s->queue_size;
710712
int i;
711713
int err;
712714

713715
for (i = 0; i < packets; ++i) {
714716
struct pkt_desc *desc = descs + i;
715-
unsigned int index = (s->packet_index + i) % s->queue_size;
716717
unsigned int cycle;
717718
unsigned int payload_length;
718719
unsigned int data_blocks;
@@ -721,21 +722,23 @@ static int generate_device_pkt_descs(struct amdtp_stream *s,
721722
cycle = compute_cycle_count(ctx_header[1]);
722723

723724
err = parse_ir_ctx_header(s, cycle, ctx_header, &payload_length,
724-
&data_blocks, &dbc, &syt, i);
725+
&data_blocks, &dbc, &syt, packet_index, i);
725726
if (err < 0)
726727
return err;
727728

728729
desc->cycle = cycle;
729730
desc->syt = syt;
730731
desc->data_blocks = data_blocks;
731732
desc->data_block_counter = dbc;
732-
desc->ctx_payload = s->buffer.packets[index].buffer;
733+
desc->ctx_payload = s->buffer.packets[packet_index].buffer;
733734

734735
if (!(s->flags & CIP_DBC_IS_END_EVENT))
735736
dbc = (dbc + desc->data_blocks) & 0xff;
736737

737738
ctx_header +=
738739
s->ctx_data.tx.ctx_header_size / sizeof(*ctx_header);
740+
741+
packet_index = (packet_index + 1) % queue_size;
739742
}
740743

741744
s->data_block_counter = dbc;

0 commit comments

Comments
 (0)