ACPI: Move module parameter gts and bfs to sleep.c
Subsystems (3)
Hey Lin,
I was wondering if you are OK with exporting the wake_sleep_flags function so that other callers of acpi_enter_sleep (which are outside the sleep.c) could use it?
[which I was hoping to post for v3.5]
.. which in 3.3 would call acpi_enter_sleep_state without trouble but with 3.4 it needs a parameter.
This little patch (compile tested, but not actually run):
commit 8f9f29819fa71de17e2e6f38fc50c4156dc3dada
Author: Konrad Rzeszutek Wilk <[email protected]> Date: Fri Apr 6 17:53:51 2012 -0400
ACPI: Convert wake_sleep_flags to a value instead of function.
With commit a2ef5c4fd44ce3922435139393b89f2cce47f576
"ACPI: Move module parameter gts and bfs to sleep.c" the wake_sleep_flags is required when calling acpi_enter_sleep_state, which means that if there are functions outside the sleep.c code they can't get get the wake_sleep_flags values.
This converts the function in to a exported value and converts the module config operands to a function.
arch/x86/kernel/acpi/sleep.h +2 -0
@@ -9,6 +9,8 @@ extern long saved_magic;extern int wakeup_pmode_return; +extern unsigned wake_sleep_flags; +extern unsigned long acpi_copy_wakeup_routine (unsigned long );extern void wakeup_long64 (void );
drivers/acpi/sleep.c +16 -22
@@ -28,23 +28,23 @@#include "internal.h" #include "sleep.h" +u8 wake_sleep_flags =ACPI_NO_OPTIONAL_METHODS ;static unsigned int gts, bfs; -module_param (gts, uint,0644 ); -module_param (bfs, uint,0644 ); -MODULE_PARM_DESC (gts,"Enable evaluation of _GTS on suspend." ); -MODULE_PARM_DESC(bfs, "Enable evaluation of _BFS on resume".); - -static u8 wake_sleep_flags (void ) +static int set_param_wake_flag (const char *val,struct kernel_param *kp) { -u8 flags =ACPI_NO_OPTIONAL_METHODS ; +int ret =param_set_int (val, kp);if (gts) - flags |=ACPI_EXECUTE_GTS ; + wake_sleep_flags |=ACPI_EXECUTE_GTS ;if (bfs) - flags |=ACPI_EXECUTE_BFS ; + wake_sleep_flags |=ACPI_EXECUTE_BFS ; -return flags; +return ret; } +module_param_call (gts, set_param_wake_flag, param_get_int, >s,0644 ); +module_param_call (bfs, set_param_wake_flag, param_get_int, &bfs,0644 ); +MODULE_PARM_DESC (gts,"Enable evaluation of _GTS on suspend." ); +MODULE_PARM_DESC(bfs, "Enable evaluation of _BFS on resume".);static u8 sleep_states[ACPI_S_STATE_COUNT ];
@@ -263,7 +263,6 @@ static int acpi_suspend_enter(suspend_state_t pm_state) {acpi_status status =AE_OK ;u32 acpi_state = acpi_target_sleep_state; -u8 flags =wake_sleep_flags ();int error;ACPI_FLUSH_CPU_CACHE ();
@@ -271,7 +270,7 @@ static int acpi_suspend_enter(suspend_state_t pm_state)switch (acpi_state) {case ACPI_STATE_S1 :barrier (); - status =acpi_enter_sleep_state (acpi_state, flags); + status =acpi_enter_sleep_state (acpi_state, wake_sleep_flags);break ;case ACPI_STATE_S3 :
@@ -288,7 +287,7 @@ static int acpi_suspend_enter(suspend_state_t pm_state)acpi_write_bit_register (ACPI_BITREG_SCI_ENABLE ,1 );/* Reprogram control registers and execute _BFS */ -acpi_leave_sleep_state_prep (acpi_state, flags); +acpi_leave_sleep_state_prep (acpi_state, wake_sleep_flags);/* ACPI 3.0 specs (P62) says that it's the responsibility * of the OSPM to clear the status bit [ implying that the
@@ -552,30 +551,27 @@ static int acpi_hibernation_begin(void)static int acpi_hibernation_enter (void ) { -u8 flags =wake_sleep_flags ();acpi_status status =AE_OK ;ACPI_FLUSH_CPU_CACHE ();/* This shouldn't return. If it returns, we have a problem */ - status =acpi_enter_sleep_state (ACPI_STATE_S4 , flags); + status =acpi_enter_sleep_state (ACPI_STATE_S4 , wake_sleep_flags);/* Reprogram control registers and execute _BFS */ -acpi_leave_sleep_state_prep (ACPI_STATE_S4 , flags); +acpi_leave_sleep_state_prep (ACPI_STATE_S4 , wake_sleep_flags);return ACPI_SUCCESS (status) ?0 : -EFAULT ; }static void acpi_hibernation_leave (void ) { -u8 flags =wake_sleep_flags (); -/* * If ACPI is not enabled by the BIOS and the boot kernel, we need to * enable it here. */ acpi_enable ();/* Reprogram control registers and execute _BFS */ -acpi_leave_sleep_state_prep (ACPI_STATE_S4 , flags); +acpi_leave_sleep_state_prep (ACPI_STATE_S4 , wake_sleep_flags);/* Check the hardware signature */ if (facs && s4_hardware_signature != facs->hardware_signature) { printk(KERN_EMERG "ACPI: Hardware changed while hibernated, "
@@ -830,12 +826,10 @@ static void acpi_power_off_prepare(void)static void acpi_power_off (void ) { -u8 flags =wake_sleep_flags (); -/* acpi_sleep_prepare(ACPI_STATE_S5) should have already been called */ printk (KERN_DEBUG "%s called\n" , __func__);local_irq_disable (); -acpi_enter_sleep_state (ACPI_STATE_S5 , flags); +acpi_enter_sleep_state (ACPI_STATE_S5 , wake_sleep_flags); }/*
Quoted 21 lines · Konrad Rzeszutek Wilk
Hey Lin,
I was wondering if you are OK with exporting the
wake_sleep_flagsfunction so that other callers ofacpi_enter_sleep(which are outside thesleep.c) could use it?[which I was hoping to post for v3.5]
.. which in 3.3 would callacpi_enter_sleep_statewithout trouble but with 3.4 it needs a parameter.This little patch (compile tested, but not actually run):
commit
8f9f29819fa71de17e2e6f38fc50c4156dc3dada
Author: Konrad Rzeszutek Wilk <[email protected]>
Date: Fri Apr 6 17:53:51 2012 -0400ACPI: Convert
wake_sleep_flagsto a value instead of function.
Quoted 8 lines
With commit
a2ef5c4fd44ce3922435139393b89f2cce47f576
"ACPI: Move module parameter gts and bfs tosleep.c" thewake_sleep_flagsis required when callingacpi_enter_sleep_state, which means that if there are functions outside thesleep.ccode they can't get get thewake_sleep_flagsvalues.This converts the function in to a exported value and converts the module config operands to a function.
Why not just export the function?
Do you mean to save a function call by converting it to a value?
Looks good to me.
Thanks,
Lin Ming
Quoted 129 lines
Signed-off-by Konrad Rzeszutek Wilk <[email protected]>arch/x86/kernel/acpi/sleep.h +2
-0@@ -9,6 +9,8 @@ extern long saved_magic; extern int wakeup_pmode_return; +extern unsigned wake_sleep_flags; + extern unsigned long acpi_copy_wakeup_routine(unsigned long); extern void wakeup_long64(void);drivers/acpi/sleep.c +10
-11@@ -28,23 +28,23 @@ #include "internal.h" #include "sleep.h" +u8 wake_sleep_flags =ACPI_NO_OPTIONAL_METHODS ; static unsigned int gts, bfs; -module_param (gts, uint,0644 ); -module_param (bfs, uint,0644 ); -MODULE_PARM_DESC (gts,"Enable evaluation of _GTS on suspend." ); -MODULE_PARM_DESC(bfs, "Enable evaluation of _BFS on resume".); - -static u8 wake_sleep_flags (void ) +static int set_param_wake_flag (const char *val,struct kernel_param *kp) { - u8 flags = ACPI_NO_OPTIONAL_METHODS; + int ret = param_set_int(val, kp); if (gts) - flags |= ACPI_EXECUTE_GTS; + wake_sleep_flags |= ACPI_EXECUTE_GTS; if (bfs) - flags |= ACPI_EXECUTE_BFS; + wake_sleep_flags |= ACPI_EXECUTE_BFS; - return flags; + return ret; } +module_param_call (gts, set_param_wake_flag, param_get_int, >s,0644 ); +module_param_call (bfs, set_param_wake_flag, param_get_int, &bfs,0644 ); +MODULE_PARM_DESC (gts,"Enable evaluation of _GTS on suspend." ); +MODULE_PARM_DESC(bfs, "Enable evaluation of _BFS on resume".); static u8 sleep_states[ACPI_S_STATE_COUNT];@@ -263,7 +263,6 @@ static int acpi_suspend_enter(suspend_state_t pm_state) { acpi_status status = AE_OK; u32 acpi_state = acpi_target_sleep_state; - u8 flags = wake_sleep_flags(); int error; ACPI_FLUSH_CPU_CACHE();@@ -271,7 +270,7 @@ static int acpi_suspend_enter(suspend_state_t pm_state) switch (acpi_state) {case
ACPI_STATE_S1:
barrier();
- status =acpi_enter_sleep_state(acpi_state, flags);
+ status =acpi_enter_sleep_state(acpi_state, wake_sleep_flags); break;case
ACPI_STATE_S3:drivers/acpi/sleep.c +4
-7@@ -288,7 +287,7 @@ static int acpi_suspend_enter(suspend_state_t pm_state) acpi_write_bit_register(ACPI_BITREG_SCI_ENABLE, 1); /* Reprogram control registers and execute _BFS */ - acpi_leave_sleep_state_prep(acpi_state, flags); + acpi_leave_sleep_state_prep(acpi_state, wake_sleep_flags); /* ACPI 3.0 specs (P62) says that it's the responsibility* of the OSPM to clear the status bit [ implying that the @@ -552,30 +551,27 @@ static int acpi_hibernation_begin(void) static int acpi_hibernation_enter(void) { - u8 flags = wake_sleep_flags(); acpi_status status = AE_OK; ACPI_FLUSH_CPU_CACHE(); /* This shouldn't return. If it returns, we have a problem */ - status = acpi_enter_sleep_state(ACPI_STATE_S4, flags); + status = acpi_enter_sleep_state(ACPI_STATE_S4, wake_sleep_flags); /* Reprogram control registers and execute _BFS */ - acpi_leave_sleep_state_prep(ACPI_STATE_S4, flags); + acpi_leave_sleep_state_prep(ACPI_STATE_S4, wake_sleep_flags); return ACPI_SUCCESS(status) ? 0 : -EFAULT; } static void acpi_hibernation_leave(void) { - u8 flags = wake_sleep_flags(); - /* * If ACPI is not enabled by the BIOS and the boot kernel, we need to * enable it here. */ acpi_enable(); /* Reprogram control registers and execute _BFS */ - acpi_leave_sleep_state_prep(ACPI_STATE_S4, flags); + acpi_leave_sleep_state_prep(ACPI_STATE_S4, wake_sleep_flags); /* Check the hardware signature */ if (facs && s4_hardware_signature != facs->hardware_signature) {printk(KERN_EMERG "ACPI: Hardware changed while hibernated, "
drivers/acpi/sleep.c +1
-4@@ -830,12 +826,10 @@ static void acpi_power_off_prepare(void) static void acpi_power_off(void) { - u8 flags = wake_sleep_flags(); - /* acpi_sleep_prepare(ACPI_STATE_S5) should have already been called */ printk(KERN_DEBUG "%s called\n", __func__); local_irq_disable(); - acpi_enter_sleep_state(ACPI_STATE_S5, flags); + acpi_enter_sleep_state(ACPI_STATE_S5, wake_sleep_flags); } /* --
Quoted 29 lines · Lin Ming
Quoted 27 lines · Konrad Rzeszutek Wilk
Hey Lin,
I was wondering if you are OK with exporting the
wake_sleep_flagsfunction so that other callers ofacpi_enter_sleep(which are outside thesleep.c) could use it?[which I was hoping to post for v3.5]
.. which in 3.3 would callacpi_enter_sleep_statewithout trouble but with 3.4 it needs a parameter.This little patch (compile tested, but not actually run):
commit
8f9f29819fa71de17e2e6f38fc50c4156dc3dada
Author: Konrad Rzeszutek Wilk <[email protected]>
Date: Fri Apr 6 17:53:51 2012 -0400ACPI: Convert
wake_sleep_flagsto a value instead of function.With commit
a2ef5c4fd44ce3922435139393b89f2cce47f576
"ACPI: Move module parameter gts and bfs tosleep.c" thewake_sleep_flagsis required when callingacpi_enter_sleep_state, which means that if there are functions outside thesleep.ccode they can't get get thewake_sleep_flagsvalues.
Quoted 4 lines
Quoted 2 lines
This converts the function in to a exported value and converts the module config operands to a function.
Why not just export the function?
That is possible too.
Quoted 1 line
Do you mean to save a function call by converting it to a value?
That was my thinking.
Quoted 135 lines
Looks good to me.
Thanks,
Lin MingQuoted 129 lines
Signed-off-by Konrad Rzeszutek Wilk <[email protected]>arch/x86/kernel/acpi/sleep.h +2
-0@@ -9,6 +9,8 @@ extern long saved_magic; extern int wakeup_pmode_return; +extern unsigned wake_sleep_flags; + extern unsigned long acpi_copy_wakeup_routine(unsigned long); extern void wakeup_long64(void);drivers/acpi/sleep.c +10
-11@@ -28,23 +28,23 @@ #include "internal.h" #include "sleep.h" +u8 wake_sleep_flags =ACPI_NO_OPTIONAL_METHODS ; static unsigned int gts, bfs; -module_param (gts, uint,0644 ); -module_param (bfs, uint,0644 ); -MODULE_PARM_DESC (gts,"Enable evaluation of _GTS on suspend." ); -MODULE_PARM_DESC(bfs, "Enable evaluation of _BFS on resume".); - -static u8 wake_sleep_flags (void ) +static int set_param_wake_flag (const char *val,struct kernel_param *kp) { - u8 flags = ACPI_NO_OPTIONAL_METHODS; + int ret = param_set_int(val, kp); if (gts) - flags |= ACPI_EXECUTE_GTS; + wake_sleep_flags |= ACPI_EXECUTE_GTS; if (bfs) - flags |= ACPI_EXECUTE_BFS; + wake_sleep_flags |= ACPI_EXECUTE_BFS; - return flags; + return ret; } +module_param_call (gts, set_param_wake_flag, param_get_int, >s,0644 ); +module_param_call (bfs, set_param_wake_flag, param_get_int, &bfs,0644 ); +MODULE_PARM_DESC (gts,"Enable evaluation of _GTS on suspend." ); +MODULE_PARM_DESC(bfs, "Enable evaluation of _BFS on resume".); static u8 sleep_states[ACPI_S_STATE_COUNT];@@ -263,7 +263,6 @@ static int acpi_suspend_enter(suspend_state_t pm_state) { acpi_status status = AE_OK; u32 acpi_state = acpi_target_sleep_state; - u8 flags = wake_sleep_flags(); int error; ACPI_FLUSH_CPU_CACHE();@@ -271,7 +270,7 @@ static int acpi_suspend_enter(suspend_state_t pm_state) switch (acpi_state) {case
ACPI_STATE_S1:
barrier();
- status =acpi_enter_sleep_state(acpi_state, flags);
+ status =acpi_enter_sleep_state(acpi_state, wake_sleep_flags); break;case
ACPI_STATE_S3:drivers/acpi/sleep.c +4
-7@@ -288,7 +287,7 @@ static int acpi_suspend_enter(suspend_state_t pm_state) acpi_write_bit_register(ACPI_BITREG_SCI_ENABLE, 1); /* Reprogram control registers and execute _BFS */ - acpi_leave_sleep_state_prep(acpi_state, flags); + acpi_leave_sleep_state_prep(acpi_state, wake_sleep_flags); /* ACPI 3.0 specs (P62) says that it's the responsibility* of the OSPM to clear the status bit [ implying that the @@ -552,30 +551,27 @@ static int acpi_hibernation_begin(void) static int acpi_hibernation_enter(void) { - u8 flags = wake_sleep_flags(); acpi_status status = AE_OK; ACPI_FLUSH_CPU_CACHE(); /* This shouldn't return. If it returns, we have a problem */ - status = acpi_enter_sleep_state(ACPI_STATE_S4, flags); + status = acpi_enter_sleep_state(ACPI_STATE_S4, wake_sleep_flags); /* Reprogram control registers and execute _BFS */ - acpi_leave_sleep_state_prep(ACPI_STATE_S4, flags); + acpi_leave_sleep_state_prep(ACPI_STATE_S4, wake_sleep_flags); return ACPI_SUCCESS(status) ? 0 : -EFAULT; } static void acpi_hibernation_leave(void) { - u8 flags = wake_sleep_flags(); - /* * If ACPI is not enabled by the BIOS and the boot kernel, we need to * enable it here. */ acpi_enable(); /* Reprogram control registers and execute _BFS */ - acpi_leave_sleep_state_prep(ACPI_STATE_S4, flags); + acpi_leave_sleep_state_prep(ACPI_STATE_S4, wake_sleep_flags); /* Check the hardware signature */ if (facs && s4_hardware_signature != facs->hardware_signature) {printk(KERN_EMERG "ACPI: Hardware changed while hibernated, "
drivers/acpi/sleep.c +1
-4@@ -830,12 +826,10 @@ static void acpi_power_off_prepare(void) static void acpi_power_off(void) { - u8 flags = wake_sleep_flags(); - /* acpi_sleep_prepare(ACPI_STATE_S5) should have already been called */ printk(KERN_DEBUG "%s called\n", __func__); local_irq_disable(); - acpi_enter_sleep_state(ACPI_STATE_S5, flags); + acpi_enter_sleep_state(ACPI_STATE_S5, wake_sleep_flags); } /* --