public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* ASoC: SOF: Race condition in ipc.c
@ 2022-06-21  2:46 noman pouigt
  2022-06-21 13:11 ` [Sound-open-firmware] " Pierre-Louis Bossart
  0 siblings, 1 reply; 3+ messages in thread
From: noman pouigt @ 2022-06-21  2:46 UTC (permalink / raw)
  To: Mark Brown, liam.r.girdwood
  Cc: linux-kernel, yangyingliang, alsa-devel, sound-open-firmware,
	yung-chuan.liao, ranjani.sridharan, peter.ujfalusi,
	pierre-louis.bossart, rander.wang

Folks,

I have borrowed part of SOF architecture for my own DSP
framework development as the memory on the DSP is
extremely small and wouldn't be able to support SOF.

Currently I am running into a race condition as below:

CPU                                            DSP
PCM_TRIGGER_START
sof_ipc_send_msg ---->

                                      <------Immediate ACK
ipc3_wait_tx_done
(wait_event_timeout)
                                      <------ POSITION update

snd_pcm_period_elapsed


As you can see TRIGGER_START didn't even finish
and waiting for it to complete in ipc3_wait_tx_done
function. However, before it could complete the position
interrupt was issued which results in calling period_elapsed
function.

In order to fix this I assume below is called in SOF framework:
schedule_work(&spcm->stream[substream->stream].period_elapsed_work);

How is this design working? If the interrupt is coming too fast
from the DSP than the associated function with this schedule_work
will not get called as the scheduler will not get time to schedule the
workqueue and elapsed function will not be called thereby not increasing
the hw_ptr. How is the flow control for data transfer achieved?

I am facing the above problem in my design.

I am wondering if I can simply add one more IPC command(don't call
wait_event_interruptible for this) after TRIGGER_START to start the
streaming.This way schedule_work for updating period_elapsed function
can be avoided and it can be called in an interrupt context.

Thanks,
Variksla

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-06-22 20:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-21  2:46 ASoC: SOF: Race condition in ipc.c noman pouigt
2022-06-21 13:11 ` [Sound-open-firmware] " Pierre-Louis Bossart
2022-06-22 20:47   ` noman pouigt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox