Return an error if the DMA's current pointer is not within the bounds of the DMA buffer. This can happen if the DMA controller is not programmed correctly, or if the SSI doesn't communicate with the DMA controller correctly.
Signed-off-by: Timur Tabi timur@freescale.com ---
This patch is for ASoC V2.
sound/soc/fsl/fsl_dma.c | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/sound/soc/fsl/fsl_dma.c b/sound/soc/fsl/fsl_dma.c index cb1e5ae..b4ae486 100644 --- a/sound/soc/fsl/fsl_dma.c +++ b/sound/soc/fsl/fsl_dma.c @@ -689,6 +689,15 @@ static snd_pcm_uframes_t fsl_dma_pointer(struct snd_pcm_substream *substream) else position = in_be32(&dma_channel->dar);
+ if ((position < dma_private->dma_buf_phys) || + (position > dma_private->dma_buf_end)) { + dev_err(substream->pcm->card->dev, + "DMA(%u,%u) pointer is out of range, halting stream\n", + dma_private->dma_info->controller_id, + dma_private->dma_info->channel_id); + return SNDRV_PCM_POS_XRUN; + } + frames = bytes_to_frames(runtime, position - dma_private->dma_buf_phys);
/*