Commit 92b862c7 authored by Clemens Ladisch's avatar Clemens Ladisch Committed by Takashi Iwai

ALSA: firewire-lib: optimize packet flushing

Trying to flush completed packets is pointless when the pointer
callback was called from the packet completion callback; avoid it.
Signed-off-by: default avatarClemens Ladisch <clemens@ladisch.de>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent e9148ddd
...@@ -178,6 +178,7 @@ void amdtp_out_stream_pcm_prepare(struct amdtp_out_stream *s) ...@@ -178,6 +178,7 @@ void amdtp_out_stream_pcm_prepare(struct amdtp_out_stream *s)
tasklet_kill(&s->period_tasklet); tasklet_kill(&s->period_tasklet);
s->pcm_buffer_pointer = 0; s->pcm_buffer_pointer = 0;
s->pcm_period_pointer = 0; s->pcm_period_pointer = 0;
s->pointer_flush = true;
} }
EXPORT_SYMBOL(amdtp_out_stream_pcm_prepare); EXPORT_SYMBOL(amdtp_out_stream_pcm_prepare);
...@@ -393,6 +394,7 @@ static void queue_out_packet(struct amdtp_out_stream *s, unsigned int cycle) ...@@ -393,6 +394,7 @@ static void queue_out_packet(struct amdtp_out_stream *s, unsigned int cycle)
s->pcm_period_pointer += data_blocks; s->pcm_period_pointer += data_blocks;
if (s->pcm_period_pointer >= pcm->runtime->period_size) { if (s->pcm_period_pointer >= pcm->runtime->period_size) {
s->pcm_period_pointer -= pcm->runtime->period_size; s->pcm_period_pointer -= pcm->runtime->period_size;
s->pointer_flush = false;
tasklet_hi_schedule(&s->period_tasklet); tasklet_hi_schedule(&s->period_tasklet);
} }
} }
...@@ -539,7 +541,11 @@ EXPORT_SYMBOL(amdtp_out_stream_start); ...@@ -539,7 +541,11 @@ EXPORT_SYMBOL(amdtp_out_stream_start);
*/ */
unsigned long amdtp_out_stream_pcm_pointer(struct amdtp_out_stream *s) unsigned long amdtp_out_stream_pcm_pointer(struct amdtp_out_stream *s)
{ {
fw_iso_context_flush_completions(s->context); /* this optimization is allowed to be racy */
if (s->pointer_flush)
fw_iso_context_flush_completions(s->context);
else
s->pointer_flush = true;
return ACCESS_ONCE(s->pcm_buffer_pointer); return ACCESS_ONCE(s->pcm_buffer_pointer);
} }
......
...@@ -68,6 +68,7 @@ struct amdtp_out_stream { ...@@ -68,6 +68,7 @@ struct amdtp_out_stream {
unsigned int pcm_buffer_pointer; unsigned int pcm_buffer_pointer;
unsigned int pcm_period_pointer; unsigned int pcm_period_pointer;
bool pointer_flush;
}; };
int amdtp_out_stream_init(struct amdtp_out_stream *s, struct fw_unit *unit, int amdtp_out_stream_init(struct amdtp_out_stream *s, struct fw_unit *unit,
......
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