linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] pseries: Make CPU hotplug and hotremove endian safe
@ 2014-09-16 20:15 Thomas Falcon
  2014-09-16 20:15 ` [PATCH v2 1/3] pseries: Make CPU hotplug path " Thomas Falcon
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Thomas Falcon @ 2014-09-16 20:15 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: nfont, bharata, Thomas Falcon

This patchset ensures that cpu hotplugging and hotremoval are 
compatible with both big and little endian architectures.  

Bharata B Rao (1):
  pseries: Make CPU hotplug path endian safe

Thomas Falcon (2):
  pseries: Fix endian issues in onlining cpu threads
  pseries: Fix endian issues in cpu hot-removal

 arch/powerpc/platforms/pseries/dlpar.c       | 50 +++++++++++++++-------------
 arch/powerpc/platforms/pseries/hotplug-cpu.c | 14 ++++----
 arch/powerpc/platforms/pseries/pseries.h     |  3 +-
 3 files changed, 37 insertions(+), 30 deletions(-)

-- 
1.8.5.2

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

* [PATCH v2 1/3] pseries: Make CPU hotplug path endian safe
  2014-09-16 20:15 [PATCH 0/3] pseries: Make CPU hotplug and hotremove endian safe Thomas Falcon
@ 2014-09-16 20:15 ` Thomas Falcon
  2014-09-24 20:15   ` Nathan Fontenot
  2014-09-16 20:15 ` [PATCH v2 2/3] pseries: Fix endian issues in onlining cpu threads Thomas Falcon
  2014-09-16 20:15 ` [PATCH v3 3/3] pseries: Fix endian issues in cpu hot-removal Thomas Falcon
  2 siblings, 1 reply; 7+ messages in thread
From: Thomas Falcon @ 2014-09-16 20:15 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: nfont, bharata, Thomas Falcon

From: Bharata B Rao <bharata@linux.vnet.ibm.com>

- ibm,rtas-configure-connector should treat the RTAS data as big endian.
- Treat ibm,ppc-interrupt-server#s as big-endian when setting
  smp_processor_id during hotplug.

Signed-off-by: Bharata B Rao <bharata@linux.vnet.ibm.com>
Signed-off-by: Thomas Falcon <tlfalcon@linux.vnet.ibm.com>
---

Changes in v2:
- Don't convert drc_index to BE in dlpar_configure_connector() but instead
  convert in the caller dlpar_cpu_probe() so that migration path isn't
  affected.
- Mark members of cc_workarea struct as __be32 instead of u32 (Thomas)
- Based on top of Thomas Falcon's two patches.
  (http://patchwork.ozlabs.org/patch/388767/)

v1: http://patchwork.ozlabs.org/patch/386216/

 arch/powerpc/platforms/pseries/dlpar.c       | 22 +++++++++++-----------
 arch/powerpc/platforms/pseries/hotplug-cpu.c |  4 ++--
 arch/powerpc/platforms/pseries/pseries.h     |  3 ++-
 3 files changed, 15 insertions(+), 14 deletions(-)

diff --git a/arch/powerpc/platforms/pseries/dlpar.c b/arch/powerpc/platforms/pseries/dlpar.c
index a2450b8..5acbe59 100644
--- a/arch/powerpc/platforms/pseries/dlpar.c
+++ b/arch/powerpc/platforms/pseries/dlpar.c
@@ -24,11 +24,11 @@
 #include <asm/rtas.h>
 
 struct cc_workarea {
-	u32	drc_index;
-	u32	zero;
-	u32	name_offset;
-	u32	prop_length;
-	u32	prop_offset;
+	__be32	drc_index;
+	__be32	zero;
+	__be32	name_offset;
+	__be32	prop_length;
+	__be32	prop_offset;
 };
 
 void dlpar_free_cc_property(struct property *prop)
@@ -48,11 +48,11 @@ static struct property *dlpar_parse_cc_property(struct cc_workarea *ccwa)
 	if (!prop)
 		return NULL;
 
-	name = (char *)ccwa + ccwa->name_offset;
+	name = (char *)ccwa + be32_to_cpu(ccwa->name_offset);
 	prop->name = kstrdup(name, GFP_KERNEL);
 
-	prop->length = ccwa->prop_length;
-	value = (char *)ccwa + ccwa->prop_offset;
+	prop->length = be32_to_cpu(ccwa->prop_length);
+	value = (char *)ccwa + be32_to_cpu(ccwa->prop_offset);
 	prop->value = kmemdup(value, prop->length, GFP_KERNEL);
 	if (!prop->value) {
 		dlpar_free_cc_property(prop);
@@ -78,7 +78,7 @@ static struct device_node *dlpar_parse_cc_node(struct cc_workarea *ccwa,
 	if (!dn)
 		return NULL;
 
-	name = (char *)ccwa + ccwa->name_offset;
+	name = (char *)ccwa + be32_to_cpu(ccwa->name_offset);
 	dn->full_name = kasprintf(GFP_KERNEL, "%s/%s", path, name);
 	if (!dn->full_name) {
 		kfree(dn);
@@ -125,7 +125,7 @@ void dlpar_free_cc_nodes(struct device_node *dn)
 #define CALL_AGAIN	-2
 #define ERR_CFG_USE     -9003
 
-struct device_node *dlpar_configure_connector(u32 drc_index,
+struct device_node *dlpar_configure_connector(__be32 drc_index,
 					      struct device_node *parent)
 {
 	struct device_node *dn;
@@ -411,7 +411,7 @@ static ssize_t dlpar_cpu_probe(const char *buf, size_t count)
 	if (!parent)
 		return -ENODEV;
 
-	dn = dlpar_configure_connector(drc_index, parent);
+	dn = dlpar_configure_connector(cpu_to_be32(drc_index), parent);
 	if (!dn)
 		return -EINVAL;
 
diff --git a/arch/powerpc/platforms/pseries/hotplug-cpu.c b/arch/powerpc/platforms/pseries/hotplug-cpu.c
index 20d6297..447f8c6 100644
--- a/arch/powerpc/platforms/pseries/hotplug-cpu.c
+++ b/arch/powerpc/platforms/pseries/hotplug-cpu.c
@@ -247,7 +247,7 @@ static int pseries_add_processor(struct device_node *np)
 	unsigned int cpu;
 	cpumask_var_t candidate_mask, tmp;
 	int err = -ENOSPC, len, nthreads, i;
-	const u32 *intserv;
+	const __be32 *intserv;
 
 	intserv = of_get_property(np, "ibm,ppc-interrupt-server#s", &len);
 	if (!intserv)
@@ -293,7 +293,7 @@ static int pseries_add_processor(struct device_node *np)
 	for_each_cpu(cpu, tmp) {
 		BUG_ON(cpu_present(cpu));
 		set_cpu_present(cpu, true);
-		set_hard_smp_processor_id(cpu, *intserv++);
+		set_hard_smp_processor_id(cpu, be32_to_cpu(*intserv++));
 	}
 	err = 0;
 out_unlock:
diff --git a/arch/powerpc/platforms/pseries/pseries.h b/arch/powerpc/platforms/pseries/pseries.h
index 361add6..1796c54 100644
--- a/arch/powerpc/platforms/pseries/pseries.h
+++ b/arch/powerpc/platforms/pseries/pseries.h
@@ -56,7 +56,8 @@ extern void hvc_vio_init_early(void);
 /* Dynamic logical Partitioning/Mobility */
 extern void dlpar_free_cc_nodes(struct device_node *);
 extern void dlpar_free_cc_property(struct property *);
-extern struct device_node *dlpar_configure_connector(u32, struct device_node *);
+extern struct device_node *dlpar_configure_connector(__be32,
+						struct device_node *);
 extern int dlpar_attach_node(struct device_node *);
 extern int dlpar_detach_node(struct device_node *);
 
-- 
1.8.5.2

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

* [PATCH v2 2/3] pseries: Fix endian issues in onlining cpu threads
  2014-09-16 20:15 [PATCH 0/3] pseries: Make CPU hotplug and hotremove endian safe Thomas Falcon
  2014-09-16 20:15 ` [PATCH v2 1/3] pseries: Make CPU hotplug path " Thomas Falcon
