-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
riscv: Introduce riscv_v_vsize to record size of Vector context
This patch is used to detect the size of CPU vector registers and use riscv_v_vsize to save the size of all the vector registers. It assumes all harts has the same capabilities in a SMP system. If a core detects VLENB that is different from the boot core, then it warns and turns off V support for user space. Co-developed-by: Guo Ren <guoren@linux.alibaba.com> Signed-off-by: Guo Ren <guoren@linux.alibaba.com> Co-developed-by: Vincent Chen <vincent.chen@sifive.com> Signed-off-by: Vincent Chen <vincent.chen@sifive.com> Signed-off-by: Greentime Hu <greentime.hu@sifive.com> Signed-off-by: Andy Chiu <andy.chiu@sifive.com> Reviewed-by: Conor Dooley <conor.dooley@microchip.com> Reviewed-by: Heiko Stuebner <heiko.stuebner@vrull.eu> Tested-by: Heiko Stuebner <heiko.stuebner@vrull.eu> Reviewed-by: Palmer Dabbelt <palmer@rivosinc.com> Link: https://lore.kernel.org/r/20230605110724.21391-9-andy.chiu@sifive.com Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
- Loading branch information
Greentime Hu
authored and
Palmer Dabbelt
committed
Jun 8, 2023
1 parent
0a3381a
commit 7017858
Showing
5 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
/* | ||
* Copyright (C) 2023 SiFive | ||
* Author: Andy Chiu <andy.chiu@sifive.com> | ||
*/ | ||
#include <linux/export.h> | ||
|
||
#include <asm/vector.h> | ||
#include <asm/csr.h> | ||
#include <asm/elf.h> | ||
#include <asm/bug.h> | ||
|
||
unsigned long riscv_v_vsize __read_mostly; | ||
EXPORT_SYMBOL_GPL(riscv_v_vsize); | ||
|
||
int riscv_v_setup_vsize(void) | ||
{ | ||
unsigned long this_vsize; | ||
|
||
/* There are 32 vector registers with vlenb length. */ | ||
riscv_v_enable(); | ||
this_vsize = csr_read(CSR_VLENB) * 32; | ||
riscv_v_disable(); | ||
|
||
if (!riscv_v_vsize) { | ||
riscv_v_vsize = this_vsize; | ||
return 0; | ||
} | ||
|
||
if (riscv_v_vsize != this_vsize) { | ||
WARN(1, "RISCV_ISA_V only supports one vlenb on SMP systems"); | ||
return -EOPNOTSUPP; | ||
} | ||
|
||
return 0; | ||
} |