powerpc/xive: add support for H_INT_RESET
cover powerpc/xive: add support for H_INT_RESET
H_INT_RESET performs a reset of the Hypervisor internal interrupt structures, removing all settings done with H_INT_SET_SOURCE_CONFIG and H_INT_SET_QUEUE_CONFIG. This is most important for kdump and kexec to be able to restart in a clean state.
First patch closes a window in the kexec sequence in which the H_INT_RESET hcall can be run concurrently with other hcalls when CPUs are brought down. The other patches wire up the reset hcall making sure it supports H_LONG_BUSY_* returned by the Hypervisor.
Cédric Le Goater (4):
powerpc/64/kexec: fix race in kexec when XIVE is shutdowned powerpc/xive: fix hcall H_INT_RESET to support long busy delays powerpc/xive: shutdown XIVE when kexec or kdump is performed powerpc/xive: prepare all hcalls to support long busy delays
arch/powerpc/kernel/machine_kexec_64.c | 8 +-- arch/powerpc/platforms/pseries/kexec.c | 7 ++- arch/powerpc/sysdev/xive/spapr.c | 89 +++++++++++++++++++++++++++++----- 3 files changed, 85 insertions(+), 19 deletions(-)
Signature · 1 line
2.13.6
PATCH 1/4 powerpc/64/kexec: fix race in kexec when XIVE is shutdowned
The kexec_state KEXEC_STATE_IRQS_OFF barrier is reached by all secondary CPUs before the kexec_cpu_down() operation is called on secondaries. This can raise conflicts and provoque errors in the XIVE hcalls when XIVE is shutdowned with H_INT_RESET on the primary CPU.
To synchronize the kexec_cpu_down() operations and make sure the secondaries have completed their task before the primary starts doing the same, let's move the primary kexec_cpu_down() after the KEXEC_STATE_REAL_MODE barrier.
--- arch/powerpc/kernel/machine_kexec_64.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
arch/powerpc/kernel/machine_kexec_64.c +4 -4
@@ -230,16 +230,16 @@ static void kexec_prepare_cpus(void)/* we are sure every CPU has IRQs off at this point */ kexec_all_irq_disabled =1 ; -/* after we tell the others to go down */ -if (ppc_md.kexec_cpu_down) - ppc_md.kexec_cpu_down (0 ,0 ); -/* * Before removing MMU mappings make sure all CPUs have entered real * mode: */ kexec_prepare_cpus_wait (KEXEC_STATE_REAL_MODE ); +/* after we tell the others to go down */ +if (ppc_md.kexec_cpu_down) + ppc_md.kexec_cpu_down (0 ,0 ); +put_cpu (); }
Signature · 1 line
2.13.6
Michael Ellerman
reviewerRe: [PATCH 1/4] powerpc/64/kexec: fix race in kexec when XIVE is shutdowned
Quoted 9 lines · C=C3=A9dric Le Goater <[email protected]> writes:
The
kexec_stateKEXEC_STATE_IRQS_OFFbarrier is reached by all secondary CPUs before thekexec_cpu_down()operation is called on secondaries. This can raise conflicts and provoque errors in the XIVE hcalls when XIVE is shutdowned withH_INT_RESETon the primary CPU.To synchronize the
kexec_cpu_down()operations and make sure the secondaries have completed their task before the primary starts doing the same, let's move the primarykexec_cpu_down()after theKEXEC_STATE_REAL_MODEbarrier.
This sounds reasonable, I'm sure you've tested it. I'm just a bit worried that it could potentially break on other platforms because it changes the sequence of operations.
Looking we only have kexec_cpu_down() implemented for pseries, powernv, ps3 and 85xx.
We can easily test the first two. ps3 doesn't do much so hopefully that's safe.
mpc85xx_smp_kexec_cpu_down() does very little on 32-bit, and on 64-bit it seems to already wait for at least one other CPU to get into KEXEC_STATE_REAL_MODE, so that's probably safe too.
So I guess I'm OK to merge this, and we'll fix any fallout. It would be good for the change log to call out the change though, and that we think it's a sensible change for all platforms.
cheers
arch/powerpc/kernel=
Quoted 6 lines
Signed-off-by C=C3=A9dric Le Goater <[email protected]>--- arch/powerpc/kernel/machine_kexec_64.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)arch/powerpc/kernel= renamed from arch/powerpc/kernel/machine_kexec_64.c +0
-0
/machine_kexec_64.c
Quoted 26 lines
index
49d34d7271e7..212ecb8e829c100644arch/powerpc/kernel/machine_kexec_64.c +0
-0@@ -230,16 +230,16 @@ static void kexec_prepare_cpus(void)/* we are sure every CPU has IRQs off at this point */ kexec_all_irq_disabled =3D 1;=20=20
arch/powerpc/kernel/machine_kexec_64.c +0
-4-/* after we tell the others to go down */ -if (ppc_md.kexec_cpu_down) - ppc_md.kexec_cpu_down (0 ,0 ); -/* * Before removing MMU mappings make sure all CPUs have entered real * mode: */ kexec_prepare_cpus_wait (KEXEC_STATE_REAL_MODE );=20=20
arch/powerpc/kernel/machine_kexec_64.c +4
-0+/* after we tell the others to go down */ +if (ppc_md.kexec_cpu_down) + ppc_md.kexec_cpu_down (0 ,0 ); +put_cpu (); }=20=20
--=20
2.13.6
Re: [PATCH 1/4] powerpc/64/kexec: fix race in kexec when XIVE is shutdowned
Quoted 7 lines · Michael Ellerman
Quoted 5 lines · Cédric Le Goater
The
kexec_stateKEXEC_STATE_IRQS_OFFbarrier is reached by all secondary CPUs before thekexec_cpu_down()operation is called on secondaries. This can raise conflicts and provoque errors in the XIVE hcalls when XIVE is shutdowned withH_INT_RESETon the primary CPU.
Quoted 8 lines
Quoted 4 lines
To synchronize the
kexec_cpu_down()operations and make sure the secondaries have completed their task before the primary starts doing the same, let's move the primarykexec_cpu_down()after theKEXEC_STATE_REAL_MODEbarrier.This sounds reasonable, I'm sure you've tested it. I'm just a bit worried that it could potentially break on other platforms because it changes the sequence of operations.
yes. We are adding a last barrier to be exact making the full sequence a little slower.
Quoted 5 lines
Looking we only have
kexec_cpu_down()implemented for pseries, powernv, ps3 and 85xx.We can easily test the first two. > ps3 doesn't do much so hopefully that's safe.
Quoted 7 lines
mpc85xx_smp_kexec_cpu_down()does very little on 32-bit, and on 64-bit it seems to already wait for at least one other CPU to get intoKEXEC_STATE_REAL_MODE, so that's probably safe too.So I guess I'm OK to merge this, and we'll fix any fallout. It would be good for the change log to call out the change though, and that we think it's a sensible change for all platforms.
OK.
Thanks,
C.
Quoted 34 lines
cheers
Quoted 32 lines
Signed-off-by Cédric Le Goater <[email protected]>--- arch/powerpc/kernel/machine_kexec_64.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)arch/powerpc/kernel/machine_kexec_64.c +4
-4@@ -230,16 +230,16 @@ static void kexec_prepare_cpus(void)/* we are sure every CPU has IRQs off at this point */ kexec_all_irq_disabled =1 ; -/* after we tell the others to go down */ -if (ppc_md.kexec_cpu_down) - ppc_md.kexec_cpu_down (0 ,0 ); -/* * Before removing MMU mappings make sure all CPUs have entered real * mode: */ kexec_prepare_cpus_wait (KEXEC_STATE_REAL_MODE ); +/* after we tell the others to go down */ +if (ppc_md.kexec_cpu_down) + ppc_md.kexec_cpu_down (0 ,0 ); +put_cpu (); }Signature · 1 line
2.13.6
Re: [PATCH 1/4] powerpc/64/kexec: fix race in kexec when XIVE is shutdowned
Quoted 29 lines · Cédric Le Goater
Quoted 7 lines · Michael Ellerman
Quoted 5 lines · Cédric Le Goater
The
kexec_stateKEXEC_STATE_IRQS_OFFbarrier is reached by all secondary CPUs before thekexec_cpu_down()operation is called on secondaries. This can raise conflicts and provoque errors in the XIVE hcalls when XIVE is shutdowned withH_INT_RESETon the primary CPU.Quoted 8 lines
Quoted 4 lines
To synchronize the
kexec_cpu_down()operations and make sure the secondaries have completed their task before the primary starts doing the same, let's move the primarykexec_cpu_down()after theKEXEC_STATE_REAL_MODEbarrier.This sounds reasonable, I'm sure you've tested it. I'm just a bit worried that it could potentially break on other platforms because it changes the sequence of operations.
yes. We are adding a last barrier to be exact making the full sequence a little slower.
Quoted 9 lines
Looking we only have
kexec_cpu_down()implemented for pseries, powernv, ps3 and 85xx.We can easily test the first two. > ps3 doesn't do much so hopefully that's safe.
mpc85xx_smp_kexec_cpu_down()does very little on 32-bit, and on 64-bit it seems to already wait for at least one other CPU to get intoKEXEC_STATE_REAL_MODE, so that's probably safe too.
Quoted 5 lines
Quoted 3 lines
So I guess I'm OK to merge this, and we'll fix any fallout. It would be good for the change log to call out the change though, and that we think it's a sensible change for all platforms.
OK.
Ah and can you please fix the 'shutdowned' spelling ? it has been bugging me since I sent the patch :) thx
C.
PATCH 2/4 powerpc/xive: fix hcall H_INT_RESET to support long busy delays
In reply to Cédric Le GoaterThe hcall H_INT_RESET can take some time to complete and in such cases it returns H_LONG_BUSY_* codes requiring the machine to sleep for a while before retrying.
--- arch/powerpc/sysdev/xive/spapr.c | 53 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 48 insertions(+), 5 deletions(-)
arch/powerpc/sysdev/xive/spapr.c +48 -5
@@ -19,6 +19,7 @@#include <linux/spinlock.h> #include <linux/cpumask.h> #include <linux/mm.h> +#include <linux/delay.h> #include <asm/prom.h> #include <asm/io.h>
@@ -108,6 +109,52 @@ static void xive_irq_bitmap_free(int irq) } } + +/* Based on the similar routines in RTAS */ +static unsigned int plpar_busy_delay_time (long rc) +{ +unsigned int ms =0 ; + +if (H_IS_LONG_BUSY (rc)) { + ms =get_longbusy_msecs (rc); + }else if (rc ==H_BUSY ) { + ms =10 ;/* seems appropriate for XIVE hcalls */ + } + +return ms; +} + +static unsigned int plpar_busy_delay (int rc) +{ +unsigned int ms; + +might_sleep (); + ms =plpar_busy_delay_time (rc); +if (ms &&need_resched ()) +msleep (ms); + +return ms; +} + +/* +* Note: this call has a partition wide scope and can take a while to +* complete. If it returns H_LONG_BUSY_* it should be retried +* periodically. +*/ +static long plpar_int_reset (unsigned long flags) +{ +long rc; + +do { + rc =plpar_hcall_norets (H_INT_RESET , flags); + }while (plpar_busy_delay (rc)); + +if (rc) +pr_err ("H_INT_RESET failed %ld\n" , rc); + +return rc; +} + static long plpar_int_get_source_info(unsigned long flags, unsigned long lisn, unsigned long *src_flags,
@@ -445,11 +492,7 @@ static void xive_spapr_put_ipi(unsigned int cpu, struct xive_cpu *xc)static void xive_spapr_shutdown (void ) { -long rc; - - rc =plpar_hcall_norets (H_INT_RESET ,0 ); -if (rc) -pr_err ("H_INT_RESET failed %ld\n" , rc); +plpar_int_reset (0 ); }/*
Signature · 1 line
2.13.6
Michael Ellerman
reviewerRe: [PATCH 2/4] powerpc/xive: fix hcall H_INT_RESET to support long busy delays
arch/powerpc/sysdev/xive/=
Quoted 1 line · C=C3=A9dric Le Goater <[email protected]> writes:
arch/powerpc/sysdev/xive/= renamed from arch/powerpc/sysdev/xive/spapr.c +0
-0
spapr.c
Quoted 20 lines
index
091f1d0d0af1..7113f5d87952100644arch/powerpc/sysdev/xive/spapr.c +0
-0@@ -108,6 +109,52 @@ static void xive_irq_bitmap_free(int irq) } }=20=20
arch/powerpc/sysdev/xive/spapr.c +13
-0+ +/* Based on the similar routines in RTAS */ +static unsigned int plpar_busy_delay_time (long rc) +{ + unsigned int ms =3D 0; + +if (H_IS_LONG_BUSY (rc)) { + ms =3D get_longbusy_msecs(rc); + } else if (rc =3D=3D H_BUSY) { + ms =3D 10; /* seems appropriate for XIVE hcalls */ + } + +return ms;
arch/powerpc/sysdev/xive/spapr.c static void xive_irq_bitmap_free(int irq) · line 134
Quoted 10 lines
arch/powerpc/sysdev/xive/spapr.c +10
-0+} + +static unsigned int plpar_busy_delay (int rc) +{ +unsigned int ms; + +might_sleep (); + ms =3D plpar_busy_delay_time(rc); +if (ms &&need_resched ()) +msleep (ms);
This is called from kexec shutdown isn't it?
In which case I don't think msleep() is a great idea.
We could be crashing for example.
An mdelay would be safer I think?
cheers
Re: [PATCH 2/4] powerpc/xive: fix hcall H_INT_RESET to support long busy delays
Quoted 36 lines · Michael Ellerman
Quoted 21 lines · Cédric Le Goater
arch/powerpc/sysdev/xive/spapr.c +13
-0@@ -108,6 +109,52 @@ static void xive_irq_bitmap_free(int irq) } } + +/* Based on the similar routines in RTAS */ +static unsigned int plpar_busy_delay_time (long rc) +{ +unsigned int ms =0 ; + +if (H_IS_LONG_BUSY (rc)) { + ms =get_longbusy_msecs (rc); + }else if (rc ==H_BUSY ) { + ms =10 ;/* seems appropriate for XIVE hcalls */ + } + +return ms;arch/powerpc/sysdev/xive/spapr.c static void xive_irq_bitmap_free(int irq) · line 134
Quoted 10 lines
arch/powerpc/sysdev/xive/spapr.c +10
-0+} + +static unsigned int plpar_busy_delay (int rc) +{ +unsigned int ms; + +might_sleep (); + ms =plpar_busy_delay_time (rc); +if (ms &&need_resched ()) +msleep (ms);This is called from kexec shutdown isn't it?
Quoted 1 line
In which case I don't think
msleep()is a great idea.>> We could be crashing for example.
yes.
Quoted 1 line
An mdelay would be safer I think?
I agree but we would mdelay be OK ? The hcall can take up to 160ms.
Thanks,
C.
PATCH 3/4 powerpc/xive: shutdown XIVE when kexec or kdump is performed
In reply to Cédric Le GoaterThe hcall H_INT_RESET should be called to make sure XIVE is fully reseted.
--- arch/powerpc/platforms/pseries/kexec.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
arch/powerpc/platforms/pseries/kexec.c +5 -2
@@ -52,8 +52,11 @@ void pseries_kexec_cpu_down(int crash_shutdown, int secondary) } } -if (xive_enabled ()) +if (xive_enabled ()) {xive_kexec_teardown_cpu (secondary); -else + +if (!secondary) +xive_shutdown (); + }else xics_kexec_teardown_cpu (secondary); }
Signature · 1 line
2.13.6
Michael Ellerman
reviewerRe: [PATCH 3/4] powerpc/xive: shutdown XIVE when kexec or kdump is performed
arch/powerpc/platfo=
Quoted 9 lines · C=C3=A9dric Le Goater <[email protected]> writes:
The hcall
H_INT_RESETshould be called to make sure XIVE is fully reseted.Signed-off-by C=C3=A9dric Le Goater <[email protected]>--- arch/powerpc/platforms/pseries/kexec.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)arch/powerpc/platfo= renamed from arch/powerpc/platforms/pseries/kexec.c +0
-0
rms/pseries/kexec.c
arch/powerpc/platforms/pseries/kexec.c void pseries_kexec_cpu_down(int crash_shutdown, int se=
Quoted 4 lines
index
eeb13429d685..1d9bbf8e7357100644arch/powerpc/platforms/pseries/kexec.c +0
-0@@ -52,8 +52,11 @@ void pseries_kexec_cpu_down(int crash_shutdown, int se=
condary)
arch/powerpc/platforms/pseries/kexec.c void pseries_kexec_cpu_down(int crash_shutdown, int secondary) · line 59
Quoted 10 lines
arch/powerpc/platforms/pseries/kexec.c +0
-0} }=20=20
arch/powerpc/platforms/pseries/kexec.c +4
-2-if (xive_enabled ()) +if (xive_enabled ()) {xive_kexec_teardown_cpu (secondary); -else + +if (!secondary) +xive_shutdown ();
Couldn't that logic go in xive_kexec_teardown_cpu()?
Why do we not want to do it on powernv?
Actually we *do* do it on powernv, but elsewhere.
cheers
Quoted 5 lines
arch/powerpc/platforms/pseries/kexec.c +1
-1+ }else xics_kexec_teardown_cpu (secondary); } --=202.13.6
Re: [PATCH 3/4] powerpc/xive: shutdown XIVE when kexec or kdump is performed
Quoted 18 lines · Michael Ellerman
Quoted 16 lines · Cédric Le Goater
The hcall
H_INT_RESETshould be called to make sure XIVE is fully reseted.Signed-off-by Cédric Le Goater <[email protected]>--- arch/powerpc/platforms/pseries/kexec.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)arch/powerpc/platforms/pseries/kexec.c +0
-0@@ -52,8 +52,11 @@ void pseries_kexec_cpu_down(int crash_shutdown, int secondary) } }
Quoted 9 lines
arch/powerpc/platforms/pseries/kexec.c void pseries_kexec_cpu_down(int crash_shutdown, int secondary) · line 59
Quoted 7 lines
arch/powerpc/platforms/pseries/kexec.c +4
-2-if (xive_enabled ()) +if (xive_enabled ()) {xive_kexec_teardown_cpu (secondary); -else + +if (!secondary) +xive_shutdown ();Couldn't that logic go in
xive_kexec_teardown_cpu()?
On powernv, we wait for the secondaries to reach OPAL before doing a XIVE shutdown. This is another kexec barrier but it is after the KEXEC_STATE_REAL_MODE barrier if I am correct.
So I don't think we can move the code in the xive_kexec_teardown_cpu()
Quoted 2 lines
Why do we not want to do it on powernv?
Quoted 1 line
Actually we *do* do it on powernv, but elsewhere.
yes in a different file.
Thanks,
C.
Quoted 7 lines
cheers
Quoted 5 lines
arch/powerpc/platforms/pseries/kexec.c +1
-0+ }else xics_kexec_teardown_cpu (secondary); }Signature · 1 line
2.13.6
PATCH 4/4 powerpc/xive: prepare all hcalls to support long busy delays
In reply to Cédric Le GoaterThis is not the case for the moment, but future releases of pHyp might need to introduce some synchronisation routines under the hood which would make the XIVE hcalls longer to complete.
As this was done for H_INT_RESET, let's wrap the other hcalls in a loop catching the H_LONG_BUSY_* codes.
--- arch/powerpc/sysdev/xive/spapr.c | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-)
arch/powerpc/sysdev/xive/spapr.c +28 -8
@@ -165,7 +165,10 @@ static long plpar_int_get_source_info(unsigned long flags,unsigned long retbuf[PLPAR_HCALL_BUFSIZE ];long rc; - rc =plpar_hcall (H_INT_GET_SOURCE_INFO , retbuf, flags, lisn); +do { + rc =plpar_hcall (H_INT_GET_SOURCE_INFO , retbuf, flags, lisn); + }while (plpar_busy_delay (rc)); +if (rc) {pr_err ("H_INT_GET_SOURCE_INFO lisn=%ld failed %ld\n" , lisn, rc);return rc;
@@ -198,8 +201,11 @@ static long plpar_int_set_source_config(unsigned long flags, flags, lisn, target, prio, sw_irq); - rc =plpar_hcall_norets (H_INT_SET_SOURCE_CONFIG , flags, lisn, - target, prio, sw_irq); +do { + rc =plpar_hcall_norets (H_INT_SET_SOURCE_CONFIG , flags, lisn, + target, prio, sw_irq); + }while (plpar_busy_delay (rc)); +if (rc) {pr_err ("H_INT_SET_SOURCE_CONFIG lisn=%ld target=%lx prio=%lx failed %ld\n" , lisn, target, prio, rc);
@@ -218,7 +224,11 @@ static long plpar_int_get_queue_info(unsigned long flags,unsigned long retbuf[PLPAR_HCALL_BUFSIZE ];long rc; - rc =plpar_hcall (H_INT_GET_QUEUE_INFO , retbuf, flags, target, priority); +do { + rc =plpar_hcall (H_INT_GET_QUEUE_INFO , retbuf, flags, target, + priority); + }while (plpar_busy_delay (rc)); +if (rc) {pr_err ("H_INT_GET_QUEUE_INFO cpu=%ld prio=%ld failed %ld\n" , target, priority, rc);
@@ -247,8 +257,11 @@ static long plpar_int_set_queue_config(unsigned long flags,pr_devel ("H_INT_SET_QUEUE_CONFIG flags=%lx target=%lx priority=%lx qpage=%lx qsize=%lx\n" , flags, target, priority, qpage, qsize); - rc =plpar_hcall_norets (H_INT_SET_QUEUE_CONFIG , flags, target, - priority, qpage, qsize); +do { + rc =plpar_hcall_norets (H_INT_SET_QUEUE_CONFIG , flags, target, + priority, qpage, qsize); + }while (plpar_busy_delay (rc)); +if (rc) {pr_err ("H_INT_SET_QUEUE_CONFIG cpu=%ld prio=%ld qpage=%lx returned %ld\n" , target, priority, qpage, rc);
@@ -262,7 +275,10 @@ static long plpar_int_sync(unsigned long flags, unsigned long lisn) {long rc; - rc =plpar_hcall_norets (H_INT_SYNC , flags, lisn); +do { + rc =plpar_hcall_norets (H_INT_SYNC , flags, lisn); + }while (plpar_busy_delay (rc)); +if (rc) {pr_err ("H_INT_SYNC lisn=%ld returned %ld\n" , lisn, rc);return rc;
@@ -285,7 +301,11 @@ static long plpar_int_esb(unsigned long flags,pr_devel ("H_INT_ESB flags=%lx lisn=%lx offset=%lx in=%lx\n" , flags, lisn, offset, in_data); - rc =plpar_hcall (H_INT_ESB , retbuf, flags, lisn, offset, in_data); +do { + rc =plpar_hcall (H_INT_ESB , retbuf, flags, lisn, offset, + in_data); + }while (plpar_busy_delay (rc)); +if (rc) {pr_err ("H_INT_ESB lisn=%ld offset=%ld returned %ld\n" , lisn, offset, rc);
Signature · 1 line
2.13.6
Michael Ellerman
reviewerRe: [PATCH 4/4] powerpc/xive: prepare all hcalls to support long busy delays
Quoted 6 lines · C=C3=A9dric Le Goater <[email protected]> writes:
This is not the case for the moment, but future releases of pHyp might need to introduce some synchronisation routines under the hood which would make the XIVE hcalls longer to complete.
As this was done for
H_INT_RESET, let's wrap the other hcalls in a loop catching the H_LONG_BUSY_* codes.
Are we sure it's safe to msleep() in all these paths?
cheers
arch/powerpc/sysdev/xive/=
Quoted 1 line
arch/powerpc/sysdev/xive/= renamed from arch/powerpc/sysdev/xive/spapr.c +0
-0
spapr.c
arch/powerpc/sysdev/xive/spapr.c static long plpar_int_get_source_info(unsigned long =
Quoted 4 lines
index
7113f5d87952..97ea0a67a173100644arch/powerpc/sysdev/xive/spapr.c +0
-0@@ -165,7 +165,10 @@ static long plpar_int_get_source_info(unsigned long =
flags,
arch/powerpc/sysdev/xive/spapr.c static long plpar_int_set_source_config(unsigned lon=
Quoted 12 lines
arch/powerpc/sysdev/xive/spapr.c +0
-0unsigned long retbuf[PLPAR_HCALL_BUFSIZE ];long rc;=20=20
arch/powerpc/sysdev/xive/spapr.c +4
-1- rc =3D plpar_hcall(H_INT_GET_SOURCE_INFO, retbuf, flags, lisn); +do { + rc =3D plpar_hcall(H_INT_GET_SOURCE_INFO, retbuf, flags, lisn); + }while (plpar_busy_delay (rc)); +if (rc) {pr_err ("H_INT_GET_SOURCE_INFO lisn=3D%ld failed %ld\n" , lisn, rc);return rc;@@ -198,8 +201,11 @@ static long plpar_int_set_source_config(unsigned lon=
g flags,
arch/powerpc/sysdev/xive/spapr.c static long plpar_int_set_source_config(unsigned long flags,
Quoted 12 lines
arch/powerpc/sysdev/xive/spapr.c +0
-0flags, lisn, target, prio, sw_irq);=20=20
=20=20arch/powerpc/sysdev/xive/spapr.c +5
-2- rc =3D plpar_hcall_norets(H_INT_SET_SOURCE_CONFIG, flags, lisn, - target, prio, sw_irq); +do { + rc =3D plpar_hcall_norets(H_INT_SET_SOURCE_CONFIG, flags, lisn, + target, prio, sw_irq); + }while (plpar_busy_delay (rc)); +if (rc) { pr_err("H_INT_SET_SOURCE_CONFIG lisn=3D%ld target=3D%lx prio=3D%lx fai=
led %ld\n",
arch/powerpc/sysdev/xive/spapr.c static long plpar_int_get_queue_info(unsigned long f=
Quoted 2 lines
arch/powerpc/sysdev/xive/spapr.c +0
-0lisn, target, prio, rc);@@ -218,7 +224,11 @@ static long plpar_int_get_queue_info(unsigned long f=
lags,
arch/powerpc/sysdev/xive/spapr.c
Quoted 4 lines
arch/powerpc/sysdev/xive/spapr.c +0
-0unsigned long retbuf[PLPAR_HCALL_BUFSIZE ];long rc;=20=20
arch/powerpc/sysdev/xive/spapr.c +0
-1- rc =3D plpar_hcall(H_INT_GET_QUEUE_INFO, retbuf, flags, target, priorit=
y);
arch/powerpc/sysdev/xive/spapr.c static long plpar_int_set_queue_config(unsigned long=
Quoted 9 lines
arch/powerpc/sysdev/xive/spapr.c +5
-0+do { + rc =3D plpar_hcall(H_INT_GET_QUEUE_INFO, retbuf, flags, target, + priority); + }while (plpar_busy_delay (rc)); +if (rc) {pr_err ("H_INT_GET_QUEUE_INFO cpu=3D%ld prio=3D%ld failed %ld\n" , target, priority, rc);@@ -247,8 +257,11 @@ static long plpar_int_set_queue_config(unsigned long=
flags,
arch/powerpc/sysdev/xive/spapr.c static long plpar_int_set_queue_config(unsigned long= · line 257
Quoted 1 line
arch/powerpc/sysdev/xive/spapr.c +0
-0pr_devel("H_INT_SET_QUEUE_CONFIG flags=3D%lx target=3D%lx priority=3D%l=
x qpage=3D%lx qsize=3D%lx\n",
arch/powerpc/sysdev/xive/spapr.c static long plpar_int_set_queue_config(unsigned long flags,
Quoted 11 lines
arch/powerpc/sysdev/xive/spapr.c +0
-0flags, target, priority, qpage, qsize);=20=20
arch/powerpc/sysdev/xive/spapr.c +5
-2- rc =3D plpar_hcall_norets(H_INT_SET_QUEUE_CONFIG, flags, target, - priority, qpage, qsize); +do { + rc =3D plpar_hcall_norets(H_INT_SET_QUEUE_CONFIG, flags, target, + priority, qpage, qsize); + }while (plpar_busy_delay (rc)); +if (rc) { pr_err("H_INT_SET_QUEUE_CONFIG cpu=3D%ld prio=3D%ld qpage=3D%lx return=
ed %ld\n",
arch/powerpc/sysdev/xive/spapr.c static long plpar_int_sync(unsigned long flags, unsi=
Quoted 2 lines
arch/powerpc/sysdev/xive/spapr.c +0
-0target, priority, qpage, rc);@@ -262,7 +275,10 @@ static long plpar_int_sync(unsigned long flags, unsi=
gned long lisn)
Quoted 26 lines
arch/powerpc/sysdev/xive/spapr.c +0
-0{long rc;=20=20
arch/powerpc/sysdev/xive/spapr.c +4
-1- rc =3D plpar_hcall_norets(H_INT_SYNC, flags, lisn); +do { + rc =3D plpar_hcall_norets(H_INT_SYNC, flags, lisn); + }while (plpar_busy_delay (rc)); +if (rc) {pr_err ("H_INT_SYNC lisn=3D%ld returned %ld\n" , lisn, rc);return rc;@@ -285,7 +301,11 @@ static long plpar_int_esb(unsigned long flags,pr_devel ("H_INT_ESB flags=3D%lx lisn=3D%lx offset=3D%lx in=3D%lx\n" , flags, lisn, offset, in_data);=20=20
arch/powerpc/sysdev/xive/spapr.c +5
-2- rc =3D plpar_hcall(H_INT_ESB, retbuf, flags, lisn, offset, in_data); +do { + rc =3D plpar_hcall(H_INT_ESB, retbuf, flags, lisn, offset, + in_data); + }while (plpar_busy_delay (rc)); +if (rc) {pr_err ("H_INT_ESB lisn=3D%ld offset=3D%ld returned %ld\n" , lisn, offset, rc); --=202.13.6
Re: [PATCH 4/4] powerpc/xive: prepare all hcalls to support long busy delays
Quoted 10 lines · Michael Ellerman
Quoted 6 lines · Cédric Le Goater
This is not the case for the moment, but future releases of pHyp might need to introduce some synchronisation routines under the hood which would make the XIVE hcalls longer to complete.
As this was done for
H_INT_RESET, let's wrap the other hcalls in a loop catching the H_LONG_BUSY_* codes.Are we sure it's safe to
msleep()in all these paths?
Hmm. No. we could be under lock as these are called at the bottom of the stack of the irq layer. Should we use mdelay() then ?
What about the rtas_busy_delay() in rtas.c ? I was wondering why we were using msleep() there also.
Thanks,
C.
Quoted 86 lines
cheers
Quoted 84 lines
arch/powerpc/sysdev/xive/spapr.c +28
-8@@ -165,7 +165,10 @@ static long plpar_int_get_source_info(unsigned long flags,unsigned long retbuf[PLPAR_HCALL_BUFSIZE ];long rc; - rc =plpar_hcall (H_INT_GET_SOURCE_INFO , retbuf, flags, lisn); +do { + rc =plpar_hcall (H_INT_GET_SOURCE_INFO , retbuf, flags, lisn); + }while (plpar_busy_delay (rc)); +if (rc) {pr_err ("H_INT_GET_SOURCE_INFO lisn=%ld failed %ld\n" , lisn, rc);return rc;@@ -198,8 +201,11 @@ static long plpar_int_set_source_config(unsigned long flags, flags, lisn, target, prio, sw_irq); - rc =plpar_hcall_norets (H_INT_SET_SOURCE_CONFIG , flags, lisn, - target, prio, sw_irq); +do { + rc =plpar_hcall_norets (H_INT_SET_SOURCE_CONFIG , flags, lisn, + target, prio, sw_irq); + }while (plpar_busy_delay (rc)); +if (rc) {pr_err ("H_INT_SET_SOURCE_CONFIG lisn=%ld target=%lx prio=%lx failed %ld\n" , lisn, target, prio, rc);@@ -218,7 +224,11 @@ static long plpar_int_get_queue_info(unsigned long flags,unsigned long retbuf[PLPAR_HCALL_BUFSIZE ];long rc; - rc =plpar_hcall (H_INT_GET_QUEUE_INFO , retbuf, flags, target, priority); +do { + rc =plpar_hcall (H_INT_GET_QUEUE_INFO , retbuf, flags, target, + priority); + }while (plpar_busy_delay (rc)); +if (rc) {pr_err ("H_INT_GET_QUEUE_INFO cpu=%ld prio=%ld failed %ld\n" , target, priority, rc);@@ -247,8 +257,11 @@ static long plpar_int_set_queue_config(unsigned long flags,pr_devel ("H_INT_SET_QUEUE_CONFIG flags=%lx target=%lx priority=%lx qpage=%lx qsize=%lx\n" , flags, target, priority, qpage, qsize); - rc =plpar_hcall_norets (H_INT_SET_QUEUE_CONFIG , flags, target, - priority, qpage, qsize); +do { + rc =plpar_hcall_norets (H_INT_SET_QUEUE_CONFIG , flags, target, + priority, qpage, qsize); + }while (plpar_busy_delay (rc)); +if (rc) {pr_err ("H_INT_SET_QUEUE_CONFIG cpu=%ld prio=%ld qpage=%lx returned %ld\n" , target, priority, qpage, rc);@@ -262,7 +275,10 @@ static long plpar_int_sync(unsigned long flags, unsigned long lisn) {long rc; - rc =plpar_hcall_norets (H_INT_SYNC , flags, lisn); +do { + rc =plpar_hcall_norets (H_INT_SYNC , flags, lisn); + }while (plpar_busy_delay (rc)); +if (rc) {pr_err ("H_INT_SYNC lisn=%ld returned %ld\n" , lisn, rc);return rc;@@ -285,7 +301,11 @@ static long plpar_int_esb(unsigned long flags,pr_devel ("H_INT_ESB flags=%lx lisn=%lx offset=%lx in=%lx\n" , flags, lisn, offset, in_data); - rc =plpar_hcall (H_INT_ESB , retbuf, flags, lisn, offset, in_data); +do { + rc =plpar_hcall (H_INT_ESB , retbuf, flags, lisn, offset, + in_data); + }while (plpar_busy_delay (rc)); +if (rc) {pr_err ("H_INT_ESB lisn=%ld offset=%ld returned %ld\n" , lisn, offset, rc);Signature · 1 line
2.13.6
Re: [PATCH 4/4] powerpc/xive: prepare all hcalls to support long busy delays
In reply to Michael EllermanQuoted 10 lines · Michael Ellerman
Quoted 6 lines · Cédric Le Goater
This is not the case for the moment, but future releases of pHyp might need to introduce some synchronisation routines under the hood which would make the XIVE hcalls longer to complete.
As this was done for
H_INT_RESET, let's wrap the other hcalls in a loop catching the H_LONG_BUSY_* codes.Are we sure it's safe to
msleep()in all these paths?
Probably not. We can have the IRQ descriptor lock. We might need to mdelay.
There's a Kconfig option (forgot which one) that will add checks for attempts to sleep inside locks, you should run with that.
Cheers,
Ben.
Quoted 87 lines
cheers
Quoted 84 lines
arch/powerpc/sysdev/xive/spapr.c +28
-8@@ -165,7 +165,10 @@ static long plpar_int_get_source_info(unsigned long flags,unsigned long retbuf[PLPAR_HCALL_BUFSIZE ];long rc; - rc =plpar_hcall (H_INT_GET_SOURCE_INFO , retbuf, flags, lisn); +do { + rc =plpar_hcall (H_INT_GET_SOURCE_INFO , retbuf, flags, lisn); + }while (plpar_busy_delay (rc)); +if (rc) {pr_err ("H_INT_GET_SOURCE_INFO lisn=%ld failed %ld\n" , lisn, rc);return rc;@@ -198,8 +201,11 @@ static long plpar_int_set_source_config(unsigned long flags, flags, lisn, target, prio, sw_irq); - rc =plpar_hcall_norets (H_INT_SET_SOURCE_CONFIG , flags, lisn, - target, prio, sw_irq); +do { + rc =plpar_hcall_norets (H_INT_SET_SOURCE_CONFIG , flags, lisn, + target, prio, sw_irq); + }while (plpar_busy_delay (rc)); +if (rc) {pr_err ("H_INT_SET_SOURCE_CONFIG lisn=%ld target=%lx prio=%lx failed %ld\n" , lisn, target, prio, rc);@@ -218,7 +224,11 @@ static long plpar_int_get_queue_info(unsigned long flags,unsigned long retbuf[PLPAR_HCALL_BUFSIZE ];long rc; - rc =plpar_hcall (H_INT_GET_QUEUE_INFO , retbuf, flags, target, priority); +do { + rc =plpar_hcall (H_INT_GET_QUEUE_INFO , retbuf, flags, target, + priority); + }while (plpar_busy_delay (rc)); +if (rc) {pr_err ("H_INT_GET_QUEUE_INFO cpu=%ld prio=%ld failed %ld\n" , target, priority, rc);@@ -247,8 +257,11 @@ static long plpar_int_set_queue_config(unsigned long flags,pr_devel ("H_INT_SET_QUEUE_CONFIG flags=%lx target=%lx priority=%lx qpage=%lx qsize=%lx\n" , flags, target, priority, qpage, qsize); - rc =plpar_hcall_norets (H_INT_SET_QUEUE_CONFIG , flags, target, - priority, qpage, qsize); +do { + rc =plpar_hcall_norets (H_INT_SET_QUEUE_CONFIG , flags, target, + priority, qpage, qsize); + }while (plpar_busy_delay (rc)); +if (rc) {pr_err ("H_INT_SET_QUEUE_CONFIG cpu=%ld prio=%ld qpage=%lx returned %ld\n" , target, priority, qpage, rc);@@ -262,7 +275,10 @@ static long plpar_int_sync(unsigned long flags, unsigned long lisn) {long rc; - rc =plpar_hcall_norets (H_INT_SYNC , flags, lisn); +do { + rc =plpar_hcall_norets (H_INT_SYNC , flags, lisn); + }while (plpar_busy_delay (rc)); +if (rc) {pr_err ("H_INT_SYNC lisn=%ld returned %ld\n" , lisn, rc);return rc;@@ -285,7 +301,11 @@ static long plpar_int_esb(unsigned long flags,pr_devel ("H_INT_ESB flags=%lx lisn=%lx offset=%lx in=%lx\n" , flags, lisn, offset, in_data); - rc =plpar_hcall (H_INT_ESB , retbuf, flags, lisn, offset, in_data); +do { + rc =plpar_hcall (H_INT_ESB , retbuf, flags, lisn, offset, + in_data); + }while (plpar_busy_delay (rc)); +if (rc) {pr_err ("H_INT_ESB lisn=%ld offset=%ld returned %ld\n" , lisn, offset, rc);Signature · 1 line
2.13.6
Michael Ellerman
reviewerRe: [PATCH 4/4] powerpc/xive: prepare all hcalls to support long busy delays
Quoted 9 lines · Benjamin Herrenschmidt
Quoted 8 lines · Michael Ellerman
C=C3=A9dric Le Goater <[email protected]> writes:
=20Quoted 6 lines
This is not the case for the moment, but future releases of pHyp might need to introduce some synchronisation routines under the hood which would make the XIVE hcalls longer to complete.
=20
As this was done forH_INT_RESET, let's wrap the other hcalls in a loop catching the H_LONG_BUSY_* codes.
Quoted 8 lines
Quoted 2 lines
=20
Are we sure it's safe tomsleep()in all these paths?Probably not. We can have the IRQ descriptor lock. We might need to mdelay.
There's a
Kconfigoption (forgot which one) that will add checks for attempts to sleep inside locks, you should run with that.
CONFIG_DEBUG_ATOMIC_SLEEP
cheers
Re: [PATCH 4/4] powerpc/xive: prepare all hcalls to support long busy delays
Quoted 13 lines · Michael Ellerman
Quoted 12 lines · Benjamin Herrenschmidt
Quoted 10 lines · Michael Ellerman
Quoted 6 lines · Cédric Le Goater
This is not the case for the moment, but future releases of pHyp might need to introduce some synchronisation routines under the hood which would make the XIVE hcalls longer to complete.
As this was done for
H_INT_RESET, let's wrap the other hcalls in a loop catching the H_LONG_BUSY_* codes.Are we sure it's safe to
msleep()in all these paths?
Quoted 7 lines
Quoted 5 lines
Probably not. We can have the IRQ descriptor lock. We might need to mdelay.
There's a
Kconfigoption (forgot which one) that will add checks for attempts to sleep inside locks, you should run with that.
CONFIG_DEBUG_ATOMIC_SLEEP
[ 435.757986] kexec_core: Starting new kernel [ 435.778162] BUG: scheduling while atomic: kexec/1633/0x00000003
That proved to be useful. Thanks.
I will resend the full series changing msleep() to mdelay() and fixing a bit the changelog.
Cheers,
C.
Quoted 9 lines · Cédric Le Goater
H_INT_RESETperforms a reset of the Hypervisor internal interrupt structures, removing all settings done withH_INT_SET_SOURCE_CONFIGandH_INT_SET_QUEUE_CONFIG. This is most important for kdump and kexec to be able to restart in a clean state.First patch closes a window in the kexec sequence in which the
H_INT_RESEThcall can be run concurrently with other hcalls when CPUs are brought down. The other patches wire up the reset hcall making sure it supports H_LONG_BUSY_* returned by the Hypervisor.
Does anyone has some time to take a look ?
Thanks,
C.
Quoted 11 lines
Cédric Le Goater (4):
powerpc/64/kexec: fix race in kexec when XIVE is shutdowned powerpc/xive: fix hcallH_INT_RESETto support long busy delays powerpc/xive: shutdown XIVE when kexec or kdump is performed powerpc/xive: prepare all hcalls to support long busy delaysarch/powerpc/kernel/machine_kexec_64.c | 8 +-- arch/powerpc/platforms/pseries/kexec.c | 7 ++- arch/powerpc/sysdev/xive/spapr.c | 89 +++++++++++++++++++++++++++++----- 3 files changed, 85 insertions(+), 19 deletions(-)