[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <mhng-BE370728-B36C-4BF9-B980-D6AF42A83272@palmerdabbelt-mac>
Date: Tue, 10 Jun 2025 15:00:22 -0700 (PDT)
From: Palmer Dabbelt <palmer@...belt.com>
To: zhangchunyan@...as.ac.cn
CC: Paul Walmsley <paul.walmsley@...ive.com>, aou@...s.berkeley.edu,
Alexandre Ghiti <alex@...ti.fr>, Charlie Jenkins <charlie@...osinc.com>, song@...nel.org, yukuai3@...wei.com,
linux-riscv@...ts.infradead.org, linux-raid@...r.kernel.org, linux-kernel@...r.kernel.org, zhang.lyra@...il.com
Subject: Re: [PATCH 3/4] raid6: riscv: Allow code to be compiled in userspace
On Tue, 10 Jun 2025 03:12:33 PDT (-0700), zhangchunyan@...as.ac.cn wrote:
> To support userspace raid6test, this patch adds __KERNEL__ ifdef for kernel
> header inclusions also userspace wrapper definitions to allow code to be
> compiled in userspace.
>
> Signed-off-by: Chunyan Zhang <zhangchunyan@...as.ac.cn>
> ---
> lib/raid6/recov_rvv.c | 7 +------
> lib/raid6/rvv.c | 11 ++++-------
> lib/raid6/rvv.h | 15 +++++++++++++++
> 3 files changed, 20 insertions(+), 13 deletions(-)
>
> diff --git a/lib/raid6/recov_rvv.c b/lib/raid6/recov_rvv.c
> index 500da521a806..8f2be833c015 100644
> --- a/lib/raid6/recov_rvv.c
> +++ b/lib/raid6/recov_rvv.c
> @@ -4,13 +4,8 @@
> * Author: Chunyan Zhang <zhangchunyan@...as.ac.cn>
> */
>
> -#include <asm/vector.h>
> #include <linux/raid/pq.h>
> -
> -static int rvv_has_vector(void)
> -{
> - return has_vector();
> -}
> +#include "rvv.h"
>
> static void __raid6_2data_recov_rvv(int bytes, u8 *p, u8 *q, u8 *dp,
> u8 *dq, const u8 *pbmul,
> diff --git a/lib/raid6/rvv.c b/lib/raid6/rvv.c
> index b193ea176d5d..99dfa16d37c7 100644
> --- a/lib/raid6/rvv.c
> +++ b/lib/raid6/rvv.c
> @@ -9,16 +9,13 @@
> * Copyright 2002-2004 H. Peter Anvin
> */
>
> -#include <asm/vector.h>
> -#include <linux/raid/pq.h>
> #include "rvv.h"
>
> +#ifdef __KERNEL__
> #define NSIZE (riscv_v_vsize / 32) /* NSIZE = vlenb */
> -
> -static int rvv_has_vector(void)
> -{
> - return has_vector();
> -}
> +#else
> +#define NSIZE 16
> +#endif
and looking at the code a bit more, this makes this VLS when run in
userspace. So we etiher need a check for that, or to check VL in the
loop.
>
> static void raid6_rvv1_gen_syndrome_real(int disks, unsigned long bytes, void **ptrs)
> {
> diff --git a/lib/raid6/rvv.h b/lib/raid6/rvv.h
> index 94044a1b707b..595dfbf95d4e 100644
> --- a/lib/raid6/rvv.h
> +++ b/lib/raid6/rvv.h
> @@ -7,6 +7,21 @@
> * Definitions for RISC-V RAID-6 code
> */
>
> +#ifdef __KERNEL__
> +#include <asm/vector.h>
> +#else
> +#define kernel_vector_begin()
> +#define kernel_vector_end()
> +#define has_vector() (1)
> +#endif
> +
> +#include <linux/raid/pq.h>
> +
> +static int rvv_has_vector(void)
> +{
> + return has_vector();
> +}
> +
> #define RAID6_RVV_WRAPPER(_n) \
> static void raid6_rvv ## _n ## _gen_syndrome(int disks, \
> size_t bytes, void **ptrs) \
Powered by blists - more mailing lists