summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sound/core/pcm_memory.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/sound/core/pcm_memory.c b/sound/core/pcm_memory.c
index 860935e3aea4..8326d16d3596 100644
--- a/sound/core/pcm_memory.c
+++ b/sound/core/pcm_memory.c
@@ -11,6 +11,7 @@
#include <linux/moduleparam.h>
#include <linux/vmalloc.h>
#include <linux/export.h>
+#include <linux/dma-mapping.h>
#include <sound/core.h>
#include <sound/pcm.h>
#include <sound/info.h>
@@ -39,6 +40,18 @@ static int do_alloc_pages(struct snd_card *card, int type, struct device *dev,
if (max_alloc_per_card &&
card->total_pcm_alloc_bytes + size > max_alloc_per_card)
return -ENOMEM;
+
+ if (IS_ENABLED(CONFIG_SND_DMA_SGBUF) &&
+ (type == SNDRV_DMA_TYPE_DEV_SG || type == SNDRV_DMA_TYPE_DEV_UC_SG) &&
+ !dma_is_direct(get_dma_ops(dev))) {
+ /* mutate to continuous page allocation */
+ dev_dbg(dev, "Use continuous page allocator\n");
+ if (type == SNDRV_DMA_TYPE_DEV_SG)
+ type = SNDRV_DMA_TYPE_DEV;
+ else
+ type = SNDRV_DMA_TYPE_DEV_UC;
+ }
+
err = snd_dma_alloc_pages(type, dev, size, dmab);
if (!err) {
mutex_lock(&card->memory_mutex);