aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/nuc900
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/nuc900
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/nuc900')
-rw-r--r--sound/soc/nuc900/nuc900-pcm.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/sound/soc/nuc900/nuc900-pcm.c b/sound/soc/nuc900/nuc900-pcm.c
index c894ff0f2580..f588ee45b4fd 100644
--- a/sound/soc/nuc900/nuc900-pcm.c
+++ b/sound/soc/nuc900/nuc900-pcm.c
@@ -314,16 +314,15 @@ static void nuc900_dma_free_dma_buffers(struct snd_pcm *pcm)
314 snd_pcm_lib_preallocate_free_for_all(pcm); 314 snd_pcm_lib_preallocate_free_for_all(pcm);
315} 315}
316 316
317static u64 nuc900_pcm_dmamask = DMA_BIT_MASK(32);
318static int nuc900_dma_new(struct snd_soc_pcm_runtime *rtd) 317static int nuc900_dma_new(struct snd_soc_pcm_runtime *rtd)
319{ 318{
320 struct snd_card *card = rtd->card->snd_card; 319 struct snd_card *card = rtd->card->snd_card;
321 struct snd_pcm *pcm = rtd->pcm; 320 struct snd_pcm *pcm = rtd->pcm;
321 int ret;
322 322
323 if (!card->dev->dma_mask) 323 ret = dma_coerce_mask_and_coherent(card->dev, DMA_BIT_MASK(32));
324 card->dev->dma_mask = &nuc900_pcm_dmamask; 324 if (ret)
325 if (!card->dev->coherent_dma_mask) 325 return ret;
326 card->dev->coherent_dma_mask = DMA_BIT_MASK(32);
327 326
328 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, 327 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
329 card->dev, 4 * 1024, (4 * 1024) - 1); 328 card->dev, 4 * 1024, (4 * 1024) - 1);