Received: by 2002:ab2:715a:0:b0:1fd:c064:50c with SMTP id l26csp6410lqm; Mon, 10 Jun 2024 10:52:21 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVBPaGdimLLeSN1aQwhFvBbKClz+nUm0jDxD1lQrTodbZcnCv3k3fEc9UmN/39Rc+yTSw8lAueJ+raBTC2O7nHJ/+HmYvK6Hicm/kp8pQ== X-Google-Smtp-Source: AGHT+IHDiyrYOYLYxLpGkymnAi2kTv8FbmT9MQzJ9JS1WqH6Y1yilA65pXS60ukh8A9zyuweEY71 X-Received: by 2002:a50:d69c:0:b0:57c:5f7e:d0f1 with SMTP id 4fb4d7f45d1cf-57c5f7ed498mr6206960a12.38.1718041941372; Mon, 10 Jun 2024 10:52:21 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718041941; cv=pass; d=google.com; s=arc-20160816; b=oVVBcnuTQI1orgfb2xpSAt3aHYL9cnSdwtKkPpkQKOeZw26eJ1B2klVcuVwylAeQyp LhduHYA5qA1LGirJW92MVqivXTS0d5q6q6nGl1OEc/kZnVqqfHyMbpuZ/f5ttynndEg6 OhDrncFtDE8q1WgwZ9qmjRsV79zAerWn1mpIUITeOsYkNQGvCtncv22VA7EKYjdH0z0V FMtwynwZ2RNCQbtpg4lfCXCha1j2Td7Ao3WexwgcMxZTQyf39W9HBv7kShC2PISluj47 1u+VAKs4DpDMBGGxbsLdTfWBqOKfNPWeqJCnXNb+gzoIoyxFVPeoJ6NenrV+DHl3ib3c xS6g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:dkim-signature; bh=FWkRgN4oixQz2NDH8nagYU0C/GTWILi37MSJzJ0VQmc=; fh=zkFnOuk2yIo0SDJqdIUZ0d5Vv50jx9BL5Pn37gjKbSw=; b=bGofuMW/p8i/aZnMdDusmu65qgaISJa0hje0MYBsBDy2rFY27eQzUvREXNiAG2Q2HF HYANN54mZd5l6HOlj7u0vXy9VNoH8HU6qvMeABJ5r1bRTDH/XvmArUcWm0KcdLFsq7nC qJOjklPE1hiP5kKxCMGH9HZP5XKL7T45txBowzrSt6QT3Ydi31AhxPPOZXe6VcQb6LA8 GCw5ipWWl+CsqEPtTeQzlbWdaw9l2So2M9iFbns46VUHTT2MlDSK9IFyWEdUYkmeOKhL ggiPY9wEdrNiDAaoovwG9IJY+kuPMTZSRqMBeW4m2eV96LB8SecnPpo31AbcKwMOT2nn WiaQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@jrtc27.com header.s=gmail.jrtc27.user header.b=Xkfjvm60; arc=pass (i=1 spf=pass spfdomain=jrtc27.com dkim=pass dkdomain=jrtc27.com); spf=pass (google.com: domain of linux-kernel+bounces-208680-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-208680-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 4fb4d7f45d1cf-57c6fabe26fsi2669813a12.318.2024.06.10.10.52.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jun 2024 10:52:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-208680-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=@jrtc27.com header.s=gmail.jrtc27.user header.b=Xkfjvm60; arc=pass (i=1 spf=pass spfdomain=jrtc27.com dkim=pass dkdomain=jrtc27.com); spf=pass (google.com: domain of linux-kernel+bounces-208680-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-208680-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 171A11F235E4 for ; Mon, 10 Jun 2024 17:52:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2350314A4E2; Mon, 10 Jun 2024 17:52:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=jrtc27.com header.i=@jrtc27.com header.b="Xkfjvm60" Received: from mail-lf1-f54.google.com (mail-lf1-f54.google.com [209.85.167.54]) (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 7A8D3147C86 for ; Mon, 10 Jun 2024 17:52:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718041931; cv=none; b=Ih+vR4o+NDsBvCxxP9OVCED8aYd1ICqqcWmxDSEeEkyAlh5963NCFRJWHRKoFX/Q9pd04w0CBgLLSxU4VKsamwaCtIFs49zewf5M4iCF4Agb2zbs3tm2CTzYTDXN8BU7Rlv1K972iAogexoJpu44o6W3itHxcAFKAsrF87/pPKU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718041931; c=relaxed/simple; bh=v44YU+l8fDTIyQ/px7h3zXXND4kIzPFteQ4qkB7IQ/0=; h=Content-Type:Mime-Version:Subject:From:In-Reply-To:Date:Cc: Message-Id:References:To; b=gkX1hva3joHaVJwgEX1dkNMfOxI3HwLkubjw00KpcnIUJXjUMbKwX7QGeyxEmcGQMskdW26F70SLRMqbvTDjEX15n4JCwBzKPCvbaL9zEH8kRlqrET7ut0PctmRd18f1Gsiuxz5lAmFwbNtPmxchSwakR2Qk/sAs9/DeTkpOZjI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=jrtc27.com; spf=pass smtp.mailfrom=jrtc27.com; dkim=pass (2048-bit key) header.d=jrtc27.com header.i=@jrtc27.com header.b=Xkfjvm60; arc=none smtp.client-ip=209.85.167.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=jrtc27.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=jrtc27.com Received: by mail-lf1-f54.google.com with SMTP id 2adb3069b0e04-52c6f381434so334915e87.2 for ; Mon, 10 Jun 2024 10:52:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jrtc27.com; s=gmail.jrtc27.user; t=1718041928; x=1718646728; darn=vger.kernel.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=FWkRgN4oixQz2NDH8nagYU0C/GTWILi37MSJzJ0VQmc=; b=Xkfjvm60rSiK5MZ6kKgSBTLIF3o1sgDk9J0ffR3u0kpgAQqAjxxTebLcryI2mi70Em LMsY9/q7l0vERkJrql17vk4jA/Rqyw+YaMJyCo+8psQHrYYX4xeA2O009bUpATJFkjRv H+nVIUyl4hsVPg+TjxlXewpiPI8XIUxZ8ddR0f7qzdaHKbOXjyblh2rsNCoSyzHssT9X QYnNc6MSi2HAsR3HPmL5iD7Uhrw+6CNEXnHLiC0CTtXM/ROxQ+CxN73PDUyDfjiv0mhu VsbXst/qCNQMxzylu7qiBbTyPn7j2Gps0eVnZiqag+Cp3tHP+VxMShjBzn61qvX5BVjH hdhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718041928; x=1718646728; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FWkRgN4oixQz2NDH8nagYU0C/GTWILi37MSJzJ0VQmc=; b=n6hSF6t1F4B5DYsZOFCiKko91kGRrq7lXW+/PhKgktMc4G0QBjSOwdOWVQJcF+V/mX dcZvKEtOIQTuRJbjGiJ+rNEcExppCpOAYb/8cOqdd92JWdDShrU3TwtdDQyKRlJQpUxB kLH9h8aCbMOhyvoM3a9Fu8E+Y7W2FA3+Ni9k+AxlfTNHj6UYqG4rUGIqmFKMuPFOnWqw NfsXsZNbmrRBAAed43rScZGYew3N/pVWWSilJocUdf0dgLpohxQqqahtHEZCR2STUQ7Y IbcETOEfJu54vGmSpFRNuyH3D/0xtLV0687T13IcHYbQLqVtCJ+MwN3d4ioYX7kQnCA0 7HcA== X-Forwarded-Encrypted: i=1; AJvYcCW9eCK8yrWTUS54l5chUjm4j0TKurSty64d4PwAzs10vkSj85gJfYRMspdaTgBq2qrLAsKViSOnqKgiqE08/CrtUjCHqMf3lsOipRXP X-Gm-Message-State: AOJu0YyaigMRk9dV9SPCFLPxXn6TiT2CZu1C8ruZuSbmiZ+huu+k1AEF QbKQsYdxYoRnvKbCh5qIawe/ttcZ7rh3xL6TBy7qkPuVi1IBUEty64j1ahlQXS4= X-Received: by 2002:a05:6512:3baa:b0:52c:8ea3:1aea with SMTP id 2adb3069b0e04-52c8ea31d06mr2106714e87.34.1718041927588; Mon, 10 Jun 2024 10:52:07 -0700 (PDT) Received: from smtpclient.apple ([131.111.5.201]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-35f2598ac1esm2762915f8f.93.2024.06.10.10.52.06 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 10 Jun 2024 10:52:07 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3774.500.171.1.1\)) Subject: Re: [PATCH 05/13] riscv: vector: Use vlenb from DT for thead From: Jessica Clarke In-Reply-To: <20240609-xtheadvector-v1-5-3fe591d7f109@rivosinc.com> Date: Mon, 10 Jun 2024 18:51:56 +0100 Cc: Conor Dooley , Rob Herring , Krzysztof Kozlowski , Paul Walmsley , Palmer Dabbelt , Albert Ou , Jisheng Zhang , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Jonathan Corbet , Shuah Khan , Guo Ren , Evan Green , Andy Chiu , linux-riscv , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , LKML , linux-sunxi@lists.linux.dev, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org Content-Transfer-Encoding: quoted-printable Message-Id: <0944414F-321F-4159-AB85-C4B66AE9550B@jrtc27.com> References: <20240609-xtheadvector-v1-0-3fe591d7f109@rivosinc.com> <20240609-xtheadvector-v1-5-3fe591d7f109@rivosinc.com> To: Charlie Jenkins X-Mailer: Apple Mail (2.3774.500.171.1.1) On 10 Jun 2024, at 05:45, Charlie Jenkins wrote: >=20 > If thead,vlenb is provided in the device tree, prefer that over = reading > the vlenb csr. >=20 > Signed-off-by: Charlie Jenkins > --- > arch/riscv/include/asm/cpufeature.h | 2 ++ > arch/riscv/kernel/cpufeature.c | 48 = +++++++++++++++++++++++++++++++++++++ > arch/riscv/kernel/vector.c | 12 +++++++++- > 3 files changed, 61 insertions(+), 1 deletion(-) >=20 > diff --git a/arch/riscv/include/asm/cpufeature.h = b/arch/riscv/include/asm/cpufeature.h > index b029ca72cebc..e0a3164c7a06 100644 > --- a/arch/riscv/include/asm/cpufeature.h > +++ b/arch/riscv/include/asm/cpufeature.h > @@ -31,6 +31,8 @@ DECLARE_PER_CPU(struct riscv_cpuinfo, = riscv_cpuinfo); > /* Per-cpu ISA extensions. */ > extern struct riscv_isainfo hart_isa[NR_CPUS]; >=20 > +extern u32 thead_vlenb_of; > + > void riscv_user_isa_enable(void); >=20 > #define _RISCV_ISA_EXT_DATA(_name, _id, _subset_exts, = _subset_exts_size) { \ > diff --git a/arch/riscv/kernel/cpufeature.c = b/arch/riscv/kernel/cpufeature.c > index 2107c59575dd..0c01f33f2348 100644 > --- a/arch/riscv/kernel/cpufeature.c > +++ b/arch/riscv/kernel/cpufeature.c > @@ -37,6 +37,8 @@ static DECLARE_BITMAP(riscv_isa, RISCV_ISA_EXT_MAX) = __read_mostly; > /* Per-cpu ISA extensions. */ > struct riscv_isainfo hart_isa[NR_CPUS]; >=20 > +u32 thead_vlenb_of; > + > /** > * riscv_isa_extension_base() - Get base extension word > * > @@ -625,6 +627,46 @@ static void __init riscv_fill_vendor_ext_list(int = cpu) > } > } >=20 > +static int has_thead_homogeneous_vlenb(void) > +{ > + int cpu; > + u32 prev_vlenb =3D 0; > + u32 vlenb; > + > + /* Ignore vlenb if vector is not enabled in the kernel */ > + if (!IS_ENABLED(CONFIG_RISCV_ISA_V)) It=E2=80=99s not V though. You probably want to split out =E2=80=9Cvector=E2= =80=9D from =E2=80=9CV=E2=80=9D in Kconfig land. Most places want the former, I assume, but some want the latter. Jess > + return 0; > + > + for_each_possible_cpu(cpu) { > + struct device_node *cpu_node; > + > + cpu_node =3D of_cpu_device_node_get(cpu); > + if (!cpu_node) { > + pr_warn("Unable to find cpu node\n"); > + return -ENOENT; > + } > + > + if (of_property_read_u32(cpu_node, "thead,vlenb", &vlenb)) { > + of_node_put(cpu_node); > + > + if (prev_vlenb) > + return -ENOENT; > + continue; > + } > + > + if (prev_vlenb && vlenb !=3D prev_vlenb) { > + of_node_put(cpu_node); > + return -ENOENT; > + } > + > + prev_vlenb =3D vlenb; > + of_node_put(cpu_node); > + } > + > + thead_vlenb_of =3D vlenb; > + return 0; > +} > + > static int __init riscv_fill_hwcap_from_ext_list(unsigned long = *isa2hwcap) > { > unsigned int cpu; > @@ -689,6 +731,12 @@ static int __init = riscv_fill_hwcap_from_ext_list(unsigned long *isa2hwcap) > riscv_fill_vendor_ext_list(cpu); > } >=20 > + if (riscv_isa_vendor_extension_available(THEAD_VENDOR_ID, = XTHEADVECTOR) && > + has_thead_homogeneous_vlenb() < 0) { > + pr_warn("Unsupported heterogeneous vlenb detected, vector extension = disabled.\n"); > + elf_hwcap &=3D ~COMPAT_HWCAP_ISA_V; > + } > + > if (bitmap_empty(riscv_isa, RISCV_ISA_EXT_MAX)) > return -ENOENT; >=20 > diff --git a/arch/riscv/kernel/vector.c b/arch/riscv/kernel/vector.c > index 6727d1d3b8f2..3ba2f2432483 100644 > --- a/arch/riscv/kernel/vector.c > +++ b/arch/riscv/kernel/vector.c > @@ -33,7 +33,17 @@ int riscv_v_setup_vsize(void) > { > unsigned long this_vsize; >=20 > - /* There are 32 vector registers with vlenb length. */ > + /* > + * There are 32 vector registers with vlenb length. > + * > + * If the thead,vlenb property was provided by the firmware, use that > + * instead of probing the CSRs. > + */ > + if (thead_vlenb_of) { > + this_vsize =3D thead_vlenb_of * 32; > + return 0; > + } > + > riscv_v_enable(); > this_vsize =3D csr_read(CSR_VLENB) * 32; > riscv_v_disable(); >=20 > --=20 > 2.44.0 >=20 >=20 > _______________________________________________ > linux-riscv mailing list > linux-riscv@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-riscv