[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <296e6f6f-e96d-2db1-77b9-288dc47d1b98@collabora.com>
Date: Fri, 6 May 2022 18:28:49 +0300
From: Dmitry Osipenko <dmitry.osipenko@...labora.com>
To: "Rafael J. Wysocki" <rafael@...nel.org>
Cc: Thierry Reding <thierry.reding@...il.com>,
Jonathan Hunter <jonathanh@...dia.com>,
Russell King <linux@...linux.org.uk>,
Catalin Marinas <catalin.marinas@....com>,
Will Deacon <will@...nel.org>, Guo Ren <guoren@...nel.org>,
Geert Uytterhoeven <geert@...ux-m68k.org>,
Greg Ungerer <gerg@...ux-m68k.org>,
Joshua Thompson <funaho@...ai.org>,
Thomas Bogendoerfer <tsbogend@...ha.franken.de>,
Sebastian Reichel <sre@...nel.org>,
Linus Walleij <linus.walleij@...aro.org>,
Philipp Zabel <p.zabel@...gutronix.de>,
Greentime Hu <green.hu@...il.com>,
Vincent Chen <deanbo422@...il.com>,
"James E.J. Bottomley" <James.Bottomley@...senpartnership.com>,
Helge Deller <deller@....de>,
Michael Ellerman <mpe@...erman.id.au>,
Benjamin Herrenschmidt <benh@...nel.crashing.org>,
Paul Mackerras <paulus@...ba.org>,
Paul Walmsley <paul.walmsley@...ive.com>,
Palmer Dabbelt <palmer@...belt.com>,
Albert Ou <aou@...s.berkeley.edu>,
Yoshinori Sato <ysato@...rs.sourceforge.jp>,
Rich Felker <dalias@...c.org>,
Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
Dave Hansen <dave.hansen@...ux.intel.com>,
the arch/x86 maintainers <x86@...nel.org>,
"H. Peter Anvin" <hpa@...or.com>,
Boris Ostrovsky <boris.ostrovsky@...cle.com>,
Juergen Gross <jgross@...e.com>,
Stefano Stabellini <sstabellini@...nel.org>,
Len Brown <lenb@...nel.org>,
Santosh Shilimkar <ssantosh@...nel.org>,
Krzysztof Kozlowski <krzk@...nel.org>,
Liam Girdwood <lgirdwood@...il.com>,
Mark Brown <broonie@...nel.org>, Pavel Machek <pavel@....cz>,
Lee Jones <lee.jones@...aro.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Guenter Roeck <linux@...ck-us.net>,
Daniel Lezcano <daniel.lezcano@...aro.org>,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
Ulf Hansson <ulf.hansson@...aro.org>,
Michał Mirosław <mirq-linux@...e.qmqm.pl>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
linux-csky@...r.kernel.org, linux-ia64@...r.kernel.org,
linux-m68k@...ts.linux-m68k.org,
"open list:BROADCOM NVRAM DRIVER" <linux-mips@...r.kernel.org>,
linux-parisc@...r.kernel.org, linux-riscv@...ts.infradead.org,
Linux-sh list <linux-sh@...r.kernel.org>,
xen-devel@...ts.xenproject.org,
ACPI Devel Maling List <linux-acpi@...r.kernel.org>,
Linux PM <linux-pm@...r.kernel.org>,
linux-tegra <linux-tegra@...r.kernel.org>
Subject: Re: [PATCH v7 04/20] kernel: Add combined power-off+restart handler
call chain API
On 4/20/22 21:47, Rafael J. Wysocki wrote:
>>>> + spin_unlock(&platform_power_off_lock);
>>>> +
>>>> + if (ret)
>>>> + return ret;
>>>> +
>>>> + ret = register_power_off_handler(&priv->power_off_nb);
>>>> + if (ret)
>>>> + priv->platform_power_off_cb = NULL;
>>>> +
>>>> + return ret;
>>>> +}
>>>> +EXPORT_SYMBOL_GPL(register_platform_power_off);
>>>> +
>>>> +/**
>>>> + * unregister_platform_power_off - Unregister platform-level power-off callback
>>>> + * @power_off: Power-off callback
>>>> + *
>>>> + * Unregisters previously registered platform power-off callback.
>>>> + *
>>>> + * Returns zero on success, or error code on failure.
>>>> + */
>>>> +int unregister_platform_power_off(void (*power_off)(void))
>>>> +{
>>>> + struct sys_off_handler_private_data *priv;
>>>> + int ret;
>>>> +
>>>> + priv = sys_off_handler_private_data(&platform_power_off_handler);
>>>> +
>>>> + if (priv->platform_power_off_cb != power_off)
>>>> + return -EINVAL;
>>>> +
>>>> + ret = unregister_power_off_handler(&priv->power_off_nb);
>>>> + priv->platform_power_off_cb = NULL;
>>>> +
>>>> + return ret;
>>>> +}
>>>> +EXPORT_SYMBOL_GPL(unregister_platform_power_off);
>>>> +
>>>> +/**
>>>> + * do_kernel_power_off - Execute kernel power-off handler call chain
>>>> + *
>>>> + * Calls functions registered with register_power_off_handler.
>>>> + *
>>>> + * Expected to be called as last step of the power-off sequence.
>>>> + *
>>>> + * Powers off the system immediately if a power-off handler function has
>>>> + * been registered. Otherwise does nothing.
>>>> + */
>>>> +void do_kernel_power_off(void)
>>>> +{
>>>> + /* legacy pm_power_off() is unchained and has highest priority */
>>>> + if (pm_power_off && pm_power_off != dummy_pm_power_off)
>>>> + return pm_power_off();
>>>> +
>>>> + blocking_notifier_call_chain(&power_off_handler_list, POWEROFF_NORMAL,
>>>> + NULL);
>>>> +}
>>>> +
>>>> +static void do_kernel_power_off_prepare(void)
>>>> +{
>>>> + /* legacy pm_power_off_prepare() is unchained and has highest priority */
>>>> + if (pm_power_off_prepare)
>>>> + return pm_power_off_prepare();
>>>> +
>>>> + blocking_notifier_call_chain(&power_off_handler_list, POWEROFF_PREPARE,
>>>> + NULL);
>>>> +}
>>>> +
>>>> /**
>>>> * kernel_power_off - power_off the system
>>>> *
>>>> @@ -304,8 +893,7 @@ EXPORT_SYMBOL_GPL(kernel_halt);
>>>> void kernel_power_off(void)
>>>> {
>>>> kernel_shutdown_prepare(SYSTEM_POWER_OFF);
>>>> - if (pm_power_off_prepare)
>>>> - pm_power_off_prepare();
>>>> + do_kernel_power_off_prepare();
>>>> migrate_to_reboot_cpu();
>>>> syscore_shutdown();
>>>> pr_emerg("Power down\n");
>>>> @@ -314,6 +902,16 @@ void kernel_power_off(void)
>>>> }
>>>> EXPORT_SYMBOL_GPL(kernel_power_off);
>>>>
>>>> +bool kernel_can_power_off(void)
>>>> +{
>>>> + if (!pm_power_off &&
>>>> + blocking_notifier_call_chain_is_empty(&power_off_handler_list))
>>>> + return false;
>>>> +
>>>> + return true;
>>> return pm_power_off ||
>>> blocking_notifier_call_chain_is_empty(&power_off_handler_list);
>> Thank you for the thorough review!
> You're very welcome!
Thanks again for taking a look at the patches. I don't have strong
preferences about the names and etc, so I'll update it all in v8 like
you suggested.
--
Best regards,
Dmitry
Powered by blists - more mailing lists