cache: deprecate CONFIG_DOUBLEMAP

Use CONFIG_CACHE_HAS_MIRRORED_MEMORY_REGIONS instead.
The new kconfig reflects more correctly on what is going on
in hardware. Also, this is not enabled by default if CPU
cache is not coherent. CPU cache can be incoherent and yet
there are no mirrored memory regions. Those relying on this
deprecated default behavior has their config adding
CONFIG_CACHE_HAS_MIRRORED_MEMORY_REGIONS separately.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
This commit is contained in:
Daniel Leung
2025-10-30 14:47:58 -07:00
committed by Henrik Brix Andersen
parent 0540d274c0
commit 3e33978078
7 changed files with 35 additions and 13 deletions

View File

@@ -1078,10 +1078,22 @@ config ICACHE
help
This option enables the support for the instruction cache (i-cache).
config CACHE_HAS_MIRRORED_MEMORY_REGIONS
bool "Mirrored memory region(s) for both cached and uncached access"
depends on CPU_CACHE_INCOHERENT
help
Enable this if hardware has mirrored memory regions at different
addressed when accessing one would go through cache, but accessing
the other would go to memory directly. A pointer can be cheaply
converted to cached or uncached access.
This applies to intra-CPU multiprocessing incoherence and makes only
sense when MP_MAX_NUM_CPUS > 1.
config CACHE_DOUBLEMAP
bool "Cache double-mapping support"
depends on CPU_CACHE_INCOHERENT
default y
select CACHE_HAS_MIRRORED_MEMORY_REGIONS
select DEPRECATED
help
Double-mapping behavior where a pointer can be cheaply converted to
point to the same cached/uncached memory at different locations.

View File

@@ -196,6 +196,11 @@ Modem HL78XX
Other subsystems
****************
* Cache
* Use :kconfig:option:`CONFIG_CACHE_HAS_MIRRORED_MEMORY_REGIONS` instead of
:kconfig:option:`CONFIG_CACHE_DOUBLEMAP` as the former is more descriptive of the feature.
JWT
===

View File

@@ -337,7 +337,7 @@ size_t arch_icache_line_size_get(void);
#endif /* CONFIG_ICACHE || __DOXYGEN__ */
#if CONFIG_CACHE_DOUBLEMAP || __DOXYGEN__
#if CONFIG_CACHE_HAS_MIRRORED_MEMORY_REGIONS || __DOXYGEN__
bool arch_cache_is_ptr_cached(void *ptr);
#define cache_is_ptr_cached(ptr) arch_cache_is_ptr_cached(ptr)
@@ -349,7 +349,7 @@ void __sparse_cache *arch_cache_cached_ptr_get(void *ptr);
void *arch_cache_uncached_ptr_get(void __sparse_cache *ptr);
#define cache_uncached_ptr(ptr) arch_cache_uncached_ptr_get(ptr)
#endif /* CONFIG_CACHE_DOUBLEMAP */
#endif /* CONFIG_CACHE_HAS_MIRRORED_MEMORY_REGIONS */
void arch_cache_init(void);

View File

