Skip to content

Commit 7bcaf0f

Browse files
zhuyingjiangbroonie
authored andcommitted
ASoC: SOF: Intel: hda: make sure DMA is start/stop by read the RUN bit
As per the HW recommendation, after setting the RUN bit (start as 1, stop as 0), software must read the bit back to make sure the bit is set right, before modifying related control registers/re-starting the DMA engine. Signed-off-by: Zhu Yingjiang <yingjiang.zhu@linux.intel.com> Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 3a39e0e commit 7bcaf0f

2 files changed

Lines changed: 28 additions & 0 deletions

File tree

‎sound/soc/sof/intel/hda-stream.c‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,9 @@ int hda_dsp_stream_trigger(struct snd_sof_dev *sdev,
217217
{
218218
struct hdac_stream *hstream = &stream->hstream;
219219
int sd_offset = SOF_STREAM_SD_OFFSET(hstream);
220+
u32 dma_start = SOF_HDA_SD_CTL_DMA_START;
221+
int ret;
222+
u32 run;
220223

221224
/* cmd must be for audio stream */
222225
switch (cmd) {
@@ -234,6 +237,16 @@ int hda_dsp_stream_trigger(struct snd_sof_dev *sdev,
234237
SOF_HDA_SD_CTL_DMA_START |
235238
SOF_HDA_CL_DMA_SD_INT_MASK);
236239

240+
ret = snd_sof_dsp_read_poll_timeout(sdev,
241+
HDA_DSP_HDA_BAR,
242+
sd_offset, run,
243+
((run & dma_start) == dma_start),
244+
HDA_DSP_REG_POLL_INTERVAL_US,
245+
HDA_DSP_STREAM_RUN_TIMEOUT);
246+
247+
if (ret)
248+
return ret;
249+
237250
hstream->running = true;
238251
break;
239252
case SNDRV_PCM_TRIGGER_SUSPEND:
@@ -244,6 +257,15 @@ int hda_dsp_stream_trigger(struct snd_sof_dev *sdev,
244257
SOF_HDA_SD_CTL_DMA_START |
245258
SOF_HDA_CL_DMA_SD_INT_MASK, 0x0);
246259

260+
ret = snd_sof_dsp_read_poll_timeout(sdev, HDA_DSP_HDA_BAR,
261+
sd_offset, run,
262+
!(run & dma_start),
263+
HDA_DSP_REG_POLL_INTERVAL_US,
264+
HDA_DSP_STREAM_RUN_TIMEOUT);
265+
266+
if (ret)
267+
return ret;
268+
247269
snd_sof_dsp_write(sdev, HDA_DSP_HDA_BAR, sd_offset +
248270
SOF_HDA_ADSP_REG_CL_SD_STS,
249271
SOF_HDA_CL_DMA_SD_INT_MASK);

‎sound/soc/sof/intel/hda.h‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,12 @@
159159
#define HDA_DSP_MBOX_UPLINK_OFFSET 0x81000
160160

161161
#define HDA_DSP_STREAM_RESET_TIMEOUT 300
162+
/*
163+
* Timeout in us, for setting the stream RUN bit, during
164+
* start/stop the stream. The timeout expires if new RUN bit
165+
* value cannot be read back within the specified time.
166+
*/
167+
#define HDA_DSP_STREAM_RUN_TIMEOUT 300
162168
#define HDA_DSP_CL_TRIGGER_TIMEOUT 300
163169

164170
#define HDA_DSP_SPIB_ENABLE 1

0 commit comments

Comments
 (0)