summaryrefslogtreecommitdiffstats
path: root/sound/core
diff options
context:
space:
mode:
authorMark Brown <broonie@kernel.org>2018-12-18 12:23:59 +0000
committerMark Brown <broonie@kernel.org>2018-12-18 12:23:59 +0000
commita7a850dba82498a1e050d8d153cae67ce0edb3b2 (patch)
treef2b50444022ad27f407e087a820ae5ff248e0492 /sound/core
parentc5fd9e77be44360b4827069c59f524815517917b (diff)
parent0f4967bc21de0bb9e107f9ad3ced852daf66acd2 (diff)
downloadlinux-a7a850dba82498a1e050d8d153cae67ce0edb3b2.tar.bz2
Merge branch 'asoc-4.21' into asoc-next
Diffstat (limited to 'sound/core')
-rw-r--r--sound/core/compress_offload.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c
index 26b5e245b074..a5b09e75e787 100644
--- a/sound/core/compress_offload.c
+++ b/sound/core/compress_offload.c
@@ -171,7 +171,8 @@ static int snd_compr_free(struct inode *inode, struct file *f)
}
data->stream.ops->free(&data->stream);
- kfree(data->stream.runtime->buffer);
+ if (!data->stream.runtime->dma_buffer_p)
+ kfree(data->stream.runtime->buffer);
kfree(data->stream.runtime);
kfree(data);
return 0;
@@ -505,7 +506,7 @@ static int snd_compr_allocate_buffer(struct snd_compr_stream *stream,
struct snd_compr_params *params)
{
unsigned int buffer_size;
- void *buffer;
+ void *buffer = NULL;
buffer_size = params->buffer.fragment_size * params->buffer.fragments;
if (stream->ops->copy) {
@@ -514,7 +515,18 @@ static int snd_compr_allocate_buffer(struct snd_compr_stream *stream,
* the data from core
*/
} else {
- buffer = kmalloc(buffer_size, GFP_KERNEL);
+ if (stream->runtime->dma_buffer_p) {
+
+ if (buffer_size > stream->runtime->dma_buffer_p->bytes)
+ dev_err(&stream->device->dev,
+ "Not enough DMA buffer");
+ else
+ buffer = stream->runtime->dma_buffer_p->area;
+
+ } else {
+ buffer = kmalloc(buffer_size, GFP_KERNEL);
+ }
+
if (!buffer)
return -ENOMEM;
}