Received: by 10.213.65.68 with SMTP id h4csp1282040imn; Wed, 21 Mar 2018 07:06:54 -0700 (PDT) X-Google-Smtp-Source: AG47ELu828O/VHC2rdkRtsCwi+A43b7rDI6txVyIK+nAbK7qakT5BH+WoIXkTC7eCekXDLA5b456 X-Received: by 10.99.131.73 with SMTP id h70mr14902648pge.195.1521641214143; Wed, 21 Mar 2018 07:06:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521641214; cv=none; d=google.com; s=arc-20160816; b=zMuLlqlGmsa5/3CtEYOnOgU9DiKDplnb3jt398VDaqDEkvbLarpTIuIiv85Bopdw5r PYSb6YEKZuVdOgnPVjge92xgRPUqMKxoCFp/hutopyI69J4m5POYks9CXJiWczlF8gBV xPn3O+uXv1pzj7I8JvmozX2rbNQgSF22oZ8nePeewvY7qvhCpke+Y3hNwVyTcMHAObp3 kK++0Q3ldQRsYJDUg4koKilVkal3h76XBRwo7y4IkpQMYIx6KoqXEYxWMtiYzjZ3O6+y AFvix56wtEk1dVwvinc/zDwY8r4hC7gdx1WsEIb8ia845hMt+l0kZfDF/F/vwHyjJjbN 49RQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=VvgMdNfH1ixBizpu959BVDBP8VGQtx6hslQi86WuRUY=; b=XCjbj+wP/o487jxvRxMw1LZJcoWtnubYUBW3gSY+VRKI7A2WrP2J4zK7lBLHI4rUeW NNHvOjrqAPHnWxYfsTXGmAzYASpF7jFizXgl1kJjO8HGaMV1YnQFmEJzksvHQSsgZJq/ CtMQq3/QvNdidXIpcM2cEWO+OAgPbvags0I5tPYcD95ohmzehjnsQFegDLoHf6OV/Foo Iq1/YOoilG9G2do1NYMBxRpqx2ZSCzTuONsKNZn1hvTPZxw6VL0dh0NlFhqX/FGq8KBM usvO0PNoc7nBd6CRZfrXKI0oIq/RMz/9vPMXVZ0IvTG15DJjL8rTO/YWRXQeKIgQImRx lx2Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w2si2840736pgm.458.2018.03.21.07.06.06; Wed, 21 Mar 2018 07:06:54 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752350AbeCUOEa (ORCPT + 99 others); Wed, 21 Mar 2018 10:04:30 -0400 Received: from atrey.karlin.mff.cuni.cz ([195.113.26.193]:49713 "EHLO atrey.karlin.mff.cuni.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751835AbeCUOE1 (ORCPT ); Wed, 21 Mar 2018 10:04:27 -0400 Received: by atrey.karlin.mff.cuni.cz (Postfix, from userid 512) id 82343801F5; Wed, 21 Mar 2018 15:04:23 +0100 (CET) Date: Wed, 21 Mar 2018 15:04:23 +0100 From: Pavel Machek To: Baolin Wang 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 Message-ID: <20180321140422.GA10700@amd> References: <7ff55372818461feed4b0550d5f88edce2cc7d41.1521631678.git.baolin.wang@linaro.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="C7zPtVaVf+AK4Oqc" Content-Disposition: inline In-Reply-To: <7ff55372818461feed4b0550d5f88edce2cc7d41.1521631678.git.baolin.wang@linaro.org> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --C7zPtVaVf+AK4Oqc Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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_pre= pare' > hook in following patch. >=20 > Signed-off-by: Baolin Wang > --- > Note: Please help to review carefully, since I have no platform to test > this conversion. >=20 > 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(-) >=20 > 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 */ > =20 > -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 =3D=3D 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; > } > =20 > +static struct notifier_block acpi_reboot_notifier =3D { > + .notifier_call =3D acpi_reboot_notify, > + .priority =3D 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) > =20 > if (acpi_sleep_state_supported(ACPI_STATE_S5)) { > sleep_states[ACPI_STATE_S5] =3D 1; > - pm_power_off_prepare =3D acpi_power_off_prepare; > + register_reboot_notifier(&acpi_reboot_notifier); > pm_power_off =3D acpi_power_off; > } else { > acpi_no_s5 =3D true; --=20 (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blo= g.html --C7zPtVaVf+AK4Oqc Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iEYEARECAAYFAlqyZmYACgkQMOfwapXb+vKPiwCghfQwm3ymuaDQlGMODFJv5DfW MRUAn0xM9yJPKHv9cFUaFvS37B8w8/yx =A/gx -----END PGP SIGNATURE----- --C7zPtVaVf+AK4Oqc--