Merge tag 'fpga-for-6.1-final' of git://git.kernel.org/pub/scm/linux/kernel/git/fpga...
[platform/kernel/linux-starfive.git] / sound / core / memalloc.c
index 03cffe7..ba09555 100644 (file)
@@ -9,6 +9,7 @@
 #include <linux/slab.h>
 #include <linux/mm.h>
 #include <linux/dma-mapping.h>
+#include <linux/dma-map-ops.h>
 #include <linux/genalloc.h>
 #include <linux/highmem.h>
 #include <linux/vmalloc.h>
@@ -543,17 +544,17 @@ static void *snd_dma_noncontig_alloc(struct snd_dma_buffer *dmab, size_t size)
 
        sgt = dma_alloc_noncontiguous(dmab->dev.dev, size, dmab->dev.dir,
                                      DEFAULT_GFP, 0);
-       if (!sgt) {
 #ifdef CONFIG_SND_DMA_SGBUF
+       if (!sgt && !get_dma_ops(dmab->dev.dev)) {
                if (dmab->dev.type == SNDRV_DMA_TYPE_DEV_WC_SG)
                        dmab->dev.type = SNDRV_DMA_TYPE_DEV_WC_SG_FALLBACK;
                else
                        dmab->dev.type = SNDRV_DMA_TYPE_DEV_SG_FALLBACK;
                return snd_dma_sg_fallback_alloc(dmab, size);
-#else
-               return NULL;
-#endif
        }
+#endif
+       if (!sgt)
+               return NULL;
 
        dmab->dev.need_sync = dma_need_sync(dmab->dev.dev,
                                            sg_dma_address(sgt->sgl));
@@ -857,7 +858,7 @@ static const struct snd_malloc_ops snd_dma_noncoherent_ops = {
 /*
  * Entry points
  */
-static const struct snd_malloc_ops *dma_ops[] = {
+static const struct snd_malloc_ops *snd_dma_ops[] = {
        [SNDRV_DMA_TYPE_CONTINUOUS] = &snd_dma_continuous_ops,
        [SNDRV_DMA_TYPE_VMALLOC] = &snd_dma_vmalloc_ops,
 #ifdef CONFIG_HAS_DMA
@@ -883,7 +884,7 @@ static const struct snd_malloc_ops *snd_dma_get_ops(struct snd_dma_buffer *dmab)
        if (WARN_ON_ONCE(!dmab))
                return NULL;
        if (WARN_ON_ONCE(dmab->dev.type <= SNDRV_DMA_TYPE_UNKNOWN ||
-                        dmab->dev.type >= ARRAY_SIZE(dma_ops)))
+                        dmab->dev.type >= ARRAY_SIZE(snd_dma_ops)))
                return NULL;
-       return dma_ops[dmab->dev.type];
+       return snd_dma_ops[dmab->dev.type];
 }