Skip to contentSkip to conversation

Kconfig: Add a default cache line size for RISC-V

PATCH In review Yu-Chien Peter Lin 3 participants 3 messages Jan 10, 2025 – Jan 16, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Kconfig: Add a default cache line size for RISC-V

Some RISC-V platforms do not define the d-cache line size through SYS_CACHE_SHIFT_n. Set a default value of 64 bytes for such cases.

---
This patch resolves compilation errors that occurs when the TEE driver is enabled:

drivers/tee/tee-uclass.c:247:41: error: 'CONFIG_SYS_CACHELINE_SIZE' undeclared (first use in this function); did you mean 'CONFIG_SYS_CBSIZE'?

    247 |                                         CONFIG_SYS_CACHELINE_SIZE);
        |                                         ^~~~~~~~~~~~~~~~~~~~~~~~~ 
  drivers/tee/optee/core.c: In function 'flush_shm_dcache':
  drivers/tee/optee/core.c:505:50: error: 'CONFIG_SYS_CACHELINE_SIZE' undeclared (first use in this function); did you mean 'CONFIG_SYS_CBSIZE'?
    505 |         flush_dcache_range(rounddown((ulong)arg, CONFIG_SYS_CACHELINE_SIZE),
        |                                                  ^~~~~~~~~~~~~~~~~~~~~~~~~
---
 arch/Kconfig | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/Kconfig +2 -1
index bb2e7bedd10..b0190b1f415 100644
@@ -52,7 +52,8 @@ config SYS_CACHELINE_SIZE
 	default 64 if SYS_CACHE_SHIFT_6
 	default 32 if SYS_CACHE_SHIFT_5
 	default 16 if SYS_CACHE_SHIFT_4
-	# Fall-back for MIPS
+	# Fall-back for MIPS and RISC-V
+	default 64 if RISCV
 	default 32 if MIPS
 
 config LINKER_LIST_ALIGN
Signature · 1 line
2.39.3
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Yu-Chien Peter Lin

Some RISC-V platforms do not define the d-cache line size through SYS_CACHE_SHIFT_n. Set a default value of 64 bytes for such cases.

You might want to add the following sentence to the commit message to make it clear from where you took the 64 byte default value:

The RISC-V ISA profile RVA23U64 requires extension Zic64b (Cache blocks must be 64 bytes in size, naturally aligned in the address space).

CCing Rick as co-maintainer of RISC-V.

Quoted 29 lines

---
This patch resolves compilation errors that occurs when the TEE driver is enabled:

drivers/tee/tee-uclass.c:247:41: error: 'CONFIG_SYS_CACHELINE_SIZE' undeclared (first use in this function); did you mean 'CONFIG_SYS_CBSIZE'?

     247 |                                         CONFIG_SYS_CACHELINE_SIZE);
         |                                         ^~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/tee/optee/core.c: In function 'flush_shm_dcache':
   drivers/tee/optee/core.c:505:50: error: 'CONFIG_SYS_CACHELINE_SIZE' undeclared (first use in this function); did you mean 'CONFIG_SYS_CBSIZE'?
     505 |         flush_dcache_range(rounddown((ulong)arg, CONFIG_SYS_CACHELINE_SIZE),
         |                                                  ^~~~~~~~~~~~~~~~~~~~~~~~~
---
  arch/Kconfig | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
arch/Kconfig +2 -1
index bb2e7bedd10..b0190b1f415 100644
@@ -52,7 +52,8 @@ config SYS_CACHELINE_SIZE
  	default 64 if SYS_CACHE_SHIFT_6
  	default 32 if SYS_CACHE_SHIFT_5
  	default 16 if SYS_CACHE_SHIFT_4
-	# Fall-back for MIPS
+	# Fall-back for MIPS and RISC-V
+	default 64 if RISCV
  	default 32 if MIPS
 
  config LINKER_LIST_ALIGN
Reviewed-by on v1 1/1
#2 lore raw
In reply to Yu-Chien Peter Lin
Quoted 12 lines · Yu-Chien Peter Lin

[EXTERNAL MAIL]

Some RISC-V platforms do not define the d-cache line size through SYS_CACHE_SHIFT_n. Set a default value of 64 bytes for such cases.

---
This patch resolves compilation errors that occurs when the TEE driver is enabled:

drivers/tee/tee-uclass.c:247:41: error: 'CONFIG_SYS_CACHELINE_SIZE' undeclared (first use in this function); did you mean 'CONFIG_SYS_CBSIZE'?

Quoted 9 lines
    247 |                                         CONFIG_SYS_CACHELINE_SIZE);
        |                                         ^~~~~~~~~~~~~~~~~~~~~~~~~
  drivers/tee/optee/core.c: In function 'flush_shm_dcache':
  drivers/tee/optee/core.c:505:50: error: 'CONFIG_SYS_CACHELINE_SIZE' undeclared (first use in this function); did you mean 'CONFIG_SYS_CBSIZE'?
    505 |         flush_dcache_range(rounddown((ulong)arg, CONFIG_SYS_CACHELINE_SIZE),
        |                                                  ^~~~~~~~~~~~~~~~~~~~~~~~~
---
 arch/Kconfig | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)