From patchwork Thu Nov 15 05:50:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huacai Chen X-Patchwork-Id: 10683531 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 042AF13B5 for ; Thu, 15 Nov 2018 05:54:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E2EA82C140 for ; Thu, 15 Nov 2018 05:54:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D6B5D2C15A; Thu, 15 Nov 2018 05:54:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1443D2C140 for ; Thu, 15 Nov 2018 05:54:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729007AbeKOQAA (ORCPT ); Thu, 15 Nov 2018 11:00:00 -0500 Received: from mail-pf1-f194.google.com ([209.85.210.194]:43610 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728388AbeKOP77 (ORCPT ); Thu, 15 Nov 2018 10:59:59 -0500 Received: by mail-pf1-f194.google.com with SMTP id g7-v6so9131377pfo.10 for ; Wed, 14 Nov 2018 21:53:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=5+bGkbwI4tte49oS5O6Ce9UszvLA7tgJLm8970u2vpI=; b=LDnDjZT2iROL2mzktTxKVAGfQ6CV8t1XJypf4b+dgBwKrKTQdmKB1eRs/+6mGbAzN2 ozNNQMn0sFStI96643eTHEGR6eBakQAA8mSwVtoTbmFjRM+eOiwonUiLpai+pZfIQ6t0 kX3rxossM2iKUu+JzU1Aq+id2naeXRXYJf5Aq5ZbNmBIKxLXPBZrza8xQiP7HrnWoGFZ EGmAvakyRmAyVhLvWdxerBU2ms9XR2gP0kcJ5+gkeU3sgiF4/mUZlPwO0dwOBJ41ubCO LrzzbdqhSvgnzYjWfARcJaI0A6QQ5oKXOEuwVjwUlTxpwUkHnhO53JaAHN6rd/jSDqPp NSKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=5+bGkbwI4tte49oS5O6Ce9UszvLA7tgJLm8970u2vpI=; b=jUxxZCyalkCdCk3hkXE1fJM4HmbO4zKWkvS9NV/04hZbcE8nFKwm0kwFPgOisARfur zUsUl0seBkTaCv5pw7oo3IYUznrsPbsLKuuHoPB69ZwwTEe+UE2L4QMNntIc6uwSst4A 3ZIOUQNBpptg9uQp5nS6I9l6Oz4KxZ2qqrZzK6dQJZb6FHLPnrVDjYILyKAZKyrUmR6k ZqVEYcXSGH72ew4K2EL6j3Wi0Q6o4bJqu+y3U/OJNSnXXomO+NGF7sEFNMKuht5NV0WL +BnrQ7sjtuhNIbdpgsTRN6ebo1Qqate6oySijf6sTcKlFLNoxZ8021Jf/MDwTLkfVxYD 2ufA== X-Gm-Message-State: AGRZ1gJp1vqAkRYuAObYNp36D/QwXKCfnIiWpzAvNsDRuKZ/+NWcnSw3 5lcWN62tqWBM7S6l8tCqtqko/4WkBjI= X-Google-Smtp-Source: AJdET5cgZODv/dubwABoD6xKpnet6O/1rbHOyZRi+stFq5afVaMRp7Y5HbbXPz45HAZN8mOGp5J2tA== X-Received: by 2002:a63:63c3:: with SMTP id x186mr4555792pgb.330.1542261213568; Wed, 14 Nov 2018 21:53:33 -0800 (PST) Received: from software.domain.org ([222.92.8.142]) by smtp.gmail.com with ESMTPSA id o1sm34882306pgn.63.2018.11.14.21.53.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 14 Nov 2018 21:53:33 -0800 (PST) From: Huacai Chen To: Jean Delvare Cc: Guenter Roeck , linux-hwmon@vger.kernel.org, Fuxin Zhang , Huacai Chen Subject: [PATCH V5 4/8] MIPS: Add __cpu_full_name[] to make CPU names more human-readable Date: Thu, 15 Nov 2018 13:50:53 +0800 Message-Id: <1542261057-6019-5-git-send-email-chenhc@lemote.com> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1542261057-6019-1-git-send-email-chenhc@lemote.com> References: <1542261057-6019-1-git-send-email-chenhc@lemote.com> Sender: linux-hwmon-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In /proc/cpuinfo, we keep "cpu model" as is, since GCC should use it for -march=native. Besides, we add __cpu_full_name[] to describe the processor in a more human-readable manner. The full name is displayed as "model name" in cpuinfo, which is needed by some userspace tools such as gnome-system-monitor. The CPU frequency in "model name" is the default value (highest), and there is also a "CPU MHz" whose value can be changed by cpufreq. This is only used by Loongson now (ICT is dropped in cpu name, and cpu name can be overwritten by BIOS). Signed-off-by: Huacai Chen --- arch/mips/include/asm/cpu-info.h | 2 ++ arch/mips/include/asm/mach-loongson64/boot_param.h | 1 + arch/mips/include/asm/time.h | 2 ++ arch/mips/kernel/cpu-probe.c | 25 ++++++++++++++++------ arch/mips/kernel/proc.c | 6 ++++++ arch/mips/kernel/time.c | 2 ++ arch/mips/loongson64/common/env.c | 13 +++++++++++ arch/mips/loongson64/loongson-3/smp.c | 1 + arch/mips/loongson64/loongson-3/smp.h | 1 + 9 files changed, 47 insertions(+), 6 deletions(-) diff --git a/arch/mips/include/asm/cpu-info.h b/arch/mips/include/asm/cpu-info.h index a41059d..6128a37 100644 --- a/arch/mips/include/asm/cpu-info.h +++ b/arch/mips/include/asm/cpu-info.h @@ -116,7 +116,9 @@ extern void cpu_probe(void); extern void cpu_report(void); extern const char *__cpu_name[]; +extern const char *__cpu_full_name[]; #define cpu_name_string() __cpu_name[raw_smp_processor_id()] +#define cpu_full_name_string() __cpu_full_name[raw_smp_processor_id()] struct seq_file; struct notifier_block; diff --git a/arch/mips/include/asm/mach-loongson64/boot_param.h b/arch/mips/include/asm/mach-loongson64/boot_param.h index 8c286be..1d69e4c 100644 --- a/arch/mips/include/asm/mach-loongson64/boot_param.h +++ b/arch/mips/include/asm/mach-loongson64/boot_param.h @@ -58,6 +58,7 @@ struct efi_cpuinfo_loongson { u16 reserved_cores_mask; u32 cpu_clock_freq; /* cpu_clock */ u32 nr_cpus; + char cpuname[64]; } __packed; #define MAX_UARTS 64 diff --git a/arch/mips/include/asm/time.h b/arch/mips/include/asm/time.h index b85ec64..5cbfbec 100644 --- a/arch/mips/include/asm/time.h +++ b/arch/mips/include/asm/time.h @@ -26,6 +26,8 @@ extern spinlock_t rtc_lock; */ extern void plat_time_init(void); +extern unsigned int mips_cpu_frequency; + /* * mips_hpt_frequency - must be set if you intend to use an R4k-compatible * counter as a timer interrupt source. diff --git a/arch/mips/kernel/cpu-probe.c b/arch/mips/kernel/cpu-probe.c index 65dc2e6..9282cd3 100644 --- a/arch/mips/kernel/cpu-probe.c +++ b/arch/mips/kernel/cpu-probe.c @@ -1500,30 +1500,40 @@ static inline void cpu_probe_legacy(struct cpuinfo_mips *c, unsigned int cpu) switch (c->processor_id & PRID_REV_MASK) { case PRID_REV_LOONGSON2E: c->cputype = CPU_LOONGSON2; - __cpu_name[cpu] = "ICT Loongson-2"; + __cpu_name[cpu] = "Loongson-2"; set_elf_platform(cpu, "loongson2e"); set_isa(c, MIPS_CPU_ISA_III); c->fpu_msk31 |= FPU_CSR_CONDX; + __cpu_full_name[cpu] = "Loongson-2E"; break; case PRID_REV_LOONGSON2F: c->cputype = CPU_LOONGSON2; - __cpu_name[cpu] = "ICT Loongson-2"; + __cpu_name[cpu] = "Loongson-2"; set_elf_platform(cpu, "loongson2f"); set_isa(c, MIPS_CPU_ISA_III); c->fpu_msk31 |= FPU_CSR_CONDX; + __cpu_full_name[cpu] = "Loongson-2F"; break; case PRID_REV_LOONGSON3A_R1: c->cputype = CPU_LOONGSON3; - __cpu_name[cpu] = "ICT Loongson-3"; + __cpu_name[cpu] = "Loongson-3"; set_elf_platform(cpu, "loongson3a"); set_isa(c, MIPS_CPU_ISA_M64R1); + __cpu_full_name[cpu] = "Loongson-3A R1 (Loongson-3A1000)"; break; case PRID_REV_LOONGSON3B_R1: + c->cputype = CPU_LOONGSON3; + __cpu_name[cpu] = "Loongson-3"; + set_elf_platform(cpu, "loongson3b"); + set_isa(c, MIPS_CPU_ISA_M64R1); + __cpu_full_name[cpu] = "Loongson-3B R1 (Loongson-3B1000)"; + break; case PRID_REV_LOONGSON3B_R2: c->cputype = CPU_LOONGSON3; - __cpu_name[cpu] = "ICT Loongson-3"; + __cpu_name[cpu] = "Loongson-3"; set_elf_platform(cpu, "loongson3b"); set_isa(c, MIPS_CPU_ISA_M64R1); + __cpu_full_name[cpu] = "Loongson-3B R2 (Loongson-3B1500)"; break; } @@ -1874,16 +1884,18 @@ static inline void cpu_probe_loongson(struct cpuinfo_mips *c, unsigned int cpu) case PRID_REV_LOONGSON3A_R2_0: case PRID_REV_LOONGSON3A_R2_1: c->cputype = CPU_LOONGSON3; - __cpu_name[cpu] = "ICT Loongson-3"; + __cpu_name[cpu] = "Loongson-3"; set_elf_platform(cpu, "loongson3a"); set_isa(c, MIPS_CPU_ISA_M64R2); + __cpu_full_name[cpu] = "Loongson-3A R2 (Loongson-3A2000)"; break; case PRID_REV_LOONGSON3A_R3_0: case PRID_REV_LOONGSON3A_R3_1: c->cputype = CPU_LOONGSON3; - __cpu_name[cpu] = "ICT Loongson-3"; + __cpu_name[cpu] = "Loongson-3"; set_elf_platform(cpu, "loongson3a"); set_isa(c, MIPS_CPU_ISA_M64R2); + __cpu_full_name[cpu] = "Loongson-3A R3 (Loongson-3A3000)"; break; } @@ -2003,6 +2015,7 @@ EXPORT_SYMBOL(__ua_limit); #endif const char *__cpu_name[NR_CPUS]; +const char *__cpu_full_name[NR_CPUS]; const char *__elf_platform; void cpu_probe(void) diff --git a/arch/mips/kernel/proc.c b/arch/mips/kernel/proc.c index b2de408..5ba82cc 100644 --- a/arch/mips/kernel/proc.c +++ b/arch/mips/kernel/proc.c @@ -15,6 +15,7 @@ #include #include #include +#include unsigned int vced_count, vcei_count; @@ -63,6 +64,11 @@ static int show_cpuinfo(struct seq_file *m, void *v) seq_printf(m, fmt, __cpu_name[n], (version >> 4) & 0x0f, version & 0x0f, (fp_vers >> 4) & 0x0f, fp_vers & 0x0f); + if (__cpu_full_name[n]) + seq_printf(m, "model name\t\t: %s\n", __cpu_full_name[n]); + if (mips_cpu_frequency) + seq_printf(m, "CPU MHz\t\t\t: %u.%02u\n", + mips_cpu_frequency / 1000000, (mips_cpu_frequency / 10000) % 100); seq_printf(m, "BogoMIPS\t\t: %u.%02u\n", cpu_data[n].udelay_val / (500000/HZ), (cpu_data[n].udelay_val / (5000/HZ)) % 100); diff --git a/arch/mips/kernel/time.c b/arch/mips/kernel/time.c index bfe02de..fc0323e 100644 --- a/arch/mips/kernel/time.c +++ b/arch/mips/kernel/time.c @@ -54,6 +54,8 @@ EXPORT_SYMBOL(perf_irq); * 2) calculate a couple of cached variables for later usage */ +unsigned int mips_cpu_frequency; +EXPORT_SYMBOL_GPL(mips_cpu_frequency); unsigned int mips_hpt_frequency; EXPORT_SYMBOL_GPL(mips_hpt_frequency); diff --git a/arch/mips/loongson64/common/env.c b/arch/mips/loongson64/common/env.c index 72e5f8f..d4f9979 100644 --- a/arch/mips/loongson64/common/env.c +++ b/arch/mips/loongson64/common/env.c @@ -18,6 +18,7 @@ * option) any later version. */ #include +#include #include #include #include @@ -25,6 +26,7 @@ u32 cpu_clock_freq; EXPORT_SYMBOL(cpu_clock_freq); +char cpu_full_name[64]; struct efi_memory_map_loongson *loongson_memmap; struct loongson_system_configuration loongson_sysconf; @@ -45,6 +47,7 @@ do { \ void __init prom_init_env(void) { /* pmon passes arguments in 32bit pointers */ + char freq[12]; unsigned int processor_id; #ifndef CONFIG_LEFI_FIRMWARE_INTERFACE @@ -151,6 +154,10 @@ void __init prom_init_env(void) loongson_sysconf.nr_nodes = (loongson_sysconf.nr_cpus + loongson_sysconf.cores_per_node - 1) / loongson_sysconf.cores_per_node; + if (!strncmp(ecpu->cpuname, "Loongson", 8)) + strncpy(cpu_full_name, ecpu->cpuname, sizeof(cpu_full_name)); + if (cpu_full_name[0] == 0) + strncpy(cpu_full_name, __cpu_full_name[0], sizeof(cpu_full_name)); loongson_sysconf.pci_mem_start_addr = eirq_source->pci_mem_start_addr; loongson_sysconf.pci_mem_end_addr = eirq_source->pci_mem_end_addr; @@ -212,5 +219,11 @@ void __init prom_init_env(void) break; } } + mips_cpu_frequency = cpu_clock_freq; pr_info("CpuClock = %u\n", cpu_clock_freq); + + /* Append default cpu frequency with round-off */ + sprintf(freq, " @ %uMHz", (cpu_clock_freq + 500000) / 1000000); + strncat(cpu_full_name, freq, sizeof(cpu_full_name)); + __cpu_full_name[0] = cpu_full_name; } diff --git a/arch/mips/loongson64/loongson-3/smp.c b/arch/mips/loongson64/loongson-3/smp.c index 8fba0aa..bfaba5b 100644 --- a/arch/mips/loongson64/loongson-3/smp.c +++ b/arch/mips/loongson64/loongson-3/smp.c @@ -341,6 +341,7 @@ static void loongson3_init_secondary(void) initcount = core0_c0count[cpu] + i/2; write_c0_count(initcount); + __cpu_full_name[cpu] = cpu_full_name; } static void loongson3_smp_finish(void) diff --git a/arch/mips/loongson64/loongson-3/smp.h b/arch/mips/loongson64/loongson-3/smp.h index 957bde8..6112d9d 100644 --- a/arch/mips/loongson64/loongson-3/smp.h +++ b/arch/mips/loongson64/loongson-3/smp.h @@ -3,6 +3,7 @@ #define __LOONGSON_SMP_H_ /* for Loongson-3 smp support */ +extern char cpu_full_name[64]; extern unsigned long long smp_group[4]; /* 4 groups(nodes) in maximum in numa case */