powerpc: move epapr paravirt init of power_save to an initcall
PATCH 1/1 powerpc: move epapr paravirt init of power_save to an initcall
From: Stuart Yoder <[email protected]>
some restructuring of epapr paravirt init resulted in ppc_md.power_save being set, and then overwritten to NULL during machine_init. This patch splits the initialization of ppc_md.power_save out into a postcore init call.
--- arch/powerpc/kernel/epapr_paravirt.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-)
arch/powerpc/kernel/epapr_paravirt.c +20 -5
@@ -52,11 +52,6 @@ static int __init early_init_dt_scan_epapr(unsigned long node,#endif } -#if !defined(CONFIG_64BIT ) || defined(CONFIG_PPC_BOOK3E_64 ) -if (of_get_flat_dt_prop (node,"has-idle" ,NULL )) - ppc_md.power_save = epapr_ev_idle; -#endif - epapr_paravirt_enabled = true;return 1 ;
@@ -69,3 +64,23 @@ int __init epapr_paravirt_early_init(void)return 0 ; } +static int __init epapr_idle_init_dt_scan (unsigned long node, +const char *uname, +int depth,void *data) +{ +#if !defined(CONFIG_64BIT ) || defined(CONFIG_PPC_BOOK3E_64 ) +if (of_get_flat_dt_prop (node,"has-idle" ,NULL )) + ppc_md.power_save = epapr_ev_idle; +#endif +return 0 ; +} + +static int __init epapr_idle_init (void ) +{ +if (epapr_paravirt_enabled) +of_scan_flat_dt (epapr_idle_init_dt_scan,NULL ); + +return 0 ; +} + +postcore_initcall (epapr_idle_init);
Signature · 1 line
1.7.9.7
Quoted 38 lines · Stuart Yoder
From: Stuart Yoder <[email protected]>
some restructuring of epapr paravirt init resulted in ppc_md.power_save being set, and then overwritten to NULL during
machine_init. This patch splits the initialization of ppc_md.power_save out into a postcore init call.Signed-off-by Stuart Yoder <[email protected]>--- arch/powerpc/kernel/epapr_paravirt.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-)arch/powerpc/kernel/epapr_paravirt.c +5
-5@@ -52,11 +52,6 @@ static int __init early_init_dt_scan_epapr(unsigned long node,#endif } -#if !defined(CONFIG_64BIT ) || defined(CONFIG_PPC_BOOK3E_64 ) -if (of_get_flat_dt_prop (node,"has-idle" ,NULL )) - ppc_md.power_save = epapr_ev_idle; -#endif - epapr_paravirt_enabled = true;return 1 ;@@ -69,3 +64,23 @@ int __init epapr_paravirt_early_init(void)return 0 ; } +static int __init epapr_idle_init_dt_scan (unsigned long node, +const char *uname, +int depth,void *data) +{ +#if !defined(CONFIG_64BIT ) || defined(CONFIG_PPC_BOOK3E_64 )
arch/powerpc/kernel/epapr_paravirt.c int __init epapr_paravirt_early_init(void) · line 81
Quoted 10 lines
arch/powerpc/kernel/epapr_paravirt.c +10
-0+if (of_get_flat_dt_prop (node,"has-idle" ,NULL )) + ppc_md.power_save = epapr_ev_idle; +#endif +return 0 ; +} + +static int __init epapr_idle_init (void ) +{ +if (epapr_paravirt_enabled) +of_scan_flat_dt (epapr_idle_init_dt_scan,NULL );
Doesn't this scan all nodes? We only want to match on /hypervisor/has-idle, no?
Alex
Quoted 57 lines
-----Original Message-----
From: Alexander Graf [mailto:[email protected]]
Sent: Wednesday, April 30, 2014 2:56 PM
To: Yoder Stuart-B08248; [email protected]; Wood Scott-B07421
Cc: [email protected]
Subject: Re: [PATCH] powerpc: move epapr paravirt init ofpower_saveto an initcall
=20
=20Quoted 8 lines · Stuart Yoder
From: Stuart Yoder <[email protected]>
some restructuring of epapr paravirt init resulted in ppc_md.power_save being set, and then overwritten to NULL during
machine_init. This patch splits the initialization of ppc_md.power_save out into a postcore init call.Review
Quoted 6 lines
Signed-off-by Stuart Yoder <[email protected]>--- arch/powerpc/kernel/epapr_paravirt.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-)(quoted diff) +0
-0
b/arch/powerpc/kernel/epapr_paravirt.carch/powerpc/kernel/epapr_paravirt.c static int __init early_init_dt_scan_epapr(unsigned
Quoted 4 lines
index 6300c13..c49b69c 100644
arch/powerpc/kernel/epapr_paravirt.c +0
-0@@ -52,11 +52,6 @@ static int __init early_init_dt_scan_epapr(unsignedlong node,
Quoted 25 lines
arch/powerpc/kernel/epapr_paravirt.c +10
-5#endif } -#if !defined(CONFIG_64BIT ) || defined(CONFIG_PPC_BOOK3E_64 ) -if (of_get_flat_dt_prop (node,"has-idle" ,NULL )) - ppc_md.power_save =3D epapr_ev_idle; -#endif - epapr_paravirt_enabled =3D true;return 1 ;@@ -69,3 +64,23 @@ int __init epapr_paravirt_early_init(void)return 0 ; } +static int __init epapr_idle_init_dt_scan (unsigned long node, +const char *uname, +int depth,void *data) +{ +#if !defined(CONFIG_64BIT ) || defined(CONFIG_PPC_BOOK3E_64 ) +if (of_get_flat_dt_prop (node,"has-idle" ,NULL )) + ppc_md.power_save =3D epapr_ev_idle; +#endif +return 0 ; +}
Quoted 8 lines
arch/powerpc/kernel/epapr_paravirt.c int __init epapr_paravirt_early_init(void) · line 81
Quoted 5 lines
arch/powerpc/kernel/epapr_paravirt.c +5
-0+ +static int __init epapr_idle_init (void ) +{ +if (epapr_paravirt_enabled) +of_scan_flat_dt (epapr_idle_init_dt_scan,NULL );=20
Doesn't this scan all nodes? We only want to match on /hypervisor/has-idle, no?
I cut/pasted from the approach the existing code in that file took, but yes you're right we just need the one property. Let me respin that to look at the hypervisor node only.
Stuart
Quoted 63 lines · Stuart Yoder
Quoted 55 lines
-----Original Message-----
From: Alexander Graf [mailto:[email protected]]
Sent: Wednesday, April 30, 2014 2:56 PM
To: Yoder Stuart-B08248; [email protected]; Wood Scott-B07421
Cc: [email protected]
Subject: Re: [PATCH] powerpc: move epapr paravirt init ofpower_saveto an initcallQuoted 8 lines · Stuart Yoder
From: Stuart Yoder <[email protected]>
some restructuring of epapr paravirt init resulted in ppc_md.power_save being set, and then overwritten to NULL during
machine_init. This patch splits the initialization of ppc_md.power_save out into a postcore init call.Review
Quoted 6 lines
Signed-off-by Stuart Yoder <[email protected]>--- arch/powerpc/kernel/epapr_paravirt.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-)(quoted diff) +0
-0
b/arch/powerpc/kernel/epapr_paravirt.carch/powerpc/kernel/epapr_paravirt.c static int __init early_init_dt_scan_epapr(unsigned
Quoted 4 lines
index 6300c13..c49b69c 100644
arch/powerpc/kernel/epapr_paravirt.c +0
-0@@ -52,11 +52,6 @@ static int __init early_init_dt_scan_epapr(unsignedlong node,
Quoted 24 lines
arch/powerpc/kernel/epapr_paravirt.c +9
-5#endif } -#if !defined(CONFIG_64BIT ) || defined(CONFIG_PPC_BOOK3E_64 ) -if (of_get_flat_dt_prop (node,"has-idle" ,NULL )) - ppc_md.power_save = epapr_ev_idle; -#endif - epapr_paravirt_enabled = true;return 1 ;@@ -69,3 +64,23 @@ int __init epapr_paravirt_early_init(void)return 0 ; } +static int __init epapr_idle_init_dt_scan (unsigned long node, +const char *uname, +int depth,void *data) +{ +#if !defined(CONFIG_64BIT ) || defined(CONFIG_PPC_BOOK3E_64 ) +if (of_get_flat_dt_prop (node,"has-idle" ,NULL )) + ppc_md.power_save = epapr_ev_idle; +#endif +return 0 ;Quoted 8 lines
arch/powerpc/kernel/epapr_paravirt.c int __init epapr_paravirt_early_init(void) · line 81
Quoted 6 lines
arch/powerpc/kernel/epapr_paravirt.c +6
-0+} + +static int __init epapr_idle_init (void ) +{ +if (epapr_paravirt_enabled) +of_scan_flat_dt (epapr_idle_init_dt_scan,NULL );Doesn't this scan all nodes? We only want to match on /hypervisor/has-idle, no?
Quoted 3 lines
I cut/pasted from the approach the existing code in that file took, but yes you're right we just need the one property. Let me respin that to look at the hypervisor node only.
The other function aborts early if it doesn't find a "hcall-instructions" property. I'm still surprised we don't limit the scope to /hypervisor at all though. Is this on purpose maybe?
Alex
Quoted 63 lines · Stuart Yoder
Quoted 55 lines
-----Original Message-----
From: Alexander Graf [mailto:[email protected]]
Sent: Wednesday, April 30, 2014 2:56 PM
To: Yoder Stuart-B08248; [email protected]; Wood Scott-B07421
Cc: [email protected]
Subject: Re: [PATCH] powerpc: move epapr paravirt init ofpower_saveto an initcallQuoted 8 lines · Stuart Yoder
From: Stuart Yoder <[email protected]>
some restructuring of epapr paravirt init resulted in ppc_md.power_save being set, and then overwritten to NULL during
machine_init. This patch splits the initialization of ppc_md.power_save out into a postcore init call.Review
Quoted 6 lines
Signed-off-by Stuart Yoder <[email protected]>--- arch/powerpc/kernel/epapr_paravirt.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-)(quoted diff) +0
-0
b/arch/powerpc/kernel/epapr_paravirt.carch/powerpc/kernel/epapr_paravirt.c static int __init early_init_dt_scan_epapr(unsigned
Quoted 4 lines
index 6300c13..c49b69c 100644
arch/powerpc/kernel/epapr_paravirt.c +0
-0@@ -52,11 +52,6 @@ static int __init early_init_dt_scan_epapr(unsignedlong node,
Quoted 24 lines
arch/powerpc/kernel/epapr_paravirt.c +9
-5#endif } -#if !defined(CONFIG_64BIT ) || defined(CONFIG_PPC_BOOK3E_64 ) -if (of_get_flat_dt_prop (node,"has-idle" ,NULL )) - ppc_md.power_save = epapr_ev_idle; -#endif - epapr_paravirt_enabled = true;return 1 ;@@ -69,3 +64,23 @@ int __init epapr_paravirt_early_init(void)return 0 ; } +static int __init epapr_idle_init_dt_scan (unsigned long node, +const char *uname, +int depth,void *data) +{ +#if !defined(CONFIG_64BIT ) || defined(CONFIG_PPC_BOOK3E_64 ) +if (of_get_flat_dt_prop (node,"has-idle" ,NULL )) + ppc_md.power_save = epapr_ev_idle; +#endif +return 0 ;Quoted 8 lines
arch/powerpc/kernel/epapr_paravirt.c int __init epapr_paravirt_early_init(void) · line 81
Quoted 6 lines
arch/powerpc/kernel/epapr_paravirt.c +6
-0+} + +static int __init epapr_idle_init (void ) +{ +if (epapr_paravirt_enabled) +of_scan_flat_dt (epapr_idle_init_dt_scan,NULL );Doesn't this scan all nodes? We only want to match on /hypervisor/has-idle, no?
Quoted 3 lines
I cut/pasted from the approach the existing code in that file took, but yes you're right we just need the one property. Let me respin that to look at the hypervisor node only.
Yeah, the same commit that introduced the breakage on has-idle also removed the explicit check for /hypervisor.
Laurentiu, was this change on purpose?
commit 4e21b94c9c644c43223878f4c848e852743e789c
Author: Laurentiu TUDOR <[email protected]> Date: Wed Jul 3 17:13:15 2013 +0300
powerpc/85xx: Move ePAPR paravirt initialization earlier
At console init, when the kernel tries to flush the log buffer the ePAPR byte-channel based console write fails silently, losing the buffered messages.
This happens because The ePAPR para-virtualization init isn't done early enough so that the hcall instruction to be set, causing the byte-channel write hcall to be a nop. To fix, change the ePAPR para-virt init to use early device tree functions and move it in early init.
arch/powerpc/kernel/epapr_paravirt.c +8 -10
@@ -30,22 +30,20 @@ extern u32 epapr_ev_idle_start[];bool epapr_paravirt_enabled; -static int __init epapr_paravirt_init (void ) +static int __init early_init_dt_scan_epapr (unsigned long node, +const char *uname, +int depth,void *data) { -struct device_node *hyper_node;const u32 *insts; -int len, i; +unsigned long len; +int i; - hyper_node =of_find_node_by_path ("/hypervisor" ); -if (!hyper_node) -return -ENODEV ; - - insts =of_get_property (hyper_node,"hcall-instructions" , &len); + insts =of_get_flat_dt_prop (node,"hcall-instructions" , &len);if (!insts) -return -ENODEV ; +return 0 ;if (len %4 || len > (4 *4 )) -return -ENODEV ; +return -1 ;
[...]
Alex
Quoted 66 lines · Alexander Graf
Quoted 64 lines · Stuart Yoder
Quoted 64 lines
-----Original Message-----
From: Alexander Graf [mailto:[email protected]]
Sent: Wednesday, April 30, 2014 2:56 PM
To: Yoder Stuart-B08248; [email protected]; Wood Scott-B07421
Cc: [email protected]
Subject: Re: [PATCH] powerpc: move epapr paravirt init ofpower_saveto an initcallQuoted 8 lines · Stuart Yoder
From: Stuart Yoder <[email protected]>
some restructuring of epapr paravirt init resulted in ppc_md.power_save being set, and then overwritten to NULL during
machine_init. This patch splits the initialization of ppc_md.power_save out into a postcore init call.Review
Quoted 7 lines
Signed-off-by Stuart Yoder <[email protected]>--- arch/powerpc/kernel/epapr_paravirt.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-)(quoted diff) +0
-0
b/arch/powerpc/kernel/epapr_paravirt.carch/powerpc/kernel/epapr_paravirt.c static int __init early_init_dt_scan_epapr(unsigned
Quoted 4 lines
index 6300c13..c49b69c 100644
arch/powerpc/kernel/epapr_paravirt.c +0
-0@@ -52,11 +52,6 @@ static int __init early_init_dt_scan_epapr(unsignedlong node,
Quoted 20 lines
arch/powerpc/kernel/epapr_paravirt.c +5
-5#endif } -#if !defined(CONFIG_64BIT ) || defined(CONFIG_PPC_BOOK3E_64 ) -if (of_get_flat_dt_prop (node,"has-idle" ,NULL )) - ppc_md.power_save = epapr_ev_idle; -#endif - epapr_paravirt_enabled = true;return 1 ;@@ -69,3 +64,23 @@ int __init epapr_paravirt_early_init(void)return 0 ; } +static int __init epapr_idle_init_dt_scan (unsigned long node, +const char *uname, +int depth,void *data) +{ +#if !defined(CONFIG_64BIT ) || defined(CONFIG_PPC_BOOK3E_64 )arch/powerpc/kernel/epapr_paravirt.c int __init epapr_paravirt_early_init(void) · line 81
Quoted 10 lines
arch/powerpc/kernel/epapr_paravirt.c +10
-0+if (of_get_flat_dt_prop (node,"has-idle" ,NULL )) + ppc_md.power_save = epapr_ev_idle; +#endif +return 0 ; +} + +static int __init epapr_idle_init (void ) +{ +if (epapr_paravirt_enabled) +of_scan_flat_dt (epapr_idle_init_dt_scan,NULL );Doesn't this scan all nodes? We only want to match on /hypervisor/has-idle, no?
Quoted 9 lines
Quoted 3 lines
I cut/pasted from the approach the existing code in that file took, but yes you're right we just need the one property. Let me respin that to look at the hypervisor node only.
Yeah, the same commit that introduced the breakage on has-idle also removed the explicit check for /hypervisor.
Laurentiu, was this change on purpose?
Alex,
IIRC, at that time i had to switch from the normal "of" functions to a completely different api that's available in early init stage. This early "of" api is pretty limited (e.g. doesn't have a way to address a specific node) and i had to use that function that scans the whole tree.
---
Best Regards, Laurentiu
Quoted 75 lines · Tudor Laurentiu
Quoted 74 lines · Alexander Graf
Quoted 65 lines · Stuart Yoder
Quoted 57 lines
-----Original Message-----
From: Alexander Graf [mailto:[email protected]]
Sent: Wednesday, April 30, 2014 2:56 PM
To: Yoder Stuart-B08248; [email protected]; Wood Scott-B07421
Cc: [email protected]
Subject: Re: [PATCH] powerpc: move epapr paravirt init ofpower_saveto an initcallQuoted 8 lines · Stuart Yoder
From: Stuart Yoder <[email protected]>
some restructuring of epapr paravirt init resulted in ppc_md.power_save being set, and then overwritten to NULL during
machine_init. This patch splits the initialization of ppc_md.power_save out into a postcore init call.Review
Quoted 7 lines
Signed-off-by Stuart Yoder <[email protected]>--- arch/powerpc/kernel/epapr_paravirt.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-)(quoted diff) +0
-0
b/arch/powerpc/kernel/epapr_paravirt.cQuoted 5 lines
index 6300c13..c49b69c 100644
arch/powerpc/kernel/epapr_paravirt.c +0
-0@@ -52,11 +52,6 @@ static int __initearly_init_dt_scan_epapr(unsigned
long node,
Quoted 24 lines
#endif }arch/powerpc/kernel/epapr_paravirt.c +9
-5-#if !defined(CONFIG_64BIT ) || defined(CONFIG_PPC_BOOK3E_64 ) -if (of_get_flat_dt_prop (node,"has-idle" ,NULL )) - ppc_md.power_save = epapr_ev_idle; -#endif - epapr_paravirt_enabled = true;return 1 ;@@ -69,3 +64,23 @@ int __init epapr_paravirt_early_init(void)return 0 ; } +static int __init epapr_idle_init_dt_scan (unsigned long node, +const char *uname, +int depth,void *data) +{ +#if !defined(CONFIG_64BIT ) || defined(CONFIG_PPC_BOOK3E_64 ) +if (of_get_flat_dt_prop (node,"has-idle" ,NULL )) + ppc_md.power_save = epapr_ev_idle; +#endif +return 0 ;Quoted 8 lines
arch/powerpc/kernel/epapr_paravirt.c int __init epapr_paravirt_early_init(void) · line 81
Quoted 6 lines
arch/powerpc/kernel/epapr_paravirt.c +6
-0+} + +static int __init epapr_idle_init (void ) +{ +if (epapr_paravirt_enabled) +of_scan_flat_dt (epapr_idle_init_dt_scan,NULL );Doesn't this scan all nodes? We only want to match on /hypervisor/has-idle, no?
Quoted 3 lines
I cut/pasted from the approach the existing code in that file took, but yes you're right we just need the one property. Let me respin that to look at the hypervisor node only.
Yeah, the same commit that introduced the breakage on has-idle also removed the explicit check for /hypervisor.
Quoted 6 lines
Quoted 2 lines
Laurentiu, was this change on purpose?
Alex,
IIRC, at that time i had to switch from the normal "of" functions to a completely different api that's available in early init stage. This early "of" api is pretty limited (e.g. doesn't have a way to address a specific node) and i had to use that function that scans the whole tree.
Ok, so it is an accident. Could you please post a patch that checks that the node we're looking at is called "hypervisor"? The simple API should give you enough information for that at least. Maybe you could even check that the parent node is the root node.
Alex
Quoted 87 lines · Alexander Graf
Quoted 79 lines · Tudor Laurentiu
Quoted 68 lines · Alexander Graf
Quoted 66 lines · Stuart Yoder
Quoted 66 lines
-----Original Message-----
From: Alexander Graf [mailto:[email protected]]
Sent: Wednesday, April 30, 2014 2:56 PM
To: Yoder Stuart-B08248; [email protected]; Wood Scott-B07421
Cc: [email protected]
Subject: Re: [PATCH] powerpc: move epapr paravirt init ofpower_saveto
an initcallQuoted 8 lines · Stuart Yoder
From: Stuart Yoder <[email protected]>
some restructuring of epapr paravirt init resulted in ppc_md.power_save being set, and then overwritten to NULL during
machine_init. This patch splits the initialization of ppc_md.power_save out into a postcore init call.Review
Quoted 7 lines
Signed-off-by Stuart Yoder <[email protected]>--- arch/powerpc/kernel/epapr_paravirt.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-)(quoted diff) +0
-0
b/arch/powerpc/kernel/epapr_paravirt.cQuoted 5 lines
index 6300c13..c49b69c 100644
arch/powerpc/kernel/epapr_paravirt.c +0
-0@@ -52,11 +52,6 @@ static int __initearly_init_dt_scan_epapr(unsigned
long node,
Quoted 20 lines
#endif }arch/powerpc/kernel/epapr_paravirt.c +5
-5-#if !defined(CONFIG_64BIT ) || defined(CONFIG_PPC_BOOK3E_64 ) -if (of_get_flat_dt_prop (node,"has-idle" ,NULL )) - ppc_md.power_save = epapr_ev_idle; -#endif - epapr_paravirt_enabled = true;return 1 ;@@ -69,3 +64,23 @@ int __init epapr_paravirt_early_init(void)return 0 ; } +static int __init epapr_idle_init_dt_scan (unsigned long node, +const char *uname, +int depth,void *data) +{ +#if !defined(CONFIG_64BIT ) || defined(CONFIG_PPC_BOOK3E_64 )arch/powerpc/kernel/epapr_paravirt.c int __init epapr_paravirt_early_init(void) · line 81
Quoted 10 lines
arch/powerpc/kernel/epapr_paravirt.c +10
-0+if (of_get_flat_dt_prop (node,"has-idle" ,NULL )) + ppc_md.power_save = epapr_ev_idle; +#endif +return 0 ; +} + +static int __init epapr_idle_init (void ) +{ +if (epapr_paravirt_enabled) +of_scan_flat_dt (epapr_idle_init_dt_scan,NULL );Doesn't this scan all nodes? We only want to match on /hypervisor/has-idle, no?
Quoted 9 lines
Quoted 3 lines
I cut/pasted from the approach the existing code in that file took, but yes you're right we just need the one property. Let me respin that to look at the hypervisor node only.
Yeah, the same commit that introduced the breakage on has-idle also removed the explicit check for /hypervisor.
Laurentiu, was this change on purpose?
Quoted 6 lines
Alex,
IIRC, at that time i had to switch from the normal "of" functions to a completely different api that's available in early init stage. This early "of" api is pretty limited (e.g. doesn't have a way to address a specific node) and i had to use that function that scans the whole tree.
Quoted 5 lines
Ok, so it is an accident. Could you please post a patch that checks that the node we're looking at is called "hypervisor"? The simple API should give you enough information for that at least. Maybe you could even check that the parent node is the root node.
Just had a quick look and it looks that that early fdt api was improved with a function that allows specifying a starting path for the scan (of_scan_flat_dt_by_path() added in commit 57d74bcf3072b65bde5aa540cedc976a75c48e5c). So i think we can simply use that instead.
---
Best Regards, Laurentiu