[RFC 3/4] dma-direct: add dma_direct_min_mask
From: Nicolas Saenz Julienne
Date: Wed Jul 17 2019 - 11:31:57 EST
Historically devices with ZONE_DMA32 have been assumed to be able to
address at least the lower 4GB of ram for DMA. This is still the defualt
behavior yet the Raspberry Pi 4 is limited to the first GB of memory.
This has been observed to trigger failures in dma_direct_supported() as
the 'min_mask' isn't properly set.
We create 'dma_direct_min_mask' in order for the arch init code to be
able to fine-tune dma direct's 'min_dma' mask.
Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@xxxxxxx>
---
kernel/dma/direct.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/kernel/dma/direct.c b/kernel/dma/direct.c
index b90e1aede743..3c8cd730648b 100644
--- a/kernel/dma/direct.c
+++ b/kernel/dma/direct.c
@@ -23,6 +23,8 @@
#define ARCH_ZONE_DMA_BITS 24
#endif
+u64 dma_direct_min_mask __ro_after_init = DMA_BIT_MASK(32);
+
/*
* For AMD SEV all DMA must be to unencrypted addresses.
*/
@@ -393,7 +395,7 @@ int dma_direct_supported(struct device *dev, u64 mask)
if (IS_ENABLED(CONFIG_ZONE_DMA))
min_mask = DMA_BIT_MASK(ARCH_ZONE_DMA_BITS);
else
- min_mask = DMA_BIT_MASK(32);
+ min_mask = dma_direct_min_mask;
min_mask = min_t(u64, min_mask, (max_pfn - 1) << PAGE_SHIFT);
--
2.22.0