@@ -449,7 +449,7 @@ static ALWAYS_INLINE size_t sys_cache_instr_line_size_get(void)
*/
static ALWAYS_INLINE bool sys_cache_is_ptr_cached(void *ptr)
{
#if defined(CONFIG_CACHE_MANAGEMENT) && defined(CONFIG_CACHE_DOUBLEMAP)
#if defined(CONFIG_CACHE_MANAGEMENT) && defined(CONFIG_CACHE_HAS_MIRRORED_MEMORY_REGIONS)
return cache_is_ptr_cached(ptr);
#else
ARG_UNUSED(ptr);
@@ -473,7 +473,7 @@ static ALWAYS_INLINE bool sys_cache_is_ptr_cached(void *ptr)
*/
static ALWAYS_INLINE bool sys_cache_is_ptr_uncached(void *ptr)
{
#if defined(CONFIG_CACHE_MANAGEMENT) && defined(CONFIG_CACHE_DOUBLEMAP)
#if defined(CONFIG_CACHE_MANAGEMENT) && defined(CONFIG_CACHE_HAS_MIRRORED_MEMORY_REGIONS)
return cache_is_ptr_uncached(ptr);
#else
ARG_UNUSED(ptr);
@@ -492,8 +492,8 @@ static ALWAYS_INLINE bool sys_cache_is_ptr_uncached(void *ptr)
* the current CPU if they exist, and writes will go first into the
* cache and be written back later.
*
* @note This API returns the same pointer if CONFIG_CACHE_DOUBLEMAP is not
* enabled.
* @note This API returns the same pointer if
* CONFIG_CACHE_HAS_MIRRORED_MEMORY_REGIONS is not enabled.
*
* @see arch_uncached_ptr()
*
@@ -502,7 +502,7 @@ static ALWAYS_INLINE bool sys_cache_is_ptr_uncached(void *ptr)
*/
static ALWAYS_INLINE void __sparse_cache *sys_cache_cached_ptr_get(void *ptr)
{
#if defined(CONFIG_CACHE_MANAGEMENT) && defined(CONFIG_CACHE_DOUBLEMAP)
#if defined(CONFIG_CACHE_MANAGEMENT) && defined(CONFIG_CACHE_HAS_MIRRORED_MEMORY_REGIONS)
return cache_cached_ptr(ptr);
#else
return (__sparse_force void __sparse_cache *)ptr;
@@ -517,8 +517,8 @@ static ALWAYS_INLINE void __sparse_cache *sys_cache_cached_ptr_get(void *ptr)
* refer to the same memory while bypassing the L1 data cache. Data
* in the L1 cache will not be inspected nor modified by the access.
*
* @note This API returns the same pointer if CONFIG_CACHE_DOUBLEMAP is not
* enabled.
* @note This API returns the same pointer if
* CONFIG_CACHE_HAS_MIRRORED_MEMORY_REGIONS is not enabled.
*
* @see arch_cached_ptr()
*
@@ -527,7 +527,7 @@ static ALWAYS_INLINE void __sparse_cache *sys_cache_cached_ptr_get(void *ptr)
*/
static ALWAYS_INLINE void *sys_cache_uncached_ptr_get(void __sparse_cache *ptr)
{
#if defined(CONFIG_CACHE_MANAGEMENT) && defined(CONFIG_CACHE_DOUBLEMAP)
#if defined(CONFIG_CACHE_MANAGEMENT) && defined(CONFIG_CACHE_HAS_MIRRORED_MEMORY_REGIONS)
return cache_uncached_ptr(ptr);
#else
return (__sparse_force void *)ptr;

View File

@@ -18,23 +18,27 @@ config SOC_SERIES_INTEL_ADSP_ACE15
select XTENSA_CPU_HAS_HIFI3
select XTENSA_CPU_HAS_HIFI4
select INTEL_ADSP_MEMORY_IS_MIRRORED
select CACHE_HAS_MIRRORED_MEMORY_REGIONS
config SOC_SERIES_INTEL_ADSP_ACE20
select XTENSA_CPU_HAS_HIFI3
select XTENSA_CPU_HAS_HIFI4
select INTEL_ADSP_MEMORY_IS_MIRRORED
select CACHE_HAS_MIRRORED_MEMORY_REGIONS
config SOC_SERIES_INTEL_ADSP_ACE30
select XTENSA_CPU_HAS_HIFI3
select XTENSA_CPU_HAS_HIFI4
select INTEL_ADSP_MEMORY_IS_MIRRORED
select KERNEL_VM_USE_CUSTOM_MEM_RANGE_CHECK if XTENSA_MMU
select CACHE_HAS_MIRRORED_MEMORY_REGIONS
config SOC_SERIES_INTEL_ADSP_ACE40
select XTENSA_CPU_HAS_HIFI3
select XTENSA_CPU_HAS_HIFI4
select INTEL_ADSP_MEMORY_IS_MIRRORED
select KERNEL_VM_USE_CUSTOM_MEM_RANGE_CHECK if XTENSA_MMU
select CACHE_HAS_MIRRORED_MEMORY_REGIONS
config SOC_INTEL_COMM_WIDGET
bool "Intel Communication Widget driver"

View File

@@ -13,6 +13,7 @@ config SOC_SERIES_INTEL_ADSP_CAVS
select ARCH_HAS_GDBSTUB
select HAS_PM
select INTEL_ADSP_MEMORY_IS_MIRRORED
select CACHE_HAS_MIRRORED_MEMORY_REGIONS
config SOC_INTEL_CAVS_V25
select XTENSA_WAITI_BUG

View File

@@ -47,7 +47,7 @@ extern "C" {
#endif /* CONFIG_ICACHE */
#if defined(CONFIG_CACHE_DOUBLEMAP)
#if defined(CONFIG_CACHE_HAS_MIRRORED_MEMORY_REGIONS)
/**
* @brief Test if a pointer is in cached region.
*