Repository navigation
IPC fixes -- for snd_pcm_period_elapse() invoking - #849
Conversation
keyonjie
commented
Apr 19, 2019
plbossart
left a comment
There was a problem hiding this comment.
see comments below, the clarity of the explanations isn't up to par and needs to be improved.
There was a problem hiding this comment.
s/elapsed/period_elapsed/ in this patch please.
|
@plbossart @keyonjie I understand the rationale for scheduling period_elapsed_work for later but I feel like we might be missing something fundamental in the way we deal with shared IRQ. But the change feels OK for now. I'll work with @lyakh after he's back from vacation to dig deeper. |
xiulipan
left a comment
There was a problem hiding this comment.
Fix looks good to change snd_pcm_period_elapsed from sync to async. That will help to make sure IPC thread is not blocking.
But indeed need to refine the comment and commit to give a more convince explanation about why need to use a task for snd_pcm_period_elapsed
And it fix #808
[ 73.081644] sof-audio-acpi 80860F28:01: pcm: trigger stream 0 dir 0 cmd 0
[ 73.081668] sof-audio-acpi 80860F28:01: ipc tx: 0x60050000: GLB_STREAM_MSG: TRIG_STOP
[ 73.082610] sof-audio-acpi 80860F28:01: ipc tx succeeded: 0x60050000: GLB_STREAM_MSG: TRIG_STOP
[ 73.082650] sof-audio-acpi 80860F28:01: pcm: free stream 0 dir 0
[ 73.082664] sof-audio-acpi 80860F28:01: ipc tx: 0x60030000: GLB_STREAM_MSG: PCM_FREE
[ 73.082790] sof-audio-acpi 80860F28:01: ipc tx succeeded: 0x60030000: GLB_STREAM_MSG: PCM_FREE
[ 73.082883] sof-audio-acpi 80860F28:01: pcm: close stream 0 dir 0
[ 73.330420] sof-audio-acpi 80860F28:01: ipc rx: 0x90020000: GLB_TRACE_MSG
[ 73.330442] sof-audio-acpi 80860F28:01: ipc rx done: 0x90020000: GLB_TRACE_MSG
|
@plbossart @keyonjie the more I look into this code, the more confusing it is to me. When the stream interrupt handler arrives, it already defers processing by waking up the threaded interrupt handler( hda_dsp_stream_threaded_handler). The whole idea of a threaded interrupt handler is to be able to do the processing while the interrupts themselves are not disabled. So when the hda_dsp_stream_threaded_handler calls snd_pcm_period_elapse() which in turn sends an IPC to the DSP and waits for a reply, the interrupts are not disabled. So this doesn't seem to explain why this would cause a timeout at all? Please correct me if I am wrong. |
|
I did a bit of reading on the topic and the threaded handler does disable interrupts until it is done processing. Sorry about the confusion. |
|
Actually snd_pcm_period_elapsed is a complex function and one principle in Linux kernel development: never make interrupt function too complex. |
|
@keyonjie I don't see any updated code and I will be unavailable tomorrow morning, so this PR will be delayed mechanically until mid-week... |
79dfeda to
9952af7
Compare
|
@plbossart updated now. |
9952af7 to
e13f182
Compare
|
@plbossart thanks, one more update done today. |
plbossart
left a comment
There was a problem hiding this comment.
please fix what can be seen as a typo. it's period_elapsed.
There was a problem hiding this comment.
please fix what can be seen as a typo. it's period_elapsed.
OK, done.
e13f182 to
980dd95
Compare
980dd95 to
72733a1
Compare
…rrupt context The IPC implementation in SOF requires sending IPCs serially: we should not send a new IPC command to the firmware before we get an ACK (or time out) from firmware, and the IRQ processing is complete. snd_pcm_period_elapsed() can be called in interrupt context before IRQ_HANDLED is returned. When the PCM is done draining, a STOP IPC will then be sent, which breaks the expectation that IPCs are handled serially and leads to IPC timeouts. This patch adds a workqueue to defer the call to snd_pcm_elapsed() after the IRQ is handled. Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
Switch to a wrapper function which schedules the actual call of snd_pcm_period_elapsed after the current IPC is completed. Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
Switch to a wrapper function which schedules the actual call of snd_pcm_period_elapsed after the current IPC is completed. Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
|
LGTM |