Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp6493881pxb; Tue, 15 Feb 2022 03:47:49 -0800 (PST) X-Google-Smtp-Source: ABdhPJyvEdrPWm6QBhUk3LjFD2oJzbejRO5tCe1N0ZpvclQI3ElpN8fIQZCPYj1IA8Ps2XmQdIeJ X-Received: by 2002:a05:6402:3552:: with SMTP id f18mr3441119edd.189.1644925669522; Tue, 15 Feb 2022 03:47:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644925669; cv=none; d=google.com; s=arc-20160816; b=hs7Xp1PSjzZcRoiNcbCSAHMeOt7aEJ6kWCgzsCAQeDFv0fa659oqHckA6jrj4UYWa9 yfj1h5zTX+xauIiUclMQgm9Is22sN6/xEguJJj5askxZ31hpndfBSIW//QJf3F+lsXTx nv98/2SZGw+5j/rVq4U2atjVrQJJPsnu5acDrpBtX9qWEmI8rve5C5MlULMz6wbLr7he 2Ilbo5d8HjsEfPHMkuWW1/Lpc1JTEsBvnAsgZPWjjAeyc5MbUkAWp7Xgr64RMYWezjxl UOv42xT8+n2cCZk89vnXWJtck57I4wx6a4nVGbCigduH9vaRZM+79YzdHBjJV/UlmUid vLfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=oSCtsd3fzrUKJIHAZet+tjs87CCWa1yDtr7CzSuhxDE=; b=vZKmeaDae1PEA3/xEBUWjZrO9uHG37PcR/BLpm2WlysVNV3My7htng7braJFkI589M h/iyjRakwF9SYOF4ia2NIMT4LfoKFJWGDvjVKuysPJkUe6lZbjp5QNWMY+vpUWQuH6n7 C3/CRmXNLSexwbQUd/pFTQERxQx4Ire9nQH7n6idAXvd0GteE+dkhNL6/ICAMWemg/tD VqyLdhGpS29aQV9F0pT1smSP7n21N+ynErmkYp986QIT7ZMzHVOU/mfRl0iMXJNELmLb YqX7MwHwMspiDd5P/g70R7hhejsNnoeL+QPcoSbhCRA5FyoEglaZ3KLqoA2hSjmTKZQq crSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@brainfault-org.20210112.gappssmtp.com header.s=20210112 header.b=4P9S1itg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m4si6114298eja.182.2022.02.15.03.47.26; Tue, 15 Feb 2022 03:47:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@brainfault-org.20210112.gappssmtp.com header.s=20210112 header.b=4P9S1itg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236376AbiBOKO1 (ORCPT + 99 others); Tue, 15 Feb 2022 05:14:27 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:47046 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234049AbiBOKOX (ORCPT ); Tue, 15 Feb 2022 05:14:23 -0500 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6690C10DA66 for ; Tue, 15 Feb 2022 02:14:14 -0800 (PST) Received: by mail-wm1-x32e.google.com with SMTP id x3-20020a05600c21c300b0037c01ad715bso1074223wmj.2 for ; Tue, 15 Feb 2022 02:14:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brainfault-org.20210112.gappssmtp.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=oSCtsd3fzrUKJIHAZet+tjs87CCWa1yDtr7CzSuhxDE=; b=4P9S1itgLjR+WLtU0yKgH6geqBsZAQDIyLWXmwIAemApD0tzz70VbQnpUarv4j9Skc Dd9sRJdtdSAWdwvA71LxPJxQR0ld/p4WNxBuHz4G6jmUYcNlmvH6jwGje4S198KK3zRB sru5PO7Itxq4Auwd+uKtL6prn5yneWmZPzRmAMR9cJIlUYOCF91rZ98QvsLjEYt8qFpJ jsOjg7urvQVsmjYMM/r0zGx+9xLexJoxSx30wzY/y9sNbL8SbMZVFZ+AizWCQ6VKKibE SuPFd9Od2yUmIlBUyeVKrggPDxCvz1rbI4F1dvZPCK2XUqLYRInf+I1K8hJwbgPf5+6a bPBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=oSCtsd3fzrUKJIHAZet+tjs87CCWa1yDtr7CzSuhxDE=; b=f0NpJvzRLr9iZYccmKQEpLhhiQ5VF2MkNREKD07FoIkXWs9lZuoBM8vKIKbte8BydV mKWJPzJb+08sbunpknAZIJEaIglJtio5xQzXvXTcWMlzyqBMFtLF+MHsyEYQ4vbi/kJw DVgqlZXhM/wotoawckW4Y4qDSUfO5v/F7yhSN4X2sxs7z8mM0bFp4p5AIVAOt03jbjQz NO5RdtOSjVTJNBqKQUHKvlFq/GQ97GpMbPoCbc/rY5bT1s99Fc7AysevCvZMkX5/EMlT jBMItmircLjKs7YM5rKinhgxCo9jTSRoGsJmsqnzP1TiNnKP/a3M1yk/jswZBA70TqhK X8Kg== X-Gm-Message-State: AOAM532Cl3QgwZKo6Xzi6Sp33mzovl5E1tP9zJBZrXkKeYL9ZUH/7eDx r7V7bhl9e5SPcoMrGOTAl7U8AZQJ/pJSNfAWRsr2wQ== X-Received: by 2002:a1c:750f:: with SMTP id o15mr2399030wmc.137.1644920052860; Tue, 15 Feb 2022 02:14:12 -0800 (PST) MIME-Version: 1.0 References: <20220215090211.911366-1-atishp@rivosinc.com> <20220215090211.911366-4-atishp@rivosinc.com> In-Reply-To: <20220215090211.911366-4-atishp@rivosinc.com> From: Anup Patel Date: Tue, 15 Feb 2022 15:44:00 +0530 Message-ID: Subject: Re: [PATCH v3 3/6] RISC-V: Extract multi-letter extension names from "riscv, isa" To: Atish Patra Cc: "linux-kernel@vger.kernel.org List" , Tsukasa OI , Heiko Stuebner , Albert Ou , Atish Patra , Damien Le Moal , DTML , Jisheng Zhang , Krzysztof Kozlowski , linux-riscv , Palmer Dabbelt , Paul Walmsley , Rob Herring Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Feb 15, 2022 at 2:32 PM Atish Patra wrote: > > From: Tsukasa OI > > Currently, there is no usage for version numbers in extensions as > any ratified non base ISA extension will always at v1.0. > > Extract the extension names in place for future parsing. > > Signed-off-by: Tsukasa OI > [Improved commit text and comments] > Signed-off-by: Atish Patra > Tested-by: Heiko Stuebner > --- > arch/riscv/kernel/cpufeature.c | 38 ++++++++++++++++++++++++++-------- > 1 file changed, 29 insertions(+), 9 deletions(-) > > diff --git a/arch/riscv/kernel/cpufeature.c b/arch/riscv/kernel/cpufeature.c > index 9d5448542226..cd9eb34f8d11 100644 > --- a/arch/riscv/kernel/cpufeature.c > +++ b/arch/riscv/kernel/cpufeature.c > @@ -119,9 +119,28 @@ void __init riscv_fill_hwcap(void) > ext_long = true; > /* Multi-letter extension must be delimited */ > for (; *isa && *isa != '_'; ++isa) > - if (!islower(*isa) && !isdigit(*isa)) > + if (unlikely(!islower(*isa) > + && !isdigit(*isa))) > ext_err = true; > - /* ... but must be ignored. */ > + /* Parse backwards */ > + ext_end = isa; > + if (unlikely(ext_err)) > + break; > + if (!isdigit(ext_end[-1])) > + break; > + /* Skip the minor version */ > + while (isdigit(*--ext_end)) > + ; > + if (ext_end[0] != 'p' > + || !isdigit(ext_end[-1])) { > + /* Advance it to offset the pre-decrement */ > + ++ext_end; > + break; > + } > + /* Skip the major version */ > + while (isdigit(*--ext_end)) > + ; > + ++ext_end; > break; > default: > if (unlikely(!islower(*ext))) { > @@ -131,6 +150,7 @@ void __init riscv_fill_hwcap(void) > /* Find next extension */ > if (!isdigit(*isa)) > break; > + /* Skip the minor version */ This comment should be moved to PATCH2 > while (isdigit(*++isa)) > ; > if (*isa != 'p') > @@ -139,20 +159,20 @@ void __init riscv_fill_hwcap(void) > --isa; > break; > } > + /* Skip the major version */ Same applies to this comment as well. > while (isdigit(*++isa)) > ; > break; > } > if (*isa != '_') > --isa; > - /* > - * TODO: Full version-aware handling including > - * multi-letter extensions will be added in-future. > - */ > - if (ext_err || ext_long) > + > + if (unlikely(ext_err)) > continue; > - this_hwcap |= isa2hwcap[(unsigned char)(*ext)]; > - this_isa |= (1UL << (*ext - 'a')); > + if (!ext_long) { > + this_hwcap |= isa2hwcap[(unsigned char)(*ext)]; > + this_isa |= (1UL << (*ext - 'a')); > + } > } > > /* > -- > 2.30.2 > Otherwise it looks good to me. Reviewed-by: Anup Patel Regards, Anup