linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/2] powerpc: Pull out cpu_core_mask updates into a separate function
@ 2013-08-12  6:28 Paul Mackerras
  2013-08-12  6:29 ` [PATCH v2 2/2] powerpc: Use ibm,chip-id property to compute cpu_core_mask if available Paul Mackerras
  0 siblings, 1 reply; 3+ messages in thread
From: Paul Mackerras @ 2013-08-12  6:28 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Vasant Hegde, Stephen Rothwell

This factors out the details of updating cpu_core_mask into a separate
function, to make it easier to change how the mask is calculated later.
This makes no functional change.

Signed-off-by: Paul Mackerras <paulus@samba.org>
---
v2: add is bool

 arch/powerpc/kernel/smp.c | 56 +++++++++++++++++++++++------------------------
 1 file changed, 28 insertions(+), 28 deletions(-)

diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c
index 38b0ba6..1568525 100644
--- a/arch/powerpc/kernel/smp.c
+++ b/arch/powerpc/kernel/smp.c
@@ -609,11 +609,36 @@ static struct device_node *cpu_to_l2cache(int cpu)
 	return cache;
 }
 
+static void traverse_core_siblings(int cpu, bool add)
+{
+	struct device_node *l2_cache;
+	const struct cpumask *mask;
+	int i;
+
+	l2_cache = cpu_to_l2cache(cpu);
+	mask = add ? cpu_online_mask : cpu_present_mask;
+	for_each_cpu(i, mask) {
+		struct device_node *np = cpu_to_l2cache(i);
+		if (!np)
+			continue;
+		if (np == l2_cache) {
+			if (add) {
+				cpumask_set_cpu(cpu, cpu_core_mask(i));
+				cpumask_set_cpu(i, cpu_core_mask(cpu));
+			} else {
+				cpumask_clear_cpu(cpu, cpu_core_mask(i));
+				cpumask_clear_cpu(i, cpu_core_mask(cpu));
+			}
+		}
+		of_node_put(np);
+	}
+	of_node_put(l2_cache);
+}
+
 /* Activate a secondary processor. */
 void start_secondary(void *unused)
 {
 	unsigned int cpu = smp_processor_id();
-	struct device_node *l2_cache;
 	int i, base;
 
 	atomic_inc(&init_mm.mm_count);
@@ -652,18 +677,7 @@ void start_secondary(void *unused)
 		cpumask_set_cpu(cpu, cpu_core_mask(base + i));
 		cpumask_set_cpu(base + i, cpu_core_mask(cpu));
 	}
-	l2_cache = cpu_to_l2cache(cpu);
-	for_each_online_cpu(i) {
-		struct device_node *np = cpu_to_l2cache(i);
-		if (!np)
-			continue;
-		if (np == l2_cache) {
-			cpumask_set_cpu(cpu, cpu_core_mask(i));
-			cpumask_set_cpu(i, cpu_core_mask(cpu));
-		}
-		of_node_put(np);
-	}
-	of_node_put(l2_cache);
+	traverse_core_siblings(cpu, true);
 
 	smp_wmb();
 	notify_cpu_starting(cpu);
@@ -719,7 +733,6 @@ int arch_sd_sibling_asym_packing(void)
 #ifdef CONFIG_HOTPLUG_CPU
 int __cpu_disable(void)
 {
-	struct device_node *l2_cache;
 	int cpu = smp_processor_id();
 	int base, i;
 	int err;
@@ -739,20 +752,7 @@ int __cpu_disable(void)
 		cpumask_clear_cpu(cpu, cpu_core_mask(base + i));
 		cpumask_clear_cpu(base + i, cpu_core_mask(cpu));
 	}
-
-	l2_cache = cpu_to_l2cache(cpu);
-	for_each_present_cpu(i) {
-		struct device_node *np = cpu_to_l2cache(i);
-		if (!np)
-			continue;
-		if (np == l2_cache) {
-			cpumask_clear_cpu(cpu, cpu_core_mask(i));
-			cpumask_clear_cpu(i, cpu_core_mask(cpu));
-		}
-		of_node_put(np);
-	}
-	of_node_put(l2_cache);
-
+	traverse_core_siblings(cpu, false);
 
 	return 0;
 }
-- 
1.8.4.rc2

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH v2 2/2] powerpc: Use ibm,chip-id property to compute cpu_core_mask if available
  2013-08-12  6:28 [PATCH v2 1/2] powerpc: Pull out cpu_core_mask updates into a separate function Paul Mackerras
@ 2013-08-12  6:29 ` Paul Mackerras
  2013-08-12  7:55   ` [PATCH v2 2/2] powerpc: Use ibm, chip-id " Vasant Hegde
  0 siblings, 1 reply; 3+ messages in thread
From: Paul Mackerras @ 2013-08-12  6:29 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Vasant Hegde, Stephen Rothwell

Some systems have an ibm,chip-id property in the cpu nodes in the
device tree.  On these systems, we now use that to compute the
cpu_core_mask (i.e. the set of core siblings) rather than looking
at cache properties.

Signed-off-by: Paul Mackerras <paulus@samba.org>
---
v2: add is bool, use of_read_number

 arch/powerpc/kernel/smp.c | 48 ++++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 45 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c
index 1568525..a4137de 100644
--- a/arch/powerpc/kernel/smp.c
+++ b/arch/powerpc/kernel/smp.c
@@ -587,6 +587,33 @@ int cpu_first_thread_of_core(int core)
 }
 EXPORT_SYMBOL_GPL(cpu_first_thread_of_core);
 
+static void traverse_siblings_chip_id(int cpu, bool add, int chipid)
+{
+	const struct cpumask *mask;
+	struct device_node *np;
+	int i, plen;
+	const __be32 *prop;
+
+	mask = add ? cpu_online_mask : cpu_present_mask;
+	for_each_cpu(i, mask) {
+		np = of_get_cpu_node(i, NULL);
+		if (!np)
+			continue;
+		prop = of_get_property(np, "ibm,chip-id", &plen);
+		if (prop && plen == sizeof(int) &&
+		    of_read_number(prop, 1) == chipid) {
+			if (add) {
+				cpumask_set_cpu(cpu, cpu_core_mask(i));
+				cpumask_set_cpu(i, cpu_core_mask(cpu));
+			} else {
+				cpumask_clear_cpu(cpu, cpu_core_mask(i));
+				cpumask_clear_cpu(i, cpu_core_mask(cpu));
+			}
+		}
+		of_node_put(np);
+	}
+}
+
 /* Must be called when no change can occur to cpu_present_mask,
  * i.e. during cpu online or offline.
  */
@@ -611,14 +638,29 @@ static struct device_node *cpu_to_l2cache(int cpu)
 
 static void traverse_core_siblings(int cpu, bool add)
 {
-	struct device_node *l2_cache;
+	struct device_node *l2_cache, *np;
 	const struct cpumask *mask;
-	int i;
+	int i, chip, plen;
+	const __be32 *prop;
+
+	/* First see if we have ibm,chip-id properties in cpu nodes */
+	np = of_get_cpu_node(cpu, NULL);
+	if (np) {
+		chip = -1;
+		prop = of_get_property(np, "ibm,chip-id", &plen);
+		if (prop && plen == sizeof(int))
+			chip = of_read_number(prop, 1);
+		of_node_put(np);
+		if (chip >= 0) {
+			traverse_siblings_chip_id(cpu, add, chip);
+			return;
+		}
+	}
 
 	l2_cache = cpu_to_l2cache(cpu);
 	mask = add ? cpu_online_mask : cpu_present_mask;
 	for_each_cpu(i, mask) {
-		struct device_node *np = cpu_to_l2cache(i);
+		np = cpu_to_l2cache(i);
 		if (!np)
 			continue;
 		if (np == l2_cache) {
-- 
1.8.4.rc2

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2 2/2] powerpc: Use ibm, chip-id property to compute cpu_core_mask if available
  2013-08-12  6:29 ` [PATCH v2 2/2] powerpc: Use ibm,chip-id property to compute cpu_core_mask if available Paul Mackerras
@ 2013-08-12  7:55   ` Vasant Hegde
  0 siblings, 0 replies; 3+ messages in thread
From: Vasant Hegde @ 2013-08-12  7:55 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: linuxppc-dev, Stephen Rothwell

On 08/12/2013 11:59 AM, Paul Mackerras wrote:
> Some systems have an ibm,chip-id property in the cpu nodes in the
> device tree.  On these systems, we now use that to compute the
> cpu_core_mask (i.e. the set of core siblings) rather than looking
> at cache properties.

Looks fine.

Tested-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>

-Vasant

>
> Signed-off-by: Paul Mackerras <paulus@samba.org>
> ---
> v2: add is bool, use of_read_number
>
>   arch/powerpc/kernel/smp.c | 48 ++++++++++++++++++++++++++++++++++++++++++++---
>   1 file changed, 45 insertions(+), 3 deletions(-)
>
> diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c
> index 1568525..a4137de 100644
> --- a/arch/powerpc/kernel/smp.c
> +++ b/arch/powerpc/kernel/smp.c
> @@ -587,6 +587,33 @@ int cpu_first_thread_of_core(int core)
>   }
>   EXPORT_SYMBOL_GPL(cpu_first_thread_of_core);
>
> +static void traverse_siblings_chip_id(int cpu, bool add, int chipid)
> +{
> +	const struct cpumask *mask;
> +	struct device_node *np;
> +	int i, plen;
> +	const __be32 *prop;
> +
> +	mask = add ? cpu_online_mask : cpu_present_mask;
> +	for_each_cpu(i, mask) {
> +		np = of_get_cpu_node(i, NULL);
> +		if (!np)
> +			continue;
> +		prop = of_get_property(np, "ibm,chip-id", &plen);
> +		if (prop && plen == sizeof(int) &&
> +		    of_read_number(prop, 1) == chipid) {
> +			if (add) {
> +				cpumask_set_cpu(cpu, cpu_core_mask(i));
> +				cpumask_set_cpu(i, cpu_core_mask(cpu));
> +			} else {
> +				cpumask_clear_cpu(cpu, cpu_core_mask(i));
> +				cpumask_clear_cpu(i, cpu_core_mask(cpu));
> +			}
> +		}
> +		of_node_put(np);
> +	}
> +}
> +
>   /* Must be called when no change can occur to cpu_present_mask,
>    * i.e. during cpu online or offline.
>    */
> @@ -611,14 +638,29 @@ static struct device_node *cpu_to_l2cache(int cpu)
>
>   static void traverse_core_siblings(int cpu, bool add)
>   {
> -	struct device_node *l2_cache;
> +	struct device_node *l2_cache, *np;
>   	const struct cpumask *mask;
> -	int i;
> +	int i, chip, plen;
> +	const __be32 *prop;
> +
> +	/* First see if we have ibm,chip-id properties in cpu nodes */
> +	np = of_get_cpu_node(cpu, NULL);
> +	if (np) {
> +		chip = -1;
> +		prop = of_get_property(np, "ibm,chip-id", &plen);
> +		if (prop && plen == sizeof(int))
> +			chip = of_read_number(prop, 1);
> +		of_node_put(np);
> +		if (chip >= 0) {
> +			traverse_siblings_chip_id(cpu, add, chip);
> +			return;
> +		}
> +	}
>
>   	l2_cache = cpu_to_l2cache(cpu);
>   	mask = add ? cpu_online_mask : cpu_present_mask;
>   	for_each_cpu(i, mask) {
> -		struct device_node *np = cpu_to_l2cache(i);
> +		np = cpu_to_l2cache(i);
>   		if (!np)
>   			continue;
>   		if (np == l2_cache) {
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-08-12  7:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-12  6:28 [PATCH v2 1/2] powerpc: Pull out cpu_core_mask updates into a separate function Paul Mackerras
2013-08-12  6:29 ` [PATCH v2 2/2] powerpc: Use ibm,chip-id property to compute cpu_core_mask if available Paul Mackerras
2013-08-12  7:55   ` [PATCH v2 2/2] powerpc: Use ibm, chip-id " Vasant Hegde

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).