Received: by 2002:a05:6500:1b45:b0:1f5:f2ab:c469 with SMTP id cz5csp917014lqb; Wed, 17 Apr 2024 15:00:28 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWC+oKyUzD/oZAn+XkSpKs//2n5WpDWJEaT2bi/ChlFoOglz8c/o+qshPzuD8fEGrRQjz20b3SXRQKwEesvt5S06UikJ4xNQhFZXMDHjA== X-Google-Smtp-Source: AGHT+IGPUyPF9mLAbQNOsVsB/r+GEIQNQBkSnHxc/VWwaFUpr1jwduaC/mno7JO5rI3UC10vpdOn X-Received: by 2002:a17:906:3687:b0:a52:5b71:d91f with SMTP id a7-20020a170906368700b00a525b71d91fmr518261ejc.19.1713391228628; Wed, 17 Apr 2024 15:00:28 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713391228; cv=pass; d=google.com; s=arc-20160816; b=Offov/GAkPC8kEt9Dmx5egPwzTVhSeKlqWVwEuMAB/OaUZGIMSPFQpX1zzdToJNg7o t3qafQRYl8RO2vWg2XarMsSOJeIyUjW8DhIYT4ZiUNVClmRVee87hHKEYAbG6AAdwxm8 jP2/c++DzbHH8bdKqBb0p6liT5Ayt4xD+brAaQp/2adv89ocZw5ZzXLYdSKc1OEtp4yj NNl61fWXfkuwPmsV08NNREe4Xa7Vze4/QQuAeGjezkJ/8ZKjSMlBu6DDoNDuLlNJMQM5 1nMsgG6/hf/UNvnJlalj7SvK38IJGATpib6h3n8iSP9H1hnGnww1cprpa3b5KSlMduz3 0h8w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=uQ2asP1T1xuvOSck++wQC9ZSwwPqaUNm6JnqVfU5CKQ=; fh=GmdyyZ4ldDf2J01OVBq3idbWjAEkFbUKENeXbZ4yOhQ=; b=euoJ8BoWm1U6PVhWxVxclmI8lxjmVplRafHyr9o/Pmxt7py1N2CsP8VLX2CyyD9aFG v64oOew1Ql3f23YhAMaLrd71/mEV2Ii8SRKELIfM6I2dqFCuLZf30DgkDQmrESaksvqm WSST/GNSNLBPcUOowngjcIBv/DJGaNOkVNEEOc/Ne39CpJoI0mZ0ZchVcGo/XNmqdu3Q L/Jh949OO8zN5Iy00H2nJY2hPgr+QQlqeFYjMVxVeIb0BGpDg1WM07j5702eMTiRuWTU ctYeqt/AayCHpQlVxnmN9BVRFzWflp939zkg1fc0vhUXSkJmGnpTKpHGjZEmVl2Eu32c kBhw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=WOraZj8S; arc=pass (i=1 spf=pass spfdomain=rivosinc.com dkim=pass dkdomain=rivosinc-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-149272-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-149272-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id b10-20020a1709063f8a00b00a3e6c5fa398si72595ejj.304.2024.04.17.15.00.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Apr 2024 15:00:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-149272-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=WOraZj8S; arc=pass (i=1 spf=pass spfdomain=rivosinc.com dkim=pass dkdomain=rivosinc-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-149272-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-149272-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 29A951F21A10 for ; Wed, 17 Apr 2024 22:00:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 686BF13C3EF; Wed, 17 Apr 2024 22:00:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b="WOraZj8S" Received: from mail-pf1-f181.google.com (mail-pf1-f181.google.com [209.85.210.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 86DB984E00 for ; Wed, 17 Apr 2024 22:00:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.181 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713391218; cv=none; b=UU70jt5YDe4p2wY7LX3RLW6xKxwiNCovkfSPdGJkBO5786cvJTTg+YM3XtKCGVqynaEyzRngE1HGwqtNYnX4ck1NPl/ngrT3PplkFqp/Aa0sliRsUVlMr0axJBBfSlYjaY3JQQVzgKUTkuYovNLfjOiQaG2FlhsSaVmNmYeaKNI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713391218; c=relaxed/simple; bh=y60YK/Ker0fujTzSEW4X61Wqj5tFfBJ72FsvVhhhsmo=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=nZOZizoHxyzjaCLMyJaXk1p3oE1TPoWrM4Hz9oHbDcPSVOY4WTtI6g/cw18zvd7DV/W7qzMCiiaiiyBpzbeTgeQHfI5NE02Iv3s0r5hvC82ddy5VEmNwt3fJ+57HNeyT1jItI30u3IKf7HT42Z1UonQ4c9eizQVbHIzsWUXbWIk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rivosinc.com; spf=pass smtp.mailfrom=rivosinc.com; dkim=pass (2048-bit key) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b=WOraZj8S; arc=none smtp.client-ip=209.85.210.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rivosinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rivosinc.com Received: by mail-pf1-f181.google.com with SMTP id d2e1a72fcca58-6ed691fb83eso254689b3a.1 for ; Wed, 17 Apr 2024 15:00:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1713391216; x=1713996016; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=uQ2asP1T1xuvOSck++wQC9ZSwwPqaUNm6JnqVfU5CKQ=; b=WOraZj8Sbz+hDwLdUooQH8nRon6s7mp3lUF3a2n46o14xuM63XMWIPmPc+Gb8lg9kv UuItN69vz2It/+oBRBla2raav294ryg0MoTJFjBTR0ezGusXbPJb8ljUA0B3YXj2BbUB kp4uuLSXxJGcnKPQCN62o9vinXFsR9Of7Y00RbPmPr+dc0VFESlgDmyeeKeHO3nb0Svm d7jyXALVNYu172jS820gfIrg6Tdq+J4vjNboJ7FtpgoUMCc+bDSP314LRjJCoOW5JZ4/ CXfYShbX0y5V4yqcU/w+KE4H5uEewqSOtISzYYtI6AzLWREFoBHl0+jVUIbRf3asa220 l+GQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713391216; x=1713996016; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=uQ2asP1T1xuvOSck++wQC9ZSwwPqaUNm6JnqVfU5CKQ=; b=GiBLYwV/DpRJ0AuUXVnEWlO7YlFFTQa0W3FBdgZe5OCpKKfRlSffpMK3dwov8ldAD4 DLLXVT7Arof4+mLJ1ARfU3y46yiCND2tx2H1vlnRKxR3xNGS47JV+G2I+Zo3NdqVTehQ JhJuiBXBt295PVXeRsJr5lWEqs1JdrIN07OoB9mnsrVsdRDL9XP6uhyZdI8IQuSF4tzk Fpc+646qLD9kyDoVywINXoUuxr2ut5tviO21FfHwM7SmJjkzxY8G2uoLq3bwntfYsRhM dhC4djATMdba4K/zua45Tvyue5t4xTNH3cY6wnOW1CHi3Ccjm0J7RvBpARnTBUnZAlOk vfeA== X-Forwarded-Encrypted: i=1; AJvYcCUIfmQCVVbPIRKPVlXJn6AhCp12cSH7vvGye8xKe9f4Ykwk2rxjzmyCL1u49qyaojEUiFcB3xGzb1oqoJtst+DVuRJaGbtJqfEhtP7d X-Gm-Message-State: AOJu0YwNlkNb1BHcXJ4QiBqSNLsj60VRTIjnvrjEPreO18gA38DY6vKk AjRaPiZdpJUWQL+LhWPIDfzjr5fB8Cn1n+xitUYNxOoyRdmA0aJFfcU3Hck6r7A= X-Received: by 2002:a05:6a21:3381:b0:1aa:6ddb:4adf with SMTP id yy1-20020a056a21338100b001aa6ddb4adfmr1271607pzb.39.1713391214298; Wed, 17 Apr 2024 15:00:14 -0700 (PDT) Received: from ghost ([50.145.13.30]) by smtp.gmail.com with ESMTPSA id j18-20020a62e912000000b006e681769ee0sm151780pfh.145.2024.04.17.15.00.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Apr 2024 15:00:13 -0700 (PDT) Date: Wed, 17 Apr 2024 15:00:07 -0700 From: Charlie Jenkins To: Conor Dooley Cc: Rob Herring , Krzysztof Kozlowski , Paul Walmsley , Palmer Dabbelt , Albert Ou , Guo Ren , Conor Dooley , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Conor Dooley , Evan Green , =?iso-8859-1?Q?Cl=E9ment_L=E9ger?= , Jonathan Corbet , Shuah Khan , linux-riscv@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Palmer Dabbelt , linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: Re: [PATCH v2 13/17] riscv: vector: Support xtheadvector save/restore Message-ID: References: <20240415-dev-charlie-support_thead_vector_6_9-v2-0-c7d68c603268@rivosinc.com> <20240415-dev-charlie-support_thead_vector_6_9-v2-13-c7d68c603268@rivosinc.com> <20240417-semisweet-willed-1ce1098d8c41@spud> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240417-semisweet-willed-1ce1098d8c41@spud> On Wed, Apr 17, 2024 at 03:50:24PM +0100, Conor Dooley wrote: > On Mon, Apr 15, 2024 at 09:12:10PM -0700, Charlie Jenkins wrote: > > > diff --git a/arch/riscv/kernel/vector.c b/arch/riscv/kernel/vector.c > > index 6727d1d3b8f2..f42eaa8178e9 100644 > > --- a/arch/riscv/kernel/vector.c > > +++ b/arch/riscv/kernel/vector.c > > @@ -33,10 +33,24 @@ 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(); > > + /* > > + * This is called before alternatives have been patched so can't use > > + * riscv_has_vendor_extension_unlikely > > () after that function name please. > > > + */ > > + if (has_xtheadvector_no_alternatives()) { > > + /* > > + * Although xtheadvector states that th.vlenb exists and > > + * overlaps with the vector 1.0 vlenb, an illegal instruction is > > + * raised if read. These systems all currently have a fixed > > + * vector length of 128, so hardcode that value. > > I had this written before the meeting, so pasting it anyway: > -- >8 -- > From 5ed25d0f841e755b8dd4f1f6a3ea824601758d8e Mon Sep 17 00:00:00 2001 > From: Conor Dooley > Date: Wed, 17 Apr 2024 14:39:36 +0100 > Subject: [PATCH] dt-bindings: riscv: cpus: add a vlen register length property > > Add a property analogous to the vlenb CSR so that software can detect > the vector length of each CPU prior to it being brought online. > Currently software has to assume that the vector length read from the > boot CPU applies to all possible CPUs. On T-Head CPUs implementing > pre-ratification vector, reading the th.vlenb CSR may produce an illegal > instruction trap, so this property is required on such systems. > > Signed-off-by: Conor Dooley > --- > We could actually enforce the latter since we know the compatibles of > the relevant CPUs and can tell if xtheadvector is present. > --- > Documentation/devicetree/bindings/riscv/cpus.yaml | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/Documentation/devicetree/bindings/riscv/cpus.yaml b/Documentation/devicetree/bindings/riscv/cpus.yaml > index d067f2a468ee..2a6449a0f1d7 100644 > --- a/Documentation/devicetree/bindings/riscv/cpus.yaml > +++ b/Documentation/devicetree/bindings/riscv/cpus.yaml > @@ -95,6 +95,12 @@ properties: > description: > The blocksize in bytes for the Zicboz cache operations. > > + riscv,vlenb: > + $ref: /schemas/types.yaml#/definitions/uint32 > + description: > + VLEN/8, the vector register length in bytes. This property is required in > + systems where the vector register length is not identical on all harts. > + > # RISC-V has multiple properties for cache op block sizes as the sizes > # differ between individual CBO extensions > cache-op-block-size: false > -- > 2.43.0 > > > > > + */ > > + this_vsize = 128; > > + } else { > > + /* There are 32 vector registers with vlenb length. */ > > + riscv_v_enable(); > > + this_vsize = csr_read(CSR_VLENB) * 32; > > + riscv_v_disable(); > > + } Thank you for this, I can add this patch to my v3. - Charlie