Re: [PATCH] MIPS: Make cpu_has_mips64r6 constant on 64-bit r6 kernels

From: Tzu-Ching Yang

Date: Mon Nov 23 2026 - 07:38:03 EST


On Mon, 23 Nov 2026, Maciej W. Rozycki wrote:
> > Your form and v1 differ only on pre-r6 kernels. I built both on
>
> Then you're doing something wrong; with __isa_ge_or_flag() I get:
[...]
> $ objdump -d vmlinux-base | grep -c dclz
> 18
> $ objdump -d vmlinux-has-mips64r6 | grep -c dclz
> 1430

Sorry, I worded that badly: I compared your form with v1, not with
mainline. Against mainline, in bytes of bloat-o-meter -t with GCC
16.2:

defconfig your form v1
--------- --------- -------
64r6el -105340 -105340
32r6el 0 0
64r2el +264 0
32r2el +3352 0

On the r6 kernels the two give the same vmlinux, byte for byte, so
your form has all of the gain that you show. On the pre-r6 kernels it
makes cpu_has_mips64r6 a run-time test, hence the growth; v1 leaves
their vmlinux as it is.

> I maintain that __isa_ge_or_flag() is the correct approach.

Understood. v2 will use your form: cpu_has_mips64r6 as cpu_has_64bits
&& __isa_ge_or_flag(6, MIPS_CPU_ISA_M64R6), with __isa_ge_and_flag()
removed.

> FWIW an early check for the ISA mismatch might be worth having if at all
> feasible, reporting the issue via a firmware printf()-like callback where
> available. Said JR instruction could be recoded as JALR $0, ... if this
> turns out feasible. Not a requirement for your change of course.

Thanks, I will look into that separately.

Tzu-Ching