aboutsummaryrefslogtreecommitdiffstats
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
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>
-rw-r--r--sound/arm/pxa2xx-pcm.c10
-rw-r--r--sound/soc/atmel/atmel-pcm.c11
-rw-r--r--sound/soc/blackfin/bf5xx-ac97-pcm.c11
-rw-r--r--sound/soc/blackfin/bf5xx-i2s-pcm.c10
-rw-r--r--sound/soc/davinci/davinci-pcm.c9
-rw-r--r--sound/soc/fsl/fsl_dma.c9
-rw-r--r--sound/soc/fsl/imx-pcm-fiq.c12
-rw-r--r--sound/soc/fsl/mpc5200_dma.c10
-rw-r--r--sound/soc/jz4740/jz4740-pcm.c12
-rw-r--r--sound/soc/kirkwood/kirkwood-dma.c9
-rw-r--r--sound/soc/nuc900/nuc900-pcm.c9
-rw-r--r--sound/soc/omap/omap-pcm.c11
-rw-r--r--sound/soc/pxa/pxa2xx-pcm.c11
-rw-r--r--sound/soc/s6000/s6000-pcm.c9
-rw-r--r--sound/soc/samsung/dma.c11
-rw-r--r--sound/soc/samsung/idma.c11
16 files changed, 61 insertions, 104 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
86static u64 pxa2xx_pcm_dmamask = 0xffffffff;
87
88int pxa2xx_pcm_new(struct snd_card *card, struct pxa2xx_pcm_client *client, 87int 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;
diff --git a/sound/soc/atmel/atmel-pcm.c b/sound/soc/atmel/atmel-pcm.c
index 3109db7b9017..fbb87e3f1019 100644
--- a/sound/soc/atmel/atmel-pcm.c
+++ b/sound/soc/atmel/atmel-pcm.c
@@ -68,18 +68,15 @@ int atmel_pcm_mmap(struct snd_pcm_substream *substream,
68} 68}
69EXPORT_SYMBOL_GPL(atmel_pcm_mmap); 69EXPORT_SYMBOL_GPL(atmel_pcm_mmap);
70 70
71static u64 atmel_pcm_dmamask = DMA_BIT_MASK(32);
72
73int atmel_pcm_new(struct snd_soc_pcm_runtime *rtd) 71int atmel_pcm_new(struct snd_soc_pcm_runtime *rtd)
74{ 72{
75 struct snd_card *card = rtd->card->snd_card; 73 struct snd_card *card = rtd->card->snd_card;
76 struct snd_pcm *pcm = rtd->pcm; 74 struct snd_pcm *pcm = rtd->pcm;
77 int ret = 0; 75 int ret;
78 76
79 if (!card->dev->dma_mask) 77 ret = dma_coerce_mask_and_coherent(card->dev, DMA_BIT_MASK(32));
80 card->dev->dma_mask = &atmel_pcm_dmamask; 78 if (ret)
81 if (!card->dev->coherent_dma_mask) 79 return ret;
82 card->dev->coherent_dma_mask = DMA_BIT_MASK(32);
83 80
84 if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) { 81 if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) {
85 pr_debug("atmel-pcm: allocating PCM playback DMA buffer\n"); 82 pr_debug("atmel-pcm: allocating PCM playback DMA buffer\n");
diff --git a/sound/soc/blackfin/bf5xx-ac97-pcm.c b/sound/soc/blackfin/bf5xx-ac97-pcm.c
index 53f84085bf1f..1d4c676eb6cc 100644
--- a/sound/soc/blackfin/bf5xx-ac97-pcm.c
+++ b/sound/soc/blackfin/bf5xx-ac97-pcm.c
@@ -415,19 +415,16 @@ static void bf5xx_pcm_free_dma_buffers(struct snd_pcm *pcm)
415 } 415 }
416} 416}
417 417
418static u64 bf5xx_pcm_dmamask = DMA_BIT_MASK(32);
419
420static int bf5xx_pcm_ac97_new(struct snd_soc_pcm_runtime *rtd) 418static int bf5xx_pcm_ac97_new(struct snd_soc_pcm_runtime *rtd)
421{ 419{
422 struct snd_card *card = rtd->card->snd_card; 420 struct snd_card *card = rtd->card->snd_card;
423 struct snd_pcm *pcm = rtd->pcm; 421 struct snd_pcm *pcm = rtd->pcm;
424 int ret = 0; 422 int ret;
425 423
426 pr_debug("%s enter\n", __func__); 424 pr_debug("%s enter\n", __func__);
427 if (!card->dev->dma_mask) 425 ret = dma_coerce_mask_and_coherent(card->dev, DMA_BIT_MASK(32));
428 card->dev->dma_mask = &bf5xx_pcm_dmamask; 426 if (ret)
429 if (!card->dev->coherent_dma_mask) 427 return ret;
430 card->dev->coherent_dma_mask = DMA_BIT_MASK(32);
431 428
432 if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) { 429 if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) {
433 ret = bf5xx_pcm_preallocate_dma_buffer(pcm, 430 ret = bf5xx_pcm_preallocate_dma_buffer(pcm,
diff --git a/sound/soc/blackfin/bf5xx-i2s-pcm.c b/sound/soc/blackfin/bf5xx-i2s-pcm.c
index 9cb4a80df98e..2a5b43417fd5 100644
--- a/sound/soc/blackfin/bf5xx-i2s-pcm.c
+++ b/sound/soc/blackfin/bf5xx-i2s-pcm.c
@@ -323,18 +323,16 @@ static struct snd_pcm_ops bf5xx_pcm_i2s_ops = {
323 .silence = bf5xx_pcm_silence, 323 .silence = bf5xx_pcm_silence,
324}; 324};
325 325
326static u64 bf5xx_pcm_dmamask = DMA_BIT_MASK(32);
327
328static int bf5xx_pcm_i2s_new(struct snd_soc_pcm_runtime *rtd) 326static int bf5xx_pcm_i2s_new(struct snd_soc_pcm_runtime *rtd)
329{ 327{
330 struct snd_card *card = rtd->card->snd_card; 328 struct snd_card *card = rtd->card->snd_card;
331 size_t size = bf5xx_pcm_hardware.buffer_bytes_max; 329 size_t size = bf5xx_pcm_hardware.buffer_bytes_max;
330 int ret;
332 331
333 pr_debug("%s enter\n", __func__); 332 pr_debug("%s enter\n", __func__);
334 if (!card->dev->dma_mask) 333 ret = dma_coerce_mask_and_coherent(card->dev, DMA_BIT_MASK(32));
335 card->dev->dma_mask = &bf5xx_pcm_dmamask; 334 if (ret)
336 if (!card->dev->coherent_dma_mask) 335 return ret;
337 card->dev->coherent_dma_mask = DMA_BIT_MASK(32);
338 336
339 return snd_pcm_lib_preallocate_pages_for_all(rtd->pcm, 337 return snd_pcm_lib_preallocate_pages_for_all(rtd->pcm,
340 SNDRV_DMA_TYPE_DEV, card->dev, size, size); 338 SNDRV_DMA_TYPE_DEV, card->dev, size, size);
diff --git a/sound/soc/davinci/davinci-pcm.c b/sound/soc/davinci/davinci-pcm.c
index 8460edce1c3b..84a63c660ab9 100644
--- a/sound/soc/davinci/davinci-pcm.c
+++ b/sound/soc/davinci/davinci-pcm.c
@@ -844,18 +844,15 @@ static void davinci_pcm_free(struct snd_pcm *pcm)
844 } 844 }
845} 845}
846 846
847static u64 davinci_pcm_dmamask = DMA_BIT_MASK(32);
848
849static int davinci_pcm_new(struct snd_soc_pcm_runtime *rtd) 847static int davinci_pcm_new(struct snd_soc_pcm_runtime *rtd)
850{ 848{
851 struct snd_card *card = rtd->card->snd_card; 849 struct snd_card *card = rtd->card->snd_card;
852 struct snd_pcm *pcm = rtd->pcm; 850 struct snd_pcm *pcm = rtd->pcm;
853 int ret; 851 int ret;
854 852
855 if (!card->dev->dma_mask) 853 ret = dma_coerce_mask_and_coherent(card->dev, DMA_BIT_MASK(32));
856 card->dev->dma_mask = &davinci_pcm_dmamask; 854 if (ret)
857 if (!card->dev->coherent_dma_mask) 855 return ret;
858 card->dev->coherent_dma_mask = DMA_BIT_MASK(32);
859 856
860 if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) { 857 if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) {
861 ret = davinci_pcm_preallocate_dma_buffer(pcm, 858 ret = davinci_pcm_preallocate_dma_buffer(pcm,
diff --git a/sound/soc/fsl/fsl_dma.c b/sound/soc/fsl/fsl_dma.c
index 9cc5c1f82f09..f73c7eff8b23 100644
--- a/sound/soc/fsl/fsl_dma.c
+++ b/sound/soc/fsl/fsl_dma.c
@@ -298,14 +298,11 @@ static int fsl_dma_new(struct snd_soc_pcm_runtime *rtd)
298{ 298{
299 struct snd_card *card = rtd->card->snd_card; 299 struct snd_card *card = rtd->card->snd_card;
300 struct snd_pcm *pcm = rtd->pcm; 300 struct snd_pcm *pcm = rtd->pcm;
301 static u64 fsl_dma_dmamask = DMA_BIT_MASK(36);
302 int ret; 301 int ret;
303 302
304 if (!card->dev->dma_mask) 303 ret = dma_coerce_mask_and_coherent(card->dev, DMA_BIT_MASK(36));
305 card->dev->dma_mask = &fsl_dma_dmamask; 304 if (ret)
306 305 return ret;
307 if (!card->dev->coherent_dma_mask)
308 card->dev->coherent_dma_mask = fsl_dma_dmamask;
309 306
310 /* Some codecs have separate DAIs for playback and capture, so we 307 /* Some codecs have separate DAIs for playback and capture, so we
311 * should allocate a DMA buffer only for the streams that are valid. 308 * should allocate a DMA buffer only for the streams that are valid.
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);
diff --git a/sound/soc/fsl/mpc5200_dma.c b/sound/soc/fsl/mpc5200_dma.c
index 2a847ca494b5..8fcf22416740 100644
--- a/sound/soc/fsl/mpc5200_dma.c
+++ b/sound/soc/fsl/mpc5200_dma.c
@@ -299,7 +299,6 @@ static struct snd_pcm_ops psc_dma_ops = {
299 .hw_params = psc_dma_hw_params, 299 .hw_params = psc_dma_hw_params,
300}; 300};
301 301
302static u64 psc_dma_dmamask = DMA_BIT_MASK(32);
303static int psc_dma_new(struct snd_soc_pcm_runtime *rtd) 302static int psc_dma_new(struct snd_soc_pcm_runtime *rtd)
304{ 303{
305 struct snd_card *card = rtd->card->snd_card; 304 struct snd_card *card = rtd->card->snd_card;
@@ -307,15 +306,14 @@ static int psc_dma_new(struct snd_soc_pcm_runtime *rtd)
307 struct snd_pcm *pcm = rtd->pcm; 306 struct snd_pcm *pcm = rtd->pcm;
308 struct psc_dma *psc_dma = snd_soc_dai_get_drvdata(rtd->cpu_dai); 307 struct psc_dma *psc_dma = snd_soc_dai_get_drvdata(rtd->cpu_dai);
309 size_t size = psc_dma_hardware.buffer_bytes_max; 308 size_t size = psc_dma_hardware.buffer_bytes_max;
310 int rc = 0; 309 int rc;
311 310
312 dev_dbg(rtd->platform->dev, "psc_dma_new(card=%p, dai=%p, pcm=%p)\n", 311 dev_dbg(rtd->platform->dev, "psc_dma_new(card=%p, dai=%p, pcm=%p)\n",
313 card, dai, pcm); 312 card, dai, pcm);
314 313
315 if (!card->dev->dma_mask) 314 rc = dma_coerce_mask_and_coherent(card->dev, DMA_BIT_MASK(32));
316 card->dev->dma_mask = &psc_dma_dmamask; 315 if (rc)
317 if (!card->dev->coherent_dma_mask) 316 return rc;
318 card->dev->coherent_dma_mask = DMA_BIT_MASK(32);
319 317
320 if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) { 318 if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) {
321 rc = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, pcm->card->dev, 319 rc = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, pcm->card->dev,
diff --git a/sound/soc/jz4740/jz4740-pcm.c b/sound/soc/jz4740/jz4740-pcm.c
index 710059292318..1d7ef28585e1 100644
--- a/sound/soc/jz4740/jz4740-pcm.c
+++ b/sound/soc/jz4740/jz4740-pcm.c
@@ -297,19 +297,15 @@ static void jz4740_pcm_free(struct snd_pcm *pcm)
297 } 297 }
298} 298}
299 299
300static u64 jz4740_pcm_dmamask = DMA_BIT_MASK(32);
301
302static int jz4740_pcm_new(struct snd_soc_pcm_runtime *rtd) 300static int jz4740_pcm_new(struct snd_soc_pcm_runtime *rtd)
303{ 301{
304 struct snd_card *card = rtd->card->snd_card; 302 struct snd_card *card = rtd->card->snd_card;
305 struct snd_pcm *pcm = rtd->pcm; 303 struct snd_pcm *pcm = rtd->pcm;
306 int ret = 0; 304 int ret;
307
308 if (!card->dev->dma_mask)
309 card->dev->dma_mask = &jz4740_pcm_dmamask;
310 305
311 if (!card->dev->coherent_dma_mask) 306 ret = dma_coerce_mask_and_coherent(card->dev, DMA_BIT_MASK(32));
312 card->dev->coherent_dma_mask = DMA_BIT_MASK(32); 307 if (ret)
308 return ret;
313 309
314 if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) { 310 if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) {
315 ret = jz4740_pcm_preallocate_dma_buffer(pcm, 311 ret = jz4740_pcm_preallocate_dma_buffer(pcm,
diff --git a/sound/soc/kirkwood/kirkwood-dma.c b/sound/soc/kirkwood/kirkwood-dma.c
index b238434f92b0..3814bb037485 100644
--- a/sound/soc/kirkwood/kirkwood-dma.c
+++ b/sound/soc/kirkwood/kirkwood-dma.c
@@ -59,8 +59,6 @@ static struct snd_pcm_hardware kirkwood_dma_snd_hw = {
59 .fifo_size = 0, 59 .fifo_size = 0,
60}; 60};
61 61
62static u64 kirkwood_dma_dmamask = DMA_BIT_MASK(32);
63
64static irqreturn_t kirkwood_dma_irq(int irq, void *dev_id) 62static irqreturn_t kirkwood_dma_irq(int irq, void *dev_id)
65{ 63{
66 struct kirkwood_dma_data *priv = dev_id; 64 struct kirkwood_dma_data *priv = dev_id;
@@ -292,10 +290,9 @@ static int kirkwood_dma_new(struct snd_soc_pcm_runtime *rtd)
292 struct snd_pcm *pcm = rtd->pcm; 290 struct snd_pcm *pcm = rtd->pcm;
293 int ret; 291 int ret;
294 292
295 if (!card->dev->dma_mask) 293 ret = dma_coerce_mask_and_coherent(card->dev, DMA_BIT_MASK(32));
296 card->dev->dma_mask = &kirkwood_dma_dmamask; 294 if (ret)
297 if (!card->dev->coherent_dma_mask) 295 return ret;
298 card->dev->coherent_dma_mask = DMA_BIT_MASK(32);
299 296
300 if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) { 297 if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) {
301 ret = kirkwood_dma_preallocate_dma_buffer(pcm, 298 ret = kirkwood_dma_preallocate_dma_buffer(pcm,
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);
diff --git a/sound/soc/omap/omap-pcm.c b/sound/soc/omap/omap-pcm.c
index a11405de86e8..b8fa9862e54c 100644
--- a/sound/soc/omap/omap-pcm.c
+++ b/sound/soc/omap/omap-pcm.c
@@ -156,8 +156,6 @@ static struct snd_pcm_ops omap_pcm_ops = {
156 .mmap = omap_pcm_mmap, 156 .mmap = omap_pcm_mmap,
157}; 157};
158 158
159static u64 omap_pcm_dmamask = DMA_BIT_MASK(64);
160
161static int omap_pcm_preallocate_dma_buffer(struct snd_pcm *pcm, 159static int omap_pcm_preallocate_dma_buffer(struct snd_pcm *pcm,
162 int stream) 160 int stream)
163{ 161{
@@ -202,12 +200,11 @@ static int omap_pcm_new(struct snd_soc_pcm_runtime *rtd)
202{ 200{
203 struct snd_card *card = rtd->card->snd_card; 201 struct snd_card *card = rtd->card->snd_card;
204 struct snd_pcm *pcm = rtd->pcm; 202 struct snd_pcm *pcm = rtd->pcm;
205 int ret = 0; 203 int ret;
206 204
207 if (!card->dev->dma_mask) 205 ret = dma_coerce_mask_and_coherent(card->dev, DMA_BIT_MASK(64));
208 card->dev->dma_mask = &omap_pcm_dmamask; 206 if (ret)
209 if (!card->dev->coherent_dma_mask) 207 return ret;
210 card->dev->coherent_dma_mask = DMA_BIT_MASK(64);
211 208
212 if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) { 209 if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) {
213 ret = omap_pcm_preallocate_dma_buffer(pcm, 210 ret = omap_pcm_preallocate_dma_buffer(pcm,
diff --git a/sound/soc/pxa/pxa2xx-pcm.c b/sound/soc/pxa/pxa2xx-pcm.c
index 806da27b8b67..d58b09f4f7a4 100644
--- a/sound/soc/pxa/pxa2xx-pcm.c
+++ b/sound/soc/pxa/pxa2xx-pcm.c
@@ -87,18 +87,15 @@ static struct snd_pcm_ops pxa2xx_pcm_ops = {
87 .mmap = pxa2xx_pcm_mmap, 87 .mmap = pxa2xx_pcm_mmap,
88}; 88};
89 89
90static u64 pxa2xx_pcm_dmamask = DMA_BIT_MASK(32);
91
92static int pxa2xx_soc_pcm_new(struct snd_soc_pcm_runtime *rtd) 90static int pxa2xx_soc_pcm_new(struct snd_soc_pcm_runtime *rtd)
93{ 91{
94 struct snd_card *card = rtd->card->snd_card; 92 struct snd_card *card = rtd->card->snd_card;
95 struct snd_pcm *pcm = rtd->pcm; 93 struct snd_pcm *pcm = rtd->pcm;
96 int ret = 0; 94 int ret;
97 95
98 if (!card->dev->dma_mask) 96 ret = dma_coerce_mask_and_coherent(card->dev, DMA_BIT_MASK(32));
99 card->dev->dma_mask = &pxa2xx_pcm_dmamask; 97 if (ret)
100 if (!card->dev->coherent_dma_mask) 98 return ret;
101 card->dev->coherent_dma_mask = DMA_BIT_MASK(32);
102 99
103 if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) { 100 if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) {
104 ret = pxa2xx_pcm_preallocate_dma_buffer(pcm, 101 ret = pxa2xx_pcm_preallocate_dma_buffer(pcm,
diff --git a/sound/soc/s6000/s6000-pcm.c b/sound/soc/s6000/s6000-pcm.c
index d0740a762963..283620a97fe7 100644
--- a/sound/soc/s6000/s6000-pcm.c
+++ b/sound/soc/s6000/s6000-pcm.c
@@ -444,8 +444,6 @@ static void s6000_pcm_free(struct snd_pcm *pcm)
444 snd_pcm_lib_preallocate_free_for_all(pcm); 444 snd_pcm_lib_preallocate_free_for_all(pcm);
445} 445}
446 446
447static u64 s6000_pcm_dmamask = DMA_BIT_MASK(32);
448
449static int s6000_pcm_new(struct snd_soc_pcm_runtime *runtime) 447static int s6000_pcm_new(struct snd_soc_pcm_runtime *runtime)
450{ 448{
451 struct snd_card *card = runtime->card->snd_card; 449 struct snd_card *card = runtime->card->snd_card;
@@ -456,10 +454,9 @@ static int s6000_pcm_new(struct snd_soc_pcm_runtime *runtime)
456 params = snd_soc_dai_get_dma_data(runtime->cpu_dai, 454 params = snd_soc_dai_get_dma_data(runtime->cpu_dai,
457 pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream); 455 pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream);
458 456
459 if (!card->dev->dma_mask) 457 res = dma_coerce_mask_and_coherent(card->dev, DMA_BIT_MASK(32));
460 card->dev->dma_mask = &s6000_pcm_dmamask; 458 if (res)
461 if (!card->dev->coherent_dma_mask) 459 return res;
462 card->dev->coherent_dma_mask = DMA_BIT_MASK(32);
463 460
464 if (params->dma_in) { 461 if (params->dma_in) {
465 s6dmac_disable_chan(DMA_MASK_DMAC(params->dma_in), 462 s6dmac_disable_chan(DMA_MASK_DMAC(params->dma_in),
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,
diff --git a/sound/soc/samsung/idma.c b/sound/soc/samsung/idma.c
index ce1e1e16f250..e4f318fc2f82 100644
--- a/sound/soc/samsung/idma.c
+++ b/sound/soc/samsung/idma.c
@@ -383,18 +383,15 @@ static int preallocate_idma_buffer(struct snd_pcm *pcm, int stream)
383 return 0; 383 return 0;
384} 384}
385 385
386static u64 idma_mask = DMA_BIT_MASK(32);
387
388static int idma_new(struct snd_soc_pcm_runtime *rtd) 386static int idma_new(struct snd_soc_pcm_runtime *rtd)
389{ 387{
390 struct snd_card *card = rtd->card->snd_card; 388 struct snd_card *card = rtd->card->snd_card;
391 struct snd_pcm *pcm = rtd->pcm; 389 struct snd_pcm *pcm = rtd->pcm;
392 int ret = 0; 390 int ret;
393 391
394 if (!card->dev->dma_mask) 392 ret = dma_coerce_mask_and_coherent(card->dev, DMA_BIT_MASK(32));
395 card->dev->dma_mask = &idma_mask; 393 if (ret)
396 if (!card->dev->coherent_dma_mask) 394 return ret;
397 card->dev->coherent_dma_mask = DMA_BIT_MASK(32);
398 395
399 if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) { 396 if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) {
400 ret = preallocate_idma_buffer(pcm, 397 ret = preallocate_idma_buffer(pcm,