Skip to content

Commit 59d2c63

Browse files
committed
Merge tag 'dma-mapping-2022-12-23' of git://git.infradead.org/users/hch/dma-mapping
Pull dma-mapping fixes from Christoph Hellwig: "Fix up the sound code to not pass __GFP_COMP to the non-coherent DMA allocator, as it copes with that just as badly as the coherent allocator, and then add a check to make sure no one passes the flag ever again" * tag 'dma-mapping-2022-12-23' of git://git.infradead.org/users/hch/dma-mapping: dma-mapping: reject GFP_COMP for noncoherent allocations ALSA: memalloc: don't use GFP_COMP for non-coherent dma allocations
2 parents e3b862e + 3622b86 commit 59d2c63

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

kernel/dma/mapping.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,8 @@ static struct page *__dma_alloc_pages(struct device *dev, size_t size,
560560
return NULL;
561561
if (WARN_ON_ONCE(gfp & (__GFP_DMA | __GFP_DMA32 | __GFP_HIGHMEM)))
562562
return NULL;
563+
if (WARN_ON_ONCE(gfp & __GFP_COMP))
564+
return NULL;
563565

564566
size = PAGE_ALIGN(size);
565567
if (dma_alloc_direct(dev, ops))
@@ -645,6 +647,8 @@ struct sg_table *dma_alloc_noncontiguous(struct device *dev, size_t size,
645647

646648
if (WARN_ON_ONCE(attrs & ~DMA_ATTR_ALLOC_SINGLE_PAGES))
647649
return NULL;
650+
if (WARN_ON_ONCE(gfp & __GFP_COMP))
651+
return NULL;
648652

649653
if (ops && ops->alloc_noncontiguous)
650654
sgt = ops->alloc_noncontiguous(dev, size, dir, gfp, attrs);

sound/core/memalloc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ static void *snd_dma_noncontig_alloc(struct snd_dma_buffer *dmab, size_t size)
542542
void *p;
543543

544544
sgt = dma_alloc_noncontiguous(dmab->dev.dev, size, dmab->dev.dir,
545-
DEFAULT_GFP | __GFP_COMP, 0);
545+
DEFAULT_GFP, 0);
546546
#ifdef CONFIG_SND_DMA_SGBUF
547547
if (!sgt && !get_dma_ops(dmab->dev.dev)) {
548548
if (dmab->dev.type == SNDRV_DMA_TYPE_DEV_WC_SG)
@@ -820,7 +820,7 @@ static void *snd_dma_noncoherent_alloc(struct snd_dma_buffer *dmab, size_t size)
820820
void *p;
821821

822822
p = dma_alloc_noncoherent(dmab->dev.dev, size, &dmab->addr,
823-
dmab->dev.dir, DEFAULT_GFP | __GFP_COMP);
823+
dmab->dev.dir, DEFAULT_GFP);
824824
if (p)
825825
dmab->dev.need_sync = dma_need_sync(dmab->dev.dev, dmab->addr);
826826
return p;

0 commit comments

Comments
 (0)