mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Nicolas Pitre <nicolas.pitre@linaro.org>
To: Sudeep KarkadaNagesha <Sudeep.KarkadaNagesha@arm.com>
Cc: linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, cpufreq@vger.kernel.org,
	linux-pm@vger.kernel.org, devicetree@vger.kernel.org,
	Russell King <linux@arm.linux.org.uk>,
	Shawn Guo <shawn.guo@linaro.org>,
	Gregory Clement <gregory.clement@free-electrons.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Viresh Kumar <viresh.kumar@linaro.org>,
	"Rafael J. Wysocki" <rjw@sisk.pl>,
	Grant Likely <grant.likely@linaro.org>,
	Rob Herring <rob.herring@calxeda.com>,
	Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>,
	Olof Johansson <olof@lixom.net>, Arnd Bergmann <arnd@arndb.de>
Subject: Re: [PATCH v3 04/16] ARM: topology: remove hwid/MPIDR dependency from cpu_capacity
Date: Mon, 22 Jul 2013 10:25:08 -0400 (EDT)	[thread overview]
Message-ID: <alpine.LFD.2.03.1307221024370.15022@syhkavp.arg> (raw)
In-Reply-To: <1374492747-13879-5-git-send-email-Sudeep.KarkadaNagesha@arm.com>

On Mon, 22 Jul 2013, Sudeep KarkadaNagesha wrote:

> From: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
> 
> Currently the topology code computes cpu capacity and stores it in
> the list along with hwid(which is MPIDR) as it parses the CPU nodes
> in the device tree. This is required as it needs to be mapped to the
> logical CPU later.
> 
> Since the CPU device nodes can be retrieved in the logical ordering
> using DT/OF helpers, its possible to store cpu_capacity also in logical
> ordering and avoid storing hwid for each entry.
> 
> This patch removes hwid by making use of of_get_cpu_node.
> 
> Cc: Russell King <linux@arm.linux.org.uk>
> Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
> Acked-by: Rob Herring <rob.herring@calxeda.com>
> Signed-off-by: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>

Acked-by: Nicolas Pitre <nico@linaro.org>