@ 2014-09-16 20:15 ` Thomas Falcon
  2014-09-24 20:15   ` Nathan Fontenot
  2014-09-16 20:15 ` [PATCH v3 3/3] pseries: Fix endian issues in cpu hot-removal Thomas Falcon
  2 siblings, 1 reply; 7+ messages in thread
From: Thomas Falcon @ 2014-09-16 20:15 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: nfont, bharata, Thomas Falcon

The ibm,ppc-interrupt-server#s property is in big endian format.
These values need to be converted when used by little endian
architectures.

Signed-off-by: Thomas Falcon <tlfalcon@linux.vnet.ibm.com>
---
Changes in v2:

 Followed suggestions from Michael Ellerman
   conversion of intserv values occur once
---
 arch/powerpc/platforms/pseries/dlpar.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/platforms/pseries/dlpar.c b/arch/powerpc/platforms/pseries/dlpar.c
index 5acbe59..187e4eb 100644
--- a/arch/powerpc/platforms/pseries/dlpar.c
+++ b/arch/powerpc/platforms/pseries/dlpar.c
@@ -363,7 +363,8 @@ static int dlpar_online_cpu(struct device_node *dn)
 	int rc = 0;
 	unsigned int cpu;
 	int len, nthreads, i;
-	const u32 *intserv;
+	const __be32 *intserv;
+	u32 thread;
 
 	intserv = of_get_property(dn, "ibm,ppc-interrupt-server#s", &len);
 	if (!intserv)
@@ -373,8 +374,9 @@ static int dlpar_online_cpu(struct device_node *dn)
 
 	cpu_maps_update_begin();
 	for (i = 0; i < nthreads; i++) {
+		thread = be32_to_cpu(intserv[i]);
 		for_each_present_cpu(cpu) {
-			if (get_hard_smp_processor_id(cpu) != intserv[i])
+			if (get_hard_smp_processor_id(cpu) != thread)
 				continue;
 			BUG_ON(get_cpu_current_state(cpu)
 					!= CPU_STATE_OFFLINE);
@@ -388,7 +390,7 @@ static int dlpar_online_cpu(struct device_node *dn)
 		}
 		if (cpu == num_possible_cpus())
 			printk(KERN_WARNING "Could not find cpu to online "
-			       "with physical id 0x%x\n", intserv[i]);
+			       "with physical id 0x%x\n", thread);
 	}
 	cpu_maps_update_done();
 
-- 
1.8.5.2

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

* [PATCH v3 3/3] pseries: Fix endian issues in cpu hot-removal
  2014-09-16 20:15 [PATCH 0/3] pseries: Make CPU hotplug and hotremove endian safe Thomas Falcon
  2014-09-16 20:15 ` [PATCH v2 1/3] pseries: Make CPU hotplug path " Thomas Falcon
  2014-09-16 20:15 ` [PATCH v2 2/3] pseries: Fix endian issues in onlining cpu threads Thomas Falcon
@ 2014-09-16 20:15 ` Thomas Falcon
  2014-09-24 20:16   ` Nathan Fontenot
  2 siblings, 1 reply; 7+ messages in thread
From: Thomas Falcon @ 2014-09-16 20:15 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: nfont, bharata, Thomas Falcon

When removing a cpu, this patch makes sure that values
gotten from or passed to firmware are in the correct
endian format.

Signed-off-by: Thomas Falcon <tlfalcon@linux.vnet.ibm.com>
---
Changes in v3:

 drc_index in dlpar_cpu_release is no longer const to
 fix compilation error found by Bharata Rao
---
 arch/powerpc/platforms/pseries/dlpar.c       | 20 +++++++++++---------
 arch/powerpc/platforms/pseries/hotplug-cpu.c | 10 ++++++----
 2 files changed, 17 insertions(+), 13 deletions(-)

diff --git a/arch/powerpc/platforms/pseries/dlpar.c b/arch/powerpc/platforms/pseries/dlpar.c
index 187e4eb..0fad5b6 100644
--- a/arch/powerpc/platforms/pseries/dlpar.c
+++ b/arch/powerpc/platforms/pseries/dlpar.c
@@ -444,7 +444,8 @@ static int dlpar_offline_cpu(struct device_node *dn)
 	int rc = 0;
 	unsigned int cpu;
 	int len, nthreads, i;
-	const u32 *intserv;
+	const __be32 *intserv;
+	u32 thread;
 
 	intserv = of_get_property(dn, "ibm,ppc-interrupt-server#s", &len);
 	if (!intserv)
@@ -454,8 +455,9 @@ static int dlpar_offline_cpu(struct device_node *dn)
 
 	cpu_maps_update_begin();
 	for (i = 0; i < nthreads; i++) {
+		thread = be32_to_cpu(intserv[i]);
 		for_each_present_cpu(cpu) {
-			if (get_hard_smp_processor_id(cpu) != intserv[i])
+			if (get_hard_smp_processor_id(cpu) != thread)
 				continue;
 
 			if (get_cpu_current_state(cpu) == CPU_STATE_OFFLINE)
@@ -477,14 +479,14 @@ static int dlpar_offline_cpu(struct device_node *dn)
 			 * Upgrade it's state to CPU_STATE_OFFLINE.
 			 */
 			set_preferred_offline_state(cpu, CPU_STATE_OFFLINE);
-			BUG_ON(plpar_hcall_norets(H_PROD, intserv[i])
+			BUG_ON(plpar_hcall_norets(H_PROD, thread)
 								!= H_SUCCESS);
 			__cpu_die(cpu);
 			break;
 		}
 		if (cpu == num_possible_cpus())
 			printk(KERN_WARNING "Could not find cpu to offline "
-			       "with physical id 0x%x\n", intserv[i]);
+			       "with physical id 0x%x\n", thread);
 	}
 	cpu_maps_update_done();
 
@@ -496,15 +498,15 @@ out:
 static ssize_t dlpar_cpu_release(const char *buf, size_t count)
 {
 	struct device_node *dn;
-	const u32 *drc_index;
+	u32 drc_index;
 	int rc;
 
 	dn = of_find_node_by_path(buf);
 	if (!dn)
 		return -EINVAL;
 
-	drc_index = of_get_property(dn, "ibm,my-drc-index", NULL);
-	if (!drc_index) {
+	rc = of_property_read_u32(dn, "ibm,my-drc-index", &drc_index);
+	if (rc) {
 		of_node_put(dn);
 		return -EINVAL;
 	}
@@ -515,7 +517,7 @@ static ssize_t dlpar_cpu_release(const char *buf, size_t count)
 		return -EINVAL;
 	}
 
-	rc = dlpar_release_drc(*drc_index);
+	rc = dlpar_release_drc(drc_index);
 	if (rc) {
 		of_node_put(dn);
 		return rc;
@@ -523,7 +525,7 @@ static ssize_t dlpar_cpu_release(const char *buf, size_t count)
 
 	rc = dlpar_detach_node(dn);
 	if (rc) {
-		dlpar_acquire_drc(*drc_index);
+		dlpar_acquire_drc(drc_index);
 		return rc;
 	}
 
diff --git a/arch/powerpc/platforms/pseries/hotplug-cpu.c b/arch/powerpc/platforms/pseries/hotplug-cpu.c
index 447f8c6..5c375f9 100644
--- a/arch/powerpc/platforms/pseries/hotplug-cpu.c
+++ b/arch/powerpc/platforms/pseries/hotplug-cpu.c
@@ -90,7 +90,7 @@ static void rtas_stop_self(void)
 {
 	static struct rtas_args args = {
 		.nargs = 0,
-		.nret = 1,
+		.nret = cpu_to_be32(1),
 		.rets = &args.args[0],
 	};
 
@@ -312,7 +312,8 @@ static void pseries_remove_processor(struct device_node *np)
 {
 	unsigned int cpu;
 	int len, nthreads, i;
-	const u32 *intserv;
+	const __be32 *intserv;
+	u32 thread;
 
 	intserv = of_get_property(np, "ibm,ppc-interrupt-server#s", &len);
 	if (!intserv)
@@ -322,8 +323,9 @@ static void pseries_remove_processor(struct device_node *np)
 
 	cpu_maps_update_begin();
 	for (i = 0; i < nthreads; i++) {
+		thread = be32_to_cpu(intserv[i]);
 		for_each_present_cpu(cpu) {
-			if (get_hard_smp_processor_id(cpu) != intserv[i])
+			if (get_hard_smp_processor_id(cpu) != thread)
 				continue;
 			BUG_ON(cpu_online(cpu));
 			set_cpu_present(cpu, false);
@@ -332,7 +334,7 @@ static void pseries_remove_processor(struct device_node *np)
 		}
 		if (cpu >= nr_cpu_ids)
 			printk(KERN_WARNING "Could not find cpu to remove "
-			       "with physical id 0x%x\n", intserv[i]);
+			       "with physical id 0x%x\n", thread);
 	}
 	cpu_maps_update_done();
 }
-- 
1.8.5.2

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

* Re: [PATCH v2 1/3] pseries: Make CPU hotplug path endian safe
  2014-09-16 20:15 ` [PATCH v2 1/3] pseries: Make CPU hotplug path " Thomas Falcon
