* [PATCH] arm64: mm: keep low RAM dma zone
@ 2024-09-01 6:12 Baruch Siach
2024-09-03 7:28 ` Christoph Hellwig
0 siblings, 1 reply; 2+ messages in thread
From: Baruch Siach @ 2024-09-01 6:12 UTC (permalink / raw)
To: Christoph Hellwig, Marek Szyprowski, Robin Murphy,
Catalin Marinas, Will Deacon
Cc: iommu, linux-arm-kernel, Petr Tesařík, Ramon Fried,
Elad Nachman, Baruch Siach, Neil Armstrong
Commit ba0fb44aed47 ("dma-mapping: replace zone_dma_bits by
zone_dma_limit") optimistically assumed that device-tree dma-ranges
property describes the system DMA limits. That assumption ignores DMA
limits of individual devices that are not encoded in device tree.
Commit 833bd284a45 ("arm64: mm: fix DMA zone when dma-ranges is
missing") fixed part of the problem for platforms that do not provide
dma-ranges at all. However platforms like SM8550-HDK provide DMA bus
limit, but have devices with stronger DMA limits.
of_dma_get_max_cpu_address() does not take device limitations into
account.
These platforms implicitly rely on DMA zone in low 32-bit RAM area.
Until we find a better way to figure out the optimal DMA zone range,
restore the low RAM DMA zone we had before commit ba0fb44aed47.
Fixes: ba0fb44aed47 ("dma-mapping: replace zone_dma_bits by zone_dma_limit")
Reported-by: Neil Armstrong <neil.armstrong@linaro.org>
Tested-by: Neil Armstrong <neil.armstrong@linaro.org> # on SM8550-HDK
Closes: https://lore.kernel.org/r/1a0c7282-63e0-4add-8e38-3abe3e0a8e2f@linaro.org
Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>
Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
Suggested-by: Robin Murphy <robin.murphy@arm.com>
Signed-off-by: Baruch Siach <baruch@tkos.co.il>
---
arch/arm64/mm/init.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c
index 5710129b8033..eb76ac6d87c0 100644
--- a/arch/arm64/mm/init.c
+++ b/arch/arm64/mm/init.c
@@ -116,8 +116,14 @@ static void __init arch_reserve_crashkernel(void)
static phys_addr_t __init max_zone_phys(phys_addr_t zone_limit)
{
- if (zone_limit == PHYS_ADDR_MAX)
- zone_limit = U32_MAX;
+ /**
+ * Information we get from firmware (e.g. DT dma-ranges) describe DMA
+ * bus constraints. Devices using DMA might have their own limitations.
+ * Some of them rely on DMA zone in low 32-bit memory. Keep low RAM
+ * DMA zone on platforms that have RAM there.
+ */
+ if (memblock_start_of_DRAM() < U32_MAX)
+ zone_limit = min(zone_limit, U32_MAX);
return min(zone_limit, memblock_end_of_DRAM() - 1) + 1;
}
--
2.45.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] arm64: mm: keep low RAM dma zone
2024-09-01 6:12 [PATCH] arm64: mm: keep low RAM dma zone Baruch Siach
@ 2024-09-03 7:28 ` Christoph Hellwig
0 siblings, 0 replies; 2+ messages in thread
From: Christoph Hellwig @ 2024-09-03 7:28 UTC (permalink / raw)
To: Baruch Siach
Cc: Christoph Hellwig, Marek Szyprowski, Robin Murphy,
Catalin Marinas, Will Deacon, iommu, linux-arm-kernel,
Petr Tesařík, Ramon Fried, Elad Nachman, Neil Armstrong
Thanks, applied.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-09-03 7:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-01 6:12 [PATCH] arm64: mm: keep low RAM dma zone Baruch Siach
2024-09-03 7:28 ` Christoph Hellwig
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).