diff options
author | Srinivas Kandagatla <srinivas.kandagatla@linaro.org> | 2016-01-11 10:17:23 -0500 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2016-01-11 10:29:25 -0500 |
commit | f5f76ea75dce553631ffb08abc44dcecb68e74d4 (patch) | |
tree | 6b6008c8d6bc0948ec2a9522ca59e5c2cf1b2fdd /sound/soc/qcom | |
parent | 8005c49d9aea74d382f474ce11afbbc7d7130bec (diff) |
ASoC: qcom: use correct device pointer in dma allocation
dev pointer in struct snd_soc_pcm_runtime does not have dma_ops set. In
v4.4 kernel dma_ops would end up pointing to dummy_dma_ops in such cases.
So attempting to use such device in allocating coherent memory on aarch64
would fail.
According to commit 1dccb598df549d892b6450c261da54cdd7af44b4 ("arm64:
simplify dma_get_ops") The current behavior of dma_get_ops is to fall
back to the global dma_ops when a device has not set its own dma_ops,
but only for DT based systems.
So, this patch fixes the driver to use correct device pointer while
allocating coherent memory, and also deletes un-necessary dma_mask setup
on soc_runtime->dev.
Without this patch lpass driver would fail with below log:
...
[ 6.541542] ADV7533: lpass_platform_alloc_buffer: Could not allocate DMA buffer
[ 6.541914] apq8016-lpass-cpu 7708000.lpass-cpu: ASoC: pcm constructor failed: -12
[ 6.548216] qcom-apq8016-sbc 7702000.sound: ASoC: can't create pcm ADV7533 :-12
[ 6.555581] qcom-apq8016-sbc 7702000.sound: ASoC: failed to instantiate card -12
[ 6.566072] qcom-apq8016-sbc: probe of 7702000.sound failed with error -12
...
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc/qcom')
-rw-r--r-- | sound/soc/qcom/lpass-platform.c | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/sound/soc/qcom/lpass-platform.c b/sound/soc/qcom/lpass-platform.c index 79688aa1941a..4aeb8e1a7160 100644 --- a/sound/soc/qcom/lpass-platform.c +++ b/sound/soc/qcom/lpass-platform.c | |||
@@ -440,18 +440,18 @@ static irqreturn_t lpass_platform_lpaif_irq(int irq, void *data) | |||
440 | } | 440 | } |
441 | 441 | ||
442 | static int lpass_platform_alloc_buffer(struct snd_pcm_substream *substream, | 442 | static int lpass_platform_alloc_buffer(struct snd_pcm_substream *substream, |
443 | struct snd_soc_pcm_runtime *soc_runtime) | 443 | struct snd_soc_pcm_runtime *rt) |
444 | { | 444 | { |
445 | struct snd_dma_buffer *buf = &substream->dma_buffer; | 445 | struct snd_dma_buffer *buf = &substream->dma_buffer; |
446 | size_t size = lpass_platform_pcm_hardware.buffer_bytes_max; | 446 | size_t size = lpass_platform_pcm_hardware.buffer_bytes_max; |
447 | 447 | ||
448 | buf->dev.type = SNDRV_DMA_TYPE_DEV; | 448 | buf->dev.type = SNDRV_DMA_TYPE_DEV; |
449 | buf->dev.dev = soc_runtime->dev; | 449 | buf->dev.dev = rt->platform->dev; |
450 | buf->private_data = NULL; | 450 | buf->private_data = NULL; |
451 | buf->area = dma_alloc_coherent(soc_runtime->dev, size, &buf->addr, | 451 | buf->area = dma_alloc_coherent(rt->platform->dev, size, &buf->addr, |
452 | GFP_KERNEL); | 452 | GFP_KERNEL); |
453 | if (!buf->area) { | 453 | if (!buf->area) { |
454 | dev_err(soc_runtime->dev, "%s: Could not allocate DMA buffer\n", | 454 | dev_err(rt->platform->dev, "%s: Could not allocate DMA buffer\n", |
455 | __func__); | 455 | __func__); |
456 | return -ENOMEM; | 456 | return -ENOMEM; |
457 | } | 457 | } |
@@ -461,12 +461,12 @@ static int lpass_platform_alloc_buffer(struct snd_pcm_substream *substream, | |||
461 | } | 461 | } |
462 | 462 | ||
463 | static void lpass_platform_free_buffer(struct snd_pcm_substream *substream, | 463 | static void lpass_platform_free_buffer(struct snd_pcm_substream *substream, |
464 | struct snd_soc_pcm_runtime *soc_runtime) | 464 | struct snd_soc_pcm_runtime *rt) |
465 | { | 465 | { |
466 | struct snd_dma_buffer *buf = &substream->dma_buffer; | 466 | struct snd_dma_buffer *buf = &substream->dma_buffer; |
467 | 467 | ||
468 | if (buf->area) { | 468 | if (buf->area) { |
469 | dma_free_coherent(soc_runtime->dev, buf->bytes, buf->area, | 469 | dma_free_coherent(rt->dev, buf->bytes, buf->area, |
470 | buf->addr); | 470 | buf->addr); |
471 | } | 471 | } |
472 | buf->area = NULL; | 472 | buf->area = NULL; |
@@ -499,9 +499,6 @@ static int lpass_platform_pcm_new(struct snd_soc_pcm_runtime *soc_runtime) | |||
499 | 499 | ||
500 | snd_soc_pcm_set_drvdata(soc_runtime, data); | 500 | snd_soc_pcm_set_drvdata(soc_runtime, data); |
501 | 501 | ||
502 | soc_runtime->dev->coherent_dma_mask = DMA_BIT_MASK(32); | ||
503 | soc_runtime->dev->dma_mask = &soc_runtime->dev->coherent_dma_mask; | ||
504 | |||
505 | ret = lpass_platform_alloc_buffer(substream, soc_runtime); | 502 | ret = lpass_platform_alloc_buffer(substream, soc_runtime); |
506 | if (ret) | 503 | if (ret) |
507 | return ret; | 504 | return ret; |