Skip to content

Commit 274bf3c

Browse files
ConchuODgregkh
authored andcommitted
RISC-V: Ignore V from the riscv,isa DT property on older T-Head CPUs
[ Upstream commit d82f322 ] Before attempting to support the pre-ratification version of vector found on older T-Head CPUs, disallow "v" in riscv,isa on these platforms. The deprecated property has no clear way to communicate the specific version of vector that is supported and much of the vendor provided software puts "v" in the isa string. riscv,isa-extensions should be used instead. This should not be too much of a burden for these systems, as the vendor shipped devicetrees and firmware do not work with a mainline kernel and will require updating. We can limit this restriction to only ignore v in riscv,isa on CPUs that report T-Head's vendor ID and a zero marchid. Newer T-Head CPUs that support the ratified version of vector should report non-zero marchid, according to Guo Ren [1]. Link: https://lore.kernel.org/linux-riscv/CAJF2gTRy5eK73=d6s7CVy9m9pB8p4rAoMHM3cZFwzg=AuF7TDA@mail.gmail.com/ [1] Fixes: dc6667a ("riscv: Extending cpufeature.c to detect V-extension") Co-developed-by: Conor Dooley <conor.dooley@microchip.com> Signed-off-by: Conor Dooley <conor.dooley@microchip.com> Acked-by: Guo Ren <guoren@kernel.org> Link: https://lore.kernel.org/r/20240223-tidings-shabby-607f086cb4d7@spud Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent fb3618f commit 274bf3c

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

arch/riscv/kernel/cpufeature.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <asm/hwprobe.h>
2222
#include <asm/patch.h>
2323
#include <asm/processor.h>
24+
#include <asm/sbi.h>
2425
#include <asm/vector.h>
2526

2627
#include "copy-unaligned.h"
@@ -396,6 +397,20 @@ static void __init riscv_fill_hwcap_from_isa_string(unsigned long *isa2hwcap)
396397
set_bit(RISCV_ISA_EXT_ZIHPM, isainfo->isa);
397398
}
398399

400+
/*
401+
* "V" in ISA strings is ambiguous in practice: it should mean
402+
* just the standard V-1.0 but vendors aren't well behaved.
403+
* Many vendors with T-Head CPU cores which implement the 0.7.1
404+
* version of the vector specification put "v" into their DTs.
405+
* CPU cores with the ratified spec will contain non-zero
406+
* marchid.
407+
*/
408+
if (acpi_disabled && riscv_cached_mvendorid(cpu) == THEAD_VENDOR_ID &&
409+
riscv_cached_marchid(cpu) == 0x0) {
410+
this_hwcap &= ~isa2hwcap[RISCV_ISA_EXT_v];
411+
clear_bit(RISCV_ISA_EXT_v, isainfo->isa);
412+
}
413+
399414
/*
400415
* All "okay" hart should have same isa. Set HWCAP based on
401416
* common capabilities of every "okay" hart, in case they don't

0 commit comments

Comments
 (0)