Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp523919rwr; Wed, 26 Apr 2023 02:42:18 -0700 (PDT) X-Google-Smtp-Source: AKy350brtziaAt3xEMz0mL71wDr+EFKOd9GS3KjWfjihjZG0pyMsZkSUE4g8B0Mx9UnYRWI2YsLk X-Received: by 2002:a17:90a:fe81:b0:246:d49c:bf64 with SMTP id co1-20020a17090afe8100b00246d49cbf64mr20440583pjb.19.1682502138698; Wed, 26 Apr 2023 02:42:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682502138; cv=none; d=google.com; s=arc-20160816; b=0o8CiJfAXo9bl2+IGYbF8evImyQT2NdfFZda3eROlnYTukS3lCQ43gQW47+ABYj+Bu dCXuWdh2t8Pa6wugO5/fY5Wkfed0AJcN1E89hKrzWZI8I4j5HQtyrTunsTmnuKsKgd5r rwyaSj5nA1K4ZqkoSTYWMLap4uZj7QTmJaVxiLDAZCO1l/MU1TRkhd/nOhj+qFwpot4E +IA6wuXX5Ez/omCGOygaV3Vo9e7yFJP4xmfgVPVxO6brqVBSqk4WyvJ7MoYCPmf4MWsJ +UTL0/Fs6epsSToaCpp0AWfJxj5tv+fFg+hBe7rnMXSPHZPhrdZI6oS3sKBxQkWgAHtU FPoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=GGzFSv98HDJv+ep2+uGlvHglFQwWd3hEUaewWLWJTeM=; b=zOc3+TEtNUhmiZVEuVPtx3sBOWVKZCV8HI8WXIVCiFEshklMChz/fyyAwrKFX6m8a+ hwvPdzd0+IacFBKOoitbPHqABgiC8QARoNz6gBmyXsC7l01QssoIbYQt9q4f1OQpG/rT uU1xwoyyRnYfOgfGbzjBozGGAI5dhBLpSJQOK0dzmuKLmDEiiR6TZk9/ggaXo/UTVdfo MLxjlccCmzp8Biagvk7OLbEBPkHzsQkPozECI8mdg9Igy0eLbfKMvs+DamBCqSrhuWar dM36rWU6sq9lS2OYM5pZpC5pKGAtJv6XnbB14GAluZnTqrhPRjF47IU4ZTuCeiXZyn2w euvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=FeUkYEDs; 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 s10-20020a17090a6e4a00b0023d15e7e1d0si15939954pjm.12.2023.04.26.02.42.04; Wed, 26 Apr 2023 02:42:18 -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; dkim=pass header.i=@ventanamicro.com header.s=google header.b=FeUkYEDs; 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 S239812AbjDZJhq (ORCPT + 99 others); Wed, 26 Apr 2023 05:37:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59714 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239666AbjDZJhp (ORCPT ); Wed, 26 Apr 2023 05:37:45 -0400 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9653393 for ; Wed, 26 Apr 2023 02:37:44 -0700 (PDT) Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-2f86ee42669so6608520f8f.2 for ; Wed, 26 Apr 2023 02:37:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1682501863; x=1685093863; 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=GGzFSv98HDJv+ep2+uGlvHglFQwWd3hEUaewWLWJTeM=; b=FeUkYEDsMultKQCqlNuwdPzZXXJ8w3+yKweQ1IN3IxJsczSEQpi8fQFiw8xxxcRxm6 l9Bd/Wrd3uvIUn6QdB6rS6RQ/HfbHGZMFNnCTzZpuIzTlaBC94c4lH5WcW8bQke2oSP4 2MhLZZooI6oiAvZ//JzkgpfgDmJjJMuZU+Ih8RqbFb8gQ3rqRn3YHBclXcI8fclXPrWx ws1gz4pFYRpzokjUGtEa2ebrenmwvSQOrAoUn8iPoJjQTydesn2Oy0m7pT3ITUrfsAJy vqzklpLRaMUh9kRX57T2UdDofMCEguEo4kFFiJ5wAQojjNGDl25N784N0rco1be9/Mwa HfVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682501863; x=1685093863; 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=GGzFSv98HDJv+ep2+uGlvHglFQwWd3hEUaewWLWJTeM=; b=Gz7mskptVZz9oDEp2E926bfGz2IVh8Vy/MTwPkp8K6v6PFFBRQuZJcTFYpUnp0d1Sn /TyenO312B9zBOq2I6F/E1IA/IjlzcPDCMQhgPJ3OhSJcT0FrIju9+OZxrchLtiL3NER z+lvRg/yKNLiLwT3iQsLIks92shvLPY3rXmU3lXp5Lr+j1EwG5f8nQ96ACIO5CPMwb2+ WhXrpRCzlELjyisa+N9SdxmTXcbo1IpSEUB7M/Mn30EOZs8PTbefeesaEa6g6IQWV7iE x2cjRcv6gLb0ZghN1FfchEfwSf3X5b5xkL8RC7iGHjMZtu2M1ItUvHq4NqxLsN/e0Hen gPpg== X-Gm-Message-State: AAQBX9fXitB/p1E/QtRJ7ZgWKmgWEbFYTjGZUpRelL7vS8X7Eh6ztQJd fmouAd6j4Cr/IT9MKPUA2MLTBg== X-Received: by 2002:adf:fc4f:0:b0:2f7:725d:e7b4 with SMTP id e15-20020adffc4f000000b002f7725de7b4mr13264555wrs.18.1682501863040; Wed, 26 Apr 2023 02:37:43 -0700 (PDT) Received: from localhost (cst2-173-16.cust.vodafone.cz. [31.30.173.16]) by smtp.gmail.com with ESMTPSA id z14-20020a5d4d0e000000b002efb4f2d240sm15266468wrt.87.2023.04.26.02.37.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Apr 2023 02:37:42 -0700 (PDT) Date: Wed, 26 Apr 2023 11:37:41 +0200 From: Andrew Jones To: Heiko Stuebner Cc: palmer@dabbelt.com, linux-riscv@lists.infradead.org, paul.walmsley@sifive.com, 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 Subject: Re: [PATCH 2/4] RISC-V: don't parse dt isa string to get rv32/rv64 Message-ID: References: <20230424194911.264850-1-heiko.stuebner@vrull.eu> <20230424194911.264850-3-heiko.stuebner@vrull.eu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230424194911.264850-3-heiko.stuebner@vrull.eu> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 Mon, Apr 24, 2023 at 09:49:09PM +0200, Heiko Stuebner wrote: > From: Heiko Stuebner > > 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 > --- > 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