Repository navigation
IPC fixes -- interrupt handler - #850
Conversation
There was a problem hiding this comment.
Allow me to challenge this patch. The only time where sdev->irq_status is used is in hda_dsp_ipc_irq_thread(), where we do this:
/* here we handle IPC interrupts only */
if (!(sdev->irq_status & HDA_DSP_ADSPIS_IPC))
return IRQ_NONE;So what does this fix improve?
There was a problem hiding this comment.
@plbossart I agree. I think both the sdev->irq_status saving and the check again in hda_dsp_ipc_irq_thread() are unnecessary.
There was a problem hiding this comment.
@plbossart
Let us think about a situation here:
Let IRQ A to be the IPC IRQ we need to handle and wake a thread.
Let IRQ B some IOC IRQ from HDA.
IRQ A comes, in the handle sdev->irq_status is set to be some useful value and we wake up the thread.
Before we go to the check bellow
/* here we handle IPC interrupts only */
if (!(sdev->irq_status & HDA_DSP_ADSPIS_IPC))
return IRQ_NONE;
IRQ B comes and reset the sdev->irq_status and do nothing
What will happen to the thread that already wake up by IRQ A?
It will just return IRQ_NONE;
And we will lost the chance to handle the IPC with IRQ A.
@ranj063
You mean we did not check the status again in thread if we return the right value in handler?
That will only work if the handler will only wake the thread bind to itself. I am not sure if the code will do like that. If so I agree with you change to leave the check in one place.
linux/sound/soc/sof/intel/hda.c
Lines 509 to 522 in 9086043
There was a problem hiding this comment.
clarify this is the maximum total playback + capture streams supported by the hardware.
This is NOT the current total number of streams in use.
There was a problem hiding this comment.
correct, maybe something like "num_of_streams_supported"?
There was a problem hiding this comment.
store total stream count (playback + capture) from GCAP
xiulipan
left a comment
There was a problem hiding this comment.
A good catch, hope I have make a right explanation to what you mean @keyonjie
Maybe we should figure out what will be request_threaded_irq do with the handler and thread that bind together.
If handler wakes only the thread bind to itself. No more check in thread is needed. Be careful in handler is enough.
There was a problem hiding this comment.
@plbossart
Let us think about a situation here:
Let IRQ A to be the IPC IRQ we need to handle and wake a thread.
Let IRQ B some IOC IRQ from HDA.
IRQ A comes, in the handle sdev->irq_status is set to be some useful value and we wake up the thread.
Before we go to the check bellow
/* here we handle IPC interrupts only */
if (!(sdev->irq_status & HDA_DSP_ADSPIS_IPC))
return IRQ_NONE;
IRQ B comes and reset the sdev->irq_status and do nothing
What will happen to the thread that already wake up by IRQ A?
It will just return IRQ_NONE;
And we will lost the chance to handle the IPC with IRQ A.
@ranj063
You mean we did not check the status again in thread if we return the right value in handler?
That will only work if the handler will only wake the thread bind to itself. I am not sure if the code will do like that. If so I agree with you change to leave the check in one place.
linux/sound/soc/sof/intel/hda.c
Lines 509 to 522 in 9086043
|
no updated code -> PR will not be merged until mid-week... |
9fb8432 to
009f7a5
Compare
|
@plbossart updated. |
plbossart
left a comment
There was a problem hiding this comment.
Please explain the first commit message in more details, what you wrote is not incorrect but doesn't capture the discussions in this PR.
009f7a5 to
4dbfc02
Compare
|
hi @ranj063 @plbossart Thanks for reviewing, updated now. |
plbossart
left a comment
There was a problem hiding this comment.
You made a change that just invalidates everything we've talked about. If you remove the check for the irq_status, then there is no possible race condition and the irq_status is useless.
I can't merge stuff that makes no sense, sorry.
4dbfc02 to
51b1523
Compare
|
@plbossart @ranj063 updated, irq_status is removed from sdev, and commit message updated alongside. |
plbossart
left a comment
There was a problem hiding this comment.
Confused on the first commit and open on the 3rd one, see below.
Thanks for the quick feedback, let's try and close this
There was a problem hiding this comment.
does it makes sense to place the log here, knowing that you read the same value below inside of a spin_lock?
Either remove this log or do this right.
There was a problem hiding this comment.
@plbossart I'd like to keep this here, as we need debug the case return before the spin_lock below sometimes (returned at pm_runtime_active failed).
There was a problem hiding this comment.
then add a comment that this is explicit and not a mistake
|
@plbossart @ranj063 can you help check if this commit message fine from your points: |
|
@keyonjie the commit message is too complicated. I'd simplify it like this: When using a shared IRQ between IPC interrupt and stream IOC interrupt, the interrupt handlers need to check the interrupt source before scheduling their respective IRQ threads. In the case of IPC handler, it should check if it is an IPC interrupt and wake up the the IPC IRQ thread. The IPC IRQ thread, once scheduled, does not need to check the IRQ source again. So, remove the superfluous check in the thread and remove the irq_status field from snd_sof_dev struct as it is no longer needed. Please feel free to modify it. |
Thanks, let me take it. |
51b1523 to
7644f4a
Compare
|
updated, @ranj063 @plbossart please help review. |
plbossart
left a comment
There was a problem hiding this comment.
ok, we're almost good. please fix the first commit title Commit 5d4f2f69badd ("ASoC: SOF: Intel: hda-ipc: remove irq_status from sdev and fix missing handling to IPC IRQ in the thread") is really too long, and add a comment for the dev_vdbg. Thanks!
There was a problem hiding this comment.
then add a comment that this is explicit and not a mistake
7644f4a to
70f9f01
Compare
Thanks, both addressed and updated, please help review. |
|
@keyonjie |
There was a problem hiding this comment.
@keyonjie do we need to intialize this to 0? we had to remove a lot of these lately. so we should be carefulof adding these in the future too.
There was a problem hiding this comment.
Good catch, this init is not needed?
There was a problem hiding this comment.
Good catch, this init is not needed?
There was a problem hiding this comment.
The explanation isn't very useful...
"Intentionally add verbose log before pm_runtime and spin lock"
There was a problem hiding this comment.
I don't want to add comments with "hardcoding" consequent invoking, which means we need maintain/update it once those invoking changed, maybe remove this verbose debugging can make everybody happy.
When using a shared IRQ between IPC interrupt and stream IOC interrupt, the interrupt handlers need to check the interrupt source before scheduling their respective IRQ threads. In the case of IPC handler, it should check if it is an IPC interrupt before waking up the IPC IRQ thread. The IPC IRQ thread, once scheduled, does not need to check the IRQ source again. So, remove the superfluous check in the thread. Remove the irq_status field from snd_sof_dev struct also as it is no longer needed. Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
Add stream_max into struct sof_intel_hda_dev to store the total hda stream number that the platform can support, and initialize it at stream_init. This can be used later e.g. for stream bitmask. Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
70f9f01 to
d9f2c03
Compare
|
@plbossart @ranj063 updated. |
The stream and IPC share the same interrupt. The stream interrupt handler mistakenly uses the ipc interrupt and return IRQ_HANDLED, causing the ipc interrupt to be missed. Make sure the stream interrupt handler only deals with stream-related interrupts. Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
We are using share irq for IPC and stream IOC interrupts.
This is a harden series to our IPC and stream interrupt handler, to make sure they won't take wrong ones and interfere with each other.
This fix might benefit to common IPC issues, e.g. thesofproject/sof#1254