Re: [PATCH V7 8/9] MIPS: Add __cpu_full_name[] to make CPU names more human-readable

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Jun 22, 2017 at 11:06:55PM +0800, Huacai Chen wrote:
> diff --git a/arch/mips/kernel/proc.c b/arch/mips/kernel/proc.c
> index 4eff2ae..78db63a 100644
> --- a/arch/mips/kernel/proc.c
> +++ b/arch/mips/kernel/proc.c

> @@ -62,6 +63,9 @@ 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 @ %uMHz\n",
> +		      __cpu_full_name[n], mips_hpt_frequency / 500000);

If the core frequency is useful (I can imagine it being useful for
humans), maybe it should be on a separate line.

This also assumes that the mips_hpt_frequency is half the core
frequency, which may not universally be the case. Perhaps that should be
abstracted too (at some point, I suppose it doesn't matter right away).

> diff --git a/arch/mips/loongson64/common/env.c b/arch/mips/loongson64/common/env.c
> index 1e8a955..9ee24ea 100644
> --- a/arch/mips/loongson64/common/env.c
> +++ b/arch/mips/loongson64/common/env.c
> @@ -25,6 +25,7 @@
>  
>  u32 cpu_clock_freq;
>  EXPORT_SYMBOL(cpu_clock_freq);
> +static char cpu_full_name[64];
>  struct efi_memory_map_loongson *loongson_memmap;
>  struct loongson_system_configuration loongson_sysconf;
>  
> @@ -151,6 +152,8 @@ 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, 64);

maybe sizeof(cpu_full_name) rather than 64.

>  
>  	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,3 +215,18 @@ void __init prom_init_env(void)
>  	}
>  	pr_info("CpuClock = %u\n", cpu_clock_freq);
>  }
> +
> +static int __init overwrite_cpu_fullname(void)
> +{
> +	int cpu;
> +
> +	if (cpu_full_name[0] == 0)
> +		return 0;
> +
> +	for(cpu = 0; cpu < NR_CPUS; cpu++)

space before open bracket please

> +		__cpu_full_name[cpu] = cpu_full_name;
> +
> +	return 0;
> +}
> +
> +core_initcall(overwrite_cpu_fullname);

Cheers
James

Attachment: signature.asc
Description: Digital signature


[Index of Archives]     [Linux MIPS Home]     [LKML Archive]     [Linux ARM Kernel]     [Linux ARM]     [Linux]     [Git]     [Yosemite News]     [Linux SCSI]     [Linux Hams]

  Powered by Linux