public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rjw@sisk.pl>
To: Len Brown <lenb@kernel.org>
Cc: robert.moore@intel.com,
	ACPI Devel Maling List <linux-acpi@vger.kernel.org>,
	Arjan van de Ven <arjan@infradead.org>,
	Carlos Corbacho <carlos@strangeworlds.co.uk>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Pavel Machek <pavel@suse.cz>,
	pm list <linux-pm@lists.linux-foundation.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Alexey Starikovskiy <aystarik@gmail.com>,
	Matthew Garrett <mjg59@srcf.ucam.org>
Subject: Re: [RFC][PATCH 2/7] ACPI: Separate invocations of _GTS and _BFS from _PTS and _WAK
Date: Mon, 7 Jan 2008 22:44:25 +0100	[thread overview]
Message-ID: <200801072244.26960.rjw@sisk.pl> (raw)
In-Reply-To: <200801071625.57129.lenb@kernel.org>

On Monday, 7 of January 2008, Len Brown wrote:
> On Saturday 05 January 2008 17:41, Rafael J. Wysocki wrote:
> > From: Rafael J. Wysocki <rjw@sisk.pl>
> > 
> > The execution of ACPI global control methods _GTS and _BFS is
> > currently tied to the preparation to enter a sleep state and to the
> > leaving of the sleep state, respectively.  However, these functions
> > are called before disabling the nonboot CPUs and after enabling
> > them, respectively (in fact, on ACPI 1.0x systems the first of them
> > ought to be called before suspending devices), while according to the
> > ACPI specification, _GTS is to be executed right prior to entering
> > the system sleep state and _BFS is to be executed right after the
> > platfor firmware has returned control to the OS on wake up.
> 
> 
> ACPI 1.0 systems don't have _GTS or _BFS -- they were added
> as optional control methods starting in ACPI 2.0.
> 
> The ACPI 1.0 installed base of Windows by definition could
> not have invoked them -- so vendors could not have possibly
> made their invocation mandatory w/o adding special handling
> fro the installed base.  I guess they never found a reason
> to do this, because I've not yet seen a BIOS that implements them.
> 
> So the patch looks good, but Linux support for _GTS and _BFS
> is purely academic at this point.
> 
> Rafael,
> Do you grant Intel permission to incorporate this change
> into the upstream ACPICA source base and ship it under
> the the ACPICA source license to all ACPICA customers?

Sure, I do.

Thanks,
Rafael


