2013-08-28 18:20:19

by Rob Herring

[permalink] [raw]
Subject: [PATCH v2] ARM: xen: only set pm function ptrs for Xen guests

From: Rob Herring <[email protected]>

xen_pm_init was unconditionally setting pm_power_off and arm_pm_restart
function pointers. This breaks multi-platform kernels. Make this
conditional on running as a Xen guest and make it a late_initcall to
ensure it is setup after platform code for Dom0.

Cc: Stefano Stabellini <[email protected]>
Signed-off-by: Rob Herring <[email protected]>
---
arch/arm/xen/enlighten.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c
index 8a6295c..13a7d1f 100644
--- a/arch/arm/xen/enlighten.c
+++ b/arch/arm/xen/enlighten.c
@@ -273,12 +273,15 @@ core_initcall(xen_guest_init);

static int __init xen_pm_init(void)
{
+ if (!of_find_compatible_node(NULL, NULL, "xen,xen"))
+ return -ENODEV;
+
pm_power_off = xen_power_off;
arm_pm_restart = xen_restart;

return 0;
}
-subsys_initcall(xen_pm_init);
+late_initcall(xen_pm_init);

static irqreturn_t xen_arm_callback(int irq, void *arg)
{
--
1.8.1.2


2013-08-28 21:22:34

by Julien Grall

[permalink] [raw]
Subject: Re: [PATCH v2] ARM: xen: only set pm function ptrs for Xen guests

On 28 August 2013 19:20, Rob Herring <[email protected]> wrote:
> From: Rob Herring <[email protected]>
>
> xen_pm_init was unconditionally setting pm_power_off and arm_pm_restart
> function pointers. This breaks multi-platform kernels. Make this
> conditional on running as a Xen guest and make it a late_initcall to
> ensure it is setup after platform code for Dom0.
>
> Cc: Stefano Stabellini <[email protected]>
> Signed-off-by: Rob Herring <[email protected]>
> ---
> arch/arm/xen/enlighten.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c
> index 8a6295c..13a7d1f 100644
> --- a/arch/arm/xen/enlighten.c
> +++ b/arch/arm/xen/enlighten.c
> @@ -273,12 +273,15 @@ core_initcall(xen_guest_init);
>
> static int __init xen_pm_init(void)
> {
> + if (!of_find_compatible_node(NULL, NULL, "xen,xen"))
> + return -ENODEV;
> +

You should use the macro xen_domain() to check if we are running
in a Xen guest.

Cheers,

--
Julien Grall

2013-08-29 11:28:57

by Stefano Stabellini

[permalink] [raw]
Subject: Re: [PATCH v2] ARM: xen: only set pm function ptrs for Xen guests

On Wed, 28 Aug 2013, Julien Grall wrote:
> On 28 August 2013 19:20, Rob Herring <[email protected]> wrote:
> > From: Rob Herring <[email protected]>
> >
> > xen_pm_init was unconditionally setting pm_power_off and arm_pm_restart
> > function pointers. This breaks multi-platform kernels. Make this
> > conditional on running as a Xen guest and make it a late_initcall to
> > ensure it is setup after platform code for Dom0.
> >
> > Cc: Stefano Stabellini <[email protected]>
> > Signed-off-by: Rob Herring <[email protected]>
> > ---
> > arch/arm/xen/enlighten.c | 5 ++++-
> > 1 file changed, 4 insertions(+), 1 deletion(-)
> >
> > diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c
> > index 8a6295c..13a7d1f 100644
> > --- a/arch/arm/xen/enlighten.c
> > +++ b/arch/arm/xen/enlighten.c
> > @@ -273,12 +273,15 @@ core_initcall(xen_guest_init);
> >
> > static int __init xen_pm_init(void)
> > {
> > + if (!of_find_compatible_node(NULL, NULL, "xen,xen"))
> > + return -ENODEV;
> > +
>
> You should use the macro xen_domain() to check if we are running
> in a Xen guest.

Yep.
Aside from that the patch is fine. Thanks for spotting and fixing this
issue.
I'll add the next version of this patch to the xen queue.