diff mbox series

[2/2] dma-mapping: reject GFP_COMP for noncohernt allocaions

Message ID 20221220082009.569785-3-hch@lst.de (mailing list archive)
State Accepted
Commit 3622b86f49f84e52fb41fee9eb55f9290613dfc3
Headers show
Series [1/2] ALSA: memalloc: don't use GFP_COMP for non-coherent dma allocations | expand

Commit Message

Christoph Hellwig Dec. 20, 2022, 8:20 a.m. UTC
While not quite as bogus as for the dma-coherent allocations that were
fixed earlier, GFP_COMP for these allocations has no benefits for
the dma-direct case, and can't be supported at all by dma dma-iommu
backend which splits up allocations into smaller orders.  Due to an
oversight in ffcb75458460 that flag stopped being cleared for all
dma allocations, but only got rejected for coherent ones, so fix up
these callers to not allow __GFP_COMP as well after the sound code
has been fixed to not ask for it.

Fixes: ffcb75458460 ("dma-mapping: reject __GFP_COMP in dma_alloc_attrs")
Reported-by: Mikhail Gavrilov <mikhail.v.gavrilov@gmail.com>
Reported-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 kernel/dma/mapping.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Kai Vehmanen Dec. 20, 2022, 2:57 p.m. UTC | #1
Hey,

On Tue, 20 Dec 2022, Christoph Hellwig wrote:

> While not quite as bogus as for the dma-coherent allocations that were
> fixed earlier, GFP_COMP for these allocations has no benefits for
> the dma-direct case, and can't be supported at all by dma dma-iommu

tested the series and this fixes the issue:
Tested-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>

Minor nit, typo "noncohernt allocaions" in subject of this second patch.

Br, Kai
Mikhail Gavrilov Dec. 21, 2022, 6:57 a.m. UTC | #2
On Tue, Dec 20, 2022 at 7:58 PM Kai Vehmanen
<kai.vehmanen@linux.intel.com> wrote:
>
> Hey,
>
> On Tue, 20 Dec 2022, Christoph Hellwig wrote:
>
> > While not quite as bogus as for the dma-coherent allocations that were
> > fixed earlier, GFP_COMP for these allocations has no benefits for
> > the dma-direct case, and can't be supported at all by dma dma-iommu
>
> tested the series and this fixes the issue:
> Tested-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
>
> Minor nit, typo "noncohernt allocaions" in subject of this second patch.
>
> Br, Kai

I also confirm that after applying this patch series issue was gone.

Tested-by: Mikhail Gavrilov <mikhail.v.gavrilov@gmail.com>

Thanks.
Christoph Hellwig Dec. 21, 2022, 7:46 a.m. UTC | #3
On Tue, Dec 20, 2022 at 04:57:25PM +0200, Kai Vehmanen wrote:
> Minor nit, typo "noncohernt allocaions" in subject of this second patch.

Thanks,

I've fixed this and queued up the series.
diff mbox series

Patch

diff --git a/kernel/dma/mapping.c b/kernel/dma/mapping.c
index c026a5a5e0466e..68106e3791f6c3 100644
--- a/kernel/dma/mapping.c
+++ b/kernel/dma/mapping.c
@@ -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))
@@ -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);