@ 2014-09-24 20:15   ` Nathan Fontenot
  0 siblings, 0 replies; 7+ messages in thread
From: Nathan Fontenot @ 2014-09-24 20:15 UTC (permalink / raw)
  To: Thomas Falcon, linuxppc-dev; +Cc: bharata

On 09/16/2014 03:15 PM, Thomas Falcon wrote:
> From: Bharata B Rao <bharata@linux.vnet.ibm.com>
> 
> - ibm,rtas-configure-connector should treat the RTAS data as big endian.
> - Treat ibm,ppc-interrupt-server#s as big-endian when setting
>   smp_processor_id during hotplug.
> 
> Signed-off-by: Bharata B Rao <bharata@linux.vnet.ibm.com>
> Signed-off-by: Thomas Falcon <tlfalcon@linux.vnet.ibm.com>

Acked-by: Nathan Fontenot <nfont@linux.vnet.ibm.com>

> ---
> 
> Changes in v2:
> - Don't convert drc_index to BE in dlpar_configure_connector() but instead
>   convert in the caller dlpar_cpu_probe() so that migration path isn't
>   affected.
> - Mark members of cc_workarea struct as __be32 instead of u32 (Thomas)
> - Based on top of Thomas Falcon's two patches.
>   (http://patchwork.ozlabs.org/patch/388767/)
> 
> v1: http://patchwork.ozlabs.org/patch/386216/
> 
>  arch/powerpc/platforms/pseries/dlpar.c       | 22 +++++++++++-----------
>  arch/powerpc/platforms/pseries/hotplug-cpu.c |  4 ++--
>  arch/powerpc/platforms/pseries/pseries.h     |  3 ++-
>  3 files changed, 15 insertions(+), 14 deletions(-)
> 
> diff --git a/arch/powerpc/platforms/pseries/dlpar.c b/arch/powerpc/platforms/pseries/dlpar.c
> index a2450b8..5acbe59 100644
> --- a/arch/powerpc/platforms/pseries/dlpar.c
> +++ b/arch/powerpc/platforms/pseries/dlpar.c
> @@ -24,11 +24,11 @@
>  #include <asm/rtas.h>
>  
>  struct cc_workarea {
> -	u32	drc_index;
> -	u32	zero;
> -	u32	name_offset;
> -	u32	prop_length;
> -	u32	prop_offset;
> +	__be32	drc_index;
> +	__be32	zero;
> +	__be32	name_offset;
> +	__be32	prop_length;
> +	__be32	prop_offset;
>  };
>  
>  void dlpar_free_cc_property(struct property *prop)
> @@ -48,11 +48,11 @@ static struct property *dlpar_parse_cc_property(struct cc_workarea *ccwa)
>  	if (!prop)
>  		return NULL;
>  
> -	name = (char *)ccwa + ccwa->name_offset;
> +	name = (char *)ccwa + be32_to_cpu(ccwa->name_offset);
>  	prop->name = kstrdup(name, GFP_KERNEL);
>  
> -	prop->length = ccwa->prop_length;
> -	value = (char *)ccwa + ccwa->prop_offset;
> +	prop->length = be32_to_cpu(ccwa->prop_length);
> +	value = (char *)ccwa + be32_to_cpu(ccwa->prop_offset);
>  	prop->value = kmemdup(value, prop->length, GFP_KERNEL);
>  	if (!prop->value) {
>  		dlpar_free_cc_property(prop);
> @@ -78,7 +78,7 @@ static struct device_node *dlpar_parse_cc_node(struct cc_workarea *ccwa,
>  	if (!dn)
>  		return NULL;
>  
> -	name = (char *)ccwa + ccwa->name_offset;
> +	name = (char *)ccwa + be32_to_cpu(ccwa->name_offset);
>  	dn->full_name = kasprintf(GFP_KERNEL, "%s/%s", path, name);
>  	if (!dn->full_name) {
>  		kfree(dn);
> @@ -125,7 +125,7 @@ void dlpar_free_cc_nodes(struct device_node *dn)
>  #define CALL_AGAIN	-2
>  #define ERR_CFG_USE     -9003
>  
> -struct device_node *dlpar_configure_connector(u32 drc_index,
> +struct device_node *dlpar_configure_connector(__be32 drc_index,
>  					      struct device_node *parent)
>  {
>  	struct device_node *dn;
> @@ -411,7 +411,7 @@ static ssize_t dlpar_cpu_probe(const char *buf, size_t count)
>  	if (!parent)
>  		return -ENODEV;
>  
> -	dn = dlpar_configure_connector(drc_index, parent);
> +	dn = dlpar_configure_connector(cpu_to_be32(drc_index), parent);
>  	if (!dn)
>  		return -EINVAL;
>  
> diff --git a/arch/powerpc/platforms/pseries/hotplug-cpu.c b/arch/powerpc/platforms/pseries/hotplug-cpu.c
> index 20d6297..447f8c6 100644
> --- a/arch/powerpc/platforms/pseries/hotplug-cpu.c
> +++ b/arch/powerpc/platforms/pseries/hotplug-cpu.c
> @@ -247,7 +247,7 @@ static int pseries_add_processor(struct device_node *np)
>  	unsigned int cpu;
>  	cpumask_var_t candidate_mask, tmp;
>  	int err = -ENOSPC, len, nthreads, i;
> -	const u32 *intserv;
> +	const __be32 *intserv;
>  
>  	intserv = of_get_property(np, "ibm,ppc-interrupt-server#s", &len);
>  	if (!intserv)
> @@ -293,7 +293,7 @@ static int pseries_add_processor(struct device_node *np)
>  	for_each_cpu(cpu, tmp) {
>  		BUG_ON(cpu_present(cpu));
>  		set_cpu_present(cpu, true);
> -		set_hard_smp_processor_id(cpu, *intserv++);
> +		set_hard_smp_processor_id(cpu, be32_to_cpu(*intserv++));
>  	}
>  	err = 0;
>  out_unlock:
> diff --git a/arch/powerpc/platforms/pseries/pseries.h b/arch/powerpc/platforms/pseries/pseries.h
> index 361add6..1796c54 100644
> --- a/arch/powerpc/platforms/pseries/pseries.h
> +++ b/arch/powerpc/platforms/pseries/pseries.h
> @@ -56,7 +56,8 @@ extern void hvc_vio_init_early(void);
>  /* Dynamic logical Partitioning/Mobility */
>  extern void dlpar_free_cc_nodes(struct device_node *);
>  extern void dlpar_free_cc_property(struct property *);
> -extern struct device_node *dlpar_configure_connector(u32, struct device_node *);
> +extern struct device_node *dlpar_configure_connector(__be32,
> +						struct device_node *);
>  extern int dlpar_attach_node(struct device_node *);
>  extern int dlpar_detach_node(struct device_node *);
>  
> 

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

* Re: [PATCH v2 2/3] pseries: Fix endian issues in onlining cpu threads
  2014-09-16 20:15 ` [PATCH v2 2/3] pseries: Fix endian issues in onlining cpu threads Thomas Falcon
