Skip to content

Commit c4a50db

Browse files
clementlegerpalmer-dabbelt
authored andcommitted
riscv: sbi: add SBI FWFT extension calls
Add FWFT extension calls. This will be ratified in SBI V3.0 hence, it is provided as a separate commit that can be left out if needed. Signed-off-by: Clément Léger <[email protected]> Reviewed-by: Andrew Jones <[email protected]> Reviewed-by: Atish Patra <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent 6d6d064 commit c4a50db

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

arch/riscv/kernel/sbi.c

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,8 @@ static int __sbi_rfence_v02(int fid, const struct cpumask *cpu_mask,
299299
return 0;
300300
}
301301

302+
static bool sbi_fwft_supported;
303+
302304
struct fwft_set_req {
303305
u32 feature;
304306
unsigned long value;
@@ -326,7 +328,15 @@ static void cpu_sbi_fwft_set(void *arg)
326328
*/
327329
int sbi_fwft_set(u32 feature, unsigned long value, unsigned long flags)
328330
{
329-
return -EOPNOTSUPP;
331+
struct sbiret ret;
332+
333+
if (!sbi_fwft_supported)
334+
return -EOPNOTSUPP;
335+
336+
ret = sbi_ecall(SBI_EXT_FWFT, SBI_EXT_FWFT_SET,
337+
feature, value, flags, 0, 0, 0);
338+
339+
return sbi_err_map_linux_errno(ret.error);
330340
}
331341

332342
/**
@@ -348,6 +358,9 @@ int sbi_fwft_set_cpumask(const cpumask_t *mask, u32 feature,
348358
.error = ATOMIC_INIT(0),
349359
};
350360

361+
if (!sbi_fwft_supported)
362+
return -EOPNOTSUPP;
363+
351364
if (feature & SBI_FWFT_GLOBAL_FEATURE_BIT)
352365
return -EINVAL;
353366

@@ -679,6 +692,11 @@ void __init sbi_init(void)
679692
pr_info("SBI DBCN extension detected\n");
680693
sbi_debug_console_available = true;
681694
}
695+
if (sbi_spec_version >= sbi_mk_version(3, 0) &&
696+
sbi_probe_extension(SBI_EXT_FWFT)) {
697+
pr_info("SBI FWFT extension detected\n");
698+
sbi_fwft_supported = true;
699+
}
682700
} else {
683701
__sbi_set_timer = __sbi_set_timer_v01;
684702
__sbi_send_ipi = __sbi_send_ipi_v01;

0 commit comments

Comments
 (0)