public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] gts and bfs fixes (v2).
@ 2012-04-10  2:34 Konrad Rzeszutek Wilk
  2012-04-10  2:34 ` [PATCH 1/2] ACPI: Convert wake_sleep_flags to a value instead of function (v2) Konrad Rzeszutek Wilk
  2012-04-10  2:34 ` [PATCH 2/2] ACPI: Pass u8 flag to acpi_enter_sleep_state from lowlevel assembler Konrad Rzeszutek Wilk
  0 siblings, 2 replies; 6+ messages in thread
From: Konrad Rzeszutek Wilk @ 2012-04-10  2:34 UTC (permalink / raw)
  To: ming.m.lin, linux-kernel, linux-pm, lenb, linux-acpi,
	konrad.r.wilk

Please consider these the two fixes to how gts and bfs parameters
are handled in 3.4-rc2:

I had sent an earlier version of 
 [PATCH 1/2] ACPI: Convert wake_sleep_flags to a value instead of

to Lin and he had reviewed it, but I redid it a bit so a second
look will be required.

The:
 [PATCH 2/2] ACPI: Pass u8 flag to acpi_enter_sleep_state from

is a regression fix - as the wakeup flag was not passed from the
assembler code to the acpi_enter_sleep_ function.

 arch/x86/kernel/acpi/sleep.h     |    2 +
 arch/x86/kernel/acpi/wakeup_32.S |    5 +++-
 arch/x86/kernel/acpi/wakeup_64.S |    3 ++
 drivers/acpi/sleep.c             |   52 ++++++++++++++++++++-----------------
 4 files changed, 37 insertions(+), 25 deletions(-)

Konrad Rzeszutek Wilk (2):
      ACPI: Convert wake_sleep_flags to a value instead of function (v2)
      ACPI: Pass u8 flag to acpi_enter_sleep_state from lowlevel assembler.



^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/2] ACPI: Convert wake_sleep_flags to a value instead of function (v2)
  2012-04-10  2:34 [PATCH] gts and bfs fixes (v2) Konrad Rzeszutek Wilk
@ 2012-04-10  2:34 ` Konrad Rzeszutek Wilk
  2012-04-10  2:50   ` Lin Ming
  2012-04-10  2:34 ` [PATCH 2/2] ACPI: Pass u8 flag to acpi_enter_sleep_state from lowlevel assembler Konrad Rzeszutek Wilk
  1 sibling, 1 reply; 6+ messages in thread
From: Konrad Rzeszutek Wilk @ 2012-04-10  2:34 UTC (permalink / raw)
  To: ming.m.lin, linux-kernel, linux-pm, lenb, linux-acpi,
	konrad.r.wilk
  Cc: Konrad Rzeszutek Wilk

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.

[v2: Parameters can be turned on/off dynamically]
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
---
 arch/x86/kernel/acpi/sleep.h |    2 +
 drivers/acpi/sleep.c         |   52 ++++++++++++++++++++++-------------------
 2 files changed, 30 insertions(+), 24 deletions(-)

diff --git a/arch/x86/kernel/acpi/sleep.h b/arch/x86/kernel/acpi/sleep.h
index 4d3feb5..7bab5fb 100644
--- a/arch/x86/kernel/acpi/sleep.h
+++ b/arch/x86/kernel/acpi/sleep.h
@@ -9,6 +9,8 @@ extern long saved_magic;
 
 extern int wakeup_pmode_return;
 
+extern unsigned char wake_sleep_flags;
+
 extern unsigned long acpi_copy_wakeup_routine(unsigned long);
 extern void wakeup_long64(void);
 
diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c
index 6a8d4d3..86bf909 100644
--- a/drivers/acpi/sleep.c
+++ b/drivers/acpi/sleep.c
@@ -28,23 +28,33 @@
 #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;
-	if (bfs)
-		flags |= ACPI_EXECUTE_BFS;
+	if (ret)
+		return ret;
 
-	return flags;
+	if (val == (const char *)&gts) {
+		if (gts)
+			wake_sleep_flags |= ACPI_EXECUTE_GTS;
+		else
+			wake_sleep_flags &= ~ACPI_EXECUTE_GTS;
+	}
+	if (val == (const char *)&bfs) {
+		if (bfs)
+			wake_sleep_flags |= ACPI_EXECUTE_BFS;
+		else
+			wake_sleep_flags &= ~ACPI_EXECUTE_BFS;
+	}
+	return ret;
 }
+module_param_call(gts, set_param_wake_flag, param_get_int, &gts, 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 +273,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 +280,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 +297,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 +561,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 +836,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);
 }
 
 /*
-- 
1.7.7.5


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/2] ACPI: Pass u8 flag to acpi_enter_sleep_state from lowlevel assembler.
  2012-04-10  2:34 [PATCH] gts and bfs fixes (v2) Konrad Rzeszutek Wilk
  2012-04-10  2:34 ` [PATCH 1/2] ACPI: Convert wake_sleep_flags to a value instead of function (v2) Konrad Rzeszutek Wilk
@ 2012-04-10  2:34 ` Konrad Rzeszutek Wilk
  1 sibling, 0 replies; 6+ messages in thread
From: Konrad Rzeszutek Wilk @ 2012-04-10  2:34 UTC (permalink / raw)
  To: ming.m.lin, linux-kernel, linux-pm, lenb, linux-acpi,
	konrad.r.wilk
  Cc: Konrad Rzeszutek Wilk

 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. But the change
to do that in the x86_acpi_suspend_lowlevel' do_suspend_lowlevel()
was not done. So the call in do_suspend_lowlevel() assembler to
acpi_enter_sleep_state would provide a potentially corrupted wakeup_flag.

This fixes it by passing the paramter.
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
---
 arch/x86/kernel/acpi/wakeup_32.S |    5 ++++-
 arch/x86/kernel/acpi/wakeup_64.S |    3 +++
 2 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/arch/x86/kernel/acpi/wakeup_32.S b/arch/x86/kernel/acpi/wakeup_32.S
index 13ab720..9e9260c 100644
--- a/arch/x86/kernel/acpi/wakeup_32.S
+++ b/arch/x86/kernel/acpi/wakeup_32.S
@@ -74,9 +74,12 @@ restore_registers:
 ENTRY(do_suspend_lowlevel)
 	call	save_processor_state
 	call	save_registers
+	movzbl  wake_sleep_flags, %eax
+	movzbl  %al, %eax
+	pushl	%eax
 	pushl	$3
 	call	acpi_enter_sleep_state
-	addl	$4, %esp
+	addl	$4*2, %esp
 
 #	In case of S3 failure, we'll emerge here.  Jump
 # 	to ret_point to recover
diff --git a/arch/x86/kernel/acpi/wakeup_64.S b/arch/x86/kernel/acpi/wakeup_64.S
index 8ea5164..66cc2ab 100644
--- a/arch/x86/kernel/acpi/wakeup_64.S
+++ b/arch/x86/kernel/acpi/wakeup_64.S
@@ -72,6 +72,9 @@ ENTRY(do_suspend_lowlevel)
 
 	addq	$8, %rsp
 	movl	$3, %edi
+	movzbl	wake_sleep_flags, %eax
+	movzbl	%al, %eax
+	mov	%eax,%esi
 	xorl	%eax, %eax
 	call	acpi_enter_sleep_state
 	/* in case something went wrong, restore the machine status and go on */
-- 
1.7.7.5


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] ACPI: Convert wake_sleep_flags to a value instead of function (v2)
  2012-04-10  2:34 ` [PATCH 1/2] ACPI: Convert wake_sleep_flags to a value instead of function (v2) Konrad Rzeszutek Wilk
