Commit cd74257b authored by Konrad Rzeszutek Wilk's avatar Konrad Rzeszutek Wilk Committed by H. Peter Anvin

x86, acpi: Call acpi_enter_sleep_state via an asmlinkage C function from assembler

With commit a2ef5c4f
"ACPI: Move module parameter gts and bfs to sleep.c" the
wake_sleep_flags is required when calling acpi_enter_sleep_state.

The assembler code in wakeup_*.S did not do that. One solution
is to call it from assembler and stick the wake_sleep_flags on
the stack (for 32-bit) or in %esi (for 64-bit). hpa and rafael
both suggested however to create a wrapper function to call
acpi_enter_sleep_state and call said wrapper function
("acpi_enter_s3") from assembler.

For 32-bit, the acpi_enter_s3 ends up looking as so:

  push   %ebp
  mov    %esp,%ebp
  sub    $0x8,%esp
  movzbl 0xc1809314,%eax [wake_sleep_flags]
  movl   $0x3,(%esp)
  mov    %eax,0x4(%esp)
  call   0xc12d1fa0 <acpi_enter_sleep_state>
  leave
  ret

And 64-bit:

  movzbl 0x9afde1(%rip),%esi        [wake_sleep_flags]
  push   %rbp
  mov    $0x3,%edi
  mov    %rsp,%rbp
  callq  0xffffffff812e9800 <acpi_enter_sleep_state>
  leaveq
  retq
Reviewed-by: default avatarH. Peter Anvin <hpa@zytor.com>
Suggested-by: default avatarH. Peter Anvin <hpa@zytor.com>
[v2: Remove extra assembler operations, per hpa review]
Signed-off-by: default avatarKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Link: http://lkml.kernel.org/r/1335150198-21899-3-git-send-email-konrad.wilk@oracle.comSigned-off-by: default avatarH. Peter Anvin <hpa@linux.intel.com>
parent 2a14e541
...@@ -24,6 +24,10 @@ unsigned long acpi_realmode_flags; ...@@ -24,6 +24,10 @@ unsigned long acpi_realmode_flags;
static char temp_stack[4096]; static char temp_stack[4096];
#endif #endif
asmlinkage void acpi_enter_s3(void)
{
acpi_enter_sleep_state(3, wake_sleep_flags);
}
/** /**
* acpi_suspend_lowlevel - save kernel state * acpi_suspend_lowlevel - save kernel state
* *
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
*/ */
#include <asm/trampoline.h> #include <asm/trampoline.h>
#include <linux/linkage.h>
extern unsigned long saved_video_mode; extern unsigned long saved_video_mode;
extern long saved_magic; extern long saved_magic;
...@@ -10,6 +11,7 @@ extern long saved_magic; ...@@ -10,6 +11,7 @@ extern long saved_magic;
extern int wakeup_pmode_return; extern int wakeup_pmode_return;
extern u8 wake_sleep_flags; extern u8 wake_sleep_flags;
extern asmlinkage void acpi_enter_s3(void);
extern unsigned long acpi_copy_wakeup_routine(unsigned long); extern unsigned long acpi_copy_wakeup_routine(unsigned long);
extern void wakeup_long64(void); extern void wakeup_long64(void);
......
...@@ -74,9 +74,7 @@ restore_registers: ...@@ -74,9 +74,7 @@ restore_registers:
ENTRY(do_suspend_lowlevel) ENTRY(do_suspend_lowlevel)
call save_processor_state call save_processor_state
call save_registers call save_registers
pushl $3 call acpi_enter_s3
call acpi_enter_sleep_state
addl $4, %esp
# In case of S3 failure, we'll emerge here. Jump # In case of S3 failure, we'll emerge here. Jump
# to ret_point to recover # to ret_point to recover
......
...@@ -71,9 +71,7 @@ ENTRY(do_suspend_lowlevel) ...@@ -71,9 +71,7 @@ ENTRY(do_suspend_lowlevel)
movq %rsi, saved_rsi movq %rsi, saved_rsi
addq $8, %rsp addq $8, %rsp
movl $3, %edi call acpi_enter_s3
xorl %eax, %eax
call acpi_enter_sleep_state
/* in case something went wrong, restore the machine status and go on */ /* in case something went wrong, restore the machine status and go on */
jmp resume_point jmp resume_point
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment