diff options
author | Russell King <rmk+kernel@arm.linux.org.uk> | 2013-06-27 07:53:37 -0400 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2013-10-31 10:48:47 -0400 |
commit | c9bd5e690a439df044678d89e89e380cf9db7930 (patch) | |
tree | e2f73839b2be962bd4b4f19279aafa38e7b72332 /sound/arm | |
parent | fa6a8d6d65b19ab44e5244ea499bcd553cc72343 (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/arm')
-rw-r--r-- | sound/arm/pxa2xx-pcm.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/sound/arm/pxa2xx-pcm.c b/sound/arm/pxa2xx-pcm.c index 69a2455b4472..e6c727b317fb 100644 --- a/sound/arm/pxa2xx-pcm.c +++ b/sound/arm/pxa2xx-pcm.c | |||
@@ -11,6 +11,7 @@ | |||
11 | */ | 11 | */ |
12 | 12 | ||
13 | #include <linux/module.h> | 13 | #include <linux/module.h> |
14 | #include <linux/dma-mapping.h> | ||
14 | #include <linux/dmaengine.h> | 15 | #include <linux/dmaengine.h> |
15 | 16 | ||
16 | #include <sound/core.h> | 17 | #include <sound/core.h> |
@@ -83,8 +84,6 @@ static struct snd_pcm_ops pxa2xx_pcm_ops = { | |||
83 | .mmap = pxa2xx_pcm_mmap, | 84 | .mmap = pxa2xx_pcm_mmap, |
84 | }; | 85 | }; |
85 | 86 | ||
86 | static u64 pxa2xx_pcm_dmamask = 0xffffffff; | ||
87 | |||
88 | int pxa2xx_pcm_new(struct snd_card *card, struct pxa2xx_pcm_client *client, | 87 | int pxa2xx_pcm_new(struct snd_card *card, struct pxa2xx_pcm_client *client, |
89 | struct snd_pcm **rpcm) | 88 | struct snd_pcm **rpcm) |
90 | { | 89 | { |
@@ -100,10 +99,9 @@ int pxa2xx_pcm_new(struct snd_card *card, struct pxa2xx_pcm_client *client, | |||
100 | pcm->private_data = client; | 99 | pcm->private_data = client; |
101 | pcm->private_free = pxa2xx_pcm_free_dma_buffers; | 100 | pcm->private_free = pxa2xx_pcm_free_dma_buffers; |
102 | 101 | ||
103 | if (!card->dev->dma_mask) | 102 | ret = dma_coerce_mask_and_coherent(card->dev, DMA_BIT_MASK(32)); |
104 | card->dev->dma_mask = &pxa2xx_pcm_dmamask; | 103 | if (ret) |
105 | if (!card->dev->coherent_dma_mask) | 104 | goto out; |
106 | card->dev->coherent_dma_mask = 0xffffffff; | ||
107 | 105 | ||
108 | if (play) { | 106 | if (play) { |
109 | int stream = SNDRV_PCM_STREAM_PLAYBACK; | 107 | int stream = SNDRV_PCM_STREAM_PLAYBACK; |