arm:pm: save the vfp state of last scheduled-out proceed while suspending
Subsystems (2)
PATCH 1/1 arm:pm: save the vfp state of last scheduled-out proceed while suspending
From: Rongjun Ying <[email protected]>
Current vfp pm suspend entry only saves the vfp state of running proceed if it is using vfp. If current proceed doesn't use vfp, the state of last process will be lost after resume. In pressure tests, we can see old vfp processes crash after resume.
In order that schedule can be faster, scheduler doesn't save vfp state if we schedule from proceeds using vfp to proceeds which don't use vfp. If system suspend happens just at proceeds which don't use vfp, we have no any chance to save old vfp state.
--- arch/arm/vfp/vfpmodule.c | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-)
arch/arm/vfp/vfpmodule.c +9 -0
@@ -384,6 +384,7 @@ static int vfp_pm_suspend(struct sys_device *dev, pm_message_t state) {struct thread_info *ti =current_thread_info ();u32 fpexc =fmrx (FPEXC ); +unsigned int cpu =get_cpu ();/* if vfp is on, then save state for resumption */ if (fpexc &FPEXC_EN ) {
@@ -392,8 +393,16 @@ static int vfp_pm_suspend(struct sys_device *dev, pm_message_t state)/* disable, just in case */ fmxr (FPEXC ,fmrx (FPEXC ) & ~FPEXC_EN ); + }else { +if (last_VFP_context[cpu]) { +fmxr (FPEXC , fpexc |FPEXC_EN ); +vfp_save_state (last_VFP_context[cpu], fpexc); +fmxr (FPEXC , fpexc); + } } +put_cpu (); +/* clear any information we had about last context state */ memset (last_VFP_context,0 ,sizeof (last_VFP_context));
Signature · 5 lines
1.7.1 Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
PATCH 1/1 arm:pm: save the vfp state of last scheduled-out proceed while suspending
Quoted 11 lines · Barry Song
From: Rongjun Ying <[email protected]>
Current vfp pm suspend entry only saves the vfp state of running proceed if it is using vfp. If current proceed doesn't use vfp, the state of last process will be lost after resume. In pressure tests, we can see old vfp processes crash after resume.
In order that schedule can be faster, scheduler doesn't save vfp state if we schedule from proceeds using vfp to proceeds which don't use vfp. If system suspend happens just at proceeds which don't use vfp, we have no any chance to save old vfp state.
Signed-off-by Rongjun Ying <[email protected]>Cc Binghua Duan <[email protected]>Signed-off-by Barry Song <[email protected]>
There was a similar patch some time ago by Colin Cross. I don't know what happened to it but please have a look at that discussion first:
http://thread.gmane.org/gmane.linux.kernel/1099558
Signature · 1 line
Catalin
PATCH 1/1 arm:pm: save the vfp state of last scheduled-out proceed while suspending
Hi Catalin,
Thanks.
2011/4/29 Catalin Marinas <[email protected]>:
Quoted 9 lines · Barry Song
Quoted 8 lines
From: Rongjun Ying <[email protected]>
Current vfp pm suspend entry only saves the vfp state of running proceed if it is using vfp. If current proceed doesn't use vfp, the state of last process will be lost after resume. In pressure tests, we can see old vfp processes crash after resume.
In order that schedule can be faster, scheduler doesn't save vfp state if we schedule from proceeds using vfp to proceeds which don't use vfp. If system suspend happens just at proceeds which don't use vfp, we have no any chance to save old vfp state.
Quoted 8 lines
Quoted 3 lines
Signed-off-by Rongjun Ying <[email protected]>Cc Binghua Duan <[email protected]>Signed-off-by Barry Song <[email protected]>There was a similar patch some time ago by Colin Cross. I don't know what happened to it but please have a look at that discussion first:
sorry, i didn't see any patch committed and lost the thread in lkml.
Seems like Rongjun's codes have handled Russel's last change but in the "else". Russel handles it before the "if (fpexc & FPEXC_EN) {". We will take over the test in
http://thread.gmane.org/gmane.linux.kernel/1099558 and continue to send patch v3.
Quoted 4 lines
--
Catalin
PATCH 1/1 arm:pm: save the vfp state of last scheduled-out proceed while suspending
2011/4/29 Barry Song <[email protected]>:
Quoted 21 lines
Hi Catalin,
Thanks.
2011/4/29 Catalin Marinas <[email protected]>:Quoted 9 lines · Barry Song
Quoted 8 lines
From: Rongjun Ying <[email protected]>
Current vfp pm suspend entry only saves the vfp state of running proceed if it is using vfp. If current proceed doesn't use vfp, the state of last process will be lost after resume. In pressure tests, we can see old vfp processes crash after resume.
In order that schedule can be faster, scheduler doesn't save vfp state if we schedule from proceeds using vfp to proceeds which don't use vfp. If system suspend happens just at proceeds which don't use vfp, we have no any chance to save old vfp state.
Quoted 8 lines
Quoted 3 lines
Signed-off-by Rongjun Ying <[email protected]>Cc Binghua Duan <[email protected]>Signed-off-by Barry Song <[email protected]>There was a similar patch some time ago by Colin Cross. I don't know what happened to it but please have a look at that discussion first:
Quoted 7 lines
sorry, i didn't see any patch committed and lost the thread in lkml.
Seems like Rongjun's codes have handled Russel's last change but in the "else". Russel handles it before the "if (fpexc &
FPEXC_EN) {". We will take over the test in
http://thread.gmane.org/gmane.linux.kernel/1099558 and continue to send patch v3.
but we don't think Russel's last change is complelety right by:
/* If lazy disable, re-enable the VFP ready for it to be saved */
if (last_VFP_context[ti->cpu] != &ti->vfpstate) {
fpexc |= FPEXC_EN;
fmxr(FPEXC, fpexc);
}
/* If VFP is on, then save state for resumption */
if (fpexc & FPEXC_EN) {
...there are still risk. For example, if process p1/p2 switch like this:
P1: use vfp
swith to -> P2: don't use vfp
switch to -> P1(use vfp), but it didn't begin touse vfp, then FPEXC_EN is not set, but suspend happen at that moment
At the last time, last_VFP_context[ti->cpu] will be &ti->vfpstate, fpexc & FPEXC_EN will be false. it loses the chance to save status. So looks like Rongjun's codes can avoid this kind of risk:
/* if vfp is on, then save state for resumption */
if (fpexc & FPEXC_EN) {@@ -392,8 +393,16 @@ static int vfp_pm_suspend(struct sys_device *dev, pm_message_t state)
/* disable, just in case */
fmxr(FPEXC, fmrx(FPEXC) & ~FPEXC_EN);
+ } else {
+ if (last_VFP_context[cpu]) {
+ fmxr(FPEXC, fpexc | FPEXC_EN);
+ vfp_save_state(last_VFP_context[cpu], fpexc);
+ fmxr(FPEXC, fpexc);
+ }
}Quoted 6 lines
Quoted 5 lines
--
Catalin
PATCH 1/1 arm:pm: save the vfp state of last scheduled-out proceed while suspending
Quoted 17 lines · Barry Song
2011/4/29 Barry Song <[email protected]>:
Quoted 5 lines
Seems like Rongjun's codes have handled Russel's last change but in the "else". Russel handles it before the "if (fpexc &
FPEXC_EN) {". We will take over the test in
http://thread.gmane.org/gmane.linux.kernel/1099558 and continue to send patch v3.but we don't think Russel's last change is complelety right by:
/* If lazy disable, re-enable the VFP ready for it to be saved */if (last_VFP_context[ti->cpu] != &ti->vfpstate) { fpexc |= FPEXC_EN; fmxr(FPEXC, fpexc); } /* If VFP is on, then save state for resumption */ if (fpexc & FPEXC_EN) { ...
Quoted 8 lines
there are still risk. For example, if process p1/p2 switch like this:
P1: use vfpswith to -> P2: don't use vfp switch to -> P1(use vfp), but it didn't begin touse vfp, then
FPEXC_ENis not set, but suspend happen at that momentAt the last time, last_VFP_context[ti->cpu] will be
&ti->vfpstate, fpexc &FPEXC_ENwill be false. it loses the chance to save status.
I think your scenario is possible on UP systems. On SMP we save the VFP context during thread switching anyway.
Quoted 4 lines
So looks like Rongjun's codes can avoid this kind of risk:
/* if vfp is on, then save state for resumption */ if (fpexc & FPEXC_EN) {
arch/arm/vfp/vfpmodule.c static int vfp_pm_suspend(struct sys_device *dev, pm_message_t state) · line 402
Quoted 10 lines
arch/arm/vfp/vfpmodule.c +6
-0@@ -392,8 +393,16 @@ static int vfp_pm_suspend(struct sys_device *dev, pm_message_t state)/* disable, just in case */ fmxr (FPEXC ,fmrx (FPEXC ) & ~FPEXC_EN ); + }else { +if (last_VFP_context[cpu]) { +fmxr (FPEXC , fpexc |FPEXC_EN ); +vfp_save_state (last_VFP_context[cpu], fpexc); +fmxr (FPEXC , fpexc); + } }
I think we need to set last_VFP_context[cpu] to NULL as well so that the context is reloaded.
Signature · 1 line
Catalin
PATCH 1/1 arm:pm: save the vfp state of last scheduled-out proceed while suspending
Hi Catalin,
2011/5/3 Catalin Marinas <[email protected]>:
Quoted 35 lines · Barry Song
Quoted 17 lines
2011/4/29 Barry Song <[email protected]>:
Quoted 5 lines
Seems like Rongjun's codes have handled Russel's last change but in the "else". Russel handles it before the "if (fpexc &
FPEXC_EN) {". We will take over the test in
http://thread.gmane.org/gmane.linux.kernel/1099558 and continue to send patch v3.but we don't think Russel's last change is complelety right by:
/* If lazy disable, re-enable the VFP ready for it to be saved */ ? ? ? ? if (last_VFP_context[ti->cpu] !=&ti->vfpstate) { ? ? ? ? ? ? ? ? fpexc |=FPEXC_EN;
? ? ? ? ? ? ? ?fmxr(FPEXC, fpexc);
? ? ? ? }
? ? ? ? /* If VFP is on, then save state for resumption */ ? ? ? ? if (fpexc &FPEXC_EN) {
? ? ? ? ? ? ? ? ...Quoted 8 lines
there are still risk. ?For example, if process p1/p2 switch like this:
P1: ? ? use vfp
? ? ? ?swith to -> P2: don't use vfp
? ? ? ? ? ? ? ? ? ? switch to ?-> P1(use vfp), but it didn't begin to use vfp, then ?FPEXC_EN is not set, but suspend happen at that momentAt the last time, last_VFP_context[ti->cpu] will be
&ti->vfpstate, fpexc &FPEXC_ENwill be false. it loses the chance to save status.I think your scenario is possible on UP systems. On SMP we save the VFP context during thread switching anyway.
Quoted 5 lines
So looks like Rongjun's codes can avoid this kind of risk:
? ? ? ?/* if vfp is on, then save state for resumption */ ? ? ? ?if (fpexc &FPEXC_EN) {(quoted diff) +0
-0@@ -392,8 +393,16 @@ static int vfp_pm_suspend(struct sys_device *dev, pm_message_t state)
Quoted 12 lines
Quoted 9 lines
? ? ? ? ? ? ? ?/* disable, just in case */
? ? ? ? ? ? ? ?fmxr(FPEXC, fmrx(FPEXC) & ~FPEXC_EN);
+ ? ? ? } else {
+ ? ? ? ? ? ? ? if (last_VFP_context[cpu]) {
+ ? ? ? ? ? ? ? ? ? ? ?fmxr(FPEXC, fpexc | FPEXC_EN);
+ ? ? ? ? ? ? ? ? ? ? ?vfp_save_state(last_VFP_context[cpu], fpexc);
+ ? ? ? ? ? ? ? ? ? ? ?fmxr(FPEXC, fpexc);
+ ? ? ? ? ? ? ? }
? ? ? ?}I think we need to set last_VFP_context[cpu] to NULL as well so that the context is reloaded.
The original codes have the below:
/* clear any information we had about last context state */
memset(last_VFP_context, 0, sizeof(last_VFP_context));Quoted 6 lines
--
Catalin
Thanks
Barry