aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/fsl/imx-pcm-fiq.c
diff options
context:
space:
mode:
authorRussell King <rmk+kernel@arm.linux.org.uk>2013-06-27 07:53:37 -0400
committerRussell King <rmk+kernel@arm.linux.org.uk>2013-10-31 10:48:47 -0400
commitc9bd5e690a439df044678d89e89e380cf9db7930 (patch)
treee2f73839b2be962bd4b4f19279aafa38e7b72332 /sound/soc/fsl/imx-pcm-fiq.c
parentfa6a8d6d65b19ab44e5244ea499bcd553cc72343 (diff)
DMA-API: sound: fix dma mask handling in a lot of drivers
This code sequence is unsafe in modules: static u64 mask = DMA_BIT_MASK(something); ... if (!dev->dma_mask) dev->dma_mask = &mask; as if a module is reloaded, the mask will be pointing at the original module's mask address, and this can lead to oopses. Moreover, they all follow this with: if (!dev->coherent_dma_mask) dev->coherent_dma_mask = mask; where 'mask' is the same value as the statically defined mask, and this bypasses the architecture's check on whether the DMA mask is possible. Fix these issues by using the new dma_coerce_coherent_and_mask() function. Acked-by: Mark Brown <broonie@linaro.org> Acked-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'sound/soc/fsl/imx-pcm-fiq.c')
-rw-r--r--sound/soc/fsl/imx-pcm-fiq.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/sound/soc/fsl/imx-pcm-fiq.c b/sound/soc/fsl/imx-pcm-fiq.c
index 34043c55f2a6..fd5f2fb955f1 100644
--- a/sound/soc/fsl/imx-pcm-fiq.c
+++ b/sound/soc/fsl/imx-pcm-fiq.c
@@ -272,18 +272,16 @@ static int imx_pcm_preallocate_dma_buffer(struct snd_pcm *pcm, int stream)
272 return 0; 272 return 0;
273} 273}
274 274
275static u64 imx_pcm_dmamask = DMA_BIT_MASK(32);
276
277static int imx_pcm_new(struct snd_soc_pcm_runtime *rtd) 275static int imx_pcm_new(struct snd_soc_pcm_runtime *rtd)
278{ 276{
279 struct snd_card *card = rtd->card->snd_card; 277 struct snd_card *card = rtd->card->snd_card;
280 struct snd_pcm *pcm = rtd->pcm; 278 struct snd_pcm *pcm = rtd->pcm;
281 int ret = 0; 279 int ret;
280
281 ret = dma_coerce_mask_and_coherent(card->dev, DMA_BIT_MASK(32));
282 if (ret)
283 return ret;
282 284
283 if (!card->dev->dma_mask)
284 card->dev->dma_mask = &imx_pcm_dmamask;
285 if (!card->dev->coherent_dma_mask)
286 card->dev->coherent_dma_mask = DMA_BIT_MASK(32);
287 if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) { 285 if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) {
288 ret = imx_pcm_preallocate_dma_buffer(pcm, 286 ret = imx_pcm_preallocate_dma_buffer(pcm,
289 SNDRV_PCM_STREAM_PLAYBACK); 287 SNDRV_PCM_STREAM_PLAYBACK);