linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/2] pseries: Fix endian issues in onlining cpu threads
@ 2014-09-12 19:11 Thomas Falcon
  2014-09-12 19:11 ` [PATCH v2 2/2] pseries: Fix endian issues in cpu hot-removal Thomas Falcon
  2014-09-15  3:01 ` [PATCH v2 1/2] pseries: Fix endian issues in onlining cpu threads Michael Ellerman
  0 siblings, 2 replies; 5+ messages in thread
From: Thomas Falcon @ 2014-09-12 19:11 UTC (permalink / raw)
  To: mpe; +Cc: Thomas Falcon, linuxppc-dev

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 c2806c8..9e9f30b2 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] 5+ messages in thread

* [PATCH v2 2/2] pseries: Fix endian issues in cpu hot-removal
  2014-09-12 19:11 [PATCH v2 1/2] pseries: Fix endian issues in onlining cpu threads Thomas Falcon
@ 2014-09-12 19:11 ` Thomas Falcon
  2014-09-15  6:46   ` Bharata B Rao
  2014-09-15  3:01 ` [PATCH v2 1/2] pseries: Fix endian issues in onlining cpu threads Michael Ellerman
  1 sibling, 1 reply; 5+ messages in thread
From: Thomas Falcon @ 2014-09-12 19:11 UTC (permalink / raw)
  To: mpe; +Cc: Thomas Falcon, linuxppc-dev

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 v2:

 Followed suggestions from Michael Ellerman:
   Conversion of intserv to cpu endian occurs once.
   Conversion of drc_index to cpu endian occurs once
   using of_property_read_u32.
---
 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 9e9f30b2..343dfdf 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;
+	const 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] 5+ messages in thread

* Re: [PATCH v2 1/2] pseries: Fix endian issues in onlining cpu threads
  2014-09-12 19:11 [PATCH v2 1/2] pseries: Fix endian issues in onlining cpu threads Thomas Falcon
  2014-09-12 19:11 ` [PATCH v2 2/2] pseries: Fix endian issues in cpu hot-removal Thomas Falcon
@ 2014-09-15  3:01 ` Michael Ellerman
  1 sibling, 0 replies; 5+ messages in thread
From: Michael Ellerman @ 2014-09-15  3:01 UTC (permalink / raw)
  To: Thomas Falcon; +Cc: Nathan Fontenot, linuxppc-dev

On Fri, 2014-09-12 at 14:11 -0500, 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>
> ---
> Changes in v2:
> 
>  Followed suggestions from Michael Ellerman
>    conversion of intserv values occur once

Thanks Tom.

I think I saw that you'd already discussed these with Nathan in another thread,
so I'll assume he's OK with them unless he says otherwise.

cheers

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

* Re: [PATCH v2 2/2] pseries: Fix endian issues in cpu hot-removal
  2014-09-12 19:11 ` [PATCH v2 2/2] pseries: Fix endian issues in cpu hot-removal Thomas Falcon
@ 2014-09-15  6:46   ` Bharata B Rao
  2014-09-16  7:00     ` Michael Ellerman
  0 siblings, 1 reply; 5+ messages in thread
From: Bharata B Rao @ 2014-09-15  6:46 UTC (permalink / raw)
  To: Thomas Falcon; +Cc: linuxppc-dev