@ 2012-04-10  2:50   ` Lin Ming
  2012-04-10  3:19     ` Konrad Rzeszutek Wilk
  2012-04-10  3:22     ` Konrad Rzeszutek Wilk
  0 siblings, 2 replies; 6+ messages in thread
From: Lin Ming @ 2012-04-10  2:50 UTC (permalink / raw)
  To: Konrad Rzeszutek Wilk
  Cc: linux-kernel, linux-pm, lenb, linux-acpi, konrad.r.wilk

On Mon, 2012-04-09 at 22:34 -0400, Konrad Rzeszutek Wilk wrote:
> 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.
> 
> [v2: Parameters can be turned on/off dynamically]
> Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> ---
>  arch/x86/kernel/acpi/sleep.h |    2 +
>  drivers/acpi/sleep.c         |   52 ++++++++++++++++++++++-------------------
>  2 files changed, 30 insertions(+), 24 deletions(-)
> 
> diff --git a/arch/x86/kernel/acpi/sleep.h b/arch/x86/kernel/acpi/sleep.h
> index 4d3feb5..7bab5fb 100644
> --- a/arch/x86/kernel/acpi/sleep.h
> +++ b/arch/x86/kernel/acpi/sleep.h
> @@ -9,6 +9,8 @@ extern long saved_magic;
>  
>  extern int wakeup_pmode_return;
>  
> +extern unsigned char wake_sleep_flags;
> +

Could you use "u8" same as the definition below?

Others look good to me.

Acked-by: Lin Ming <ming.m.lin@intel.com>

Thanks,
Lin Ming

>  extern unsigned long acpi_copy_wakeup_routine(unsigned long);
>  extern void wakeup_long64(void);
>  
> diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c
> index 6a8d4d3..86bf909 100644
> --- a/drivers/acpi/sleep.c
> +++ b/drivers/acpi/sleep.c
> @@ -28,23 +28,33 @@
>  #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;
> -	if (bfs)
> -		flags |= ACPI_EXECUTE_BFS;
> +	if (ret)
> +		return ret;
>  
> -	return flags;
> +	if (val == (const char *)&gts) {
> +		if (gts)
> +			wake_sleep_flags |= ACPI_EXECUTE_GTS;
> +		else
> +			wake_sleep_flags &= ~ACPI_EXECUTE_GTS;
> +	}
> +	if (val == (const char *)&bfs) {
> +		if (bfs)
> +			wake_sleep_flags |= ACPI_EXECUTE_BFS;
> +		else
> +			wake_sleep_flags &= ~ACPI_EXECUTE_BFS;
> +	}
> +	return ret;
>  }
> +module_param_call(gts, set_param_wake_flag, param_get_int, &gts, 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 +273,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 +280,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 +297,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 +561,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 +836,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);
>  }
>  
>  /*



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] ACPI: Convert wake_sleep_flags to a value instead of function (v2)
  2012-04-10  2:50   ` Lin Ming
@ 2012-04-10  3:19     ` Konrad Rzeszutek Wilk
  2012-04-10  3:22     ` Konrad Rzeszutek Wilk
  1 sibling, 0 replies; 6+ messages in thread
From: Konrad Rzeszutek Wilk @ 2012-04-10  3:19 UTC (permalink / raw)
  To: Lin Ming; +Cc: linux-kernel, linux-pm, lenb, linux-acpi, konrad.r.wilk

On Tue, Apr 10, 2012 at 10:50:26AM +0800, Lin Ming wrote:
> On Mon, 2012-04-09 at 22:34 -0400, Konrad Rzeszutek Wilk wrote:
> > 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.
> > 
> > [v2: Parameters can be turned on/off dynamically]
> > Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> > ---
> >  arch/x86/kernel/acpi/sleep.h |    2 +
> >  drivers/acpi/sleep.c         |   52 ++++++++++++++++++++++-------------------
> >  2 files changed, 30 insertions(+), 24 deletions(-)
> > 
> > diff --git a/arch/x86/kernel/acpi/sleep.h b/arch/x86/kernel/acpi/sleep.h
> > index 4d3feb5..7bab5fb 100644
> > --- a/arch/x86/kernel/acpi/sleep.h
> > +++ b/arch/x86/kernel/acpi/sleep.h
> > @@ -9,6 +9,8 @@ extern long saved_magic;
> >  
> >  extern int wakeup_pmode_return;
> >  
> > +extern unsigned char wake_sleep_flags;
> > +
> 
> Could you use "u8" same as the definition below?

Yes. Thx for spotting that.

> 
> Others look good to me.
> 
> Acked-by: Lin Ming <ming.m.lin@intel.com>

Great! Thanks.

