From patchwork Fri Apr 12 04:11:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charlie Jenkins X-Patchwork-Id: 13626803 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 CB03DC4345F for ; Fri, 12 Apr 2024 04:15:53 +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:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=XuoPb5NRdiSDndevJQrU6UseGRAxnMCBU6z/1UAt6tw=; b=xpHh4y9rWPugvS VISSSlG+3Cl0nheLm76cDXl0ZkoCQmTR/wRpk+AllD59TLL+zG674PuVHYyUOVh8sj42wtqMZ5bFT EZeaujZ7sExfT272O6ypD0qIQ7uOwUab3AOnRWcV9gVsKOjuVkgazklItqM4RXYybNbpluhYJr9xF fZPw5+pha8Bsnx4K24/2aDV3YMGhXyRM21tjYHKCxfFX141UawIawpFV5kVnRlVyLKYaDKHxFyOFt 07lnkPVx0bXW7Ai1lwG6mkzUIJvWecShJVi6Q5wkfKTOm2N2l2OG9Fx7oDmIiyHp0n6vx8YdnhCvv zk3PCssoxMQzZ610ehwQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rv8KD-0000000FDQd-33yl; Fri, 12 Apr 2024 04:15:41 +0000 Received: from mail-pf1-x434.google.com ([2607:f8b0:4864:20::434]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rv8Ge-0000000FAUA-2z2Z for linux-arm-kernel@lists.infradead.org; Fri, 12 Apr 2024 04:12:07 +0000 Received: by mail-pf1-x434.google.com with SMTP id d2e1a72fcca58-6ecf05fd12fso526660b3a.2 for ; Thu, 11 Apr 2024 21:12:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1712895120; x=1713499920; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=plhzSwBN2tg2hM/OGJHCzSMFajymGFMMB5gXR65w0nY=; b=GUYfJ7r8V6VvJg/BNAb+WxG/YG0tYRG9C7h9GISzdwx/3zVxxUhCPkB/lGdmb+ghbs p61K5ZFn+14gu0gbCiCjGMmE6Kqe0c74H9u35YsYKkVcVNCFdE6TsjgdPRVlBqqCjkSq Mc6/uqnBYAYd319r8OQPhvxBfzN6xUJOqHbgmUE64PRAaba5i6tG5JJK9fjQSqzZ+0HV B1oiJljeaw613ItaGFFDcundazl16QNWlXNKzH25z9CacYW/+offRvE7cpN2COWt3fpW c5YrprWGOEWzkqv0XydBj/loZvrriaeIc8nLhDqQCY52GrlR/w8fBM4VwNeRgVJMTDs2 P3hQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712895120; x=1713499920; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=plhzSwBN2tg2hM/OGJHCzSMFajymGFMMB5gXR65w0nY=; b=pJBaQcjSTTxCkvgrDA3IuyqsgDhkyhPjS6XnFBIwiEfI5uxbgx/sKSYlh3f42tCA9P JqqA/ZbBscIuZeD8rXlDuE5d+EwVTLgVk4OIBEPgQJomPsIkJWSf/8nuzUiNITkp86cl RxHqC2C3Rfjmp5ZV+5gUTy0jFyG+oMRdQxpqlgP0Okf/9vZ0Qcdlboz/8HQ9EM650RZl lpaGVNblEf8CNx+DWsi7Y2QiulA+WifvmEhc3KThtpcE0dtmCbi0XbvCUBy6nhPneY8R 8ha1tHDTW6IrQPzM8HHoRyUzI+c9FB6MBQa+MYiVXdtPbsc+kbkyFIefpRUvvL3SKBZ6 YcEQ== X-Forwarded-Encrypted: i=1; AJvYcCVGJfotu/NlWiM7NDKXOXBrlMONK7+fFajhpmvFhZa9yB9piWVCR9nNLaPlqUMwO0tQ+UQ4TxB72IOVteFKbgqV9S/CyDnllBLWPvK22mE9SUTDxmM= X-Gm-Message-State: AOJu0YxcwjvFBAww/hZO2+Pq/QqDevtp0yaQKO2WW9VSwgXSqmkWLbw8 a4GCR92rCLEHpkPg80ZlMah842GLF/2J+GGKdPn5JZn1zvzY2+ssRtlCCZ6WRWY= X-Google-Smtp-Source: AGHT+IGB7qEzfffwtlvMeSArFRe5b2IbJWtk76uBcLMkAO0+GhaFRMgJf/WL0fMJial1eSC+YOsckw== X-Received: by 2002:a05:6a00:4b56:b0:6ea:7647:282d with SMTP id kr22-20020a056a004b5600b006ea7647282dmr1404792pfb.29.1712895119945; Thu, 11 Apr 2024 21:11:59 -0700 (PDT) Received: from charlie.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id ka13-20020a056a00938d00b006e57247f4e5sm1949712pfb.8.2024.04.11.21.11.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Apr 2024 21:11:59 -0700 (PDT) From: Charlie Jenkins Date: Thu, 11 Apr 2024 21:11:21 -0700 Subject: [PATCH 15/19] riscv: hwcap: Add v to hwcap if xtheadvector enabled MIME-Version: 1.0 Message-Id: <20240411-dev-charlie-support_thead_vector_6_9-v1-15-4af9815ec746@rivosinc.com> References: <20240411-dev-charlie-support_thead_vector_6_9-v1-0-4af9815ec746@rivosinc.com> In-Reply-To: <20240411-dev-charlie-support_thead_vector_6_9-v1-0-4af9815ec746@rivosinc.com> To: Conor Dooley , 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 , =?utf-8?b?Q2zDqW1lbnQgTMOpZ2Vy?= , Jonathan Corbet , Shuah Khan Cc: 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, Charlie Jenkins X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1712895091; l=2034; i=charlie@rivosinc.com; s=20231120; h=from:subject:message-id; bh=lbXM7gEz8TjX6THMhyqDltfPVCT1kYIv/wwg0eIvR1o=; b=gL8I89W2iPbnp9JhxSnVt0+YsdfyK3XR6HPgX62u6VidPvO2DFakfFikn+qtu3GgFR+cwPIl7 u5WOsb8FluDDKKVd3JMS+Bqr6mmxoegGLXkHjjZWJ1mhV6fSumSV/y8 X-Developer-Key: i=charlie@rivosinc.com; a=ed25519; pk=t4RSWpMV1q5lf/NWIeR9z58bcje60/dbtxxmoSfBEcs= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240411_211201_048546_BC16EDD4 X-CRM114-Status: GOOD ( 13.67 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org xtheadvector is not vector 1.0 compatible, but it can leverage all of the same save/restore routines as vector plus riscv_v_first_use_handler(). vector 1.0 and xtheadvector are mutually exclusive so there is no risk of overlap. Signed-off-by: Charlie Jenkins --- arch/riscv/kernel/cpufeature.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/arch/riscv/kernel/cpufeature.c b/arch/riscv/kernel/cpufeature.c index 41a4d2028428..59f628b1341c 100644 --- a/arch/riscv/kernel/cpufeature.c +++ b/arch/riscv/kernel/cpufeature.c @@ -647,9 +647,13 @@ static void __init riscv_fill_hwcap_from_isa_string(unsigned long *isa2hwcap) * Many vendors with T-Head CPU cores which implement the 0.7.1 * version of the vector specification put "v" into their DTs. * CPU cores with the ratified spec will contain non-zero - * marchid. + * marchid. Only allow "v" to be set if xtheadvector is present. */ - if (acpi_disabled && this_vendorid == THEAD_VENDOR_ID && + if (__riscv_isa_vendor_extension_available(isavendorinfo->isa, + RISCV_ISA_VENDOR_EXT_XTHEADVECTOR)) { + this_hwcap |= isa2hwcap[RISCV_ISA_EXT_v]; + set_bit(RISCV_ISA_EXT_v, isainfo->isa); + } else if (acpi_disabled && this_vendorid == THEAD_VENDOR_ID && this_archid == 0x0) { this_hwcap &= ~isa2hwcap[RISCV_ISA_EXT_v]; clear_bit(RISCV_ISA_EXT_v, isainfo->isa); @@ -776,6 +780,15 @@ static int __init riscv_fill_hwcap_from_ext_list(unsigned long *isa2hwcap) of_node_put(cpu_node); + /* + * Enable kernel vector routines if xtheadvector is present + */ + if (__riscv_isa_vendor_extension_available(isavendorinfo->isa, + RISCV_ISA_VENDOR_EXT_XTHEADVECTOR)) { + this_hwcap |= isa2hwcap[RISCV_ISA_EXT_v]; + set_bit(RISCV_ISA_EXT_v, isainfo->isa); + } + /* * All "okay" harts should have same isa. Set HWCAP based on * common capabilities of every "okay" hart, in case they don't.