@ 2014-09-24 20:15   ` Nathan Fontenot
  0 siblings, 0 replies; 7+ messages in thread
From: Nathan Fontenot @ 2014-09-24 20:15 UTC (permalink / raw)
  To: Thomas Falcon, linuxppc-dev; +Cc: bharata

On 09/16/2014 03:15 PM, Thomas Falcon wrote:
> The ibm,ppc-interrupt-server#s property is in big endian format.
> These values need to be converted when used by little endian
> architectures.
> 
> Signed-off-by: Thomas Falcon <tlfalcon@linux.vnet.ibm.com>

Acked-by: Nathan Fontenot <nfont@linux.vnet.ibm.com>

> ---
> Changes in v2:
> 
>  Followed suggestions from Michael Ellerman
>    conversion of intserv values occur once
> ---
>  arch/powerpc/platforms/pseries/dlpar.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/powerpc/platforms/pseries/dlpar.c b/arch/powerpc/platforms/pseries/dlpar.c
> index 5acbe59..187e4eb 100644
> --- a/arch/powerpc/platforms/pseries/dlpar.c
> +++ b/arch/powerpc/platforms/pseries/dlpar.c
> @@ -363,7 +363,8 @@ static int dlpar_online_cpu(struct device_node *dn)
>  	int rc = 0;
>  	unsigned int cpu;
>  	int len, nthreads, i;
> -	const u32 *intserv;
> +	const __be32 *intserv;
> +	u32 thread;
>  
>  	intserv = of_get_property(dn, "ibm,ppc-interrupt-server#s", &len);
>  	if (!intserv)
> @@ -373,8 +374,9 @@ static int dlpar_online_cpu(struct device_node *dn)
>  
>  	cpu_maps_update_begin();
>  	for (i = 0; i < nthreads; i++) {
> +		thread = be32_to_cpu(intserv[i]);
>  		for_each_present_cpu(cpu) {
> -			if (get_hard_smp_processor_id(cpu) != intserv[i])
> +			if (get_hard_smp_processor_id(cpu) != thread)
>  				continue;
>  			BUG_ON(get_cpu_current_state(cpu)
>  					!= CPU_STATE_OFFLINE);
> @@ -388,7 +390,7 @@ static int dlpar_online_cpu(struct device_node *dn)
>  		}
>  		if (cpu == num_possible_cpus())
>  			printk(KERN_WARNING "Could not find cpu to online "
> -			       "with physical id 0x%x\n", intserv[i]);
> +			       "with physical id 0x%x\n", thread);
>  	}
>  	cpu_maps_update_done();
>  
> 

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

* Re: [PATCH v3 3/3] pseries: Fix endian issues in cpu hot-removal
  2014-09-16 20:15 ` [PATCH v3 3/3] pseries: Fix endian issues in cpu hot-removal Thomas Falcon
