Re: [PATCH] MIPS: ingenic: Let Config.VI tell whether the icache is virtual

From: Paul Cercueil

Date: Wed Nov 11 2026 - 11:30:57 EST


Hi Hunter,

Le mardi 10 novembre 2026 à 21:09 -0700, Hunter Laux via B4 Relay a écrit :
> From: Hunter Laux <hunterlaux@xxxxxxxxx>
>
> The Ingenic CPU support treats every XBurst instruction cache as
> virtually tagged: the feature overrides fix cpu_has_vtag_icache to 1,
> and the probe sets MIPS_CACHE_VTAG. The setting came in with the JZ4740
> feature overrides in commit 83ccf69d8f11 ("MIPS: JZ4740: Add base
> support for Ingenic JZ4740 System-on-a-Chip") without a stated reason,
> and Ingenic's own kernels treat the icache as physically tagged.
>
> Neither XBurst1 nor XBurst II has a virtually tagged icache. Both
> programming manuals describe a physically tagged one and hardwire
> Config.VI to 0, which the cache probe already reads. On the X2600, code
> at a virtual address remapped to another page through the TLB alone
> runs the new page, while the old line is still in the icache. XBurst1
> has not been tested. Treating the icache as virtually tagged is
> incorrect and costs needless icache flushes.
>
> Drop both and leave it to Config.VI.
>
> Cc: Lars-Peter Clausen <lars@xxxxxxxxxx>
> Assisted-by: Claude:claude-opus-5-5
> Signed-off-by: Hunter Laux <hunterlaux@xxxxxxxxx>

The docs I have do say that both caches are "virtually indexed, physically
tagged". So the patch looks good.

If anything it's missing a Fixes: tag (with stable@xxxxxxxxxxxxxxx in Cc).

> ---
> Lars, the override came with your JZ4740 support in 2010. On the off
> chance you remember a reason for setting cpu_has_vtag_icache to 1,
> I'd like to hear it.
> ---
>  arch/mips/include/asm/mach-ingenic/cpu-feature-overrides.h | 1 -
>  arch/mips/kernel/cpu-probe.c                               | 3 ---
>  2 files changed, 4 deletions(-)
>
> diff --git a/arch/mips/include/asm/mach-ingenic/cpu-feature-overrides.h
> b/arch/mips/include/asm/mach-ingenic/cpu-feature-overrides.h
> index 7ace50127f..71c03f1dd4 100644
> --- a/arch/mips/include/asm/mach-ingenic/cpu-feature-overrides.h
> +++ b/arch/mips/include/asm/mach-ingenic/cpu-feature-overrides.h
> @@ -27,7 +27,6 @@
>  #define cpu_has_mips3d 0
>  #define cpu_has_smartmips 0
>  #define kernel_uses_llsc 1
> -#define cpu_has_vtag_icache 1

Don't remove it, set it to 0.

Cheers,
-Paul

>  #define cpu_has_dc_aliases 0
>  #define cpu_has_ic_fills_f_dc 0
>  #define cpu_has_pindexed_dcache 0
> diff --git a/arch/mips/kernel/cpu-probe.c b/arch/mips/kernel/cpu-probe.c
> index 489612ed9d..bef92e6cd6 100644
> --- a/arch/mips/kernel/cpu-probe.c
> +++ b/arch/mips/kernel/cpu-probe.c
> @@ -1763,9 +1763,6 @@ static inline void cpu_probe_ingenic(struct cpuinfo_mips
> *c, unsigned int cpu)
>   c->options &= ~MIPS_CPU_COUNTER;
>   BUG_ON(__builtin_constant_p(cpu_has_counter) && cpu_has_counter);
>  
> - /* XBurst has virtually tagged icache */
> - c->icache.flags |= MIPS_CACHE_VTAG;
> -
>   switch (c->processor_id & PRID_IMP_MASK) {
>  
>   /* XBurst®1 with MXU1.0/MXU1.1 SIMD ISA */
>
> ---
> base-commit: b3dfbde62cf1981c4638939c159dfd087b7a72e9
> change-id: 20261110-mips-xburst-icache-vi-db10a8d03dd6
>
> Best regards,