Skip to content

Commit

Permalink
Merge tag 'dma-mapping-2022-12-23' of git://git.infradead.org/users/h…
Browse files Browse the repository at this point in the history
…ch/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
  • Loading branch information
Linus Torvalds committed Dec 23, 2022
2 parents e3b862e + 3622b86 commit 59d2c63
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions kernel/dma/mapping.c
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,8 @@ static struct page *__dma_alloc_pages(struct device *dev, size_t size,
return NULL;
if (WARN_ON_ONCE(gfp & (__GFP_DMA | __GFP_DMA32 | __GFP_HIGHMEM)))
return NULL;
if (WARN_ON_ONCE(gfp & __GFP_COMP))
return NULL;

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

if (WARN_ON_ONCE(attrs & ~DMA_ATTR_ALLOC_SINGLE_PAGES))
return NULL;
if (WARN_ON_ONCE(gfp & __GFP_COMP))
return NULL;

if (ops && ops->alloc_noncontiguous)
sgt = ops->alloc_noncontiguous(dev, size, dir, gfp, attrs);
Expand Down
4 changes: 2 additions & 2 deletions sound/core/memalloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ static void *snd_dma_noncontig_alloc(struct snd_dma_buffer *dmab, size_t size)
void *p;

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

p = dma_alloc_noncoherent(dmab->dev.dev, size, &dmab->addr,
dmab->dev.dir, DEFAULT_GFP | __GFP_COMP);
dmab->dev.dir, DEFAULT_GFP);
if (p)
dmab->dev.need_sync = dma_need_sync(dmab->dev.dev, dmab->addr);
return p;
Expand Down

0 comments on commit 59d2c63

Please sign in to comment.