On Sat, Sep 13, 2014 at 12:41 AM, Thomas Falcon
<tlfalcon@linux.vnet.ibm.com> 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>
> ---
> Changes in v2:
>
>  Followed suggestions from Michael Ellerman:
>    Conversion of intserv to cpu endian occurs once.
>    Conversion of drc_index to cpu endian occurs once
>    using of_property_read_u32.
> ---
>  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/platfo=
rms/pseries/dlpar.c
> index 9e9f30b2..343dfdf 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 =3D 0;
>         unsigned int cpu;
>         int len, nthreads, i;
> -       const u32 *intserv;
> +       const __be32 *intserv;
> +       u32 thread;
>
>         intserv =3D of_get_property(dn, "ibm,ppc-interrupt-server#s", &le=
n);
>         if (!intserv)
> @@ -454,8 +455,9 @@ static int dlpar_offline_cpu(struct device_node *dn)
>
>         cpu_maps_update_begin();
>         for (i =3D 0; i < nthreads; i++) {
> +               thread =3D be32_to_cpu(intserv[i]);
>                 for_each_present_cpu(cpu) {
> -                       if (get_hard_smp_processor_id(cpu) !=3D intserv[i=
])
> +                       if (get_hard_smp_processor_id(cpu) !=3D thread)
>                                 continue;
>
>                         if (get_cpu_current_state(cpu) =3D=3D CPU_STATE_O=
FFLINE)
> @@ -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_OFFLIN=
E);
> -                       BUG_ON(plpar_hcall_norets(H_PROD, intserv[i])
> +                       BUG_ON(plpar_hcall_norets(H_PROD, thread)
>                                                                 !=3D H_SU=
CCESS);
>                         __cpu_die(cpu);
>                         break;
>                 }
>                 if (cpu =3D=3D num_possible_cpus())
>                         printk(KERN_WARNING "Could not find cpu to offlin=
e "
> -                              "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;
> +       const u32 drc_index;
>         int rc;
>
>         dn =3D of_find_node_by_path(buf);
>         if (!dn)
>                 return -EINVAL;
>
> -       drc_index =3D of_get_property(dn, "ibm,my-drc-index", NULL);
> -       if (!drc_index) {
> +       rc =3D of_property_read_u32(dn, "ibm,my-drc-index", &drc_index);

Use of const for drc_index causes compilation problems.

Warning on Fedora 20 BE

arch/powerpc/platforms/pseries/dlpar.c: In function =E2=80=98dlpar_cpu_rele=
ase=E2=80=99:
arch/powerpc/platforms/pseries/dlpar.c:508:2: warning: passing
argument 3 of =E2=80=98of_property_read_u32=E2=80=99 discards =E2=80=98cons=
t=E2=80=99 qualifier from
pointer target type [enabled by default]
  rc =3D of_property_read_u32(dn, "ibm,my-drc-index", &drc_index);
  ^
In file included from arch/powerpc/platforms/pseries/dlpar.c:18:0:
include/linux/of.h:699:19: note: expected =E2=80=98u32 *=E2=80=99 but argum=
ent is of
type =E2=80=98const u32 *=E2=80=99
 static inline int of_property_read_u32(const struct device_node *np,

Error on Ubuntu 14.04 LE

arch/powerpc/platforms/pseries/dlpar.c: In function =E2=80=98dlpar_cpu_rele=
ase=E2=80=99:
arch/powerpc/platforms/pseries/dlpar.c:508:2: error: passing argument
3 of =E2=80=98of_property_read_u32=E2=80=99 discards =E2=80=98const=E2=80=
=99 qualifier from pointer
target type [-Werror]
  rc =3D of_property_read_u32(dn, "ibm,my-drc-index", &drc_index);
  ^
In file included from arch/powerpc/platforms/pseries/dlpar.c:18:0:
include/linux/of.h:699:19: note: expected =E2=80=98u32 *=E2=80=99 but argum=
ent is of
type =E2=80=98const u32 *=E2=80=99
 static inline int of_property_read_u32(const struct device_node *np,
                   ^
cc1: all warnings being treated as errors

Regards,
Bharata.

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

* Re: [PATCH v2 2/2] pseries: Fix endian issues in cpu hot-removal
  2014-09-15  6:46   ` Bharata B Rao
@ 2014-09-16  7:00     ` Michael Ellerman
  0 siblings, 0 replies; 5+ messages in thread
From: Michael Ellerman @ 2014-09-16  7:00 UTC (permalink / raw)
  To: Bharata B Rao; +Cc: linuxppc-dev, Thomas Falcon

On Mon, 2014-09-15 at 12:16 +0530, Bharata B Rao wrote:
> On Sat, Sep 13, 2014 at 12:41 AM, Thomas Falcon
> <tlfalcon@linux.vnet.ibm.com> wrote:
> >
> > diff --git a/arch/powerpc/platforms/pseries/dlpar.c b/arch/powerpc/platforms/pseries/dlpar.c
> > index 9e9f30b2..343dfdf 100644
> > --- a/arch/powerpc/platforms/pseries/dlpar.c
> > +++ b/arch/powerpc/platforms/pseries/dlpar.c
> > @@ -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;
> > +       const 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);
> 
> Use of const for drc_index causes compilation problems.

Yes that's clearly wrong.

Please fix and retest.

cheers

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

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

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-12 19:11 [PATCH v2 1/2] pseries: Fix endian issues in onlining cpu threads Thomas Falcon
2014-09-12 19:11 ` [PATCH v2 2/2] pseries: Fix endian issues in cpu hot-removal Thomas Falcon
2014-09-15  6:46   ` Bharata B Rao
2014-09-16  7:00     ` Michael Ellerman
2014-09-15  3:01 ` [PATCH v2 1/2] pseries: Fix endian issues in onlining cpu threads Michael Ellerman

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