From: Chen Yu Date: Sat, 31 Aug 2024 11:01:19 +0000 (+0800) Subject: dma-direct: optimize page freeing when it is not addressable X-Git-Tag: v6.12-rc1~125^2~4 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f689a3ab7b8ece9e5787ff058b96b8630e4931ad;p=thirdparty%2Fkernel%2Flinux.git dma-direct: optimize page freeing when it is not addressable When the CMA allocation succeeds but isn't addressable, its buffer has already been released and the page is set to NULL. So later when the normal page allocation succeeds but isn't addressable, __free_pages() can be used to free that normal page rather than using dma_free_contiguous that does extra checks that are not needed. Signed-off-by: Chen Yu Signed-off-by: Christoph Hellwig --- diff --git a/kernel/dma/direct.c b/kernel/dma/direct.c index f2ba074a6a542..5b4e6d3bf7bcc 100644 --- a/kernel/dma/direct.c +++ b/kernel/dma/direct.c @@ -140,7 +140,7 @@ again: if (!page) page = alloc_pages_node(node, gfp, get_order(size)); if (page && !dma_coherent_ok(dev, page_to_phys(page), size)) { - dma_free_contiguous(dev, page, size); + __free_pages(page, get_order(size)); page = NULL; if (IS_ENABLED(CONFIG_ZONE_DMA32) &&