linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pavel Machek <pavel@ucw.cz>
To: Baolin Wang <baolin.wang@linaro.org>
Cc: rjw@rjwysocki.net, lenb@kernel.org, andrew.smirnov@gmail.com,
	akpm@linux-foundation.org, broonie@kernel.org, arnd@arndb.de,
	linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-pm@vger.kernel.org
Subject: Re: [PATCH 1/2] ACPI / PM: Use register_reboot_notifier() instead of pm_power_off_prepare
Date: Wed, 21 Mar 2018 15:04:23 +0100	[thread overview]
Message-ID: <20180321140422.GA10700@amd> (raw)
In-Reply-To: <7ff55372818461feed4b0550d5f88edce2cc7d41.1521631678.git.baolin.wang@linaro.org>

[-- Attachment #1: Type: text/plain, Size: 2447 bytes --]

On Wed 2018-03-21 19:30:16, Baolin Wang wrote:
> We can register one notifier through register_reboot_notifier() function to
> prepare to power off the system, then we can remove the 'pm_power_off_prepare'
> hook in following patch.
> 
> Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
> ---
> Note: Please help to review carefully, since I have no platform to test
> this conversion.
> 
> I saw there is another reboot notifier in this driver, I am not sure the
> orders between them. I can change the priority of notifier to keep their
> orders if it is necessary.

I don't understand why this is good idea... and you should really test
it. I'm sure you can find PC or notebook somewhere...
								Pavel

>  drivers/acpi/sleep.c |   22 ++++++++++++++++------
>  1 file changed, 16 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c
> index 46cde091..b3de894 100644
> --- a/drivers/acpi/sleep.c
> +++ b/drivers/acpi/sleep.c
> @@ -1229,14 +1229,24 @@ static void acpi_sleep_hibernate_setup(void)
>  static inline void acpi_sleep_hibernate_setup(void) {}
>  #endif /* !CONFIG_HIBERNATION */
>  
> -static void acpi_power_off_prepare(void)
> +static int acpi_reboot_notify(struct notifier_block *this, unsigned long code,
> +			      void *x)
>  {
> -	/* Prepare to power off the system */
> -	acpi_sleep_prepare(ACPI_STATE_S5);
> -	acpi_disable_all_gpes();
> -	acpi_os_wait_events_complete();
> +	if (code == SYSTEM_POWER_OFF) {
> +		/* Prepare to power off the system */
> +		acpi_sleep_prepare(ACPI_STATE_S5);
> +		acpi_disable_all_gpes();
> +		acpi_os_wait_events_complete();
> +	}
> +
> +	return NOTIFY_DONE;
>  }
>  
> +static struct notifier_block acpi_reboot_notifier = {
> +	.notifier_call	= acpi_reboot_notify,
> +	.priority	= 0,
> +};
> +
>  static void acpi_power_off(void)
>  {
>  	/* acpi_sleep_prepare(ACPI_STATE_S5) should have already been called */
> @@ -1261,7 +1271,7 @@ int __init acpi_sleep_init(void)
>  
>  	if (acpi_sleep_state_supported(ACPI_STATE_S5)) {
>  		sleep_states[ACPI_STATE_S5] = 1;
> -		pm_power_off_prepare = acpi_power_off_prepare;
> +		register_reboot_notifier(&acpi_reboot_notifier);
>  		pm_power_off = acpi_power_off;
>  	} else {
>  		acpi_no_s5 = true;

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

  parent reply	other threads:[~2018-03-21 14:04 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-21 11:30 [PATCH 1/2] ACPI / PM: Use register_reboot_notifier() instead of pm_power_off_prepare Baolin Wang
2018-03-21 11:30 ` [PATCH 2/2] kernel / reboot: Remove the pm_power_off_prepare hook Baolin Wang
2018-03-21 14:04 ` Pavel Machek [this message]
2018-03-22  2:23   ` [PATCH 1/2] ACPI / PM: Use register_reboot_notifier() instead of pm_power_off_prepare Baolin Wang

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=20180321140422.GA10700@amd \
    --to=pavel@ucw.cz \
    --cc=akpm@linux-foundation.org \
    --cc=andrew.smirnov@gmail.com \
    --cc=arnd@arndb.de \
    --cc=baolin.wang@linaro.org \
    --cc=broonie@kernel.org \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rjw@rjwysocki.net \
    /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;
as well as URLs for NNTP newsgroup(s).