> ---
>  arch/arm/kernel/topology.c | 61 +++++++++++++++-------------------------------
>  1 file changed, 19 insertions(+), 42 deletions(-)
> 
> diff --git a/arch/arm/kernel/topology.c b/arch/arm/kernel/topology.c
> index c5a5954..28ef27a 100644
> --- a/arch/arm/kernel/topology.c
> +++ b/arch/arm/kernel/topology.c
> @@ -74,12 +74,8 @@ struct cpu_efficiency table_efficiency[] = {
>  	{NULL, },
>  };
>  
> -struct cpu_capacity {
> -	unsigned long hwid;
> -	unsigned long capacity;
> -};
> -
> -struct cpu_capacity *cpu_capacity;
> +unsigned long *__cpu_capacity;
> +#define cpu_capacity(cpu)	__cpu_capacity[cpu]
>  
>  unsigned long middle_capacity = 1;
>  
> @@ -100,15 +96,19 @@ static void __init parse_dt_topology(void)
>  	unsigned long capacity = 0;
>  	int alloc_size, cpu = 0;
>  
> -	alloc_size = nr_cpu_ids * sizeof(struct cpu_capacity);
> -	cpu_capacity = kzalloc(alloc_size, GFP_NOWAIT);
> +	alloc_size = nr_cpu_ids * sizeof(*__cpu_capacity);
> +	__cpu_capacity = kzalloc(alloc_size, GFP_NOWAIT);
>  
> -	while ((cn = of_find_node_by_type(cn, "cpu"))) {
> -		const u32 *rate, *reg;
> +	for_each_possible_cpu(cpu) {
> +		const u32 *rate;
>  		int len;
>  
> -		if (cpu >= num_possible_cpus())
> -			break;
> +		/* too early to use cpu->of_node */
> +		cn = of_get_cpu_node(cpu);
> +		if (!cn) {
> +			pr_err("missing device node for CPU %d\n", cpu);
> +			continue;
> +		}
>  
>  		for (cpu_eff = table_efficiency; cpu_eff->compatible; cpu_eff++)
>  			if (of_device_is_compatible(cn, cpu_eff->compatible))
> @@ -124,12 +124,6 @@ static void __init parse_dt_topology(void)
>  			continue;
>  		}
>  
> -		reg = of_get_property(cn, "reg", &len);
> -		if (!reg || len != 4) {
> -			pr_err("%s missing reg property\n", cn->full_name);
> -			continue;
> -		}
> -
>  		capacity = ((be32_to_cpup(rate)) >> 20) * cpu_eff->efficiency;
>  
>  		/* Save min capacity of the system */
> @@ -140,13 +134,9 @@ static void __init parse_dt_topology(void)
>  		if (capacity > max_capacity)
>  			max_capacity = capacity;
>  
> -		cpu_capacity[cpu].capacity = capacity;
> -		cpu_capacity[cpu++].hwid = be32_to_cpup(reg);
> +		cpu_capacity(cpu) = capacity;
>  	}
>  
> -	if (cpu < num_possible_cpus())
> -		cpu_capacity[cpu].hwid = (unsigned long)(-1);
> -
>  	/* If min and max capacities are equals, we bypass the update of the
>  	 * cpu_scale because all CPUs have the same capacity. Otherwise, we
>  	 * compute a middle_capacity factor that will ensure that the capacity
> @@ -154,9 +144,7 @@ static void __init parse_dt_topology(void)
>  	 * SCHED_POWER_SCALE, which is the default value, but with the
>  	 * constraint explained near table_efficiency[].
>  	 */
> -	if (min_capacity == max_capacity)
> -		cpu_capacity[0].hwid = (unsigned long)(-1);
> -	else if (4*max_capacity < (3*(max_capacity + min_capacity)))
> +	if (4*max_capacity < (3*(max_capacity + min_capacity)))
>  		middle_capacity = (min_capacity + max_capacity)
>  				>> (SCHED_POWER_SHIFT+1);
>  	else
> @@ -170,23 +158,12 @@ static void __init parse_dt_topology(void)
>   * boot. The update of all CPUs is in O(n^2) for heteregeneous system but the
>   * function returns directly for SMP system.
>   */
> -void update_cpu_power(unsigned int cpu, unsigned long hwid)
> +void update_cpu_power(unsigned int cpu)
>  {
> -	unsigned int idx = 0;
> -
> -	/* look for the cpu's hwid in the cpu capacity table */
> -	for (idx = 0; idx < num_possible_cpus(); idx++) {
> -		if (cpu_capacity[idx].hwid == hwid)
> -			break;
> -
> -		if (cpu_capacity[idx].hwid == -1)
> -			return;
> -	}
> -
> -	if (idx == num_possible_cpus())
> +	if (!cpu_capacity(cpu))
>  		return;
>  
> -	set_power_scale(cpu, cpu_capacity[idx].capacity / middle_capacity);
> +	set_power_scale(cpu, cpu_capacity(cpu) / middle_capacity);
>  
>  	printk(KERN_INFO "CPU%u: update cpu_power %lu\n",
>  		cpu, arch_scale_freq_power(NULL, cpu));
> @@ -194,7 +171,7 @@ void update_cpu_power(unsigned int cpu, unsigned long hwid)
>  
>  #else
>  static inline void parse_dt_topology(void) {}
> -static inline void update_cpu_power(unsigned int cpuid, unsigned int mpidr) {}
> +static inline void update_cpu_power(unsigned int cpuid) {}
>  #endif
>  
>   /*
> @@ -281,7 +258,7 @@ void store_cpu_topology(unsigned int cpuid)
>  
>  	update_siblings_masks(cpuid);
>  
> -	update_cpu_power(cpuid, mpidr & MPIDR_HWID_BITMASK);
> +	update_cpu_power(cpuid);
>  
>  	printk(KERN_INFO "CPU%u: thread %d, cpu %d, socket %d, mpidr %x\n",
>  		cpuid, cpu_topology[cpuid].thread_id,
> -- 
> 1.8.1.2
> 
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
> 

  reply	other threads:[~2013-07-22 14:25 UTC|newest]

Thread overview: 127+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-17 14:06 [RFC PATCH v2 00/15] DT/core: update cpu device of_node Sudeep.KarkadaNagesha
2013-07-17 14:06 ` [RFC PATCH v2 01/15] of: add support for retrieving cpu node for a given logical cpu index Sudeep.KarkadaNagesha
2013-07-17 14:30   ` Nicolas Pitre
2013-07-17 14:50   ` Rob Herring
2013-07-17 15:18     ` Sudeep KarkadaNagesha
2013-07-17 14:06 ` [RFC PATCH v2 02/15] driver/core: cpu: initialize of_node in cpu's device struture Sudeep.KarkadaNagesha
2013-07-17 14:06 ` [RFC PATCH v2 03/15] ARM: DT/kernel: define ARM specific arch_match_cpu_phys_id Sudeep.KarkadaNagesha
2013-07-17 14:06 ` [RFC PATCH v2 04/15] ARM: topology: remove hwid/MPIDR dependency from cpu_capacity Sudeep.KarkadaNagesha
2013-07-17 14:06 ` [RFC PATCH v2 05/15] ARM: mvebu: remove device tree parsing for cpu nodes Sudeep.KarkadaNagesha
2013-07-17 14:06 ` [RFC PATCH v2 06/15] drivers/bus: arm-cci: avoid parsing DT for cpu device nodes Sudeep.KarkadaNagesha
2013-07-17 14:06 ` [RFC PATCH v2 07/15] cpufreq: imx6q-cpufreq: remove device tree parsing for cpu nodes Sudeep.KarkadaNagesha
2013-07-17 14:06 ` [RFC PATCH v2 08/15] cpufreq: cpufreq-cpu0: " Sudeep.KarkadaNagesha
2013-07-17 14:06 ` [RFC PATCH v2 09/15] cpufreq: highbank-cpufreq: " Sudeep.KarkadaNagesha
2013-07-17 14:06 ` [RFC PATCH v2 10/15] cpufreq: spear-cpufreq: " Sudeep.KarkadaNagesha
2013-07-17 14:06 ` [RFC PATCH v2 11/15] cpufreq: kirkwood-cpufreq: " Sudeep.KarkadaNagesha
2013-07-17 14:43   ` Andrew Lunn
2013-07-18  7:53     ` Viresh Kumar
2013-07-18  8:24     ` Sudeep KarkadaNagesha
2013-07-18 10:14       ` Sudeep KarkadaNagesha
2013-07-18 18:30         ` Rob Herring
2013-07-17 14:06 ` [RFC PATCH v2 12/15] cpufreq: arm_big_little: " Sudeep.KarkadaNagesha
2013-07-17 14:06 ` [RFC PATCH v2 13/15] cpufreq: maple-cpufreq: " Sudeep.KarkadaNagesha
2013-07-17 14:06 ` [RFC PATCH v2 14/15] cpufreq: pmac64-cpufreq: " Sudeep.KarkadaNagesha
2013-07-17 14:06 ` [RFC PATCH v2 15/15] cpufreq: pmac32-cpufreq: " Sudeep.KarkadaNagesha
2013-07-18  7:54 ` [RFC PATCH v2 00/15] DT/core: update cpu device of_node Viresh Kumar
2013-07-22 11:32 ` [PATCH v3 00/16] " Sudeep KarkadaNagesha
2013-07-22 11:32   ` [PATCH v3 01/16] of: add support for retrieving cpu node for a given logical cpu index Sudeep KarkadaNagesha
2013-07-22 14:14     ` Nicolas Pitre
2013-07-22 15:07       ` Sudeep KarkadaNagesha
2013-07-23 10:54         ` Sudeep KarkadaNagesha
2013-08-15 11:32     ` Tomasz Figa
2013-08-15 14:59       ` Sudeep KarkadaNagesha
2013-07-22 11:32   ` [PATCH v3 02/16] ARM: DT/kernel: define ARM specific arch_match_cpu_phys_id Sudeep KarkadaNagesha
2013-07-22 14:14     ` Nicolas Pitre
2013-07-22 11:32   ` [PATCH v3 03/16] driver/core: cpu: initialize of_node in cpu's device struture Sudeep KarkadaNagesha
2013-08-15 11:35     ` Tomasz Figa
2013-08-15 15:13       ` Sudeep KarkadaNagesha
2013-07-22 11:32   ` [PATCH v3 04/16] ARM: topology: remove hwid/MPIDR dependency from cpu_capacity Sudeep KarkadaNagesha
2013-07-22 14:25     ` Nicolas Pitre [this message]
2013-07-22 11:32   ` [PATCH v3 05/16] ARM: mvebu: remove device tree parsing for cpu nodes Sudeep KarkadaNagesha
2013-08-01  9:54     ` Sudeep KarkadaNagesha
2013-08-01 12:02       ` Jason Cooper
2013-08-05 16:28         ` Sudeep KarkadaNagesha
2013-08-06  8:25           ` Gregory CLEMENT
2013-08-06  9:02             ` Sudeep KarkadaNagesha
2013-07-22 11:32   ` [PATCH v3 06/16] drivers/bus: arm-cci: avoid parsing DT for cpu device nodes Sudeep KarkadaNagesha
2013-07-22 14:37     ` Nicolas Pitre
2013-07-22 11:32   ` [PATCH v3 07/16] of/device: add helper to get cpu device node from logical cpu index Sudeep KarkadaNagesha
2013-07-26 17:01     ` Sudeep KarkadaNagesha
2013-07-26 18:55       ` Rob Herring
2013-07-22 11:32   ` [PATCH v3 08/16] cpufreq: imx6q-cpufreq: remove device tree parsing for cpu nodes Sudeep KarkadaNagesha
2013-07-22 11:32   ` [PATCH v3 09/16] cpufreq: cpufreq-cpu0: " Sudeep KarkadaNagesha
2013-07-22 11:32   ` [PATCH v3 10/16] cpufreq: highbank-cpufreq: " Sudeep KarkadaNagesha
2013-07-22 11:32   ` [PATCH v3 11/16] cpufreq: spear-cpufreq: " Sudeep KarkadaNagesha
2013-07-22 11:32   ` [PATCH v3 12/16] cpufreq: kirkwood-cpufreq: " Sudeep KarkadaNagesha
2013-07-23  9:25     ` Andrew Lunn
2013-07-22 11:32   ` [PATCH v3 13/16] cpufreq: arm_big_little: " Sudeep KarkadaNagesha
2013-07-22 11:32   ` [PATCH v3 14/16] cpufreq: maple-cpufreq: " Sudeep KarkadaNagesha
2013-07-22 11:32   ` [PATCH v3 15/16] cpufreq: pmac64-cpufreq: " Sudeep KarkadaNagesha
2013-07-22 11:32   ` [PATCH v3 16/16] cpufreq: pmac32-cpufreq: " Sudeep KarkadaNagesha
2013-08-01 10:05   ` [PATCH v3 00/16] DT/core: update cpu device of_node Sudeep KarkadaNagesha
2013-08-15 17:09   ` [RFC PATCH 0/4] DT: move of_get_cpu_node from PPC to DT core Sudeep KarkadaNagesha
2013-08-15 17:09     ` [RFC PATCH 1/4] microblaze: remove undefined of_get_cpu_node declaration Sudeep KarkadaNagesha
2013-08-15 17:09     ` [RFC PATCH 2/4] openrisc: " Sudeep KarkadaNagesha
2013-08-16  9:41       ` Sudeep KarkadaNagesha
2013-08-21  5:10         ` Jonas Bonn
2013-08-15 17:09     ` [RFC PATCH 3/4] powerpc: refactor of_get_cpu_node to support other architectures Sudeep KarkadaNagesha
2013-08-16  4:49       ` Benjamin Herrenschmidt
2013-08-16  8:48         ` Sudeep KarkadaNagesha
2013-08-16 12:32           ` Benjamin Herrenschmidt
2013-08-16 12:44             ` Sudeep KarkadaNagesha
2013-08-16  4:50       ` Benjamin Herrenschmidt
2013-08-16  8:43         ` Sudeep KarkadaNagesha
2013-08-15 17:09     ` [RFC PATCH 4/4] of: move of_get_cpu_node implementation to DT core library Sudeep KarkadaNagesha
2013-08-16 17:39     ` [RFC PATCH v2 0/4] DT: move of_get_cpu_node from PPC to DT core Sudeep KarkadaNagesha
2013-08-16 17:39       ` [RFC PATCH v2 3/4] powerpc: refactor of_get_cpu_node to support other architectures Sudeep KarkadaNagesha
2013-08-16 22:13         ` Benjamin Herrenschmidt
2013-08-19 10:13           ` Sudeep KarkadaNagesha
2013-08-17 10:50         ` Tomasz Figa
2013-08-17 22:09           ` Benjamin Herrenschmidt
2013-08-17 22:22             ` Tomasz Figa
2013-08-19 10:19             ` Mark Rutland
2013-08-19 13:02               ` Rob Herring
2013-08-19 13:56                 ` Sudeep KarkadaNagesha
2013-08-22 13:59                   ` Mark Rutland
2013-08-22 16:51                     ` Sudeep KarkadaNagesha
2013-08-28 19:46                     ` Grant Likely
2013-08-29  9:50                       ` Lorenzo Pieralisi
2013-08-16 17:39       ` [RFC PATCH v2 4/4] of: move of_get_cpu_node implementation to DT core library Sudeep KarkadaNagesha
2013-08-16 22:14         ` Benjamin Herrenschmidt
2013-08-19 10:21           ` Sudeep KarkadaNagesha
2013-08-19 13:11         ` Rob Herring
2013-08-19 13:24           ` Sudeep KarkadaNagesha
2013-08-20  9:30   ` [PATCH v4 00/19] DT/core: update cpu device of_node Sudeep KarkadaNagesha
2013-08-20  9:30     ` [PATCH v4 01/19] microblaze: remove undefined of_get_cpu_node declaration Sudeep KarkadaNagesha
2013-08-20  9:30     ` [PATCH v4 02/19] openrisc: " Sudeep KarkadaNagesha
2013-08-20  9:30     ` [PATCH v4 03/19] powerpc: refactor of_get_cpu_node to support other architectures Sudeep KarkadaNagesha
2013-08-20 12:27       ` Rafael J. Wysocki
2013-08-20 12:22         ` Sudeep KarkadaNagesha
2013-08-20 21:48           ` Benjamin Herrenschmidt
2013-08-22  6:15       ` Benjamin Herrenschmidt
2013-08-22 13:29         ` Sudeep KarkadaNagesha
2013-08-20  9:30     ` [PATCH v4 04/19] of: move of_get_cpu_node implementation to DT core library Sudeep KarkadaNagesha
2013-08-20  9:30     ` [PATCH v4 05/19] ARM: DT/kernel: define ARM specific arch_match_cpu_phys_id Sudeep KarkadaNagesha
2013-08-20  9:30     ` [PATCH v4 06/19] driver/core: cpu: initialize of_node in cpu's device struture Sudeep KarkadaNagesha
2013-08-20 12:28       ` Rafael J. Wysocki
2013-08-20 15:18       ` Greg Kroah-Hartman
2013-08-20  9:30     ` [PATCH v4 07/19] of/device: add helper to get cpu device node from logical cpu index Sudeep KarkadaNagesha
2013-08-20  9:30     ` [PATCH v4 08/19] ARM: topology: remove hwid/MPIDR dependency from cpu_capacity Sudeep KarkadaNagesha
2013-08-20  9:30     ` [PATCH v4 09/19] ARM: mvebu: remove device tree parsing for cpu nodes Sudeep KarkadaNagesha
2013-08-20  9:30     ` [PATCH v4 10/19] drivers/bus: arm-cci: avoid parsing DT for cpu device nodes Sudeep KarkadaNagesha
2013-08-20  9:30     ` [PATCH v4 11/19] cpufreq: imx6q-cpufreq: remove device tree parsing for cpu nodes Sudeep KarkadaNagesha
2013-08-20  9:30     ` [PATCH v4 12/19] cpufreq: cpufreq-cpu0: " Sudeep KarkadaNagesha
2013-09-06 13:44       ` Guennadi Liakhovetski
2013-09-09  9:24         ` Sudeep KarkadaNagesha
2013-09-09 14:32           ` Shawn Guo
2013-09-09 15:24             ` Sudeep KarkadaNagesha
2013-09-10  2:44               ` Shawn Guo
2013-09-10 10:56                 ` Sudeep KarkadaNagesha
2013-09-10 11:19                   ` Shawn Guo
2013-08-20  9:30     ` [PATCH v4 13/19] cpufreq: highbank-cpufreq: " Sudeep KarkadaNagesha
2013-08-20  9:30     ` [PATCH v4 14/19] cpufreq: spear-cpufreq: " Sudeep KarkadaNagesha
2013-08-20  9:30     ` [PATCH v4 15/19] cpufreq: kirkwood-cpufreq: " Sudeep KarkadaNagesha
2013-08-20  9:30     ` [PATCH v4 16/19] cpufreq: arm_big_little: " Sudeep KarkadaNagesha
2013-08-20  9:30     ` [PATCH v4 17/19] cpufreq: maple-cpufreq: " Sudeep KarkadaNagesha
2013-08-20  9:30     ` [PATCH v4 18/19] cpufreq: pmac64-cpufreq: " Sudeep KarkadaNagesha
2013-08-20  9:30     ` [PATCH v4 19/19] cpufreq: pmac32-cpufreq: " Sudeep KarkadaNagesha

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.LFD.2.03.1307221024370.15022@syhkavp.arg \
    --to=nicolas.pitre@linaro.org \
    --cc=Sudeep.KarkadaNagesha@arm.com \
    --cc=arnd@arndb.de \
    --cc=cpufreq@vger.kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=grant.likely@linaro.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=gregory.clement@free-electrons.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=lorenzo.pieralisi@arm.com \
    --cc=olof@lixom.net \
    --cc=rjw@sisk.pl \
    --cc=rob.herring@calxeda.com \
    --cc=shawn.guo@linaro.org \
    --cc=viresh.kumar@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®