Re: [v2, 2/5] riscv: Add support for kernel mode vector

Conor Dooley
2023-07-24T10:49:34Z

[-- Attachment #1.1: Type: text/plain, Size: 1574 bytes --]

Hey Andy,

On Fri, Jul 21, 2023 at 11:28:52AM +0000, Andy Chiu wrote:
> From: Greentime Hu <greentime.hu@sifive.com>
>
> Add kernel_vector_begin() and kernel_vector_end() function declarations
> and corresponding definitions in kernel_mode_vector.c
>
> These are needed to wrap uses of vector in kernel mode.
>
> 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>
> ---
> Changelog v2:
> - 's/kernel_rvv/kernel_vector' and return void in kernel_vector_begin
> (Conor)
> - export may_use_simd to include/asm/simd.h
> ---

> +/*
> + * kernel_vector_begin(): obtain the CPU vector registers for use by the calling
> + * context
> + *
> + * Must not be called unless may_use_simd() returns true.
> + * Task context in the vector registers is saved back to memory as necessary.
> + *
> + * A matching call to kernel_vector_end() must be made before returning from the
> + * calling context.
> + *
> + * The caller may freely use the vector registers until kernel_vector_end() is
> + * called.
> + */
> +void kernel_vector_begin(void)
> +{
> + if (WARN_ON(!has_vector()))
> + return;
> +
> + BUG_ON(!may_use_simd());
> +
> + riscv_v_vstate_save(current, task_pt_regs(current));
> +
> + get_cpu_vector_context();
> +
> + riscv_v_enable();
> +

> + return 0;

This breaks the build as you have made the function void.

Otherwise, this looks fine to me.

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

[-- Attachment #2: Type: text/plain, Size: 161 bytes --]