[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <aTc2qaf6JxBPLvtH@curiosity>
Date: Mon, 8 Dec 2025 23:35:53 +0300
From: Sergey Matyukevich <geomatsi@...il.com>
To: Andy Chiu <andybnac@...il.com>
Cc: Jonathan Corbet <corbet@....net>, Paul Walmsley <pjw@...nel.org>,
Palmer Dabbelt <palmer@...belt.com>,
Albert Ou <aou@...s.berkeley.edu>, Alexandre Ghiti <alex@...ti.fr>,
Charlie Jenkins <charlie@...osinc.com>,
Conor Dooley <conor.dooley@...rochip.com>,
Andrew Jones <ajones@...tanamicro.com>,
linux-riscv@...ts.infradead.org, linux-doc@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] riscv: hwprobe: expose vector register length in bytes
Hi Andy
On Wed, Dec 03, 2025 at 11:57:06AM -0600, Andy Chiu wrote:
> Hi Sergey,
>
> On Fri, Nov 21, 2025 at 1:37 PM Sergey Matyukevich <geomatsi@...il.com> wrote:
> >
> > The vector register length can be obtained from the read-only CSR vlenb.
> > However reading this CSR may be undesirable in some cases. XTheadVector
> > extension is one example: existing implementations may not provide this
> > register. On such platforms, vlenb is specified as device-tree property.
>
> I wonder why a hwprobe entry is needed even in this context. If vlenb
> is not available, we can always use a vsetvli and read the destination
> register to infer register length. Isn't that also true for Vector
> 0.7, or are you considering anything else?
Sure, reading vsetvli works for XTheadVector as well. The primary reason
for the new hwprobe key is convenience. Vector 1.0 and XTheadVector have
some differences that complicate that sort of autodetection. For instance,
an older encoding for vsetvli. Good examples are vstate save and restore
functions in `arch/riscv/include/asm/vector.h`. Using hwprobe seems more
convenient than using vector-or-xtheadvector logic with custom opcods,
especially since the kernel already has all the necessary information.
> > Reading vlenb also initializes the application’s vector context, even
> > though the application may decide not to use the vector extension based
> > on the reported length.
> >
> > Meanwhile the kernel already determines vlenb at boot, either from the
> > CSR or from the device tree. So add RISCV_HWPROBE_KEY_VECTOR_REG_LENGTH
> > to expose the vector register length already known to the kernel.
> >
> > Signed-off-by: Sergey Matyukevich <geomatsi@...il.com>
> > ---
> > Documentation/arch/riscv/hwprobe.rst | 3 +++
> > arch/riscv/include/asm/hwprobe.h | 2 +-
> > arch/riscv/include/uapi/asm/hwprobe.h | 1 +
> > arch/riscv/kernel/sys_hwprobe.c | 6 ++++++
> > 4 files changed, 11 insertions(+), 1 deletion(-)
[snip]...
> Thanks,
> Andy
Regards,
Sergey
Powered by blists - more mailing lists