From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 73DDBC4345F for ; Wed, 17 Apr 2024 22:00:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=WmhAo5Q7hHzeI7lAzLSRoACTKxsw+GNxdDqIHV+F1Qo=; b=YJpz0Kpeei4bAJ 1s9CWraLjYhBR9+C5bw25jPuu/MmWpF71cxyjxnC4i0crXu+coxLSnCEhA5VkUPszTZMl2J/qaDiH ZOeDu1oI0cs2HNW30y+L71x0xnKXO85VSNIlriLy6mzp/NdsYGL96TL1Hrdi5xJ16KhG2tXSM1wN+ eu1Z5iLfeuM31fGBHQSsUIpma7270AUeGgaypbARvFAGvj8sGlZxQZI2IkZxerjmyvYd/Hc6zelzz RmJWX3TiWKPqAztdrEWZPrAmjZRSBrRXRUkSG439kjT1O0wRHswiCknQ+NqQOByaRdDjp4CSkdOYM Qw+BRgIraY/r93q39Pmg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rxDKJ-000000009Ib-0rse; Wed, 17 Apr 2024 22:00:23 +0000 Received: from mail-pf1-x430.google.com ([2607:f8b0:4864:20::430]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rxDKF-000000009Gc-49ze for linux-arm-kernel@lists.infradead.org; Wed, 17 Apr 2024 22:00:21 +0000 Received: by mail-pf1-x430.google.com with SMTP id d2e1a72fcca58-6ed267f2936so238234b3a.3 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=lists.infradead.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=FTnB/i734lCk/9Fhus4BECsFwziFT3FBsLaiT7hZpaN8wbsxk2By4FROGJNvSs+uhE eMAQd7IcR5MhnyoXevutAu0JEfsfMVaiUUWGQz2hu4lQT9+Hqv1VN++NjlXGUYQwVopl iSJQEE01ia1jZ9EQ6GJj7TQM56BpREzu2UgAQuzGJc4msgZK6CRAmHpzdrbUwl4p0ojU oPECYGMsj5XrvpiKUcUKb2FrSe3ETGUyWI5COsTvvNHN5ELXjRIOVJ9RLzw0r4LMxboz dIDGzvvarc3r9raoPs4rqIW69wSNAcPO/4T71D8tVmLLv3rNjNTx5Xo79Y44XPuZp+t/ /R8w== 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=us7ymIcQRdCBLU7meMylJTlcBK3CmdtfVcoZsehiElK1gWSGxlJVfd2Qa3MsPzckAd 50KYMj/mn/7rcmMZi7QGAw8dpnLxaknd8Cd/RvElknACTswhsbOt32nWn/h1pv4IZtU4 hrgJWNPKbMrvGwxXoV3Ze/WlKhuRCke5pwrYUVLSWOMxlId1em/5tMSH0Z/ZdJeJb4Fn PSrWjqT1xzftwfOmaI7I/ooZVqK/2KepxId5jPqDnqQ2Y4UwSmqeEOAeME8dJWbFAZ2l wmP3q8DfeWUAqayq/JWwTYaa1CM2WfsS3FDfyP/PVWdKnkonXh5j89JhDfXPkxSJdnVp tR8Q== X-Forwarded-Encrypted: i=1; AJvYcCX0HEBbPh7zq4KB8yZq9ecHmYb6i6u4TDxk2TFyE8uccn7NIfChOuK1tSpm53Fsxjt4qpdwfwY5e8m/4yI27xJdOAG7Dxe4aTHqNsvO5aznTIAPxaI= X-Gm-Message-State: AOJu0Yw5QMxHE46UkRb2JMRPhTJcvpB/n1t6j3ej50LLLYWlY0W6Umwv eo4WK4jh5NZxWxSkcOwegXm5xjQD1VHHpdpAfr09Cy/ai/CC2xvew2iWWEnHkUM= X-Google-Smtp-Source: AGHT+IEiDU5SQjuL7+0vdKdkoS1KFGY8onYhPVJwXQzy7eXZ9mhuURRy3tq7dfxgiflxBiFa6A84tg== 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> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20240417-semisweet-willed-1ce1098d8c41@spud> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240417_150020_203905_F1DCB807 X-CRM114-Status: GOOD ( 35.09 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel