Commit 7b8c87b2 authored by Shaokun Zhang's avatar Shaokun Zhang Committed by Catalin Marinas

arm64: cacheinfo: Update cache_line_size detected from DT or PPTT

cache_line_size is derived from CTR_EL0.CWG field and is called mostly
for I/O device drivers. For some platforms like the HiSilicon Kunpeng920
server SoC, cache line sizes are different between L1/2 cache and L3
cache while L1 cache line size is 64-byte and L3 is 128-byte, but
CTR_EL0.CWG is misreporting using L1 cache line size.

We shall correct the right value which is important for I/O performance.
Let's update the cache line size if it is detected from DT or PPTT
information.

Cc: Will Deacon <will.deacon@arm.com>
Cc: Jeremy Linton <jeremy.linton@arm.com>
Cc: Zhenfa Qiu <qiuzhenfa@hisilicon.com>
Reported-by: default avatarZhenfa Qiu <qiuzhenfa@hisilicon.com>
Suggested-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
Reviewed-by: default avatarSudeep Holla <sudeep.holla@arm.com>
Signed-off-by: default avatarShaokun Zhang <zhangshaokun@hisilicon.com>
Signed-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
parent 9a83c84c
...@@ -91,11 +91,7 @@ static inline u32 cache_type_cwg(void) ...@@ -91,11 +91,7 @@ static inline u32 cache_type_cwg(void)
#define __read_mostly __attribute__((__section__(".data..read_mostly"))) #define __read_mostly __attribute__((__section__(".data..read_mostly")))
static inline int cache_line_size(void) int cache_line_size(void);
{
u32 cwg = cache_type_cwg();
return cwg ? 4 << cwg : ARCH_DMA_MINALIGN;
}
/* /*
* Read the effective value of CTR_EL0. * Read the effective value of CTR_EL0.
......
...@@ -28,6 +28,17 @@ ...@@ -28,6 +28,17 @@
#define CLIDR_CTYPE(clidr, level) \ #define CLIDR_CTYPE(clidr, level) \
(((clidr) & CLIDR_CTYPE_MASK(level)) >> CLIDR_CTYPE_SHIFT(level)) (((clidr) & CLIDR_CTYPE_MASK(level)) >> CLIDR_CTYPE_SHIFT(level))
int cache_line_size(void)
{
u32 cwg = cache_type_cwg();
if (coherency_max_size != 0)
return coherency_max_size;
return cwg ? 4 << cwg : ARCH_DMA_MINALIGN;
}
EXPORT_SYMBOL_GPL(cache_line_size);
static inline enum cache_type get_cache_type(int level) static inline enum cache_type get_cache_type(int level)
{ {
u64 clidr; u64 clidr;
......
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