Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp1808716rwb; Thu, 29 Sep 2022 02:30:28 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5iAgipjtUY8eWo8kNs1DR4nVi5TkSYfw5UxgtPJm2lNWdAEVFeHsZWPeWLWrNSSR+AuBqJ X-Received: by 2002:a17:907:9617:b0:783:3fe1:e3d9 with SMTP id gb23-20020a170907961700b007833fe1e3d9mr1890595ejc.516.1664443828058; Thu, 29 Sep 2022 02:30:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664443828; cv=none; d=google.com; s=arc-20160816; b=LY8iGebzilAU4cBpGiXPEmijESbfo/o2WD/PupAt7MMZfWZKnXwOnqUL4T9BjTgX4C YjSlo32ojPSzyCYtpd5Dp+Ad/nfMbliBlvti1d9LV81UsCTcTXX7SVIQ9v3j0BBZAIZx OiEzswiloSTFhNGyhzEts9KmXNsCyzIV+FMcWjQ7lLhMvZKPWH1wPxpsCaqGCsREpCEQ aOF57numSyvFj+uzdxy/C0E9ZjxmCHcTF0NhkrmhPo5SOdQSL8XXLnI06xJSGsW+pUu/ dobQeAa0v4jPkblpUb2kmTyiWeLECfJC45ehbxLw8QgTAOdEzvipy3/Yz2aeRuKKvBcy DkUQ== 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=dRD/G55eehFgc+a3HuAbZA4vvOo6UwcBCMhhANlRMPI=; b=QGuuqyrGo2Y0PIg5Irszf/hknd2QudRgd6bQRNo3nvHERWeLT2yJ4Xn1Av+RkNa0JM GZVuh+HK/sN0C55xYLZ6kAWJB9a/QMtqU5SHEW2SAaONT9Wqrw3OCXOcfnJ23sC8pqQp JEik3ntVoBT1f0+T82/Nio5MDkUJ16EjF1VoQ1KlO5YzWuZ+++mRKmUwvifyHVHeHGN3 bleIPwLpG5AZeumYm5bH0JEsuQgbyYQImbrKE/onh6jrwx/mtYA+4i1AD2BClKR3GPcn 8FZSRKPsab/9qm1tktezU/Siy98i0vuXmLXAR1fDNX9zFQymPbfTIY59Usad8034LNms pPPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=IsiY5fHs; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bw11-20020a170906c1cb00b0077e8ff79426si6761003ejb.511.2022.09.29.02.30.02; Thu, 29 Sep 2022 02:30:28 -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=@kernel.org header.s=k20201202 header.b=IsiY5fHs; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235551AbiI2IcG (ORCPT + 99 others); Thu, 29 Sep 2022 04:32:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43602 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235532AbiI2IcD (ORCPT ); Thu, 29 Sep 2022 04:32:03 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6012AA6C43 for ; Thu, 29 Sep 2022 01:31:55 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id C8F71B823AE for ; Thu, 29 Sep 2022 08:31:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7FEFEC433C1 for ; Thu, 29 Sep 2022 08:31:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1664440312; bh=BvrFJCULs2Wza/EdwzmscEXyeFBnBeIhY36lcoV68Oo=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=IsiY5fHsx/p744TlSHVaFTosnPyDkiR5Mc8DwJukR83HABNVkh2VbXR7N5pIw3Fq+ 7sklrOfwh6e0K3iAlL8JCRYzeCf9Fjg5LXy4aHqrneoGdsfTKr0Dgn58COY+x8gG40 EW95D7cJdImGWpGYb/o9XDtuyaE3oJOeBpv4L8fiVCWZPp8iq7AKQ0V4XJNrYm8jrS K04/j4vfZRReG8WmwG7ovywFWHol9FGZkiBojIufsin8myyfU1PbJb64dBzSWpYG1Y VHZ46pbrEW/95+btIZLIcjN6lAjbTdsR+XXGUFGg+bYOc0ytmLKtqpxOhedoJ2jOLA vo5X9uEbyIfLA== Received: by mail-vk1-f169.google.com with SMTP id g85so294859vkf.10 for ; Thu, 29 Sep 2022 01:31:52 -0700 (PDT) X-Gm-Message-State: ACrzQf04lr4fN+fAeW9Be2d5YK/Jt/J6De9oErLXcpJDgghWWic1YhAG 7ilLnLLOAWecdJOgVWk9+9PKXLMlGjXwVTT9qqI= X-Received: by 2002:a1f:2596:0:b0:3a2:5864:697c with SMTP id l144-20020a1f2596000000b003a25864697cmr823963vkl.37.1664440311493; Thu, 29 Sep 2022 01:31:51 -0700 (PDT) MIME-Version: 1.0 References: <20220929073623.7604-1-lvjianmin@loongson.cn> In-Reply-To: <20220929073623.7604-1-lvjianmin@loongson.cn> From: Huacai Chen Date: Thu, 29 Sep 2022 16:31:37 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] LoongArch: Fix cpu name after s3/s4 To: Jianmin Lv Cc: WANG Xuerui , linux-kernel@vger.kernel.org, loongarch@lists.linux.dev Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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 Hi, Jianmin, How about do it like this? diff --git a/arch/loongarch/kernel/cpu-probe.c b/arch/loongarch/kernel/cpu-probe.c index 1bc9fec4e474..1734362d1fa9 100644 --- a/arch/loongarch/kernel/cpu-probe.c +++ b/arch/loongarch/kernel/cpu-probe.c @@ -265,7 +265,9 @@ static inline void cpu_probe_loongson(struct cpuinfo_loongarch *c, unsigned int uint64_t *vendor = (void *)(&cpu_full_name[VENDOR_OFFSET]); uint64_t *cpuname = (void *)(&cpu_full_name[CPUNAME_OFFSET]); - __cpu_full_name[cpu] = cpu_full_name; + if (!__cpu_full_name[cpu]) + __cpu_full_name[cpu] = cpu_full_name; + *vendor = iocsr_read64(LOONGARCH_IOCSR_VENDOR); *cpuname = iocsr_read64(LOONGARCH_IOCSR_CPUNAME); Huacai On Thu, Sep 29, 2022 at 3:36 PM Jianmin Lv wrote: > > On coming back from s3/s4, the cpu name will be overwritten > in cpu_probe path of seconary cpu, so we adjust the postion > of using cpu name existed in cpu hardware register, and only > use it while failing to get cpu name from SMBIOS. > > Signed-off-by: Jianmin Lv > > diff --git a/arch/loongarch/include/asm/cpu-info.h b/arch/loongarch/include/asm/cpu-info.h > index b6c4f96079df..937dce2a930a 100644 > --- a/arch/loongarch/include/asm/cpu-info.h > +++ b/arch/loongarch/include/asm/cpu-info.h > @@ -64,6 +64,7 @@ extern void cpu_probe(void); > > extern const char *__cpu_family[]; > extern const char *__cpu_full_name[]; > +extern char cpu_full_name[]; > #define cpu_family_string() __cpu_family[raw_smp_processor_id()] > #define cpu_full_name_string() __cpu_full_name[raw_smp_processor_id()] > > diff --git a/arch/loongarch/kernel/cpu-probe.c b/arch/loongarch/kernel/cpu-probe.c > index 529ab8f44ec6..a548b2197224 100644 > --- a/arch/loongarch/kernel/cpu-probe.c > +++ b/arch/loongarch/kernel/cpu-probe.c > @@ -180,14 +180,13 @@ static void cpu_probe_common(struct cpuinfo_loongarch *c) > #define VENDOR_OFFSET 0 > #define CPUNAME_OFFSET 9 > > -static char cpu_full_name[MAX_NAME_LEN] = " - "; > +char cpu_full_name[MAX_NAME_LEN] = " - "; > > static inline void cpu_probe_loongson(struct cpuinfo_loongarch *c, unsigned int cpu) > { > uint64_t *vendor = (void *)(&cpu_full_name[VENDOR_OFFSET]); > uint64_t *cpuname = (void *)(&cpu_full_name[CPUNAME_OFFSET]); > > - __cpu_full_name[cpu] = cpu_full_name; > *vendor = iocsr_read64(LOONGARCH_IOCSR_VENDOR); > *cpuname = iocsr_read64(LOONGARCH_IOCSR_CPUNAME); > > diff --git a/arch/loongarch/kernel/env.c b/arch/loongarch/kernel/env.c > index 82b478a5c665..955d82aa298e 100644 > --- a/arch/loongarch/kernel/env.c > +++ b/arch/loongarch/kernel/env.c > @@ -44,6 +44,9 @@ static int __init init_cpu_fullname(void) > if (loongson_sysconf.cpuname && !strncmp(loongson_sysconf.cpuname, "Loongson", 8)) { > for (cpu = 0; cpu < NR_CPUS; cpu++) > __cpu_full_name[cpu] = loongson_sysconf.cpuname; > + } else { > + for (cpu = 0; cpu < NR_CPUS; cpu++) > + __cpu_full_name[cpu] = cpu_full_name; > } > return 0; > } > -- > 2.31.1 >