> > Move the execution of _GTS and _BFS to the right places.
> > 
> > Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
> > Acked-by: Pavel Machek <pavel@suse.cz>
> > ---
> >  drivers/acpi/hardware/hwsleep.c |   75 ++++++++++++++++++++++++++++++----------
> >  drivers/acpi/sleep/main.c       |    7 +++
> >  include/acpi/acpixf.h           |    2 +
> >  3 files changed, 66 insertions(+), 18 deletions(-)
> > 
> > Index: linux-2.6/drivers/acpi/hardware/hwsleep.c
> > ===================================================================
> > --- linux-2.6.orig/drivers/acpi/hardware/hwsleep.c
> > +++ linux-2.6/drivers/acpi/hardware/hwsleep.c
> > @@ -192,18 +192,13 @@ acpi_status acpi_enter_sleep_state_prep(
> >  	arg.type = ACPI_TYPE_INTEGER;
> >  	arg.integer.value = sleep_state;
> >  
> > -	/* Run the _PTS and _GTS methods */
> > +	/* Run the _PTS method */
> >  
> >  	status = acpi_evaluate_object(NULL, METHOD_NAME__PTS, &arg_list, NULL);
> >  	if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
> >  		return_ACPI_STATUS(status);
> >  	}
> >  
> > -	status = acpi_evaluate_object(NULL, METHOD_NAME__GTS, &arg_list, NULL);
> > -	if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
> > -		return_ACPI_STATUS(status);
> > -	}
> > -
> >  	/* Setup the argument to _SST */
> >  
> >  	switch (sleep_state) {
> > @@ -262,6 +257,8 @@ acpi_status asmlinkage acpi_enter_sleep_
> >  	struct acpi_bit_register_info *sleep_type_reg_info;
> >  	struct acpi_bit_register_info *sleep_enable_reg_info;
> >  	u32 in_value;
> > +	struct acpi_object_list arg_list;
> > +	union acpi_object arg;
> >  	acpi_status status;
> >  
> >  	ACPI_FUNCTION_TRACE(acpi_enter_sleep_state);
> > @@ -307,6 +304,18 @@ acpi_status asmlinkage acpi_enter_sleep_
> >  		return_ACPI_STATUS(status);
> >  	}
> >  
> > +	/* Execute the _GTS method */
> > +
> > +	arg_list.count = 1;
> > +	arg_list.pointer = &arg;
> > +	arg.type = ACPI_TYPE_INTEGER;
> > +	arg.integer.value = sleep_state;
> > +
> > +	status = acpi_evaluate_object(NULL, METHOD_NAME__GTS, &arg_list, NULL);
> > +	if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
> > +		return_ACPI_STATUS(status);
> > +	}
> > +
> >  	/* Get current value of PM1A control */
> >  
> >  	status = acpi_hw_register_read(ACPI_REGISTER_PM1_CONTROL, &PM1Acontrol);
> > @@ -473,17 +482,18 @@ ACPI_EXPORT_SYMBOL(acpi_enter_sleep_stat
> >  
> >  /*******************************************************************************
> >   *
> > - * FUNCTION:    acpi_leave_sleep_state
> > + * FUNCTION:    acpi_leave_sleep_state_prep
> >   *
> > - * PARAMETERS:  sleep_state         - Which sleep state we just exited
> > + * PARAMETERS:  sleep_state         - Which sleep state we are exiting
> >   *
> >   * RETURN:      Status
> >   *
> > - * DESCRIPTION: Perform OS-independent ACPI cleanup after a sleep
> > - *              Called with interrupts ENABLED.
> > + * DESCRIPTION: Perform the first state of OS-independent ACPI cleanup after a
> > + *              sleep.
> > + *              Called with interrupts DISABLED.
> >   *
> >   ******************************************************************************/
> > -acpi_status acpi_leave_sleep_state(u8 sleep_state)
> > +acpi_status acpi_leave_sleep_state_prep(u8 sleep_state)
> >  {
> >  	struct acpi_object_list arg_list;
> >  	union acpi_object arg;
> > @@ -493,7 +503,7 @@ acpi_status acpi_leave_sleep_state(u8 sl
> >  	u32 PM1Acontrol;
> >  	u32 PM1Bcontrol;
> >  
> > -	ACPI_FUNCTION_TRACE(acpi_leave_sleep_state);
> > +	ACPI_FUNCTION_TRACE(acpi_leave_sleep_state_prep);
> >  
> >  	/*
> >  	 * Set SLP_TYPE and SLP_EN to state S0.
> > @@ -540,6 +550,41 @@ acpi_status acpi_leave_sleep_state(u8 sl
> >  		}
> >  	}
> >  
> > +	/* Execute the _BFS method */
> > +
> > +	arg_list.count = 1;
> > +	arg_list.pointer = &arg;
> > +	arg.type = ACPI_TYPE_INTEGER;
> > +	arg.integer.value = sleep_state;
> > +
> > +	status = acpi_evaluate_object(NULL, METHOD_NAME__BFS, &arg_list, NULL);
> > +	if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
> > +		ACPI_EXCEPTION((AE_INFO, status, "During Method _BFS"));
> > +	}
> > +
> > +	return_ACPI_STATUS(status);
> > +}
> > +
> > +/*******************************************************************************
> > + *
> > + * FUNCTION:    acpi_leave_sleep_state
> > + *
> > + * PARAMETERS:  sleep_state         - Which sleep state we just exited
> > + *
> > + * RETURN:      Status
> > + *
> > + * DESCRIPTION: Perform OS-independent ACPI cleanup after a sleep
> > + *              Called with interrupts ENABLED.
> > + *
> > + ******************************************************************************/
> > +acpi_status acpi_leave_sleep_state(u8 sleep_state)
> > +{
> > +	struct acpi_object_list arg_list;
> > +	union acpi_object arg;
> > +	acpi_status status;
> > +
> > +	ACPI_FUNCTION_TRACE(acpi_leave_sleep_state);
> > +
> >  	/* Ensure enter_sleep_state_prep -> enter_sleep_state ordering */
> >  
> >  	acpi_gbl_sleep_type_a = ACPI_SLEEP_TYPE_INVALID;
> > @@ -558,12 +603,6 @@ acpi_status acpi_leave_sleep_state(u8 sl
> >  		ACPI_EXCEPTION((AE_INFO, status, "During Method _SST"));
> >  	}
> >  
> > -	arg.integer.value = sleep_state;
> > -	status = acpi_evaluate_object(NULL, METHOD_NAME__BFS, &arg_list, NULL);
> > -	if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
> > -		ACPI_EXCEPTION((AE_INFO, status, "During Method _BFS"));
> > -	}
> > -
> >  	/*
> >  	 * GPEs must be enabled before _WAK is called as GPEs
> >  	 * might get fired there
> > Index: linux-2.6/drivers/acpi/sleep/main.c
> > ===================================================================
> > --- linux-2.6.orig/drivers/acpi/sleep/main.c
> > +++ linux-2.6/drivers/acpi/sleep/main.c
> > @@ -139,6 +139,9 @@ static int acpi_pm_enter(suspend_state_t
> >  		break;
> >  	}
> >  
> > +	/* Reprogram control registers and execute _BFS */
> > +	acpi_leave_sleep_state_prep(acpi_state);
> > +
> >  	/* ACPI 3.0 specs (P62) says that it's the responsabilty
> >  	 * of the OSPM to clear the status bit [ implying that the
> >  	 * POWER_BUTTON event should not reach userspace ]
> > @@ -272,6 +275,8 @@ static int acpi_hibernation_enter(void)
> >  	acpi_enable_wakeup_device(ACPI_STATE_S4);
> >  	/* This shouldn't return.  If it returns, we have a problem */
> >  	status = acpi_enter_sleep_state(ACPI_STATE_S4);
> > +	/* Reprogram control registers and execute _BFS */
> > +	acpi_leave_sleep_state_prep(ACPI_STATE_S4);
> >  	local_irq_restore(flags);
> >  
> >  	return ACPI_SUCCESS(status) ? 0 : -EFAULT;
> > @@ -284,6 +289,8 @@ static void acpi_hibernation_leave(void)
> >  	 * enable it here.
> >  	 */
> >  	acpi_enable();
> > +	/* Reprogram control registers and execute _BFS */
> > +	acpi_leave_sleep_state_prep(ACPI_STATE_S4);
> >  }
> >  
> >  static void acpi_hibernation_finish(void)
> > Index: linux-2.6/include/acpi/acpixf.h
> > ===================================================================
> > --- linux-2.6.orig/include/acpi/acpixf.h
> > +++ linux-2.6/include/acpi/acpixf.h
> > @@ -335,6 +335,8 @@ acpi_status asmlinkage acpi_enter_sleep_
> >  
> >  acpi_status asmlinkage acpi_enter_sleep_state_s4bios(void);
> >  
> > +acpi_status acpi_leave_sleep_state_prep(u8 sleep_state);
> > +
> >  acpi_status acpi_leave_sleep_state(u8 sleep_state);
> >  
> >  #endif				/* __ACXFACE_H__ */
> > 
> > -
> > 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
> > 

  reply	other threads:[~2008-01-07 21:42 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-05 22:32 [RFC][PATCH 0/7] Fix the ACPI 1.0 vs ACPI 2.0 suspend ordering issue (rev. 2) Rafael J. Wysocki
2008-01-05 22:38 ` [RFC][PATCH 1/7] Suspend: Introduce open() and close() callbacks Rafael J. Wysocki
2008-01-06  0:31   ` David Brownell
2008-01-06 13:15     ` Rafael J. Wysocki
2008-01-05 22:41 ` [RFC][PATCH 2/7] ACPI: Separate invocations of _GTS and _BFS from _PTS and _WAK Rafael J. Wysocki
2008-01-07 21:25   ` Len Brown
2008-01-07 21:44     ` Rafael J. Wysocki [this message]
2008-01-05 22:42 ` [RFC][PATCH 3/7] ACPI: Separate disabling of GPEs from _PTS Rafael J. Wysocki
2008-01-05 22:48 ` [RFC][PATCH 4/7] ACPI Suspend: Call _PTS before suspending devices Rafael J. Wysocki
2008-01-05 22:50 ` [RFC][PATCH 5/7] Hibernation: Introduce open() and close() callbacks Rafael J. Wysocki
2008-01-05 22:56 ` [RFC][PATCH 6/7] ACPI hibernation: Call _PTS before suspending devices Rafael J. Wysocki
2008-01-05 22:58 ` [RFC][PATCH 7/7] ACPI: Print message before calling _PTS Rafael J. Wysocki
  -- strict thread matches above, loose matches on Subject: below --
2007-12-27 18:03 [RFC][PATCH 0/7] Fix the ACPI 1.0 vs ACPI 2.0 suspend ordering issue Rafael J. Wysocki
2007-12-27 18:15 ` [RFC][PATCH 2/7] ACPI: Separate invocations of _GTS and _BFS from _PTS and _WAK Rafael J. Wysocki
2008-01-03 10:42   ` Pavel Machek
2008-01-03 17:06     ` Rafael J. Wysocki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200801072244.26960.rjw@sisk.pl \
    --to=rjw@sisk.pl \
    --cc=akpm@linux-foundation.org \
    --cc=arjan@infradead.org \
    --cc=aystarik@gmail.com \
    --cc=carlos@strangeworlds.co.uk \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-pm@lists.linux-foundation.org \
    --cc=mjg59@srcf.ucam.org \
    --cc=pavel@suse.cz \
    --cc=robert.moore@intel.com \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox