Message ID | 20230424194911.264850-3-heiko.stuebner@vrull.eu |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2972570vqo; Mon, 24 Apr 2023 12:54:13 -0700 (PDT) X-Google-Smtp-Source: AKy350bFbwo3LqtnMyDwf3y4aSSo9CiVEGHRIh7SlzAADFKadF65nUcnpHu9Ujbr6UuBSjdV40k4 X-Received: by 2002:a05:6a21:338a:b0:f2:791f:7ce1 with SMTP id yy10-20020a056a21338a00b000f2791f7ce1mr15439170pzb.44.1682366053411; Mon, 24 Apr 2023 12:54:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682366053; cv=none; d=google.com; s=arc-20160816; b=S61/ooO6h3e3Y42hlRwcTFAO0By1Wl2EkuoxnLRRYciv8itqjm2c0YXipk6gbz2OJL cIxT3KmK2t41d+YSwmaaTxO0Odh6LtHkbmrLdTTqA9tr9rAcqpLT/X192M2CKGHDEF/m 2GG+ICdGVM5grbvSXXPU96w2NuEVvcMhqlsjX1tLg7SZmeOgP5VVBiyU+cAlExzDS5ZI Q70POXwiR+h5OAErFhyPnEFeCpFuqJKBgxQE3NtO3D/BFMVzes3wbnvJvUM0VpZAe9Sq MW0UppZdEDWffvVOj+h/xQKW0JumoBQVbYrgAUuyEYlc9YAd8zB0SvY0nCMWIM3mG0QO A+uw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=trTmhS5lId6OYTwGH2NgD1aG797fWIRCzQnC/hW83ho=; b=iU4K38BaBfg4Ok5y5iCDhuXyljUDJ+CKOZvnB5XlnF11ThhLPwN3MkzENkPGkgtdrM 5/tv7qm4ITGXFZh2+EyQwzrxP0kXQ20bKGHIgM3QB/TLeSnkMyHE4JeR8gAf3F2rRlid E/dxw7gcokDMAQ0yIKIfPd+e5sqN+hAnwMGnOq8rXY9UmKH/dQ+4dU4+J4XB/3ItxGMl 7GaW2hS0E8qn8OmxyADkRpT8eUuD2yDQYpbRyoe5ZHA+x+mvaqWRWLjvhooIxJREgCPq pp4UMHTXSFw466YoL94p6RwkFJXJnd8CPRTAhFNINq15HLW3N1t0ijRYIC3PPYbWPNyC Hltw== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=sntech.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 4-20020a630004000000b0050beec91e30si11623061pga.768.2023.04.24.12.53.59; Mon, 24 Apr 2023 12:54:13 -0700 (PDT) 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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=sntech.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232963AbjDXTuM (ORCPT <rfc822;fengqi706@gmail.com> + 99 others); Mon, 24 Apr 2023 15:50:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48322 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232593AbjDXTtl (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 24 Apr 2023 15:49:41 -0400 Received: from gloria.sntech.de (gloria.sntech.de [185.11.138.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9C2A65FDC for <linux-kernel@vger.kernel.org>; Mon, 24 Apr 2023 12:49:35 -0700 (PDT) Received: from ip4d1634d3.dynamic.kabel-deutschland.de ([77.22.52.211] helo=phil.lan) by gloria.sntech.de with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from <heiko@sntech.de>) id 1pr2Bi-0006Mz-OX; Mon, 24 Apr 2023 21:49:26 +0200 From: Heiko Stuebner <heiko@sntech.de> To: palmer@dabbelt.com, linux-riscv@lists.infradead.org, paul.walmsley@sifive.com Cc: heiko@sntech.de, kito.cheng@sifive.com, jrtc27@jrtc27.com, conor.dooley@microchip.com, matthias.bgg@gmail.com, heinrich.schuchardt@canonical.com, greentime.hu@sifive.com, nick.knight@sifive.com, christoph.muellner@vrull.eu, philipp.tomsich@vrull.eu, richard.henderson@linaro.org, arnd@arndb.de, linux-kernel@vger.kernel.org, Heiko Stuebner <heiko.stuebner@vrull.eu> Subject: [PATCH 2/4] RISC-V: don't parse dt isa string to get rv32/rv64 Date: Mon, 24 Apr 2023 21:49:09 +0200 Message-Id: <20230424194911.264850-3-heiko.stuebner@vrull.eu> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230424194911.264850-1-heiko.stuebner@vrull.eu> References: <20230424194911.264850-1-heiko.stuebner@vrull.eu> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_PASS, T_SCC_BODY_TEXT_LINE,T_SPF_HELO_TEMPERROR 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764088667235853844?= X-GMAIL-MSGID: =?utf-8?q?1764088667235853844?= |
Series |
Expose the isa-string via the AT_BASE_PLATFORM aux vector
|
|
Commit Message
Heiko Stübner
April 24, 2023, 7:49 p.m. UTC
From: Heiko Stuebner <heiko.stuebner@vrull.eu> When filling hwcap the kernel already expects the isa string to start with rv32 if CONFIG_32BIT and rv64 if CONFIG_64BIT. So when recreating the runtime isa-string we can also just go the other way to get the correct starting point for it. Signed-off-by: Heiko Stuebner <heiko.stuebner@vrull.eu> --- arch/riscv/kernel/cpu.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
Comments
On Mon, Apr 24, 2023 at 09:49:09PM +0200, Heiko Stuebner wrote: > From: Heiko Stuebner <heiko.stuebner@vrull.eu> > > When filling hwcap the kernel already expects the isa string to start with > rv32 if CONFIG_32BIT and rv64 if CONFIG_64BIT. > > So when recreating the runtime isa-string we can also just go the other way > to get the correct starting point for it. > > Signed-off-by: Heiko Stuebner <heiko.stuebner@vrull.eu> > --- > arch/riscv/kernel/cpu.c | 10 +++++++--- > 1 file changed, 7 insertions(+), 3 deletions(-) > > diff --git a/arch/riscv/kernel/cpu.c b/arch/riscv/kernel/cpu.c > index ebc478f0a16c..06c2f587a176 100644 > --- a/arch/riscv/kernel/cpu.c > +++ b/arch/riscv/kernel/cpu.c > @@ -244,7 +244,7 @@ static void strcat_isa_ext(char *isa_str) > */ > static const char base_riscv_exts[13] = "imafdqcbkjpvh"; > > -static char *riscv_create_isa_string(const char *isa) > +static char *riscv_create_isa_string(void) > { > int maxlen = 4; > char *isa_str; > @@ -261,7 +261,11 @@ static char *riscv_create_isa_string(const char *isa) > return ERR_PTR(-ENOMEM); > > /* Print the rv[64/32] part */ > - strncat(isa_str, isa, 4); > +#if IS_ENABLED(CONFIG_32BIT) > + strncat(isa_str, "rv32", 4); > +#elif IS_ENABLED(CONFIG_64BIT) > + strncat(isa_str, "rv64", 4); > +#endif I see we do the validation in riscv_fill_hwcap() and we also do this #ifdeffery there, but I can't see any reason not to do if (IS_ENABLED(CONFIG_32BIT)) ... else ... instead. > > for (i = 0; i < sizeof(base_riscv_exts); i++) { > if (__riscv_isa_extension_available(NULL, base_riscv_exts[i] - 'a')) > @@ -280,7 +284,7 @@ static void print_isa(struct seq_file *f, const char *isa) > > seq_puts(f, "isa\t\t: "); > > - isa_str = riscv_create_isa_string(isa); > + isa_str = riscv_create_isa_string(); Why are we still passing 'isa' to print_isa()? It's now unused and print_isa()'s single caller only fetches it from the DT for this one purpose, so that of_property_read_string() call could now also be dropped. > if (!IS_ERR(isa_str)) { > seq_write(f, isa_str, strlen(isa_str)); > kfree(isa_str); > -- > 2.39.0 > Thanks, drew
On Mon, 24 Apr 2023 12:49:09 PDT (-0700), heiko@sntech.de wrote: > From: Heiko Stuebner <heiko.stuebner@vrull.eu> > > When filling hwcap the kernel already expects the isa string to start with > rv32 if CONFIG_32BIT and rv64 if CONFIG_64BIT. > > So when recreating the runtime isa-string we can also just go the other way > to get the correct starting point for it. > > Signed-off-by: Heiko Stuebner <heiko.stuebner@vrull.eu> > --- > arch/riscv/kernel/cpu.c | 10 +++++++--- > 1 file changed, 7 insertions(+), 3 deletions(-) > > diff --git a/arch/riscv/kernel/cpu.c b/arch/riscv/kernel/cpu.c > index ebc478f0a16c..06c2f587a176 100644 > --- a/arch/riscv/kernel/cpu.c > +++ b/arch/riscv/kernel/cpu.c > @@ -244,7 +244,7 @@ static void strcat_isa_ext(char *isa_str) > */ > static const char base_riscv_exts[13] = "imafdqcbkjpvh"; > > -static char *riscv_create_isa_string(const char *isa) > +static char *riscv_create_isa_string(void) > { > int maxlen = 4; > char *isa_str; > @@ -261,7 +261,11 @@ static char *riscv_create_isa_string(const char *isa) > return ERR_PTR(-ENOMEM); > > /* Print the rv[64/32] part */ > - strncat(isa_str, isa, 4); > +#if IS_ENABLED(CONFIG_32BIT) > + strncat(isa_str, "rv32", 4); > +#elif IS_ENABLED(CONFIG_64BIT) > + strncat(isa_str, "rv64", 4); > +#endif > > for (i = 0; i < sizeof(base_riscv_exts); i++) { > if (__riscv_isa_extension_available(NULL, base_riscv_exts[i] - 'a')) > @@ -280,7 +284,7 @@ static void print_isa(struct seq_file *f, const char *isa) > > seq_puts(f, "isa\t\t: "); > > - isa_str = riscv_create_isa_string(isa); > + isa_str = riscv_create_isa_string(); > if (!IS_ERR(isa_str)) { > seq_write(f, isa_str, strlen(isa_str)); > kfree(isa_str); Conor pointed out this one, I just looked at the cover letter and got distracted by uABI stuff. It's not directly fixing anything so I'm going to leave it out of this merge window, particularly given that it's tied up with the rest. Reviewed-by: Palmer Dabbelt <palmer@rivosinc.com>
diff --git a/arch/riscv/kernel/cpu.c b/arch/riscv/kernel/cpu.c index ebc478f0a16c..06c2f587a176 100644 --- a/arch/riscv/kernel/cpu.c +++ b/arch/riscv/kernel/cpu.c @@ -244,7 +244,7 @@ static void strcat_isa_ext(char *isa_str) */ static const char base_riscv_exts[13] = "imafdqcbkjpvh"; -static char *riscv_create_isa_string(const char *isa) +static char *riscv_create_isa_string(void) { int maxlen = 4; char *isa_str; @@ -261,7 +261,11 @@ static char *riscv_create_isa_string(const char *isa) return ERR_PTR(-ENOMEM); /* Print the rv[64/32] part */ - strncat(isa_str, isa, 4); +#if IS_ENABLED(CONFIG_32BIT) + strncat(isa_str, "rv32", 4); +#elif IS_ENABLED(CONFIG_64BIT) + strncat(isa_str, "rv64", 4); +#endif for (i = 0; i < sizeof(base_riscv_exts); i++) { if (__riscv_isa_extension_available(NULL, base_riscv_exts[i] - 'a')) @@ -280,7 +284,7 @@ static void print_isa(struct seq_file *f, const char *isa) seq_puts(f, "isa\t\t: "); - isa_str = riscv_create_isa_string(isa); + isa_str = riscv_create_isa_string(); if (!IS_ERR(isa_str)) { seq_write(f, isa_str, strlen(isa_str)); kfree(isa_str);