> 
> Thanks,
> Lin Ming
> 
> >  extern unsigned long acpi_copy_wakeup_routine(unsigned long);
> >  extern void wakeup_long64(void);
> >  
> > diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c
> > index 6a8d4d3..86bf909 100644
> > --- a/drivers/acpi/sleep.c
> > +++ b/drivers/acpi/sleep.c
> > @@ -28,23 +28,33 @@
> >  #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;
> > -	if (bfs)
> > -		flags |= ACPI_EXECUTE_BFS;
> > +	if (ret)
> > +		return ret;
> >  
> > -	return flags;
> > +	if (val == (const char *)&gts) {
> > +		if (gts)
> > +			wake_sleep_flags |= ACPI_EXECUTE_GTS;
> > +		else
> > +			wake_sleep_flags &= ~ACPI_EXECUTE_GTS;
> > +	}
> > +	if (val == (const char *)&bfs) {
> > +		if (bfs)
> > +			wake_sleep_flags |= ACPI_EXECUTE_BFS;
> > +		else
> > +			wake_sleep_flags &= ~ACPI_EXECUTE_BFS;
> > +	}
> > +	return ret;
> >  }
> > +module_param_call(gts, set_param_wake_flag, param_get_int, &gts, 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 +273,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 +280,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 +297,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 +561,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 +836,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);
> >  }
> >  
> >  /*
> 
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] ACPI: Convert wake_sleep_flags to a value instead of function (v2)
  2012-04-10  2:50   ` Lin Ming
  2012-04-10  3:19     ` Konrad Rzeszutek Wilk
@ 2012-04-10  3:22     ` Konrad Rzeszutek Wilk
  1 sibling, 0 replies; 6+ messages in thread
From: Konrad Rzeszutek Wilk @ 2012-04-10  3:22 UTC (permalink / raw)
  To: Lin Ming; +Cc: linux-kernel, linux-pm, lenb, linux-acpi, konrad.r.wilk

On Tue, Apr 10, 2012 at 10:50:26AM +0800, Lin Ming wrote:
> On Mon, 2012-04-09 at 22:34 -0400, Konrad Rzeszutek Wilk wrote:
> > 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.
> > 
> > [v2: Parameters can be turned on/off dynamically]

v3 version:

commit 667c0e7d85ac2fb8b852b9b777b78e392e6a72e9
Author: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Date:   Fri Apr 6 17:53:51 2012 -0400

    ACPI: Convert wake_sleep_flags to a value instead of function (v2)
    
    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.
    
    Acked-by: Lin Ming <ming.m.lin@intel.com>
    [v2: Parameters can be turned on/off dynamically]
    [v3: unsigned char -> u8]
    Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>

diff --git a/arch/x86/kernel/acpi/sleep.h b/arch/x86/kernel/acpi/sleep.h
index 416d4be..fe5fdda 100644
--- a/arch/x86/kernel/acpi/sleep.h
+++ b/arch/x86/kernel/acpi/sleep.h
@@ -9,6 +9,8 @@ extern long saved_magic;
 
 extern int wakeup_pmode_return;
 
+extern u8 wake_sleep_flags;
+
 extern unsigned long acpi_copy_wakeup_routine(unsigned long);
 extern void wakeup_long64(void);
 
diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c
index 1d661b5..f81f5d4 100644
--- a/drivers/acpi/sleep.c
+++ b/drivers/acpi/sleep.c
@@ -28,23 +28,33 @@
 #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;
-	if (bfs)
-		flags |= ACPI_EXECUTE_BFS;
+	if (ret)
+		return ret;
 
-	return flags;
+	if (val == (const char *)&gts) {
+		if (gts)
+			wake_sleep_flags |= ACPI_EXECUTE_GTS;
+		else
+			wake_sleep_flags &= ~ACPI_EXECUTE_GTS;
+	}
+	if (val == (const char *)&bfs) {
+		if (bfs)
+			wake_sleep_flags |= ACPI_EXECUTE_BFS;
+		else
+			wake_sleep_flags &= ~ACPI_EXECUTE_BFS;
+	}
+	return ret;
 }
+module_param_call(gts, set_param_wake_flag, param_get_int, &gts, 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 +273,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 +280,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:
@@ -286,7 +295,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
@@ -550,30 +559,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, "
@@ -828,12 +834,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);
 }
 
 /*

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-04-10  3:27 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-04-10  2:34 [PATCH] gts and bfs fixes (v2) Konrad Rzeszutek Wilk
2012-04-10  2:34 ` [PATCH 1/2] ACPI: Convert wake_sleep_flags to a value instead of function (v2) Konrad Rzeszutek Wilk
2012-04-10  2:50   ` Lin Ming
2012-04-10  3:19     ` Konrad Rzeszutek Wilk
2012-04-10  3:22     ` Konrad Rzeszutek Wilk
2012-04-10  2:34 ` [PATCH 2/2] ACPI: Pass u8 flag to acpi_enter_sleep_state from lowlevel assembler Konrad Rzeszutek Wilk

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox