[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <fe2e245ba534fc3cee9890ba12d1da13084e67a5.1722249878.git.baruch@tkos.co.il>
Date: Mon, 29 Jul 2024 13:51:24 +0300
From: Baruch Siach <baruch@...s.co.il>
To: Christoph Hellwig <hch@....de>,
Marek Szyprowski <m.szyprowski@...sung.com>,
Catalin Marinas <catalin.marinas@....com>,
Will Deacon <will@...nel.org>
Cc: Baruch Siach <baruch@...s.co.il>,
Robin Murphy <robin.murphy@....com>,
iommu@...ts.linux.dev,
linux-arm-kernel@...ts.infradead.org,
linux-kernel@...r.kernel.org,
linuxppc-dev@...ts.ozlabs.org,
linux-s390@...r.kernel.org,
Petr Tesařík <petr@...arici.cz>,
Ramon Fried <ramon@...reality.ai>,
Elad Nachman <enachman@...vell.com>
Subject: [PATCH v3 1/3] dma-mapping: improve DMA zone selection
When device DMA limit does not fit in DMA32 zone it should use DMA zone,
even when DMA zone is stricter than needed.
Same goes for devices that can't allocate from the entire normal zone.
Limit to DMA32 in that case.
Reported-by: Catalin Marinas <catalin.marinas@....com>
Signed-off-by: Baruch Siach <baruch@...s.co.il>
---
kernel/dma/direct.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/kernel/dma/direct.c b/kernel/dma/direct.c
index 4480a3cd92e0..3b4be4ca3b08 100644
--- a/kernel/dma/direct.c
+++ b/kernel/dma/direct.c
@@ -4,7 +4,7 @@
*
* DMA operations that map physical memory directly without using an IOMMU.
*/
-#include <linux/memblock.h> /* for max_pfn */
+#include <linux/memblock.h>
#include <linux/export.h>
#include <linux/mm.h>
#include <linux/dma-map-ops.h>
@@ -59,9 +59,9 @@ static gfp_t dma_direct_optimal_gfp_mask(struct device *dev, u64 *phys_limit)
* zones.
*/
*phys_limit = dma_to_phys(dev, dma_limit);
- if (*phys_limit <= DMA_BIT_MASK(zone_dma_bits))
+ if (*phys_limit < DMA_BIT_MASK(32))
return GFP_DMA;
- if (*phys_limit <= DMA_BIT_MASK(32))
+ if (*phys_limit < memblock_end_of_DRAM())
return GFP_DMA32;
return 0;
}
--
2.43.0
Powered by blists - more mailing lists