@ 2014-09-24 20:16   ` Nathan Fontenot
  0 siblings, 0 replies; 7+ messages in thread
From: Nathan Fontenot @ 2014-09-24 20:16 UTC (permalink / raw)
  To: Thomas Falcon, linuxppc-dev; +Cc: bharata

On 09/16/2014 03:15 PM, Thomas Falcon wrote:
> When removing a cpu, this patch makes sure that values
> gotten from or passed to firmware are in the correct
> endian format.
> 
> Signed-off-by: Thomas Falcon <tlfalcon@linux.vnet.ibm.com>

Acked-by: Nathan Fontenot <nfont@linux.vnet.ibm.com>

> ---
> Changes in v3:
> 
>  drc_index in dlpar_cpu_release is no longer const to
>  fix compilation error found by Bharata Rao
> ---
>  arch/powerpc/platforms/pseries/dlpar.c       | 20 +++++++++++---------
>  arch/powerpc/platforms/pseries/hotplug-cpu.c | 10 ++++++----
>  2 files changed, 17 insertions(+), 13 deletions(-)
> 
> diff --git a/arch/powerpc/platforms/pseries/dlpar.c b/arch/powerpc/platforms/pseries/dlpar.c
> index 187e4eb..0fad5b6 100644
> --- a/arch/powerpc/platforms/pseries/dlpar.c
> +++ b/arch/powerpc/platforms/pseries/dlpar.c
> @@ -444,7 +444,8 @@ static int dlpar_offline_cpu(struct device_node *dn)
>  	int rc = 0;
>  	unsigned int cpu;
>  	int len, nthreads, i;
> -	const u32 *intserv;
> +	const __be32 *intserv;
> +	u32 thread;
>  
>  	intserv = of_get_property(dn, "ibm,ppc-interrupt-server#s", &len);
>  	if (!intserv)
> @@ -454,8 +455,9 @@ static int dlpar_offline_cpu(struct device_node *dn)
>  
>  	cpu_maps_update_begin();
>  	for (i = 0; i < nthreads; i++) {
> +		thread = be32_to_cpu(intserv[i]);
>  		for_each_present_cpu(cpu) {
> -			if (get_hard_smp_processor_id(cpu) != intserv[i])
> +			if (get_hard_smp_processor_id(cpu) != thread)
>  				continue;
>  
>  			if (get_cpu_current_state(cpu) == CPU_STATE_OFFLINE)
> @@ -477,14 +479,14 @@ static int dlpar_offline_cpu(struct device_node *dn)
>  			 * Upgrade it's state to CPU_STATE_OFFLINE.
>  			 */
>  			set_preferred_offline_state(cpu, CPU_STATE_OFFLINE);
> -			BUG_ON(plpar_hcall_norets(H_PROD, intserv[i])
> +			BUG_ON(plpar_hcall_norets(H_PROD, thread)
>  								!= H_SUCCESS);
>  			__cpu_die(cpu);
>  			break;
>  		}
>  		if (cpu == num_possible_cpus())
>  			printk(KERN_WARNING "Could not find cpu to offline "
> -			       "with physical id 0x%x\n", intserv[i]);
> +			       "with physical id 0x%x\n", thread);
>  	}
>  	cpu_maps_update_done();
>  
> @@ -496,15 +498,15 @@ out:
>  static ssize_t dlpar_cpu_release(const char *buf, size_t count)
>  {
>  	struct device_node *dn;
> -	const u32 *drc_index;
> +	u32 drc_index;
>  	int rc;
>  
>  	dn = of_find_node_by_path(buf);
>  	if (!dn)
>  		return -EINVAL;
>  
> -	drc_index = of_get_property(dn, "ibm,my-drc-index", NULL);
> -	if (!drc_index) {
> +	rc = of_property_read_u32(dn, "ibm,my-drc-index", &drc_index);
> +	if (rc) {
>  		of_node_put(dn);
>  		return -EINVAL;
>  	}
> @@ -515,7 +517,7 @@ static ssize_t dlpar_cpu_release(const char *buf, size_t count)
>  		return -EINVAL;
>  	}
>  
> -	rc = dlpar_release_drc(*drc_index);
> +	rc = dlpar_release_drc(drc_index);
>  	if (rc) {
>  		of_node_put(dn);
>  		return rc;
> @@ -523,7 +525,7 @@ static ssize_t dlpar_cpu_release(const char *buf, size_t count)
>  
>  	rc = dlpar_detach_node(dn);
>  	if (rc) {
> -		dlpar_acquire_drc(*drc_index);
> +		dlpar_acquire_drc(drc_index);
>  		return rc;
>  	}
>  
> diff --git a/arch/powerpc/platforms/pseries/hotplug-cpu.c b/arch/powerpc/platforms/pseries/hotplug-cpu.c
> index 447f8c6..5c375f9 100644
> --- a/arch/powerpc/platforms/pseries/hotplug-cpu.c
> +++ b/arch/powerpc/platforms/pseries/hotplug-cpu.c
> @@ -90,7 +90,7 @@ static void rtas_stop_self(void)
>  {
>  	static struct rtas_args args = {
>  		.nargs = 0,
> -		.nret = 1,
> +		.nret = cpu_to_be32(1),
>  		.rets = &args.args[0],
>  	};
>  
> @@ -312,7 +312,8 @@ static void pseries_remove_processor(struct device_node *np)
>  {
>  	unsigned int cpu;
>  	int len, nthreads, i;
> -	const u32 *intserv;
> +	const __be32 *intserv;
> +	u32 thread;
>  
>  	intserv = of_get_property(np, "ibm,ppc-interrupt-server#s", &len);
>  	if (!intserv)
> @@ -322,8 +323,9 @@ static void pseries_remove_processor(struct device_node *np)
>  
>  	cpu_maps_update_begin();
>  	for (i = 0; i < nthreads; i++) {
> +		thread = be32_to_cpu(intserv[i]);
>  		for_each_present_cpu(cpu) {
> -			if (get_hard_smp_processor_id(cpu) != intserv[i])
> +			if (get_hard_smp_processor_id(cpu) != thread)
>  				continue;
>  			BUG_ON(cpu_online(cpu));
>  			set_cpu_present(cpu, false);
> @@ -332,7 +334,7 @@ static void pseries_remove_processor(struct device_node *np)
>  		}
>  		if (cpu >= nr_cpu_ids)
>  			printk(KERN_WARNING "Could not find cpu to remove "
> -			       "with physical id 0x%x\n", intserv[i]);
> +			       "with physical id 0x%x\n", thread);
>  	}
>  	cpu_maps_update_done();
>  }
> 

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

end of thread, other threads:[~2014-09-24 20:16 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-16 20:15 [PATCH 0/3] pseries: Make CPU hotplug and hotremove endian safe Thomas Falcon
2014-09-16 20:15 ` [PATCH v2 1/3] pseries: Make CPU hotplug path " Thomas Falcon
2014-09-24 20:15   ` Nathan Fontenot
2014-09-16 20:15 ` [PATCH v2 2/3] pseries: Fix endian issues in onlining cpu threads Thomas Falcon
2014-09-24 20:15   ` Nathan Fontenot
2014-09-16 20:15 ` [PATCH v3 3/3] pseries: Fix endian issues in cpu hot-removal Thomas Falcon
2014-09-24 20:16   ` Nathan Fontenot

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).