Commit ebc7e21e authored by Catalin Marinas's avatar Catalin Marinas

arm64: Increase ARCH_DMA_MINALIGN to 128

This patch increases the ARCH_DMA_MINALIGN to 128 so that it covers the
currently known Cache Writeback Granule (CTR_EL0.CWG) on arm64 and moves
the fallback in cache_line_size() from L1_CACHE_BYTES to this constant.
In addition, it warns (and taints) if the CWG is larger than
ARCH_DMA_MINALIGN as this is not safe with non-coherent DMA.

Cc: Will Deacon <will.deacon@arm.com>
Cc: Robin Murphy <robin.murphy@arm.com>
Signed-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
parent d93277b9
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
* cache before the transfer is done, causing old data to be seen by * cache before the transfer is done, causing old data to be seen by
* the CPU. * the CPU.
*/ */
#define ARCH_DMA_MINALIGN L1_CACHE_BYTES #define ARCH_DMA_MINALIGN (128)
#ifndef __ASSEMBLY__ #ifndef __ASSEMBLY__
...@@ -77,7 +77,7 @@ static inline u32 cache_type_cwg(void) ...@@ -77,7 +77,7 @@ static inline u32 cache_type_cwg(void)
static inline int cache_line_size(void) static inline int cache_line_size(void)
{ {
u32 cwg = cache_type_cwg(); u32 cwg = cache_type_cwg();
return cwg ? 4 << cwg : L1_CACHE_BYTES; return cwg ? 4 << cwg : ARCH_DMA_MINALIGN;
} }
#endif /* __ASSEMBLY__ */ #endif /* __ASSEMBLY__ */
......
...@@ -1606,7 +1606,6 @@ static void __init setup_system_capabilities(void) ...@@ -1606,7 +1606,6 @@ static void __init setup_system_capabilities(void)
void __init setup_cpu_features(void) void __init setup_cpu_features(void)
{ {
u32 cwg; u32 cwg;
int cls;
setup_system_capabilities(); setup_system_capabilities();
mark_const_caps_ready(); mark_const_caps_ready();
...@@ -1627,13 +1626,9 @@ void __init setup_cpu_features(void) ...@@ -1627,13 +1626,9 @@ void __init setup_cpu_features(void)
* Check for sane CTR_EL0.CWG value. * Check for sane CTR_EL0.CWG value.
*/ */
cwg = cache_type_cwg(); cwg = cache_type_cwg();
cls = cache_line_size();
if (!cwg) if (!cwg)
pr_warn("No Cache Writeback Granule information, assuming cache line size %d\n", pr_warn("No Cache Writeback Granule information, assuming %d\n",
cls); ARCH_DMA_MINALIGN);
if (L1_CACHE_BYTES < cls)
pr_warn("L1_CACHE_BYTES smaller than the Cache Writeback Granule (%d < %d)\n",
L1_CACHE_BYTES, cls);
} }
static bool __maybe_unused static bool __maybe_unused
......
...@@ -504,6 +504,11 @@ static int __init arm64_dma_init(void) ...@@ -504,6 +504,11 @@ static int __init arm64_dma_init(void)
max_pfn > (arm64_dma_phys_limit >> PAGE_SHIFT)) max_pfn > (arm64_dma_phys_limit >> PAGE_SHIFT))
swiotlb = 1; swiotlb = 1;
WARN_TAINT(ARCH_DMA_MINALIGN < cache_line_size(),
TAINT_CPU_OUT_OF_SPEC,
"ARCH_DMA_MINALIGN smaller than CTR_EL0.CWG (%d < %d)",
ARCH_DMA_MINALIGN, cache_line_size());
return atomic_pool_init(); return atomic_pool_init();
} }
arch_initcall(arm64_dma_init); arch_initcall(arm64_dma_init);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment