Commit f0117128 authored by Takashi Sakamoto's avatar Takashi Sakamoto Committed by Takashi Iwai

ALSA: firewire-lib: keep history to process isochronous packet

The history to process isochronous packets is useful when computing gap
between current isochronous cycle and the latest isochronous cycle in
which packet is processed (in IR context) and scheduled (in IT context).

This commit stores the most recent packet descriptors to keep the history.
Signed-off-by: default avatarTakashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20230109021738.75543-4-o-takashi@sakamocchi.jpSigned-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 0cac60c7
...@@ -1047,7 +1047,7 @@ static void process_rx_packets(struct fw_iso_context *context, u32 tstamp, size_ ...@@ -1047,7 +1047,7 @@ static void process_rx_packets(struct fw_iso_context *context, u32 tstamp, size_
const __be32 *ctx_header = header; const __be32 *ctx_header = header;
const unsigned int events_per_period = d->events_per_period; const unsigned int events_per_period = d->events_per_period;
unsigned int event_count = s->ctx_data.rx.event_count; unsigned int event_count = s->ctx_data.rx.event_count;
struct pkt_desc *desc = s->pkt_descs; struct pkt_desc *desc = s->packet_descs_cursor;
unsigned int pkt_header_length; unsigned int pkt_header_length;
unsigned int packets; unsigned int packets;
bool need_hw_irq; bool need_hw_irq;
...@@ -1106,6 +1106,7 @@ static void process_rx_packets(struct fw_iso_context *context, u32 tstamp, size_ ...@@ -1106,6 +1106,7 @@ static void process_rx_packets(struct fw_iso_context *context, u32 tstamp, size_
} }
s->ctx_data.rx.event_count = event_count; s->ctx_data.rx.event_count = event_count;
s->packet_descs_cursor = desc;
} }
static void skip_rx_packets(struct fw_iso_context *context, u32 tstamp, size_t header_length, static void skip_rx_packets(struct fw_iso_context *context, u32 tstamp, size_t header_length,
...@@ -1202,7 +1203,7 @@ static void process_tx_packets(struct fw_iso_context *context, u32 tstamp, size_ ...@@ -1202,7 +1203,7 @@ static void process_tx_packets(struct fw_iso_context *context, u32 tstamp, size_
{ {
struct amdtp_stream *s = private_data; struct amdtp_stream *s = private_data;
__be32 *ctx_header = header; __be32 *ctx_header = header;
struct pkt_desc *desc = s->pkt_descs; struct pkt_desc *desc = s->packet_descs_cursor;
unsigned int packet_count; unsigned int packet_count;
unsigned int desc_count; unsigned int desc_count;
int i; int i;
...@@ -1228,6 +1229,10 @@ static void process_tx_packets(struct fw_iso_context *context, u32 tstamp, size_ ...@@ -1228,6 +1229,10 @@ static void process_tx_packets(struct fw_iso_context *context, u32 tstamp, size_
if (d->replay.enable) if (d->replay.enable)
cache_seq(s, desc, desc_count); cache_seq(s, desc, desc_count);
for (i = 0; i < desc_count; ++i)
desc = amdtp_stream_next_packet_desc(s, desc);
s->packet_descs_cursor = desc;
} }
for (i = 0; i < packet_count; ++i) { for (i = 0; i < packet_count; ++i) {
...@@ -1664,7 +1669,7 @@ static int amdtp_stream_start(struct amdtp_stream *s, int channel, int speed, ...@@ -1664,7 +1669,7 @@ static int amdtp_stream_start(struct amdtp_stream *s, int channel, int speed,
err = -ENOMEM; err = -ENOMEM;
goto err_context; goto err_context;
} }
s->pkt_descs = descs; s->packet_descs = descs;
INIT_LIST_HEAD(&s->packet_descs_list); INIT_LIST_HEAD(&s->packet_descs_list);
for (i = 0; i < s->queue_size; ++i) { for (i = 0; i < s->queue_size; ++i) {
...@@ -1672,6 +1677,7 @@ static int amdtp_stream_start(struct amdtp_stream *s, int channel, int speed, ...@@ -1672,6 +1677,7 @@ static int amdtp_stream_start(struct amdtp_stream *s, int channel, int speed,
list_add_tail(&descs->link, &s->packet_descs_list); list_add_tail(&descs->link, &s->packet_descs_list);
++descs; ++descs;
} }
s->packet_descs_cursor = list_first_entry(&s->packet_descs_list, struct pkt_desc, link);
s->packet_index = 0; s->packet_index = 0;
do { do {
...@@ -1710,8 +1716,8 @@ static int amdtp_stream_start(struct amdtp_stream *s, int channel, int speed, ...@@ -1710,8 +1716,8 @@ static int amdtp_stream_start(struct amdtp_stream *s, int channel, int speed,
return 0; return 0;
err_pkt_descs: err_pkt_descs:
kfree(s->pkt_descs); kfree(s->packet_descs);
s->pkt_descs = NULL; s->packet_descs = NULL;
err_context: err_context:
if (s->direction == AMDTP_OUT_STREAM) { if (s->direction == AMDTP_OUT_STREAM) {
kfree(s->ctx_data.rx.seq.descs); kfree(s->ctx_data.rx.seq.descs);
...@@ -1805,8 +1811,8 @@ static void amdtp_stream_stop(struct amdtp_stream *s) ...@@ -1805,8 +1811,8 @@ static void amdtp_stream_stop(struct amdtp_stream *s)
fw_iso_context_destroy(s->context); fw_iso_context_destroy(s->context);
s->context = ERR_PTR(-1); s->context = ERR_PTR(-1);
iso_packets_buffer_destroy(&s->buffer, s->unit); iso_packets_buffer_destroy(&s->buffer, s->unit);
kfree(s->pkt_descs); kfree(s->packet_descs);
s->pkt_descs = NULL; s->packet_descs = NULL;
if (s->direction == AMDTP_OUT_STREAM) { if (s->direction == AMDTP_OUT_STREAM) {
kfree(s->ctx_data.rx.seq.descs); kfree(s->ctx_data.rx.seq.descs);
......
...@@ -126,8 +126,9 @@ struct amdtp_stream { ...@@ -126,8 +126,9 @@ struct amdtp_stream {
struct iso_packets_buffer buffer; struct iso_packets_buffer buffer;
unsigned int queue_size; unsigned int queue_size;
int packet_index; int packet_index;
struct pkt_desc *pkt_descs; struct pkt_desc *packet_descs;
struct list_head packet_descs_list; struct list_head packet_descs_list;
struct pkt_desc *packet_descs_cursor;
int tag; int tag;
union { union {
struct { struct {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment