aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/samsung/dma.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/samsung/dma.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/samsung/dma.c')
-rw-r--r--sound/soc/samsung/dma.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/sound/soc/samsung/dma.c b/sound/soc/samsung/dma.c
index 9338d11e9216..fe2748b494d4 100644
--- a/sound/soc/samsung/dma.c
+++ b/sound/soc/samsung/dma.c
@@ -406,20 +406,17 @@ static void dma_free_dma_buffers(struct snd_pcm *pcm)
406 } 406 }
407} 407}
408 408
409static u64 dma_mask = DMA_BIT_MASK(32);
410
411static int dma_new(struct snd_soc_pcm_runtime *rtd) 409static int dma_new(struct snd_soc_pcm_runtime *rtd)
412{ 410{
413 struct snd_card *card = rtd->card->snd_card; 411 struct snd_card *card = rtd->card->snd_card;
414 struct snd_pcm *pcm = rtd->pcm; 412 struct snd_pcm *pcm = rtd->pcm;
415 int ret = 0; 413 int ret;
416 414
417 pr_debug("Entered %s\n", __func__); 415 pr_debug("Entered %s\n", __func__);
418 416
419 if (!card->dev->dma_mask) 417 ret = dma_coerce_mask_and_coherent(card->dev, DMA_BIT_MASK(32));
420 card->dev->dma_mask = &dma_mask; 418 if (ret)
421 if (!card->dev->coherent_dma_mask) 419 return ret;
422 card->dev->coherent_dma_mask = DMA_BIT_MASK(32);
423 420
424 if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) { 421 if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) {
425 ret = preallocate_dma_buffer(pcm, 422 ret = preallocate_dma_buffer(pcm,