Re: [PATCH] pseries: Fix endianness in cpu hotplug and hotremove

2014-09-08 Thread Nathan Fontenot
It looks like you have a lot of the same changes as the patch Bharata
sent out last week. Including the one issue I saw in Bharata's patch
below.

On 09/05/2014 02:09 PM, Thomas Falcon wrote:
 This patch attempts to ensure that all values are in the proper
 endianness format when both hotadding and hotremoving cpus.
 
 Signed-off-by: Thomas Falcon tlfal...@linux.vnet.ibm.com
 ---
  arch/powerpc/platforms/pseries/dlpar.c   | 56 
 ++--
  arch/powerpc/platforms/pseries/hotplug-cpu.c | 20 +-
  2 files changed, 38 insertions(+), 38 deletions(-)
 
 diff --git a/arch/powerpc/platforms/pseries/dlpar.c 
 b/arch/powerpc/platforms/pseries/dlpar.c
 index a2450b8..c1d7e40 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);
 @@ -148,7 +148,7 @@ struct device_node *dlpar_configure_connector(u32 
 drc_index,
   return NULL;
  
   ccwa = (struct cc_workarea *)data_buf[0];
 - ccwa-drc_index = drc_index;
 + ccwa-drc_index = cpu_to_be32(drc_index);

This will break partition migration.

The drc index valued passed into dlpar_configure_connector() from the migration
path, pseries_devicetree_update(), is already in BE format.

-Nathan

   ccwa-zero = 0;
  
   do {
 @@ -363,10 +363,10 @@ 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_be;
  
 - intserv = of_get_property(dn, ibm,ppc-interrupt-server#s, len);
 - if (!intserv)
 + intserv_be = of_get_property(dn, ibm,ppc-interrupt-server#s, len);
 + if (!intserv_be)
   return -EINVAL;
  
   nthreads = len / sizeof(u32);
 @@ -374,7 +374,7 @@ static int dlpar_online_cpu(struct device_node *dn)
   cpu_maps_update_begin();
   for (i = 0; i  nthreads; i++) {
   for_each_present_cpu(cpu) {
 - if (get_hard_smp_processor_id(cpu) != intserv[i])
 + if (get_hard_smp_processor_id(cpu) != 
 be32_to_cpu(intserv_be[i]))
   continue;
   BUG_ON(get_cpu_current_state(cpu)
   != CPU_STATE_OFFLINE);
 @@ -388,7 +388,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, 
 be32_to_cpu(intserv_be[i]));
   }
   cpu_maps_update_done();
  
 @@ -442,18 +442,17 @@ 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_be;
  
 - intserv = of_get_property(dn, ibm,ppc-interrupt-server#s, len);
 - if (!intserv)
 + intserv_be = of_get_property(dn, ibm,ppc-interrupt-server#s, len);
 + if (!intserv_be)
   return -EINVAL;
  
   nthreads = len / sizeof(u32);
 -
   cpu_maps_update_begin();
   for (i = 0; i  nthreads; i++) {
   for_each_present_cpu(cpu) {
 - if (get_hard_smp_processor_id(cpu) != intserv[i])
 + if (get_hard_smp_processor_id(cpu) != 
 be32_to_cpu(intserv_be[i]))
   continue;
  
   if (get_cpu_current_state(cpu) == CPU_STATE_OFFLINE)
 @@ -469,20 +468,19 @@ static int dlpar_offline_cpu(struct 

Re: [PATCH] pseries: Fix endianness in cpu hotplug and hotremove

2014-09-08 Thread Thomas Falcon
I guess we were both working on it independently.  I had made the 
changes to hotplug a cpu a few weeks ago, but was blocked on removing a 
cpu.  Last week I realized what was blocking me and fixed cpu removal, 
so I sent the patch along.  Since Bharata has already submitted a patch 
that will handle hotplugging, I'll resubmit this with only the changes 
needed to remove a cpu.


Tom

On 09/08/2014 09:07 AM, Nathan Fontenot wrote:

It looks like you have a lot of the same changes as the patch Bharata
sent out last week. Including the one issue I saw in Bharata's patch
below.

On 09/05/2014 02:09 PM, Thomas Falcon wrote:

This patch attempts to ensure that all values are in the proper
endianness format when both hotadding and hotremoving cpus.

Signed-off-by: Thomas Falcon tlfal...@linux.vnet.ibm.com
---
  arch/powerpc/platforms/pseries/dlpar.c   | 56 ++--
  arch/powerpc/platforms/pseries/hotplug-cpu.c | 20 +-
  2 files changed, 38 insertions(+), 38 deletions(-)

diff --git a/arch/powerpc/platforms/pseries/dlpar.c 
b/arch/powerpc/platforms/pseries/dlpar.c
index a2450b8..c1d7e40 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);
@@ -148,7 +148,7 @@ struct device_node *dlpar_configure_connector(u32 drc_index,
return NULL;
  
  	ccwa = (struct cc_workarea *)data_buf[0];

-   ccwa-drc_index = drc_index;
+   ccwa-drc_index = cpu_to_be32(drc_index);

This will break partition migration.

The drc index valued passed into dlpar_configure_connector() from the migration
path, pseries_devicetree_update(), is already in BE format.

-Nathan


ccwa-zero = 0;
  
  	do {

@@ -363,10 +363,10 @@ 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_be;
  
-	intserv = of_get_property(dn, ibm,ppc-interrupt-server#s, len);

-   if (!intserv)
+   intserv_be = of_get_property(dn, ibm,ppc-interrupt-server#s, len);
+   if (!intserv_be)
return -EINVAL;
  
  	nthreads = len / sizeof(u32);

@@ -374,7 +374,7 @@ static int dlpar_online_cpu(struct device_node *dn)
cpu_maps_update_begin();
for (i = 0; i  nthreads; i++) {
for_each_present_cpu(cpu) {
-   if (get_hard_smp_processor_id(cpu) != intserv[i])
+   if (get_hard_smp_processor_id(cpu) != 
be32_to_cpu(intserv_be[i]))
continue;
BUG_ON(get_cpu_current_state(cpu)
!= CPU_STATE_OFFLINE);
@@ -388,7 +388,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, 
be32_to_cpu(intserv_be[i]));
}
cpu_maps_update_done();
  
@@ -442,18 +442,17 @@ 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_be;
  
-	intserv = of_get_property(dn, ibm,ppc-interrupt-server#s, len);

-   if (!intserv)
+   intserv_be = of_get_property(dn, ibm,ppc-interrupt-server#s, len);
+   if (!intserv_be)
return -EINVAL;
  
  	nthreads = len / sizeof(u32);

-

[PATCH] pseries: Fix endianness in cpu hotplug and hotremove

2014-09-05 Thread Thomas Falcon
This patch attempts to ensure that all values are in the proper
endianness format when both hotadding and hotremoving cpus.

Signed-off-by: Thomas Falcon tlfal...@linux.vnet.ibm.com
---
 arch/powerpc/platforms/pseries/dlpar.c   | 56 ++--
 arch/powerpc/platforms/pseries/hotplug-cpu.c | 20 +-
 2 files changed, 38 insertions(+), 38 deletions(-)

diff --git a/arch/powerpc/platforms/pseries/dlpar.c 
b/arch/powerpc/platforms/pseries/dlpar.c
index a2450b8..c1d7e40 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);
@@ -148,7 +148,7 @@ struct device_node *dlpar_configure_connector(u32 drc_index,
return NULL;
 
ccwa = (struct cc_workarea *)data_buf[0];
-   ccwa-drc_index = drc_index;
+   ccwa-drc_index = cpu_to_be32(drc_index);
ccwa-zero = 0;
 
do {
@@ -363,10 +363,10 @@ 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_be;
 
-   intserv = of_get_property(dn, ibm,ppc-interrupt-server#s, len);
-   if (!intserv)
+   intserv_be = of_get_property(dn, ibm,ppc-interrupt-server#s, len);
+   if (!intserv_be)
return -EINVAL;
 
nthreads = len / sizeof(u32);
@@ -374,7 +374,7 @@ static int dlpar_online_cpu(struct device_node *dn)
cpu_maps_update_begin();
for (i = 0; i  nthreads; i++) {
for_each_present_cpu(cpu) {
-   if (get_hard_smp_processor_id(cpu) != intserv[i])
+   if (get_hard_smp_processor_id(cpu) != 
be32_to_cpu(intserv_be[i]))
continue;
BUG_ON(get_cpu_current_state(cpu)
!= CPU_STATE_OFFLINE);
@@ -388,7 +388,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, 
be32_to_cpu(intserv_be[i]));
}
cpu_maps_update_done();
 
@@ -442,18 +442,17 @@ 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_be;
 
-   intserv = of_get_property(dn, ibm,ppc-interrupt-server#s, len);
-   if (!intserv)
+   intserv_be = of_get_property(dn, ibm,ppc-interrupt-server#s, len);
+   if (!intserv_be)
return -EINVAL;
 
nthreads = len / sizeof(u32);
-
cpu_maps_update_begin();
for (i = 0; i  nthreads; i++) {
for_each_present_cpu(cpu) {
-   if (get_hard_smp_processor_id(cpu) != intserv[i])
+   if (get_hard_smp_processor_id(cpu) != 
be32_to_cpu(intserv_be[i]))
continue;
 
if (get_cpu_current_state(cpu) == CPU_STATE_OFFLINE)
@@ -469,20 +468,19 @@ static int dlpar_offline_cpu(struct device_node *dn)
break;
 
}
-
/*
 * The cpu is in CPU_STATE_INACTIVE.
 * Upgrade it's state to CPU_STATE_OFFLINE.
 */
set_preferred_offline_state(cpu, CPU_STATE_OFFLINE);
-