Skip to content

Commit a584e36

Browse files
maass-hamburgcfriedt
authored andcommitted
arch: cache: set default of line size
set default of line size to the value from the devicetree. Signed-off-by: Fin Maaß <[email protected]>
1 parent f64126f commit a584e36

File tree

5 files changed

+12
-30
lines changed

5 files changed

+12
-30
lines changed

arch/Kconfig

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1123,11 +1123,11 @@ config DCACHE_LINE_SIZE_DETECT
11231123
config DCACHE_LINE_SIZE
11241124
int "d-cache line size"
11251125
depends on !DCACHE_LINE_SIZE_DETECT
1126+
default $(dt_node_int_prop_int,/cpus/cpu@0,d-cache-line-size) \
1127+
if $(dt_node_has_prop,/cpus/cpu@0,d-cache-line-size)
11261128
default 0
11271129
help
1128-
Size in bytes of a CPU d-cache line. If this is set to 0 the value is
1129-
obtained from the 'd-cache-line-size' DT property instead if present.
1130-
1130+
Size in bytes of a CPU d-cache line.
11311131

11321132
Detect automatically at runtime by selecting DCACHE_LINE_SIZE_DETECT.
11331133

@@ -1149,10 +1149,11 @@ config ICACHE_LINE_SIZE_DETECT
11491149
config ICACHE_LINE_SIZE
11501150
int "i-cache line size"
11511151
depends on !ICACHE_LINE_SIZE_DETECT
1152+
default $(dt_node_int_prop_int,/cpus/cpu@0,i-cache-line-size) \
1153+
if $(dt_node_has_prop,/cpus/cpu@0,i-cache-line-size)
11521154
default 0
11531155
help
1154-
Size in bytes of a CPU i-cache line. If this is set to 0 the value is
1155-
obtained from the 'i-cache-line-size' DT property instead if present.
1156+
Size in bytes of a CPU i-cache line.
11561157

11571158
Detect automatically at runtime by selecting ICACHE_LINE_SIZE_DETECT.
11581159

drivers/cache/cache_andes.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -534,9 +534,6 @@ static int andes_cache_init(void)
534534
}
535535
#elif (CONFIG_ICACHE_LINE_SIZE != 0)
536536
cache_cfg.instr_line_size = CONFIG_ICACHE_LINE_SIZE;
537-
#elif DT_NODE_HAS_PROP(DT_PATH(cpus, cpu_0), i_cache_line_size)
538-
cache_cfg.instr_line_size =
539-
DT_PROP(DT_PATH(cpus, cpu_0), i_cache_line_size);
540537
#else
541538
LOG_ERR("Please specific the i-cache-line-size "
542539
"CPU0 property of the DT");
@@ -558,9 +555,6 @@ static int andes_cache_init(void)
558555
}
559556
#elif (CONFIG_DCACHE_LINE_SIZE != 0)
560557
cache_cfg.data_line_size = CONFIG_DCACHE_LINE_SIZE;
561-
#elif DT_NODE_HAS_PROP(DT_PATH(cpus, cpu_0), d_cache_line_size)
562-
cache_cfg.data_line_size =
563-
DT_PROP(DT_PATH(cpus, cpu_0), d_cache_line_size);
564558
#else
565559
LOG_ERR("Please specific the d-cache-line-size "
566560
"CPU0 property of the DT");

include/zephyr/cache.h

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,6 @@ extern "C" {
3535
* @{
3636
*/
3737

38-
/**
39-
* @cond INTERNAL_HIDDEN
40-
*
41-
*/
42-
43-
#define _CPU DT_PATH(cpus, cpu_0)
44-
45-
/** @endcond */
46-
4738
/**
4839
* @brief Enable the d-cache
4940
*
@@ -398,7 +389,6 @@ static ALWAYS_INLINE int sys_cache_instr_flush_and_invd_range(void *addr, size_t
398389
*
399390
* - At run-time when @kconfig{CONFIG_DCACHE_LINE_SIZE_DETECT} is set.
400391
* - At compile time using the value set in @kconfig{CONFIG_DCACHE_LINE_SIZE}.
401-
* - At compile time using the `d-cache-line-size` CPU0 property of the DT.
402392
* - 0 otherwise
403393
*
404394
* @retval size Size of the d-cache line.
@@ -408,10 +398,10 @@ static ALWAYS_INLINE size_t sys_cache_data_line_size_get(void)
408398
{
409399
#ifdef CONFIG_DCACHE_LINE_SIZE_DETECT
410400
return cache_data_line_size_get();
411-
#elif (CONFIG_DCACHE_LINE_SIZE != 0)
401+
#elif defined(CONFIG_DCACHE_LINE_SIZE)
412402
return CONFIG_DCACHE_LINE_SIZE;
413403
#else
414-
return DT_PROP_OR(_CPU, d_cache_line_size, 0);
404+
return 0;
415405
#endif
416406
}
417407

@@ -425,7 +415,6 @@ static ALWAYS_INLINE size_t sys_cache_data_line_size_get(void)
425415
*
426416
* - At run-time when @kconfig{CONFIG_ICACHE_LINE_SIZE_DETECT} is set.
427417
* - At compile time using the value set in @kconfig{CONFIG_ICACHE_LINE_SIZE}.
428-
* - At compile time using the `i-cache-line-size` CPU0 property of the DT.
429418
* - 0 otherwise
430419
*
431420
* @retval size Size of the d-cache line.
@@ -435,10 +424,10 @@ static ALWAYS_INLINE size_t sys_cache_instr_line_size_get(void)
435424
{
436425
#ifdef CONFIG_ICACHE_LINE_SIZE_DETECT
437426
return cache_instr_line_size_get();
438-
#elif (CONFIG_ICACHE_LINE_SIZE != 0)
427+
#elif defined(CONFIG_ICACHE_LINE_SIZE)
439428
return CONFIG_ICACHE_LINE_SIZE;
440429
#else
441-
return DT_PROP_OR(_CPU, i_cache_line_size, 0);
430+
return 0;
442431
#endif
443432
}
444433

include/zephyr/sys/spsc_pbuf.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ extern "C" {
4040

4141
/**@} */
4242

43-
#if CONFIG_DCACHE_LINE_SIZE != 0
43+
#ifdef CONFIG_DCACHE_LINE_SIZE
4444
#define Z_SPSC_PBUF_LOCAL_DCACHE_LINE CONFIG_DCACHE_LINE_SIZE
4545
#else
46-
#define Z_SPSC_PBUF_LOCAL_DCACHE_LINE DT_PROP_OR(CPU, d_cache_line_size, 0)
46+
#define Z_SPSC_PBUF_LOCAL_DCACHE_LINE 0
4747
#endif
4848

4949
#ifndef CONFIG_SPSC_PBUF_REMOTE_DCACHE_LINE

tests/drivers/spi/spi_loopback/src/spi.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,6 @@ const struct gpio_dt_spec mosi_pin = GPIO_DT_SPEC_GET_OR(DT_PATH(zephyr_user), m
7474
#define __NOCACHE
7575
#if CONFIG_DCACHE_LINE_SIZE != 0
7676
#define __BUF_ALIGN __aligned(CONFIG_DCACHE_LINE_SIZE)
77-
#else
78-
#define __BUF_ALIGN __aligned(DT_PROP_OR(DT_PATH(cpus, cpu_0), d_cache_line_size, 32))
7977
#endif
8078
#endif /* CONFIG_NOCACHE_MEMORY */
8179

0 commit comments

Comments
 (0)