* [PATCH v4 01/25] notifier: Remove extern annotation from function prototypes
2021-11-26 18:00 [PATCH v4 00/25] Introduce power-off+restart call chain API Dmitry Osipenko
@ 2021-11-26 18:00 ` Dmitry Osipenko
2021-11-26 18:00 ` [PATCH v4 02/25] notifier: Add blocking_notifier_call_chain_is_empty() Dmitry Osipenko
` (23 subsequent siblings)
24 siblings, 0 replies; 52+ messages in thread
From: Dmitry Osipenko @ 2021-11-26 18:00 UTC (permalink / raw)
To: Thierry Reding, Jonathan Hunter, Russell King, Catalin Marinas,
Will Deacon, Guo Ren, Geert Uytterhoeven, Greg Ungerer,
Joshua Thompson, Thomas Bogendoerfer, Sebastian Reichel,
Linus Walleij, Philipp Zabel, Greentime Hu, Vincent Chen,
James E.J. Bottomley, Helge Deller, Michael Ellerman,
Benjamin Herrenschmidt, Paul Mackerras, Paul Walmsley,
Palmer Dabbelt, Albert Ou, Yoshinori Sato, Rich Felker,
Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
H. Peter Anvin, Boris Ostrovsky, Juergen Gross,
Stefano Stabellini, Rafael J. Wysocki, Len Brown,
Santosh Shilimkar, Krzysztof Kozlowski, Liam Girdwood, Mark Brown,
Pavel Machek, Lee Jones, Andrew Morton, Guenter Roeck,
Daniel Lezcano, Andy Shevchenko, Ulf Hansson, alankao,
K . C . Kuen-Chern Lin
Cc: linux-arm-kernel, linux-kernel, linux-csky, linux-ia64,
linux-m68k, linux-mips, linux-parisc, linuxppc-dev, linux-riscv,
linux-sh, xen-devel, linux-acpi, linux-pm, linux-tegra
There is no need to annotate function prototypes with 'extern', it makes
code less readable. Remove unnecessary annotations from <notifier.h>.
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
include/linux/notifier.h | 30 +++++++++++++++---------------
1 file changed, 15 insertions(+), 15 deletions(-)
diff --git a/include/linux/notifier.h b/include/linux/notifier.h
index 87069b8459af..4b80a815b666 100644
--- a/include/linux/notifier.h
+++ b/include/linux/notifier.h
@@ -90,7 +90,7 @@ struct srcu_notifier_head {
} while (0)
/* srcu_notifier_heads must be cleaned up dynamically */
-extern void srcu_init_notifier_head(struct srcu_notifier_head *nh);
+void srcu_init_notifier_head(struct srcu_notifier_head *nh);
#define srcu_cleanup_notifier_head(name) \
cleanup_srcu_struct(&(name)->srcu);
@@ -141,36 +141,36 @@ extern void srcu_init_notifier_head(struct srcu_notifier_head *nh);
#ifdef __KERNEL__
-extern int atomic_notifier_chain_register(struct atomic_notifier_head *nh,
+int atomic_notifier_chain_register(struct atomic_notifier_head *nh,
struct notifier_block *nb);
-extern int blocking_notifier_chain_register(struct blocking_notifier_head *nh,
+int blocking_notifier_chain_register(struct blocking_notifier_head *nh,
struct notifier_block *nb);
-extern int raw_notifier_chain_register(struct raw_notifier_head *nh,
+int raw_notifier_chain_register(struct raw_notifier_head *nh,
struct notifier_block *nb);
-extern int srcu_notifier_chain_register(struct srcu_notifier_head *nh,
+int srcu_notifier_chain_register(struct srcu_notifier_head *nh,
struct notifier_block *nb);
-extern int atomic_notifier_chain_unregister(struct atomic_notifier_head *nh,
+int atomic_notifier_chain_unregister(struct atomic_notifier_head *nh,
struct notifier_block *nb);
-extern int blocking_notifier_chain_unregister(struct blocking_notifier_head *nh,
+int blocking_notifier_chain_unregister(struct blocking_notifier_head *nh,
struct notifier_block *nb);
-extern int raw_notifier_chain_unregister(struct raw_notifier_head *nh,
+int raw_notifier_chain_unregister(struct raw_notifier_head *nh,
struct notifier_block *nb);
-extern int srcu_notifier_chain_unregister(struct srcu_notifier_head *nh,
+int srcu_notifier_chain_unregister(struct srcu_notifier_head *nh,
struct notifier_block *nb);
-extern int atomic_notifier_call_chain(struct atomic_notifier_head *nh,
+int atomic_notifier_call_chain(struct atomic_notifier_head *nh,
unsigned long val, void *v);
-extern int blocking_notifier_call_chain(struct blocking_notifier_head *nh,
+int blocking_notifier_call_chain(struct blocking_notifier_head *nh,
unsigned long val, void *v);
-extern int raw_notifier_call_chain(struct raw_notifier_head *nh,
+int raw_notifier_call_chain(struct raw_notifier_head *nh,
unsigned long val, void *v);
-extern int srcu_notifier_call_chain(struct srcu_notifier_head *nh,
+int srcu_notifier_call_chain(struct srcu_notifier_head *nh,
unsigned long val, void *v);
-extern int blocking_notifier_call_chain_robust(struct blocking_notifier_head *nh,
+int blocking_notifier_call_chain_robust(struct blocking_notifier_head *nh,
unsigned long val_up, unsigned long val_down, void *v);
-extern int raw_notifier_call_chain_robust(struct raw_notifier_head *nh,
+int raw_notifier_call_chain_robust(struct raw_notifier_head *nh,
unsigned long val_up, unsigned long val_down, void *v);
#define NOTIFY_DONE 0x0000 /* Don't care */
--
2.33.1
^ permalink raw reply related [flat|nested] 52+ messages in thread* [PATCH v4 02/25] notifier: Add blocking_notifier_call_chain_is_empty()
2021-11-26 18:00 [PATCH v4 00/25] Introduce power-off+restart call chain API Dmitry Osipenko
2021-11-26 18:00 ` [PATCH v4 01/25] notifier: Remove extern annotation from function prototypes Dmitry Osipenko
@ 2021-11-26 18:00 ` Dmitry Osipenko
2021-12-10 18:14 ` Rafael J. Wysocki
2021-11-26 18:00 ` [PATCH v4 03/25] notifier: Add atomic/blocking_notifier_has_unique_priority() Dmitry Osipenko
` (22 subsequent siblings)
24 siblings, 1 reply; 52+ messages in thread
From: Dmitry Osipenko @ 2021-11-26 18:00 UTC (permalink / raw)
To: Thierry Reding, Jonathan Hunter, Russell King, Catalin Marinas,
Will Deacon, Guo Ren, Geert Uytterhoeven, Greg Ungerer,
Joshua Thompson, Thomas Bogendoerfer, Sebastian Reichel,
Linus Walleij, Philipp Zabel, Greentime Hu, Vincent Chen,
James E.J. Bottomley, Helge Deller, Michael Ellerman,
Benjamin Herrenschmidt, Paul Mackerras, Paul Walmsley,
Palmer Dabbelt, Albert Ou, Yoshinori Sato, Rich Felker,
Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
H. Peter Anvin, Boris Ostrovsky, Juergen Gross,
Stefano Stabellini, Rafael J. Wysocki, Len Brown,
Santosh Shilimkar, Krzysztof Kozlowski, Liam Girdwood, Mark Brown,
Pavel Machek, Lee Jones, Andrew Morton, Guenter Roeck,
Daniel Lezcano, Andy Shevchenko, Ulf Hansson, alankao,
K . C . Kuen-Chern Lin
Cc: linux-arm-kernel, linux-kernel, linux-csky, linux-ia64,
linux-m68k, linux-mips, linux-parisc, linuxppc-dev, linux-riscv,
linux-sh, xen-devel, linux-acpi, linux-pm, linux-tegra
Add blocking_notifier_call_chain_is_empty() that returns true if call
chain is empty.
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
include/linux/notifier.h | 2 ++
kernel/notifier.c | 14 ++++++++++++++
2 files changed, 16 insertions(+)
diff --git a/include/linux/notifier.h b/include/linux/notifier.h
index 4b80a815b666..924c9d7c8e73 100644
--- a/include/linux/notifier.h
+++ b/include/linux/notifier.h
@@ -173,6 +173,8 @@ int blocking_notifier_call_chain_robust(struct blocking_notifier_head *nh,
int raw_notifier_call_chain_robust(struct raw_notifier_head *nh,
unsigned long val_up, unsigned long val_down, void *v);
+bool blocking_notifier_call_chain_is_empty(struct blocking_notifier_head *nh);
+
#define NOTIFY_DONE 0x0000 /* Don't care */
#define NOTIFY_OK 0x0001 /* Suits me */
#define NOTIFY_STOP_MASK 0x8000 /* Don't call further */
diff --git a/kernel/notifier.c b/kernel/notifier.c
index b8251dc0bc0f..b20cb7b9b1f0 100644
--- a/kernel/notifier.c
+++ b/kernel/notifier.c
@@ -322,6 +322,20 @@ int blocking_notifier_call_chain(struct blocking_notifier_head *nh,
}
EXPORT_SYMBOL_GPL(blocking_notifier_call_chain);
+/**
+ * blocking_notifier_call_chain_is_empty - Check whether notifier chain is empty
+ * @nh: Pointer to head of the blocking notifier chain
+ *
+ * Checks whether notifier chain is empty.
+ *
+ * Returns true is notifier chain is empty, false otherwise.
+ */
+bool blocking_notifier_call_chain_is_empty(struct blocking_notifier_head *nh)
+{
+ return !rcu_access_pointer(nh->head);
+}
+EXPORT_SYMBOL_GPL(blocking_notifier_call_chain_is_empty);
+
/*
* Raw notifier chain routines. There is no protection;
* the caller must provide it. Use at your own risk!
--
2.33.1
^ permalink raw reply related [flat|nested] 52+ messages in thread* Re: [PATCH v4 02/25] notifier: Add blocking_notifier_call_chain_is_empty()
2021-11-26 18:00 ` [PATCH v4 02/25] notifier: Add blocking_notifier_call_chain_is_empty() Dmitry Osipenko
@ 2021-12-10 18:14 ` Rafael J. Wysocki
2021-12-10 18:19 ` Dmitry Osipenko
0 siblings, 1 reply; 52+ messages in thread
From: Rafael J. Wysocki @ 2021-12-10 18:14 UTC (permalink / raw)
To: Dmitry Osipenko
Cc: Thierry Reding, Jonathan Hunter, Russell King, Catalin Marinas,
Will Deacon, Guo Ren, Geert Uytterhoeven, Greg Ungerer,
Joshua Thompson, Thomas Bogendoerfer, Sebastian Reichel,
Linus Walleij, Philipp Zabel, Greentime Hu, Vincent Chen,
James E.J. Bottomley, Helge Deller, Michael Ellerman,
Benjamin Herrenschmidt, Paul Mackerras, Paul Walmsley,
Palmer Dabbelt, Albert Ou, Yoshinori Sato, Rich Felker,
Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen,
the arch/x86 maintainers, H. Peter Anvin, Boris Ostrovsky,
Juergen Gross, Stefano Stabellini, Rafael J. Wysocki, Len Brown,
Santosh Shilimkar, Krzysztof Kozlowski, Liam Girdwood, Mark Brown,
Pavel Machek, Lee Jones, Andrew Morton, Guenter Roeck,
Daniel Lezcano, Andy Shevchenko, Ulf Hansson, alankao,
K . C . Kuen-Chern Lin, Linux ARM, Linux Kernel Mailing List,
linux-csky, linux-ia64, linux-m68k, linux-mips, linux-parisc,
linuxppc-dev, linux-riscv, Linux-sh list, xen-devel,
ACPI Devel Maling List, Linux PM, linux-tegra
On Fri, Nov 26, 2021 at 7:01 PM Dmitry Osipenko <digetx@gmail.com> wrote:
>
> Add blocking_notifier_call_chain_is_empty() that returns true if call
> chain is empty.
>
> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
> ---
> include/linux/notifier.h | 2 ++
> kernel/notifier.c | 14 ++++++++++++++
> 2 files changed, 16 insertions(+)
>
> diff --git a/include/linux/notifier.h b/include/linux/notifier.h
> index 4b80a815b666..924c9d7c8e73 100644
> --- a/include/linux/notifier.h
> +++ b/include/linux/notifier.h
> @@ -173,6 +173,8 @@ int blocking_notifier_call_chain_robust(struct blocking_notifier_head *nh,
> int raw_notifier_call_chain_robust(struct raw_notifier_head *nh,
> unsigned long val_up, unsigned long val_down, void *v);
>
> +bool blocking_notifier_call_chain_is_empty(struct blocking_notifier_head *nh);
> +
> #define NOTIFY_DONE 0x0000 /* Don't care */
> #define NOTIFY_OK 0x0001 /* Suits me */
> #define NOTIFY_STOP_MASK 0x8000 /* Don't call further */
> diff --git a/kernel/notifier.c b/kernel/notifier.c
> index b8251dc0bc0f..b20cb7b9b1f0 100644
> --- a/kernel/notifier.c
> +++ b/kernel/notifier.c
> @@ -322,6 +322,20 @@ int blocking_notifier_call_chain(struct blocking_notifier_head *nh,
> }
> EXPORT_SYMBOL_GPL(blocking_notifier_call_chain);
>
> +/**
> + * blocking_notifier_call_chain_is_empty - Check whether notifier chain is empty
> + * @nh: Pointer to head of the blocking notifier chain
> + *
> + * Checks whether notifier chain is empty.
> + *
> + * Returns true is notifier chain is empty, false otherwise.
> + */
> +bool blocking_notifier_call_chain_is_empty(struct blocking_notifier_head *nh)
> +{
> + return !rcu_access_pointer(nh->head);
> +}
> +EXPORT_SYMBOL_GPL(blocking_notifier_call_chain_is_empty);
The check is not reliable (racy) without locking, so I wouldn't export
anything like this to modules.
At least IMO it should be added along with a user.
^ permalink raw reply [flat|nested] 52+ messages in thread* Re: [PATCH v4 02/25] notifier: Add blocking_notifier_call_chain_is_empty()
2021-12-10 18:14 ` Rafael J. Wysocki
@ 2021-12-10 18:19 ` Dmitry Osipenko
0 siblings, 0 replies; 52+ messages in thread
From: Dmitry Osipenko @ 2021-12-10 18:19 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: Thierry Reding, Jonathan Hunter, Russell King, Catalin Marinas,
Will Deacon, Guo Ren, Geert Uytterhoeven, Greg Ungerer,
Joshua Thompson, Thomas Bogendoerfer, Sebastian Reichel,
Linus Walleij, Philipp Zabel, Greentime Hu, Vincent Chen,
James E.J. Bottomley, Helge Deller, Michael Ellerman,
Benjamin Herrenschmidt, Paul Mackerras, Paul Walmsley,
Palmer Dabbelt, Albert Ou, Yoshinori Sato, Rich Felker,
Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen,
the arch/x86 maintainers, H. Peter Anvin, Boris Ostrovsky,
Juergen Gross, Stefano Stabellini, Len Brown, Santosh Shilimkar,
Krzysztof Kozlowski, Liam Girdwood, Mark Brown, Pavel Machek,
Lee Jones, Andrew Morton, Guenter Roeck, Daniel Lezcano,
Andy Shevchenko, Ulf Hansson, alankao, K . C . Kuen-Chern Lin,
Linux ARM, Linux Kernel Mailing List, linux-csky, linux-ia64,
linux-m68k, linux-mips, linux-parisc, linuxppc-dev, linux-riscv,
Linux-sh list, xen-devel, ACPI Devel Maling List, Linux PM,
linux-tegra
10.12.2021 21:14, Rafael J. Wysocki пишет:
> On Fri, Nov 26, 2021 at 7:01 PM Dmitry Osipenko <digetx@gmail.com> wrote:
>>
>> Add blocking_notifier_call_chain_is_empty() that returns true if call
>> chain is empty.
>>
>> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
>> ---
>> include/linux/notifier.h | 2 ++
>> kernel/notifier.c | 14 ++++++++++++++
>> 2 files changed, 16 insertions(+)
>>
>> diff --git a/include/linux/notifier.h b/include/linux/notifier.h
>> index 4b80a815b666..924c9d7c8e73 100644
>> --- a/include/linux/notifier.h
>> +++ b/include/linux/notifier.h
>> @@ -173,6 +173,8 @@ int blocking_notifier_call_chain_robust(struct blocking_notifier_head *nh,
>> int raw_notifier_call_chain_robust(struct raw_notifier_head *nh,
>> unsigned long val_up, unsigned long val_down, void *v);
>>
>> +bool blocking_notifier_call_chain_is_empty(struct blocking_notifier_head *nh);
>> +
>> #define NOTIFY_DONE 0x0000 /* Don't care */
>> #define NOTIFY_OK 0x0001 /* Suits me */
>> #define NOTIFY_STOP_MASK 0x8000 /* Don't call further */
>> diff --git a/kernel/notifier.c b/kernel/notifier.c
>> index b8251dc0bc0f..b20cb7b9b1f0 100644
>> --- a/kernel/notifier.c
>> +++ b/kernel/notifier.c
>> @@ -322,6 +322,20 @@ int blocking_notifier_call_chain(struct blocking_notifier_head *nh,
>> }
>> EXPORT_SYMBOL_GPL(blocking_notifier_call_chain);
>>
>> +/**
>> + * blocking_notifier_call_chain_is_empty - Check whether notifier chain is empty
>> + * @nh: Pointer to head of the blocking notifier chain
>> + *
>> + * Checks whether notifier chain is empty.
>> + *
>> + * Returns true is notifier chain is empty, false otherwise.
>> + */
>> +bool blocking_notifier_call_chain_is_empty(struct blocking_notifier_head *nh)
>> +{
>> + return !rcu_access_pointer(nh->head);
>> +}
>> +EXPORT_SYMBOL_GPL(blocking_notifier_call_chain_is_empty);
>
> The check is not reliable (racy) without locking, so I wouldn't export
> anything like this to modules.
>
> At least IMO it should be added along with a user.
>
I'll remove the export since it's indeed not obvious how other users may
want to use this function.
^ permalink raw reply [flat|nested] 52+ messages in thread
* [PATCH v4 03/25] notifier: Add atomic/blocking_notifier_has_unique_priority()
2021-11-26 18:00 [PATCH v4 00/25] Introduce power-off+restart call chain API Dmitry Osipenko
2021-11-26 18:00 ` [PATCH v4 01/25] notifier: Remove extern annotation from function prototypes Dmitry Osipenko
2021-11-26 18:00 ` [PATCH v4 02/25] notifier: Add blocking_notifier_call_chain_is_empty() Dmitry Osipenko
@ 2021-11-26 18:00 ` Dmitry Osipenko
2021-12-10 18:19 ` Rafael J. Wysocki
2021-11-26 18:00 ` [PATCH v4 04/25] reboot: Correct typo in a comment Dmitry Osipenko
` (21 subsequent siblings)
24 siblings, 1 reply; 52+ messages in thread
From: Dmitry Osipenko @ 2021-11-26 18:00 UTC (permalink / raw)
To: Thierry Reding, Jonathan Hunter, Russell King, Catalin Marinas,
Will Deacon, Guo Ren, Geert Uytterhoeven, Greg Ungerer,
Joshua Thompson, Thomas Bogendoerfer, Sebastian Reichel,
Linus Walleij, Philipp Zabel, Greentime Hu, Vincent Chen,
James E.J. Bottomley, Helge Deller, Michael Ellerman,
Benjamin Herrenschmidt, Paul Mackerras, Paul Walmsley,
Palmer Dabbelt, Albert Ou, Yoshinori Sato, Rich Felker,
Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
H. Peter Anvin, Boris Ostrovsky, Juergen Gross,
Stefano Stabellini, Rafael J. Wysocki, Len Brown,
Santosh Shilimkar, Krzysztof Kozlowski, Liam Girdwood, Mark Brown,
Pavel Machek, Lee Jones, Andrew Morton, Guenter Roeck,
Daniel Lezcano, Andy Shevchenko, Ulf Hansson, alankao,
K . C . Kuen-Chern Lin
Cc: linux-arm-kernel, linux-kernel, linux-csky, linux-ia64,
linux-m68k, linux-mips, linux-parisc, linuxppc-dev, linux-riscv,
linux-sh, xen-devel, linux-acpi, linux-pm, linux-tegra
Add atomic/blocking_notifier_has_unique_priority() helpers which return
true if given handler has unique priority.
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
include/linux/notifier.h | 5 +++
kernel/notifier.c | 69 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 74 insertions(+)
diff --git a/include/linux/notifier.h b/include/linux/notifier.h
index 924c9d7c8e73..2c4036f225e1 100644
--- a/include/linux/notifier.h
+++ b/include/linux/notifier.h
@@ -175,6 +175,11 @@ int raw_notifier_call_chain_robust(struct raw_notifier_head *nh,
bool blocking_notifier_call_chain_is_empty(struct blocking_notifier_head *nh);
+bool atomic_notifier_has_unique_priority(struct atomic_notifier_head *nh,
+ struct notifier_block *nb);
+bool blocking_notifier_has_unique_priority(struct blocking_notifier_head *nh,
+ struct notifier_block *nb);
+
#define NOTIFY_DONE 0x0000 /* Don't care */
#define NOTIFY_OK 0x0001 /* Suits me */
#define NOTIFY_STOP_MASK 0x8000 /* Don't call further */
diff --git a/kernel/notifier.c b/kernel/notifier.c
index b20cb7b9b1f0..7a325b742104 100644
--- a/kernel/notifier.c
+++ b/kernel/notifier.c
@@ -122,6 +122,19 @@ static int notifier_call_chain_robust(struct notifier_block **nl,
return ret;
}
+static int notifier_has_unique_priority(struct notifier_block **nl,
+ struct notifier_block *n)
+{
+ while (*nl && (*nl)->priority >= n->priority) {
+ if ((*nl)->priority = n->priority && *nl != n)
+ return false;
+
+ nl = &((*nl)->next);
+ }
+
+ return true;
+}
+
/*
* Atomic notifier chain routines. Registration and unregistration
* use a spinlock, and call_chain is synchronized by RCU (no locks).
@@ -203,6 +216,30 @@ int atomic_notifier_call_chain(struct atomic_notifier_head *nh,
EXPORT_SYMBOL_GPL(atomic_notifier_call_chain);
NOKPROBE_SYMBOL(atomic_notifier_call_chain);
+/**
+ * atomic_notifier_has_unique_priority - Checks whether notifier's priority is unique
+ * @nh: Pointer to head of the atomic notifier chain
+ * @n: Entry in notifier chain to check
+ *
+ * Checks whether there is another notifier in the chain with the same priority.
+ * Must be called in process context.
+ *
+ * Returns true if priority is unique, false otherwise.
+ */
+bool atomic_notifier_has_unique_priority(struct atomic_notifier_head *nh,
+ struct notifier_block *n)
+{
+ unsigned long flags;
+ bool ret;
+
+ spin_lock_irqsave(&nh->lock, flags);
+ ret = notifier_has_unique_priority(&nh->head, n);
+ spin_unlock_irqrestore(&nh->lock, flags);
+
+ return ret;
+}
+EXPORT_SYMBOL_GPL(atomic_notifier_has_unique_priority);
+
/*
* Blocking notifier chain routines. All access to the chain is
* synchronized by an rwsem.
@@ -336,6 +373,38 @@ bool blocking_notifier_call_chain_is_empty(struct blocking_notifier_head *nh)
}
EXPORT_SYMBOL_GPL(blocking_notifier_call_chain_is_empty);
+/**
+ * blocking_notifier_has_unique_priority - Checks whether notifier's priority is unique
+ * @nh: Pointer to head of the blocking notifier chain
+ * @n: Entry in notifier chain to check
+ *
+ * Checks whether there is another notifier in the chain with the same priority.
+ * Must be called in process context.
+ *
+ * Returns true if priority is unique, false otherwise.
+ */
+bool blocking_notifier_has_unique_priority(struct blocking_notifier_head *nh,
+ struct notifier_block *n)
+{
+ bool ret;
+
+ /*
+ * This code gets used during boot-up, when task switching is
+ * not yet working and interrupts must remain disabled. At such
+ * times we must not call down_read().
+ */
+ if (system_state != SYSTEM_BOOTING)
+ down_read(&nh->rwsem);
+
+ ret = notifier_has_unique_priority(&nh->head, n);
+
+ if (system_state != SYSTEM_BOOTING)
+ up_read(&nh->rwsem);
+
+ return ret;
+}
+EXPORT_SYMBOL_GPL(blocking_notifier_has_unique_priority);
+
/*
* Raw notifier chain routines. There is no protection;
* the caller must provide it. Use at your own risk!
--
2.33.1
^ permalink raw reply related [flat|nested] 52+ messages in thread* Re: [PATCH v4 03/25] notifier: Add atomic/blocking_notifier_has_unique_priority()
2021-11-26 18:00 ` [PATCH v4 03/25] notifier: Add atomic/blocking_notifier_has_unique_priority() Dmitry Osipenko
@ 2021-12-10 18:19 ` Rafael J. Wysocki
2021-12-10 18:52 ` Dmitry Osipenko
0 siblings, 1 reply; 52+ messages in thread
From: Rafael J. Wysocki @ 2021-12-10 18:19 UTC (permalink / raw)
To: Dmitry Osipenko
Cc: Thierry Reding, Jonathan Hunter, Russell King, Catalin Marinas,
Will Deacon, Guo Ren, Geert Uytterhoeven, Greg Ungerer,
Joshua Thompson, Thomas Bogendoerfer, Sebastian Reichel,
Linus Walleij, Philipp Zabel, Greentime Hu, Vincent Chen,
James E.J. Bottomley, Helge Deller, Michael Ellerman,
Benjamin Herrenschmidt, Paul Mackerras, Paul Walmsley,
Palmer Dabbelt, Albert Ou, Yoshinori Sato, Rich Felker,
Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen,
the arch/x86 maintainers, H. Peter Anvin, Boris Ostrovsky,
Juergen Gross, Stefano Stabellini, Rafael J. Wysocki, Len Brown,
Santosh Shilimkar, Krzysztof Kozlowski, Liam Girdwood, Mark Brown,
Pavel Machek, Lee Jones, Andrew Morton, Guenter Roeck,
Daniel Lezcano, Andy Shevchenko, Ulf Hansson, alankao,
K . C . Kuen-Chern Lin, Linux ARM, Linux Kernel Mailing List,
linux-csky, linux-ia64, linux-m68k, linux-mips, linux-parisc,
linuxppc-dev, linux-riscv, Linux-sh list, xen-devel,
ACPI Devel Maling List, Linux PM, linux-tegra
On Fri, Nov 26, 2021 at 7:02 PM Dmitry Osipenko <digetx@gmail.com> wrote:
>
> Add atomic/blocking_notifier_has_unique_priority() helpers which return
> true if given handler has unique priority.
>
> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
> ---
> include/linux/notifier.h | 5 +++
> kernel/notifier.c | 69 ++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 74 insertions(+)
>
> diff --git a/include/linux/notifier.h b/include/linux/notifier.h
> index 924c9d7c8e73..2c4036f225e1 100644
> --- a/include/linux/notifier.h
> +++ b/include/linux/notifier.h
> @@ -175,6 +175,11 @@ int raw_notifier_call_chain_robust(struct raw_notifier_head *nh,
>
> bool blocking_notifier_call_chain_is_empty(struct blocking_notifier_head *nh);
>
> +bool atomic_notifier_has_unique_priority(struct atomic_notifier_head *nh,
> + struct notifier_block *nb);
> +bool blocking_notifier_has_unique_priority(struct blocking_notifier_head *nh,
> + struct notifier_block *nb);
> +
> #define NOTIFY_DONE 0x0000 /* Don't care */
> #define NOTIFY_OK 0x0001 /* Suits me */
> #define NOTIFY_STOP_MASK 0x8000 /* Don't call further */
> diff --git a/kernel/notifier.c b/kernel/notifier.c
> index b20cb7b9b1f0..7a325b742104 100644
> --- a/kernel/notifier.c
> +++ b/kernel/notifier.c
> @@ -122,6 +122,19 @@ static int notifier_call_chain_robust(struct notifier_block **nl,
> return ret;
> }
>
> +static int notifier_has_unique_priority(struct notifier_block **nl,
> + struct notifier_block *n)
> +{
> + while (*nl && (*nl)->priority >= n->priority) {
> + if ((*nl)->priority = n->priority && *nl != n)
> + return false;
> +
> + nl = &((*nl)->next);
> + }
> +
> + return true;
> +}
> +
> /*
> * Atomic notifier chain routines. Registration and unregistration
> * use a spinlock, and call_chain is synchronized by RCU (no locks).
> @@ -203,6 +216,30 @@ int atomic_notifier_call_chain(struct atomic_notifier_head *nh,
> EXPORT_SYMBOL_GPL(atomic_notifier_call_chain);
> NOKPROBE_SYMBOL(atomic_notifier_call_chain);
>
> +/**
> + * atomic_notifier_has_unique_priority - Checks whether notifier's priority is unique
> + * @nh: Pointer to head of the atomic notifier chain
> + * @n: Entry in notifier chain to check
> + *
> + * Checks whether there is another notifier in the chain with the same priority.
> + * Must be called in process context.
> + *
> + * Returns true if priority is unique, false otherwise.
> + */
> +bool atomic_notifier_has_unique_priority(struct atomic_notifier_head *nh,
> + struct notifier_block *n)
> +{
> + unsigned long flags;
> + bool ret;
> +
> + spin_lock_irqsave(&nh->lock, flags);
> + ret = notifier_has_unique_priority(&nh->head, n);
> + spin_unlock_irqrestore(&nh->lock, flags);
This only works if the caller can prevent new entries from being added
to the list at this point or if the caller knows that they cannot be
added for some reason, but the kerneldoc doesn't mention this
limitation.
> +
> + return ret;
> +}
> +EXPORT_SYMBOL_GPL(atomic_notifier_has_unique_priority);
> +
> /*
> * Blocking notifier chain routines. All access to the chain is
> * synchronized by an rwsem.
> @@ -336,6 +373,38 @@ bool blocking_notifier_call_chain_is_empty(struct blocking_notifier_head *nh)
> }
> EXPORT_SYMBOL_GPL(blocking_notifier_call_chain_is_empty);
>
> +/**
> + * blocking_notifier_has_unique_priority - Checks whether notifier's priority is unique
> + * @nh: Pointer to head of the blocking notifier chain
> + * @n: Entry in notifier chain to check
> + *
> + * Checks whether there is another notifier in the chain with the same priority.
> + * Must be called in process context.
> + *
> + * Returns true if priority is unique, false otherwise.
> + */
> +bool blocking_notifier_has_unique_priority(struct blocking_notifier_head *nh,
> + struct notifier_block *n)
> +{
> + bool ret;
> +
> + /*
> + * This code gets used during boot-up, when task switching is
> + * not yet working and interrupts must remain disabled. At such
> + * times we must not call down_read().
> + */
> + if (system_state != SYSTEM_BOOTING)
No, please don't do this, it makes the whole thing error-prone.
> + down_read(&nh->rwsem);
> +
> + ret = notifier_has_unique_priority(&nh->head, n);
> +
> + if (system_state != SYSTEM_BOOTING)
> + up_read(&nh->rwsem);
And still what if a new entry with a non-unique priority is added to
the chain at this point?
> +
> + return ret;
> +}
> +EXPORT_SYMBOL_GPL(blocking_notifier_has_unique_priority);
> +
> /*
> * Raw notifier chain routines. There is no protection;
> * the caller must provide it. Use at your own risk!
> --
> 2.33.1
>
^ permalink raw reply [flat|nested] 52+ messages in thread* Re: [PATCH v4 03/25] notifier: Add atomic/blocking_notifier_has_unique_priority()
2021-12-10 18:19 ` Rafael J. Wysocki
@ 2021-12-10 18:52 ` Dmitry Osipenko
2021-12-10 19:05 ` Rafael J. Wysocki
0 siblings, 1 reply; 52+ messages in thread
From: Dmitry Osipenko @ 2021-12-10 18:52 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: Thierry Reding, Jonathan Hunter, Russell King, Catalin Marinas,
Will Deacon, Guo Ren, Geert Uytterhoeven, Greg Ungerer,
Joshua Thompson, Thomas Bogendoerfer, Sebastian Reichel,
Linus Walleij, Philipp Zabel, Greentime Hu, Vincent Chen,
James E.J. Bottomley, Helge Deller, Michael Ellerman,
Benjamin Herrenschmidt, Paul Mackerras, Paul Walmsley,
Palmer Dabbelt, Albert Ou, Yoshinori Sato, Rich Felker,
Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen,
the arch/x86 maintainers, H. Peter Anvin, Boris Ostrovsky,
Juergen Gross, Stefano Stabellini, Len Brown, Santosh Shilimkar,
Krzysztof Kozlowski, Liam Girdwood, Mark Brown, Pavel Machek,
Lee Jones, Andrew Morton, Guenter Roeck, Daniel Lezcano,
Andy Shevchenko, Ulf Hansson, alankao, K . C . Kuen-Chern Lin,
Linux ARM, Linux Kernel Mailing List, linux-csky, linux-ia64,
linux-m68k, linux-mips, linux-parisc, linuxppc-dev, linux-riscv,
Linux-sh list, xen-devel, ACPI Devel Maling List, Linux PM,
linux-tegra
10.12.2021 21:19, Rafael J. Wysocki пишет:
...
>> +bool atomic_notifier_has_unique_priority(struct atomic_notifier_head *nh,
>> + struct notifier_block *n)
>> +{
>> + unsigned long flags;
>> + bool ret;
>> +
>> + spin_lock_irqsave(&nh->lock, flags);
>> + ret = notifier_has_unique_priority(&nh->head, n);
>> + spin_unlock_irqrestore(&nh->lock, flags);
>
> This only works if the caller can prevent new entries from being added
> to the list at this point or if the caller knows that they cannot be
> added for some reason, but the kerneldoc doesn't mention this
> limitation.
I'll update the comment.
..
>> +bool blocking_notifier_has_unique_priority(struct blocking_notifier_head *nh,
>> + struct notifier_block *n)
>> +{
>> + bool ret;
>> +
>> + /*
>> + * This code gets used during boot-up, when task switching is
>> + * not yet working and interrupts must remain disabled. At such
>> + * times we must not call down_read().
>> + */
>> + if (system_state != SYSTEM_BOOTING)
>
> No, please don't do this, it makes the whole thing error-prone.
What should I do then?
>> + down_read(&nh->rwsem);
>> +
>> + ret = notifier_has_unique_priority(&nh->head, n);
>> +
>> + if (system_state != SYSTEM_BOOTING)
>> + up_read(&nh->rwsem);
>
> And still what if a new entry with a non-unique priority is added to
> the chain at this point?
If entry with a non-unique priority is added after the check, then
obviously it won't be detected. I don't understand the question. These
down/up_read() are the locks that prevent the race, if that's the question.
^ permalink raw reply [flat|nested] 52+ messages in thread* Re: [PATCH v4 03/25] notifier: Add atomic/blocking_notifier_has_unique_priority()
2021-12-10 18:52 ` Dmitry Osipenko
@ 2021-12-10 19:05 ` Rafael J. Wysocki
2021-12-10 19:33 ` Dmitry Osipenko
0 siblings, 1 reply; 52+ messages in thread
From: Rafael J. Wysocki @ 2021-12-10 19:05 UTC (permalink / raw)
To: Dmitry Osipenko
Cc: Rafael J. Wysocki, Thierry Reding, Jonathan Hunter, Russell King,
Catalin Marinas, Will Deacon, Guo Ren, Geert Uytterhoeven,
Greg Ungerer, Joshua Thompson, Thomas Bogendoerfer,
Sebastian Reichel, Linus Walleij, Philipp Zabel, Greentime Hu,
Vincent Chen, James E.J. Bottomley, Helge Deller,
Michael Ellerman, Benjamin Herrenschmidt, Paul Mackerras,
Paul Walmsley, Palmer Dabbelt, Albert Ou, Yoshinori Sato,
Rich Felker, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
Dave Hansen, the arch/x86 maintainers, H. Peter Anvin,
Boris Ostrovsky, Juergen Gross, Stefano Stabellini, Len Brown,
Santosh Shilimkar, Krzysztof Kozlowski, Liam Girdwood, Mark Brown,
Pavel Machek, Lee Jones, Andrew Morton, Guenter Roeck,
Daniel Lezcano, Andy Shevchenko, Ulf Hansson, alankao,
K . C . Kuen-Chern Lin, Linux ARM, Linux Kernel Mailing List,
linux-csky, linux-ia64, linux-m68k, linux-mips, linux-parisc,
linuxppc-dev, linux-riscv, Linux-sh list, xen-devel,
ACPI Devel Maling List, Linux PM, linux-tegra
On Fri, Dec 10, 2021 at 7:52 PM Dmitry Osipenko <digetx@gmail.com> wrote:
>
> 10.12.2021 21:19, Rafael J. Wysocki пишет:
> ...
> >> +bool atomic_notifier_has_unique_priority(struct atomic_notifier_head *nh,
> >> + struct notifier_block *n)
> >> +{
> >> + unsigned long flags;
> >> + bool ret;
> >> +
> >> + spin_lock_irqsave(&nh->lock, flags);
> >> + ret = notifier_has_unique_priority(&nh->head, n);
> >> + spin_unlock_irqrestore(&nh->lock, flags);
> >
> > This only works if the caller can prevent new entries from being added
> > to the list at this point or if the caller knows that they cannot be
> > added for some reason, but the kerneldoc doesn't mention this
> > limitation.
>
> I'll update the comment.
>
> ..
> >> +bool blocking_notifier_has_unique_priority(struct blocking_notifier_head *nh,
> >> + struct notifier_block *n)
> >> +{
> >> + bool ret;
> >> +
> >> + /*
> >> + * This code gets used during boot-up, when task switching is
> >> + * not yet working and interrupts must remain disabled. At such
> >> + * times we must not call down_read().
> >> + */
> >> + if (system_state != SYSTEM_BOOTING)
> >
> > No, please don't do this, it makes the whole thing error-prone.
>
> What should I do then?
First of all, do you know of any users who may want to call this
during early initialization? If so, then why may they want to do
that?
Depending on the above, I would consider adding a special mechanism for them.
> >> + down_read(&nh->rwsem);
> >> +
> >> + ret = notifier_has_unique_priority(&nh->head, n);
> >> +
> >> + if (system_state != SYSTEM_BOOTING)
> >> + up_read(&nh->rwsem);
> >
> > And still what if a new entry with a non-unique priority is added to
> > the chain at this point?
>
> If entry with a non-unique priority is added after the check, then
> obviously it won't be detected.
Why isn't this a problem?
> I don't understand the question. These
> down/up_read() are the locks that prevent the race, if that's the question.
Not really, they only prevent the race from occurring while
notifier_has_unique_priority() is running.
If anyone depends on this check for correctness, they need to lock the
rwsem, do the check, do the thing depending on the check while holding
the rwsem and then release the rwsem. Otherwise it is racy.
^ permalink raw reply [flat|nested] 52+ messages in thread* Re: [PATCH v4 03/25] notifier: Add atomic/blocking_notifier_has_unique_priority()
2021-12-10 19:05 ` Rafael J. Wysocki
@ 2021-12-10 19:33 ` Dmitry Osipenko
2021-12-10 20:16 ` Dmitry Osipenko
0 siblings, 1 reply; 52+ messages in thread
From: Dmitry Osipenko @ 2021-12-10 19:33 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: Thierry Reding, Jonathan Hunter, Russell King, Catalin Marinas,
Will Deacon, Guo Ren, Geert Uytterhoeven, Greg Ungerer,
Joshua Thompson, Thomas Bogendoerfer, Sebastian Reichel,
Linus Walleij, Philipp Zabel, Greentime Hu, Vincent Chen,
James E.J. Bottomley, Helge Deller, Michael Ellerman,
Benjamin Herrenschmidt, Paul Mackerras, Paul Walmsley,
Palmer Dabbelt, Albert Ou, Yoshinori Sato, Rich Felker,
Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen,
the arch/x86 maintainers, H. Peter Anvin, Boris Ostrovsky,
Juergen Gross, Stefano Stabellini, Len Brown, Santosh Shilimkar,
Krzysztof Kozlowski, Liam Girdwood, Mark Brown, Pavel Machek,
Lee Jones, Andrew Morton, Guenter Roeck, Daniel Lezcano,
Andy Shevchenko, Ulf Hansson, alankao, K . C . Kuen-Chern Lin,
Linux ARM, Linux Kernel Mailing List, linux-csky, linux-ia64,
linux-m68k, linux-mips, linux-parisc, linuxppc-dev, linux-riscv,
Linux-sh list, xen-devel, ACPI Devel Maling List, Linux PM,
linux-tegra
10.12.2021 22:05, Rafael J. Wysocki пишет:
> On Fri, Dec 10, 2021 at 7:52 PM Dmitry Osipenko <digetx@gmail.com> wrote:
>>
>> 10.12.2021 21:19, Rafael J. Wysocki пишет:
>> ...
>>>> +bool atomic_notifier_has_unique_priority(struct atomic_notifier_head *nh,
>>>> + struct notifier_block *n)
>>>> +{
>>>> + unsigned long flags;
>>>> + bool ret;
>>>> +
>>>> + spin_lock_irqsave(&nh->lock, flags);
>>>> + ret = notifier_has_unique_priority(&nh->head, n);
>>>> + spin_unlock_irqrestore(&nh->lock, flags);
>>>
>>> This only works if the caller can prevent new entries from being added
>>> to the list at this point or if the caller knows that they cannot be
>>> added for some reason, but the kerneldoc doesn't mention this
>>> limitation.
>>
>> I'll update the comment.
>>
>> ..
>>>> +bool blocking_notifier_has_unique_priority(struct blocking_notifier_head *nh,
>>>> + struct notifier_block *n)
>>>> +{
>>>> + bool ret;
>>>> +
>>>> + /*
>>>> + * This code gets used during boot-up, when task switching is
>>>> + * not yet working and interrupts must remain disabled. At such
>>>> + * times we must not call down_read().
>>>> + */
>>>> + if (system_state != SYSTEM_BOOTING)
>>>
>>> No, please don't do this, it makes the whole thing error-prone.
>>
>> What should I do then?
>
> First of all, do you know of any users who may want to call this
> during early initialization? If so, then why may they want to do
> that?
I'll need to carefully review all those dozens of platform restart
handlers to answer this question.
> Depending on the above, I would consider adding a special mechanism for them.
Please notice that every blocking_notifier_*() function has this
SYSTEM_BOOTING check, it's not my invention. Notifier API needs to be
generic.
>>>> + down_read(&nh->rwsem);
>>>> +
>>>> + ret = notifier_has_unique_priority(&nh->head, n);
>>>> +
>>>> + if (system_state != SYSTEM_BOOTING)
>>>> + up_read(&nh->rwsem);
>>>
>>> And still what if a new entry with a non-unique priority is added to
>>> the chain at this point?
>>
>> If entry with a non-unique priority is added after the check, then
>> obviously it won't be detected.
>
> Why isn't this a problem?>> I don't understand the question. These
>> down/up_read() are the locks that prevent the race, if that's the question.
>
> Not really, they only prevent the race from occurring while
> notifier_has_unique_priority() is running.
>
> If anyone depends on this check for correctness, they need to lock the
> rwsem, do the check, do the thing depending on the check while holding
> the rwsem and then release the rwsem. Otherwise it is racy.
>
It's fine that it's a bit "racy" since in the context of this series. We
always do the check after adding new entry, so it's not a problem.
There are two options:
1. Use blocking_notifier_has_unique_priority() like it's done in this
patchset. Remove it after all drivers are converted to the new API and
add blocking_notifier_chain_register_unique().
2. Add blocking_notifier_chain_register_unique(), but don't let it fail
the registration of non-unique entries until all drivers are converted
to the new API.
^ permalink raw reply [flat|nested] 52+ messages in thread* Re: [PATCH v4 03/25] notifier: Add atomic/blocking_notifier_has_unique_priority()
2021-12-10 19:33 ` Dmitry Osipenko
@ 2021-12-10 20:16 ` Dmitry Osipenko
0 siblings, 0 replies; 52+ messages in thread
From: Dmitry Osipenko @ 2021-12-10 20:16 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: Thierry Reding, Jonathan Hunter, Russell King, Catalin Marinas,
Will Deacon, Guo Ren, Geert Uytterhoeven, Greg Ungerer,
Joshua Thompson, Thomas Bogendoerfer, Sebastian Reichel,
Linus Walleij, Philipp Zabel, Greentime Hu, Vincent Chen,
James E.J. Bottomley, Helge Deller, Michael Ellerman,
Benjamin Herrenschmidt, Paul Mackerras, Paul Walmsley,
Palmer Dabbelt, Albert Ou, Yoshinori Sato, Rich Felker,
Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen,
the arch/x86 maintainers, H. Peter Anvin, Boris Ostrovsky,
Juergen Gross, Stefano Stabellini, Len Brown, Santosh Shilimkar,
Krzysztof Kozlowski, Liam Girdwood, Mark Brown, Pavel Machek,
Lee Jones, Andrew Morton, Guenter Roeck, Daniel Lezcano,
Andy Shevchenko, Ulf Hansson, alankao, K . C . Kuen-Chern Lin,
Linux ARM, Linux Kernel Mailing List, linux-csky, linux-ia64,
linux-m68k, linux-mips, linux-parisc, linuxppc-dev, linux-riscv,
Linux-sh list, xen-devel, ACPI Devel Maling List, Linux PM,
linux-tegra
10.12.2021 22:33, Dmitry Osipenko пишет:
>> Not really, they only prevent the race from occurring while
>> notifier_has_unique_priority() is running.
>>
>> If anyone depends on this check for correctness, they need to lock the
>> rwsem, do the check, do the thing depending on the check while holding
>> the rwsem and then release the rwsem. Otherwise it is racy.
>>
> It's fine that it's a bit "racy" since in the context of this series. We
> always do the check after adding new entry, so it's not a problem.
>
> There are two options:
>
> 1. Use blocking_notifier_has_unique_priority() like it's done in this
> patchset. Remove it after all drivers are converted to the new API and
> add blocking_notifier_chain_register_unique().
>
> 2. Add blocking_notifier_chain_register_unique(), but don't let it fail
> the registration of non-unique entries until all drivers are converted
> to the new API.
There is third, perhaps the best option:
3. Add blocking_notifier_chain_register_unique() and fall back to
blocking_notifier_chain_register() if unique fails, do it until all
drivers are converted to the new API.
^ permalink raw reply [flat|nested] 52+ messages in thread
* [PATCH v4 04/25] reboot: Correct typo in a comment
2021-11-26 18:00 [PATCH v4 00/25] Introduce power-off+restart call chain API Dmitry Osipenko
` (2 preceding siblings ...)
2021-11-26 18:00 ` [PATCH v4 03/25] notifier: Add atomic/blocking_notifier_has_unique_priority() Dmitry Osipenko
@ 2021-11-26 18:00 ` Dmitry Osipenko
2021-12-10 18:21 ` Rafael J. Wysocki
2021-11-26 18:00 ` [PATCH v4 05/25] reboot: Warn if restart handler has duplicated priority Dmitry Osipenko
` (20 subsequent siblings)
24 siblings, 1 reply; 52+ messages in thread
From: Dmitry Osipenko @ 2021-11-26 18:00 UTC (permalink / raw)
To: Thierry Reding, Jonathan Hunter, Russell King, Catalin Marinas,
Will Deacon, Guo Ren, Geert Uytterhoeven, Greg Ungerer,
Joshua Thompson, Thomas Bogendoerfer, Sebastian Reichel,
Linus Walleij, Philipp Zabel, Greentime Hu, Vincent Chen,
James E.J. Bottomley, Helge Deller, Michael Ellerman,
Benjamin Herrenschmidt, Paul Mackerras, Paul Walmsley,
Palmer Dabbelt, Albert Ou, Yoshinori Sato, Rich Felker,
Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
H. Peter Anvin, Boris Ostrovsky, Juergen Gross,
Stefano Stabellini, Rafael J. Wysocki, Len Brown,
Santosh Shilimkar, Krzysztof Kozlowski, Liam Girdwood, Mark Brown,
Pavel Machek, Lee Jones, Andrew Morton, Guenter Roeck,
Daniel Lezcano, Andy Shevchenko, Ulf Hansson, alankao,
K . C . Kuen-Chern Lin
Cc: linux-arm-kernel, linux-kernel, linux-csky, linux-ia64,
linux-m68k, linux-mips, linux-parisc, linuxppc-dev, linux-riscv,
linux-sh, xen-devel, linux-acpi, linux-pm, linux-tegra
Correct s/implemenations/implementations/ in <reboot.h>.
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
include/linux/reboot.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/linux/reboot.h b/include/linux/reboot.h
index af907a3d68d1..7c288013a3ca 100644
--- a/include/linux/reboot.h
+++ b/include/linux/reboot.h
@@ -63,7 +63,7 @@ struct pt_regs;
extern void machine_crash_shutdown(struct pt_regs *);
/*
- * Architecture independent implemenations of sys_reboot commands.
+ * Architecture independent implementations of sys_reboot commands.
*/
extern void kernel_restart_prepare(char *cmd);
--
2.33.1
^ permalink raw reply related [flat|nested] 52+ messages in thread* Re: [PATCH v4 04/25] reboot: Correct typo in a comment
2021-11-26 18:00 ` [PATCH v4 04/25] reboot: Correct typo in a comment Dmitry Osipenko
@ 2021-12-10 18:21 ` Rafael J. Wysocki
0 siblings, 0 replies; 52+ messages in thread
From: Rafael J. Wysocki @ 2021-12-10 18:21 UTC (permalink / raw)
To: Dmitry Osipenko
Cc: Thierry Reding, Jonathan Hunter, Russell King, Catalin Marinas,
Will Deacon, Guo Ren, Geert Uytterhoeven, Greg Ungerer,
Joshua Thompson, Thomas Bogendoerfer, Sebastian Reichel,
Linus Walleij, Philipp Zabel, Greentime Hu, Vincent Chen,
James E.J. Bottomley, Helge Deller, Michael Ellerman,
Benjamin Herrenschmidt, Paul Mackerras, Paul Walmsley,
Palmer Dabbelt, Albert Ou, Yoshinori Sato, Rich Felker,
Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen,
the arch/x86 maintainers, H. Peter Anvin, Boris Ostrovsky,
Juergen Gross, Stefano Stabellini, Rafael J. Wysocki, Len Brown,
Santosh Shilimkar, Krzysztof Kozlowski, Liam Girdwood, Mark Brown,
Pavel Machek, Lee Jones, Andrew Morton, Guenter Roeck,
Daniel Lezcano, Andy Shevchenko, Ulf Hansson, alankao,
K . C . Kuen-Chern Lin, Linux ARM, Linux Kernel Mailing List,
linux-csky, linux-ia64, linux-m68k, linux-mips, linux-parisc,
linuxppc-dev, linux-riscv, Linux-sh list, xen-devel,
ACPI Devel Maling List, Linux PM, linux-tegra
On Fri, Nov 26, 2021 at 7:02 PM Dmitry Osipenko <digetx@gmail.com> wrote:
>
> Correct s/implemenations/implementations/ in <reboot.h>.
>
> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
This patch clearly need not be part of this series.
> ---
> include/linux/reboot.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/linux/reboot.h b/include/linux/reboot.h
> index af907a3d68d1..7c288013a3ca 100644
> --- a/include/linux/reboot.h
> +++ b/include/linux/reboot.h
> @@ -63,7 +63,7 @@ struct pt_regs;
> extern void machine_crash_shutdown(struct pt_regs *);
>
> /*
> - * Architecture independent implemenations of sys_reboot commands.
> + * Architecture independent implementations of sys_reboot commands.
> */
>
> extern void kernel_restart_prepare(char *cmd);
> --
> 2.33.1
>
^ permalink raw reply [flat|nested] 52+ messages in thread
* [PATCH v4 05/25] reboot: Warn if restart handler has duplicated priority
2021-11-26 18:00 [PATCH v4 00/25] Introduce power-off+restart call chain API Dmitry Osipenko
` (3 preceding siblings ...)
2021-11-26 18:00 ` [PATCH v4 04/25] reboot: Correct typo in a comment Dmitry Osipenko
@ 2021-11-26 18:00 ` Dmitry Osipenko
[not found] ` <YaLNOJTM+lVq+YNS@qmqm.qmqm.pl>
2021-11-26 18:00 ` [PATCH v4 06/25] reboot: Warn if unregister_restart_handler() fails Dmitry Osipenko
` (19 subsequent siblings)
24 siblings, 1 reply; 52+ messages in thread
From: Dmitry Osipenko @ 2021-11-26 18:00 UTC (permalink / raw)
To: Thierry Reding, Jonathan Hunter, Russell King, Catalin Marinas,
Will Deacon, Guo Ren, Geert Uytterhoeven, Greg Ungerer,
Joshua Thompson, Thomas Bogendoerfer, Sebastian Reichel,
Linus Walleij, Philipp Zabel, Greentime Hu, Vincent Chen,
James E.J. Bottomley, Helge Deller, Michael Ellerman,
Benjamin Herrenschmidt, Paul Mackerras, Paul Walmsley,
Palmer Dabbelt, Albert Ou, Yoshinori Sato, Rich Felker,
Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
H. Peter Anvin, Boris Ostrovsky, Juergen Gross,
Stefano Stabellini, Rafael J. Wysocki, Len Brown,
Santosh Shilimkar, Krzysztof Kozlowski, Liam Girdwood, Mark Brown,
Pavel Machek, Lee Jones, Andrew Morton, Guenter Roeck,
Daniel Lezcano, Andy Shevchenko, Ulf Hansson, alankao,
K . C . Kuen-Chern Lin
Cc: linux-arm-kernel, linux-kernel, linux-csky, linux-ia64,
linux-m68k, linux-mips, linux-parisc, linuxppc-dev, linux-riscv,
linux-sh, xen-devel, linux-acpi, linux-pm, linux-tegra
Add sanity check which ensures that there are no two restart handlers
registered with the same priority. Normally it's a direct sign of a
problem if two handlers use the same priority.
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
kernel/reboot.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/kernel/reboot.c b/kernel/reboot.c
index 6bcc5d6a6572..e6659ae329f1 100644
--- a/kernel/reboot.c
+++ b/kernel/reboot.c
@@ -182,7 +182,20 @@ static ATOMIC_NOTIFIER_HEAD(restart_handler_list);
*/
int register_restart_handler(struct notifier_block *nb)
{
- return atomic_notifier_chain_register(&restart_handler_list, nb);
+ int ret;
+
+ ret = atomic_notifier_chain_register(&restart_handler_list, nb);
+ if (ret)
+ return ret;
+
+ /*
+ * Handler must have unique priority. Otherwise call order is
+ * determined by registration order, which is unreliable.
+ */
+ WARN(!atomic_notifier_has_unique_priority(&restart_handler_list, nb),
+ "restart handler must have unique priority\n");
+
+ return 0;
}
EXPORT_SYMBOL(register_restart_handler);
--
2.33.1
^ permalink raw reply related [flat|nested] 52+ messages in thread* [PATCH v4 06/25] reboot: Warn if unregister_restart_handler() fails
2021-11-26 18:00 [PATCH v4 00/25] Introduce power-off+restart call chain API Dmitry Osipenko
` (4 preceding siblings ...)
2021-11-26 18:00 ` [PATCH v4 05/25] reboot: Warn if restart handler has duplicated priority Dmitry Osipenko
@ 2021-11-26 18:00 ` Dmitry Osipenko
2021-12-10 18:32 ` Rafael J. Wysocki
2021-11-26 18:00 ` [PATCH v4 07/25] reboot: Remove extern annotation from function prototypes Dmitry Osipenko
` (18 subsequent siblings)
24 siblings, 1 reply; 52+ messages in thread
From: Dmitry Osipenko @ 2021-11-26 18:00 UTC (permalink / raw)
To: Thierry Reding, Jonathan Hunter, Russell King, Catalin Marinas,
Will Deacon, Guo Ren, Geert Uytterhoeven, Greg Ungerer,
Joshua Thompson, Thomas Bogendoerfer, Sebastian Reichel,
Linus Walleij, Philipp Zabel, Greentime Hu, Vincent Chen,
James E.J. Bottomley, Helge Deller, Michael Ellerman,
Benjamin Herrenschmidt, Paul Mackerras, Paul Walmsley,
Palmer Dabbelt, Albert Ou, Yoshinori Sato, Rich Felker,
Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
H. Peter Anvin, Boris Ostrovsky, Juergen Gross,
Stefano Stabellini, Rafael J. Wysocki, Len Brown,
Santosh Shilimkar, Krzysztof Kozlowski, Liam Girdwood, Mark Brown,
Pavel Machek, Lee Jones, Andrew Morton, Guenter Roeck,
Daniel Lezcano, Andy Shevchenko, Ulf Hansson, alankao,
K . C . Kuen-Chern Lin
Cc: linux-arm-kernel, linux-kernel, linux-csky, linux-ia64,
linux-m68k, linux-mips, linux-parisc, linuxppc-dev, linux-riscv,
linux-sh, xen-devel, linux-acpi, linux-pm, linux-tegra
Emit warning if unregister_restart_handler() fails since it never should
fail. This will ease further API development by catching mistakes early.
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
kernel/reboot.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/reboot.c b/kernel/reboot.c
index e6659ae329f1..f0e7b9c13f6b 100644
--- a/kernel/reboot.c
+++ b/kernel/reboot.c
@@ -210,7 +210,7 @@ EXPORT_SYMBOL(register_restart_handler);
*/
int unregister_restart_handler(struct notifier_block *nb)
{
- return atomic_notifier_chain_unregister(&restart_handler_list, nb);
+ return WARN_ON(atomic_notifier_chain_unregister(&restart_handler_list, nb));
}
EXPORT_SYMBOL(unregister_restart_handler);
--
2.33.1
^ permalink raw reply related [flat|nested] 52+ messages in thread* Re: [PATCH v4 06/25] reboot: Warn if unregister_restart_handler() fails
2021-11-26 18:00 ` [PATCH v4 06/25] reboot: Warn if unregister_restart_handler() fails Dmitry Osipenko
@ 2021-12-10 18:32 ` Rafael J. Wysocki
2021-12-10 18:54 ` Dmitry Osipenko
0 siblings, 1 reply; 52+ messages in thread
From: Rafael J. Wysocki @ 2021-12-10 18:32 UTC (permalink / raw)
To: Dmitry Osipenko
Cc: Thierry Reding, Jonathan Hunter, Russell King, Catalin Marinas,
Will Deacon, Guo Ren, Geert Uytterhoeven, Greg Ungerer,
Joshua Thompson, Thomas Bogendoerfer, Sebastian Reichel,
Linus Walleij, Philipp Zabel, Greentime Hu, Vincent Chen,
James E.J. Bottomley, Helge Deller, Michael Ellerman,
Benjamin Herrenschmidt, Paul Mackerras, Paul Walmsley,
Palmer Dabbelt, Albert Ou, Yoshinori Sato, Rich Felker,
Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen,
the arch/x86 maintainers, H. Peter Anvin, Boris Ostrovsky,
Juergen Gross, Stefano Stabellini, Rafael J. Wysocki, Len Brown,
Santosh Shilimkar, Krzysztof Kozlowski, Liam Girdwood, Mark Brown,
Pavel Machek, Lee Jones, Andrew Morton, Guenter Roeck,
Daniel Lezcano, Andy Shevchenko, Ulf Hansson, alankao,
K . C . Kuen-Chern Lin, Linux ARM, Linux Kernel Mailing List,
linux-csky, linux-ia64, linux-m68k, linux-mips, linux-parisc,
linuxppc-dev, linux-riscv, Linux-sh list, xen-devel,
ACPI Devel Maling List, Linux PM, linux-tegra
On Fri, Nov 26, 2021 at 7:02 PM Dmitry Osipenko <digetx@gmail.com> wrote:
>
> Emit warning if unregister_restart_handler() fails since it never should
> fail. This will ease further API development by catching mistakes early.
>
> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
> ---
> kernel/reboot.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/reboot.c b/kernel/reboot.c
> index e6659ae329f1..f0e7b9c13f6b 100644
> --- a/kernel/reboot.c
> +++ b/kernel/reboot.c
> @@ -210,7 +210,7 @@ EXPORT_SYMBOL(register_restart_handler);
> */
> int unregister_restart_handler(struct notifier_block *nb)
> {
> - return atomic_notifier_chain_unregister(&restart_handler_list, nb);
> + return WARN_ON(atomic_notifier_chain_unregister(&restart_handler_list, nb));
The only reason why it can fail is if the object pointed to by nb is
not in the chain. Why WARN() about this? And what about systems with
panic_on_warn set?
> }
> EXPORT_SYMBOL(unregister_restart_handler);
>
> --
> 2.33.1
>
^ permalink raw reply [flat|nested] 52+ messages in thread* Re: [PATCH v4 06/25] reboot: Warn if unregister_restart_handler() fails
2021-12-10 18:32 ` Rafael J. Wysocki
@ 2021-12-10 18:54 ` Dmitry Osipenko
2021-12-10 19:08 ` Rafael J. Wysocki
0 siblings, 1 reply; 52+ messages in thread
From: Dmitry Osipenko @ 2021-12-10 18:54 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: Thierry Reding, Jonathan Hunter, Russell King, Catalin Marinas,
Will Deacon, Guo Ren, Geert Uytterhoeven, Greg Ungerer,
Joshua Thompson, Thomas Bogendoerfer, Sebastian Reichel,
Linus Walleij, Philipp Zabel, Greentime Hu, Vincent Chen,
James E.J. Bottomley, Helge Deller, Michael Ellerman,
Benjamin Herrenschmidt, Paul Mackerras, Paul Walmsley,
Palmer Dabbelt, Albert Ou, Yoshinori Sato, Rich Felker,
Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen,
the arch/x86 maintainers, H. Peter Anvin, Boris Ostrovsky,
Juergen Gross, Stefano Stabellini, Len Brown, Santosh Shilimkar,
Krzysztof Kozlowski, Liam Girdwood, Mark Brown, Pavel Machek,
Lee Jones, Andrew Morton, Guenter Roeck, Daniel Lezcano,
Andy Shevchenko, Ulf Hansson, alankao, K . C . Kuen-Chern Lin,
Linux ARM, Linux Kernel Mailing List, linux-csky, linux-ia64,
linux-m68k, linux-mips, linux-parisc, linuxppc-dev, linux-riscv,
Linux-sh list, xen-devel, ACPI Devel Maling List, Linux PM,
linux-tegra
10.12.2021 21:32, Rafael J. Wysocki пишет:
> On Fri, Nov 26, 2021 at 7:02 PM Dmitry Osipenko <digetx@gmail.com> wrote:
>>
>> Emit warning if unregister_restart_handler() fails since it never should
>> fail. This will ease further API development by catching mistakes early.
>>
>> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
>> ---
>> kernel/reboot.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/kernel/reboot.c b/kernel/reboot.c
>> index e6659ae329f1..f0e7b9c13f6b 100644
>> --- a/kernel/reboot.c
>> +++ b/kernel/reboot.c
>> @@ -210,7 +210,7 @@ EXPORT_SYMBOL(register_restart_handler);
>> */
>> int unregister_restart_handler(struct notifier_block *nb)
>> {
>> - return atomic_notifier_chain_unregister(&restart_handler_list, nb);
>> + return WARN_ON(atomic_notifier_chain_unregister(&restart_handler_list, nb));
>
> The only reason why it can fail is if the object pointed to by nb is
> not in the chain.
I had exactly this case where object wasn't in the chain due to a bug
and this warning was very helpful.
> Why WARN() about this? And what about systems with
> panic_on_warn set?
That warning condition will never happen normally, only when something
is seriously wrong.
Those systems with panic_on_warn will get what was they asked for.
^ permalink raw reply [flat|nested] 52+ messages in thread* Re: [PATCH v4 06/25] reboot: Warn if unregister_restart_handler() fails
2021-12-10 18:54 ` Dmitry Osipenko
@ 2021-12-10 19:08 ` Rafael J. Wysocki
2021-12-10 19:38 ` Dmitry Osipenko
0 siblings, 1 reply; 52+ messages in thread
From: Rafael J. Wysocki @ 2021-12-10 19:08 UTC (permalink / raw)
To: Dmitry Osipenko
Cc: Rafael J. Wysocki, Thierry Reding, Jonathan Hunter, Russell King,
Catalin Marinas, Will Deacon, Guo Ren, Geert Uytterhoeven,
Greg Ungerer, Joshua Thompson, Thomas Bogendoerfer,
Sebastian Reichel, Linus Walleij, Philipp Zabel, Greentime Hu,
Vincent Chen, James E.J. Bottomley, Helge Deller,
Michael Ellerman, Benjamin Herrenschmidt, Paul Mackerras,
Paul Walmsley, Palmer Dabbelt, Albert Ou, Yoshinori Sato,
Rich Felker, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
Dave Hansen, the arch/x86 maintainers, H. Peter Anvin,
Boris Ostrovsky, Juergen Gross, Stefano Stabellini, Len Brown,
Santosh Shilimkar, Krzysztof Kozlowski, Liam Girdwood, Mark Brown,
Pavel Machek, Lee Jones, Andrew Morton, Guenter Roeck,
Daniel Lezcano, Andy Shevchenko, Ulf Hansson, alankao,
K . C . Kuen-Chern Lin, Linux ARM, Linux Kernel Mailing List,
linux-csky, linux-ia64, linux-m68k, linux-mips, linux-parisc,
linuxppc-dev, linux-riscv, Linux-sh list, xen-devel,
ACPI Devel Maling List, Linux PM, linux-tegra
On Fri, Dec 10, 2021 at 7:54 PM Dmitry Osipenko <digetx@gmail.com> wrote:
>
> 10.12.2021 21:32, Rafael J. Wysocki пишет:
> > On Fri, Nov 26, 2021 at 7:02 PM Dmitry Osipenko <digetx@gmail.com> wrote:
> >>
> >> Emit warning if unregister_restart_handler() fails since it never should
> >> fail. This will ease further API development by catching mistakes early.
> >>
> >> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
> >> ---
> >> kernel/reboot.c | 2 +-
> >> 1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >> diff --git a/kernel/reboot.c b/kernel/reboot.c
> >> index e6659ae329f1..f0e7b9c13f6b 100644
> >> --- a/kernel/reboot.c
> >> +++ b/kernel/reboot.c
> >> @@ -210,7 +210,7 @@ EXPORT_SYMBOL(register_restart_handler);
> >> */
> >> int unregister_restart_handler(struct notifier_block *nb)
> >> {
> >> - return atomic_notifier_chain_unregister(&restart_handler_list, nb);
> >> + return WARN_ON(atomic_notifier_chain_unregister(&restart_handler_list, nb));
> >
> > The only reason why it can fail is if the object pointed to by nb is
> > not in the chain.
>
> I had exactly this case where object wasn't in the chain due to a bug
> and this warning was very helpful.
During the development. In production it would be rather annoying.
> > Why WARN() about this? And what about systems with
> > panic_on_warn set?
>
> That warning condition will never happen normally, only when something
> is seriously wrong.
>
> Those systems with panic_on_warn will get what was they asked for.
They may not be asking for panicking on bugs in the reboot notifier
code, though. That's what your change is making them panic on.
^ permalink raw reply [flat|nested] 52+ messages in thread* Re: [PATCH v4 06/25] reboot: Warn if unregister_restart_handler() fails
2021-12-10 19:08 ` Rafael J. Wysocki
@ 2021-12-10 19:38 ` Dmitry Osipenko
0 siblings, 0 replies; 52+ messages in thread
From: Dmitry Osipenko @ 2021-12-10 19:38 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: Thierry Reding, Jonathan Hunter, Russell King, Catalin Marinas,
Will Deacon, Guo Ren, Geert Uytterhoeven, Greg Ungerer,
Joshua Thompson, Thomas Bogendoerfer, Sebastian Reichel,
Linus Walleij, Philipp Zabel, Greentime Hu, Vincent Chen,
James E.J. Bottomley, Helge Deller, Michael Ellerman,
Benjamin Herrenschmidt, Paul Mackerras, Paul Walmsley,
Palmer Dabbelt, Albert Ou, Yoshinori Sato, Rich Felker,
Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen,
the arch/x86 maintainers, H. Peter Anvin, Boris Ostrovsky,
Juergen Gross, Stefano Stabellini, Len Brown, Santosh Shilimkar,
Krzysztof Kozlowski, Liam Girdwood, Mark Brown, Pavel Machek,
Lee Jones, Andrew Morton, Guenter Roeck, Daniel Lezcano,
Andy Shevchenko, Ulf Hansson, alankao, K . C . Kuen-Chern Lin,
Linux ARM, Linux Kernel Mailing List, linux-csky, linux-ia64,
linux-m68k, linux-mips, linux-parisc, linuxppc-dev, linux-riscv,
Linux-sh list, xen-devel, ACPI Devel Maling List, Linux PM,
linux-tegra
10.12.2021 22:08, Rafael J. Wysocki пишет:
> On Fri, Dec 10, 2021 at 7:54 PM Dmitry Osipenko <digetx@gmail.com> wrote:
>>
>> 10.12.2021 21:32, Rafael J. Wysocki пишет:
>>> On Fri, Nov 26, 2021 at 7:02 PM Dmitry Osipenko <digetx@gmail.com> wrote:
>>>>
>>>> Emit warning if unregister_restart_handler() fails since it never should
>>>> fail. This will ease further API development by catching mistakes early.
>>>>
>>>> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
>>>> ---
>>>> kernel/reboot.c | 2 +-
>>>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>>>
>>>> diff --git a/kernel/reboot.c b/kernel/reboot.c
>>>> index e6659ae329f1..f0e7b9c13f6b 100644
>>>> --- a/kernel/reboot.c
>>>> +++ b/kernel/reboot.c
>>>> @@ -210,7 +210,7 @@ EXPORT_SYMBOL(register_restart_handler);
>>>> */
>>>> int unregister_restart_handler(struct notifier_block *nb)
>>>> {
>>>> - return atomic_notifier_chain_unregister(&restart_handler_list, nb);
>>>> + return WARN_ON(atomic_notifier_chain_unregister(&restart_handler_list, nb));
>>>
>>> The only reason why it can fail is if the object pointed to by nb is
>>> not in the chain.
>>
>> I had exactly this case where object wasn't in the chain due to a bug
>> and this warning was very helpful.
>
> During the development. In production it would be rather annoying.
>
>>> Why WARN() about this? And what about systems with
>>> panic_on_warn set?
>>
>> That warning condition will never happen normally, only when something
>> is seriously wrong.
>>
>> Those systems with panic_on_warn will get what was they asked for.
>
> They may not be asking for panicking on bugs in the reboot notifier
> code, though. That's what your change is making them panic on.
>
Alright, I'll drop the warnings and turn the warning about uniqueness
into error or warning message.
^ permalink raw reply [flat|nested] 52+ messages in thread
* [PATCH v4 07/25] reboot: Remove extern annotation from function prototypes
2021-11-26 18:00 [PATCH v4 00/25] Introduce power-off+restart call chain API Dmitry Osipenko
` (5 preceding siblings ...)
2021-11-26 18:00 ` [PATCH v4 06/25] reboot: Warn if unregister_restart_handler() fails Dmitry Osipenko
@ 2021-11-26 18:00 ` Dmitry Osipenko
2021-12-10 18:09 ` Rafael J. Wysocki
2021-11-26 18:00 ` [PATCH v4 09/25] ARM: Use do_kernel_power_off() Dmitry Osipenko
` (17 subsequent siblings)
24 siblings, 1 reply; 52+ messages in thread
From: Dmitry Osipenko @ 2021-11-26 18:00 UTC (permalink / raw)
To: Thierry Reding, Jonathan Hunter, Russell King, Catalin Marinas,
Will Deacon, Guo Ren, Geert Uytterhoeven, Greg Ungerer,
Joshua Thompson, Thomas Bogendoerfer, Sebastian Reichel,
Linus Walleij, Philipp Zabel, Greentime Hu, Vincent Chen,
James E.J. Bottomley, Helge Deller, Michael Ellerman,
Benjamin Herrenschmidt, Paul Mackerras, Paul Walmsley,
Palmer Dabbelt, Albert Ou, Yoshinori Sato, Rich Felker,
Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
H. Peter Anvin, Boris Ostrovsky, Juergen Gross,
Stefano Stabellini, Rafael J. Wysocki, Len Brown,
Santosh Shilimkar, Krzysztof Kozlowski, Liam Girdwood, Mark Brown,
Pavel Machek, Lee Jones, Andrew Morton, Guenter Roeck,
Daniel Lezcano, Andy Shevchenko, Ulf Hansson, alankao,
K . C . Kuen-Chern Lin
Cc: linux-arm-kernel, linux-kernel, linux-csky, linux-ia64,
linux-m68k, linux-mips, linux-parisc, linuxppc-dev, linux-riscv,
linux-sh, xen-devel, linux-acpi, linux-pm, linux-tegra
There is no need to annotate function prototypes with 'extern', it makes
code less readable. Remove unnecessary annotations from <reboot.h>.
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
include/linux/reboot.h | 38 +++++++++++++++++++-------------------
1 file changed, 19 insertions(+), 19 deletions(-)
diff --git a/include/linux/reboot.h b/include/linux/reboot.h
index 7c288013a3ca..b7fa25726323 100644
--- a/include/linux/reboot.h
+++ b/include/linux/reboot.h
@@ -40,36 +40,36 @@ extern int reboot_cpu;
extern int reboot_force;
-extern int register_reboot_notifier(struct notifier_block *);
-extern int unregister_reboot_notifier(struct notifier_block *);
+int register_reboot_notifier(struct notifier_block *);
+int unregister_reboot_notifier(struct notifier_block *);
-extern int devm_register_reboot_notifier(struct device *, struct notifier_block *);
+int devm_register_reboot_notifier(struct device *, struct notifier_block *);
-extern int register_restart_handler(struct notifier_block *);
-extern int unregister_restart_handler(struct notifier_block *);
-extern void do_kernel_restart(char *cmd);
+int register_restart_handler(struct notifier_block *);
+int unregister_restart_handler(struct notifier_block *);
+void do_kernel_restart(char *cmd);
/*
* Architecture-specific implementations of sys_reboot commands.
*/
-extern void migrate_to_reboot_cpu(void);
-extern void machine_restart(char *cmd);
-extern void machine_halt(void);
-extern void machine_power_off(void);
+void migrate_to_reboot_cpu(void);
+void machine_restart(char *cmd);
+void machine_halt(void);
+void machine_power_off(void);
-extern void machine_shutdown(void);
+void machine_shutdown(void);
struct pt_regs;
-extern void machine_crash_shutdown(struct pt_regs *);
+void machine_crash_shutdown(struct pt_regs *);
/*
* Architecture independent implementations of sys_reboot commands.
*/
-extern void kernel_restart_prepare(char *cmd);
-extern void kernel_restart(char *cmd);
-extern void kernel_halt(void);
-extern void kernel_power_off(void);
+void kernel_restart_prepare(char *cmd);
+void kernel_restart(char *cmd);
+void kernel_halt(void);
+void kernel_power_off(void);
extern int C_A_D; /* for sysctl */
void ctrl_alt_del(void);
@@ -77,15 +77,15 @@ void ctrl_alt_del(void);
#define POWEROFF_CMD_PATH_LEN 256
extern char poweroff_cmd[POWEROFF_CMD_PATH_LEN];
-extern void orderly_poweroff(bool force);
-extern void orderly_reboot(void);
+void orderly_poweroff(bool force);
+void orderly_reboot(void);
void hw_protection_shutdown(const char *reason, int ms_until_forced);
/*
* Emergency restart, callable from an interrupt handler.
*/
-extern void emergency_restart(void);
+void emergency_restart(void);
#include <asm/emergency-restart.h>
#endif /* _LINUX_REBOOT_H */
--
2.33.1
^ permalink raw reply related [flat|nested] 52+ messages in thread* Re: [PATCH v4 07/25] reboot: Remove extern annotation from function prototypes
2021-11-26 18:00 ` [PATCH v4 07/25] reboot: Remove extern annotation from function prototypes Dmitry Osipenko
@ 2021-12-10 18:09 ` Rafael J. Wysocki
2021-12-10 18:15 ` Dmitry Osipenko
0 siblings, 1 reply; 52+ messages in thread
From: Rafael J. Wysocki @ 2021-12-10 18:09 UTC (permalink / raw)
To: Dmitry Osipenko
Cc: Thierry Reding, Jonathan Hunter, Russell King, Catalin Marinas,
Will Deacon, Guo Ren, Geert Uytterhoeven, Greg Ungerer,
Joshua Thompson, Thomas Bogendoerfer, Sebastian Reichel,
Linus Walleij, Philipp Zabel, Greentime Hu, Vincent Chen,
James E.J. Bottomley, Helge Deller, Michael Ellerman,
Benjamin Herrenschmidt, Paul Mackerras, Paul Walmsley,
Palmer Dabbelt, Albert Ou, Yoshinori Sato, Rich Felker,
Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen,
the arch/x86 maintainers, H. Peter Anvin, Boris Ostrovsky,
Juergen Gross, Stefano Stabellini, Rafael J. Wysocki, Len Brown,
Santosh Shilimkar, Krzysztof Kozlowski, Liam Girdwood, Mark Brown,
Pavel Machek, Lee Jones, Andrew Morton, Guenter Roeck,
Daniel Lezcano, Andy Shevchenko, Ulf Hansson, alankao,
K . C . Kuen-Chern Lin, Linux ARM, Linux Kernel Mailing List,
linux-csky, linux-ia64, linux-m68k, linux-mips, linux-parisc,
linuxppc-dev, linux-riscv, Linux-sh list, xen-devel,
ACPI Devel Maling List, Linux PM, linux-tegra
On Fri, Nov 26, 2021 at 7:02 PM Dmitry Osipenko <digetx@gmail.com> wrote:
>
> There is no need to annotate function prototypes with 'extern', it makes
> code less readable. Remove unnecessary annotations from <reboot.h>.
>
> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
I'm not sure that this is really useful.
Personally, I tend to respect the existing conventions like this.
Surely, this change is not required for the rest of the series to work.
> ---
> include/linux/reboot.h | 38 +++++++++++++++++++-------------------
> 1 file changed, 19 insertions(+), 19 deletions(-)
>
> diff --git a/include/linux/reboot.h b/include/linux/reboot.h
> index 7c288013a3ca..b7fa25726323 100644
> --- a/include/linux/reboot.h
> +++ b/include/linux/reboot.h
> @@ -40,36 +40,36 @@ extern int reboot_cpu;
> extern int reboot_force;
>
>
> -extern int register_reboot_notifier(struct notifier_block *);
> -extern int unregister_reboot_notifier(struct notifier_block *);
> +int register_reboot_notifier(struct notifier_block *);
> +int unregister_reboot_notifier(struct notifier_block *);
>
> -extern int devm_register_reboot_notifier(struct device *, struct notifier_block *);
> +int devm_register_reboot_notifier(struct device *, struct notifier_block *);
>
> -extern int register_restart_handler(struct notifier_block *);
> -extern int unregister_restart_handler(struct notifier_block *);
> -extern void do_kernel_restart(char *cmd);
> +int register_restart_handler(struct notifier_block *);
> +int unregister_restart_handler(struct notifier_block *);
> +void do_kernel_restart(char *cmd);
>
> /*
> * Architecture-specific implementations of sys_reboot commands.
> */
>
> -extern void migrate_to_reboot_cpu(void);
> -extern void machine_restart(char *cmd);
> -extern void machine_halt(void);
> -extern void machine_power_off(void);
> +void migrate_to_reboot_cpu(void);
> +void machine_restart(char *cmd);
> +void machine_halt(void);
> +void machine_power_off(void);
>
> -extern void machine_shutdown(void);
> +void machine_shutdown(void);
> struct pt_regs;
> -extern void machine_crash_shutdown(struct pt_regs *);
> +void machine_crash_shutdown(struct pt_regs *);
>
> /*
> * Architecture independent implementations of sys_reboot commands.
> */
>
> -extern void kernel_restart_prepare(char *cmd);
> -extern void kernel_restart(char *cmd);
> -extern void kernel_halt(void);
> -extern void kernel_power_off(void);
> +void kernel_restart_prepare(char *cmd);
> +void kernel_restart(char *cmd);
> +void kernel_halt(void);
> +void kernel_power_off(void);
>
> extern int C_A_D; /* for sysctl */
> void ctrl_alt_del(void);
> @@ -77,15 +77,15 @@ void ctrl_alt_del(void);
> #define POWEROFF_CMD_PATH_LEN 256
> extern char poweroff_cmd[POWEROFF_CMD_PATH_LEN];
>
> -extern void orderly_poweroff(bool force);
> -extern void orderly_reboot(void);
> +void orderly_poweroff(bool force);
> +void orderly_reboot(void);
> void hw_protection_shutdown(const char *reason, int ms_until_forced);
>
> /*
> * Emergency restart, callable from an interrupt handler.
> */
>
> -extern void emergency_restart(void);
> +void emergency_restart(void);
> #include <asm/emergency-restart.h>
>
> #endif /* _LINUX_REBOOT_H */
> --
> 2.33.1
>
^ permalink raw reply [flat|nested] 52+ messages in thread
* Re: [PATCH v4 07/25] reboot: Remove extern annotation from function prototypes
2021-12-10 18:09 ` Rafael J. Wysocki
@ 2021-12-10 18:15 ` Dmitry Osipenko
2021-12-10 18:35 ` Rafael J. Wysocki
0 siblings, 1 reply; 52+ messages in thread
From: Dmitry Osipenko @ 2021-12-10 18:15 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: Thierry Reding, Jonathan Hunter, Russell King, Catalin Marinas,
Will Deacon, Guo Ren, Geert Uytterhoeven, Greg Ungerer,
Joshua Thompson, Thomas Bogendoerfer, Sebastian Reichel,
Linus Walleij, Philipp Zabel, Greentime Hu, Vincent Chen,
James E.J. Bottomley, Helge Deller, Michael Ellerman,
Benjamin Herrenschmidt, Paul Mackerras, Paul Walmsley,
Palmer Dabbelt, Albert Ou, Yoshinori Sato, Rich Felker,
Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen,
the arch/x86 maintainers, H. Peter Anvin, Boris Ostrovsky,
Juergen Gross, Stefano Stabellini, Len Brown, Santosh Shilimkar,
Krzysztof Kozlowski, Liam Girdwood, Mark Brown, Pavel Machek,
Lee Jones, Andrew Morton, Guenter Roeck, Daniel Lezcano,
Andy Shevchenko, Ulf Hansson, alankao, K . C . Kuen-Chern Lin,
Linux ARM, Linux Kernel Mailing List, linux-csky, linux-ia64,
linux-m68k, linux-mips, linux-parisc, linuxppc-dev, linux-riscv,
Linux-sh list, xen-devel, ACPI Devel Maling List, Linux PM,
linux-tegra
10.12.2021 21:09, Rafael J. Wysocki пишет:
> On Fri, Nov 26, 2021 at 7:02 PM Dmitry Osipenko <digetx@gmail.com> wrote:
>>
>> There is no need to annotate function prototypes with 'extern', it makes
>> code less readable. Remove unnecessary annotations from <reboot.h>.
>>
>> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
>
> I'm not sure that this is really useful.
>
> Personally, I tend to respect the existing conventions like this.
>
> Surely, this change is not required for the rest of the series to work.
Problem that such things start to spread all over the kernel with a
copy-paste approach if there is nobody to clean up the code.
This is not a common convention and sometimes it's getting corrected [1].
[1] https://git.kernel.org/linus/6d7434931
^ permalink raw reply [flat|nested] 52+ messages in thread
* Re: [PATCH v4 07/25] reboot: Remove extern annotation from function prototypes
2021-12-10 18:15 ` Dmitry Osipenko
@ 2021-12-10 18:35 ` Rafael J. Wysocki
2021-12-10 18:56 ` Dmitry Osipenko
0 siblings, 1 reply; 52+ messages in thread
From: Rafael J. Wysocki @ 2021-12-10 18:35 UTC (permalink / raw)
To: Dmitry Osipenko
Cc: Rafael J. Wysocki, Thierry Reding, Jonathan Hunter, Russell King,
Catalin Marinas, Will Deacon, Guo Ren, Geert Uytterhoeven,
Greg Ungerer, Joshua Thompson, Thomas Bogendoerfer,
Sebastian Reichel, Linus Walleij, Philipp Zabel, Greentime Hu,
Vincent Chen, James E.J. Bottomley, Helge Deller,
Michael Ellerman, Benjamin Herrenschmidt, Paul Mackerras,
Paul Walmsley, Palmer Dabbelt, Albert Ou, Yoshinori Sato,
Rich Felker, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
Dave Hansen, the arch/x86 maintainers, H. Peter Anvin,
Boris Ostrovsky, Juergen Gross, Stefano Stabellini, Len Brown,
Santosh Shilimkar, Krzysztof Kozlowski, Liam Girdwood, Mark Brown,
Pavel Machek, Lee Jones, Andrew Morton, Guenter Roeck,
Daniel Lezcano, Andy Shevchenko, Ulf Hansson, alankao,
K . C . Kuen-Chern Lin, Linux ARM, Linux Kernel Mailing List,
linux-csky, linux-ia64, linux-m68k, linux-mips, linux-parisc,
linuxppc-dev, linux-riscv, Linux-sh list, xen-devel,
ACPI Devel Maling List, Linux PM, linux-tegra
On Fri, Dec 10, 2021 at 7:16 PM Dmitry Osipenko <digetx@gmail.com> wrote:
>
> 10.12.2021 21:09, Rafael J. Wysocki пишет:
> > On Fri, Nov 26, 2021 at 7:02 PM Dmitry Osipenko <digetx@gmail.com> wrote:
> >>
> >> There is no need to annotate function prototypes with 'extern', it makes
> >> code less readable. Remove unnecessary annotations from <reboot.h>.
> >>
> >> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
> >
> > I'm not sure that this is really useful.
> >
> > Personally, I tend to respect the existing conventions like this.
> >
> > Surely, this change is not required for the rest of the series to work.
>
> Problem that such things start to spread all over the kernel with a
> copy-paste approach if there is nobody to clean up the code.
>
> This is not a common convention and sometimes it's getting corrected [1].
>
> [1] https://git.kernel.org/linus/6d7434931
In separate patches outside of series adding new features, if one is
so inclined.
^ permalink raw reply [flat|nested] 52+ messages in thread
* Re: [PATCH v4 07/25] reboot: Remove extern annotation from function prototypes
2021-12-10 18:35 ` Rafael J. Wysocki
@ 2021-12-10 18:56 ` Dmitry Osipenko
0 siblings, 0 replies; 52+ messages in thread
From: Dmitry Osipenko @ 2021-12-10 18:56 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: Thierry Reding, Jonathan Hunter, Russell King, Catalin Marinas,
Will Deacon, Guo Ren, Geert Uytterhoeven, Greg Ungerer,
Joshua Thompson, Thomas Bogendoerfer, Sebastian Reichel,
Linus Walleij, Philipp Zabel, Greentime Hu, Vincent Chen,
James E.J. Bottomley, Helge Deller, Michael Ellerman,
Benjamin Herrenschmidt, Paul Mackerras, Paul Walmsley,
Palmer Dabbelt, Albert Ou, Yoshinori Sato, Rich Felker,
Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen,
the arch/x86 maintainers, H. Peter Anvin, Boris Ostrovsky,
Juergen Gross, Stefano Stabellini, Len Brown, Santosh Shilimkar,
Krzysztof Kozlowski, Liam Girdwood, Mark Brown, Pavel Machek,
Lee Jones, Andrew Morton, Guenter Roeck, Daniel Lezcano,
Andy Shevchenko, Ulf Hansson, alankao, K . C . Kuen-Chern Lin,
Linux ARM, Linux Kernel Mailing List, linux-csky, linux-ia64,
linux-m68k, linux-mips, linux-parisc, linuxppc-dev, linux-riscv,
Linux-sh list, xen-devel, ACPI Devel Maling List, Linux PM,
linux-tegra
10.12.2021 21:35, Rafael J. Wysocki пишет:
> On Fri, Dec 10, 2021 at 7:16 PM Dmitry Osipenko <digetx@gmail.com> wrote:
>>
>> 10.12.2021 21:09, Rafael J. Wysocki пишет:
>>> On Fri, Nov 26, 2021 at 7:02 PM Dmitry Osipenko <digetx@gmail.com> wrote:
>>>>
>>>> There is no need to annotate function prototypes with 'extern', it makes
>>>> code less readable. Remove unnecessary annotations from <reboot.h>.
>>>>
>>>> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
>>>
>>> I'm not sure that this is really useful.
>>>
>>> Personally, I tend to respect the existing conventions like this.
>>>
>>> Surely, this change is not required for the rest of the series to work.
>>
>> Problem that such things start to spread all over the kernel with a
>> copy-paste approach if there is nobody to clean up the code.
>>
>> This is not a common convention and sometimes it's getting corrected [1].
>>
>> [1] https://git.kernel.org/linus/6d7434931
>
> In separate patches outside of series adding new features, if one is
> so inclined.
>
Alright, I'll drop this patch then because it can't be done in parallel
without creating the merge conflict. I'll try not to forget to come back
to this later on.
^ permalink raw reply [flat|nested] 52+ messages in thread
* [PATCH v4 09/25] ARM: Use do_kernel_power_off()
2021-11-26 18:00 [PATCH v4 00/25] Introduce power-off+restart call chain API Dmitry Osipenko
` (6 preceding siblings ...)
2021-11-26 18:00 ` [PATCH v4 07/25] reboot: Remove extern annotation from function prototypes Dmitry Osipenko
@ 2021-11-26 18:00 ` Dmitry Osipenko
2021-11-26 18:00 ` [PATCH v4 10/25] csky: " Dmitry Osipenko
` (16 subsequent siblings)
24 siblings, 0 replies; 52+ messages in thread
From: Dmitry Osipenko @ 2021-11-26 18:00 UTC (permalink / raw)
To: Thierry Reding, Jonathan Hunter, Russell King, Catalin Marinas,
Will Deacon, Guo Ren, Geert Uytterhoeven, Greg Ungerer,
Joshua Thompson, Thomas Bogendoerfer, Sebastian Reichel,
Linus Walleij, Philipp Zabel, Greentime Hu, Vincent Chen,
James E.J. Bottomley, Helge Deller, Michael Ellerman,
Benjamin Herrenschmidt, Paul Mackerras, Paul Walmsley,
Palmer Dabbelt, Albert Ou, Yoshinori Sato, Rich Felker,
Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
H. Peter Anvin, Boris Ostrovsky, Juergen Gross,
Stefano Stabellini, Rafael J. Wysocki, Len Brown,
Santosh Shilimkar, Krzysztof Kozlowski, Liam Girdwood, Mark Brown,
Pavel Machek, Lee Jones, Andrew Morton, Guenter Roeck,
Daniel Lezcano, Andy Shevchenko, Ulf Hansson, alankao,
K . C . Kuen-Chern Lin
Cc: linux-arm-kernel, linux-kernel, linux-csky, linux-ia64,
linux-m68k, linux-mips, linux-parisc, linuxppc-dev, linux-riscv,
linux-sh, xen-devel, linux-acpi, linux-pm, linux-tegra
Kernel now supports chained power-off handlers. Use do_kernel_power_off()
that invokes chained power-off handlers. It also invokes legacy
pm_power_off() for now, which will be removed once all drivers will
be converted to the new power-off API.
Reviewed-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
arch/arm/kernel/reboot.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/arch/arm/kernel/reboot.c b/arch/arm/kernel/reboot.c
index 3044fcb8d073..2cb943422554 100644
--- a/arch/arm/kernel/reboot.c
+++ b/arch/arm/kernel/reboot.c
@@ -116,9 +116,7 @@ void machine_power_off(void)
{
local_irq_disable();
smp_send_stop();
-
- if (pm_power_off)
- pm_power_off();
+ do_kernel_power_off();
}
/*
--
2.33.1
^ permalink raw reply related [flat|nested] 52+ messages in thread* [PATCH v4 10/25] csky: Use do_kernel_power_off()
2021-11-26 18:00 [PATCH v4 00/25] Introduce power-off+restart call chain API Dmitry Osipenko
` (7 preceding siblings ...)
2021-11-26 18:00 ` [PATCH v4 09/25] ARM: Use do_kernel_power_off() Dmitry Osipenko
@ 2021-11-26 18:00 ` Dmitry Osipenko
2021-11-26 18:00 ` [PATCH v4 11/25] riscv: " Dmitry Osipenko
` (15 subsequent siblings)
24 siblings, 0 replies; 52+ messages in thread
From: Dmitry Osipenko @ 2021-11-26 18:00 UTC (permalink / raw)
To: Thierry Reding, Jonathan Hunter, Russell King, Catalin Marinas,
Will Deacon, Guo Ren, Geert Uytterhoeven, Greg Ungerer,
Joshua Thompson, Thomas Bogendoerfer, Sebastian Reichel,
Linus Walleij, Philipp Zabel, Greentime Hu, Vincent Chen,
James E.J. Bottomley, Helge Deller, Michael Ellerman,
Benjamin Herrenschmidt, Paul Mackerras, Paul Walmsley,
Palmer Dabbelt, Albert Ou, Yoshinori Sato, Rich Felker,
Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
H. Peter Anvin, Boris Ostrovsky, Juergen Gross,
Stefano Stabellini, Rafael J. Wysocki, Len Brown,
Santosh Shilimkar, Krzysztof Kozlowski, Liam Girdwood, Mark Brown,
Pavel Machek, Lee Jones, Andrew Morton, Guenter Roeck,
Daniel Lezcano, Andy Shevchenko, Ulf Hansson, alankao,
K . C . Kuen-Chern Lin
Cc: linux-arm-kernel, linux-kernel, linux-csky, linux-ia64,
linux-m68k, linux-mips, linux-parisc, linuxppc-dev, linux-riscv,
linux-sh, xen-devel, linux-acpi, linux-pm, linux-tegra
Kernel now supports chained power-off handlers. Use do_kernel_power_off()
that invokes chained power-off handlers. It also invokes legacy
pm_power_off() for now, which will be removed once all drivers will
be converted to the new power-off API.
Acked-by: Guo Ren <guoren@kernel.org>
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
arch/csky/kernel/power.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/arch/csky/kernel/power.c b/arch/csky/kernel/power.c
index 923ee4e381b8..86ee202906f8 100644
--- a/arch/csky/kernel/power.c
+++ b/arch/csky/kernel/power.c
@@ -9,16 +9,14 @@ EXPORT_SYMBOL(pm_power_off);
void machine_power_off(void)
{
local_irq_disable();
- if (pm_power_off)
- pm_power_off();
+ do_kernel_power_off();
asm volatile ("bkpt");
}
void machine_halt(void)
{
local_irq_disable();
- if (pm_power_off)
- pm_power_off();
+ do_kernel_power_off();
asm volatile ("bkpt");
}
--
2.33.1
^ permalink raw reply related [flat|nested] 52+ messages in thread* [PATCH v4 11/25] riscv: Use do_kernel_power_off()
2021-11-26 18:00 [PATCH v4 00/25] Introduce power-off+restart call chain API Dmitry Osipenko
` (8 preceding siblings ...)
2021-11-26 18:00 ` [PATCH v4 10/25] csky: " Dmitry Osipenko
@ 2021-11-26 18:00 ` Dmitry Osipenko
2021-11-26 18:00 ` [PATCH v4 12/25] arm64: " Dmitry Osipenko
` (14 subsequent siblings)
24 siblings, 0 replies; 52+ messages in thread
From: Dmitry Osipenko @ 2021-11-26 18:00 UTC (permalink / raw)
To: Thierry Reding, Jonathan Hunter, Russell King, Catalin Marinas,
Will Deacon, Guo Ren, Geert Uytterhoeven, Greg Ungerer,
Joshua Thompson, Thomas Bogendoerfer, Sebastian Reichel,
Linus Walleij, Philipp Zabel, Greentime Hu, Vincent Chen,
James E.J. Bottomley, Helge Deller, Michael Ellerman,
Benjamin Herrenschmidt, Paul Mackerras, Paul Walmsley,
Palmer Dabbelt, Albert Ou, Yoshinori Sato, Rich Felker,
Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
H. Peter Anvin, Boris Ostrovsky, Juergen Gross,
Stefano Stabellini, Rafael J. Wysocki, Len Brown,
Santosh Shilimkar, Krzysztof Kozlowski, Liam Girdwood, Mark Brown,
Pavel Machek, Lee Jones, Andrew Morton, Guenter Roeck,
Daniel Lezcano, Andy Shevchenko, Ulf Hansson, alankao,
K . C . Kuen-Chern Lin
Cc: linux-arm-kernel, linux-kernel, linux-csky, linux-ia64,
linux-m68k, linux-mips, linux-parisc, linuxppc-dev, linux-riscv,
linux-sh, xen-devel, linux-acpi, linux-pm, linux-tegra
Kernel now supports chained power-off handlers. Use do_kernel_power_off()
that invokes chained power-off handlers. It also invokes legacy
pm_power_off() for now, which will be removed once all drivers will
be converted to the new power-off API.
Acked-by: Palmer Dabbelt <palmer@dabbelt.com>
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
arch/riscv/kernel/reset.c | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/arch/riscv/kernel/reset.c b/arch/riscv/kernel/reset.c
index 9c842c41684a..912288572226 100644
--- a/arch/riscv/kernel/reset.c
+++ b/arch/riscv/kernel/reset.c
@@ -23,16 +23,12 @@ void machine_restart(char *cmd)
void machine_halt(void)
{
- if (pm_power_off != NULL)
- pm_power_off();
- else
- default_power_off();
+ do_kernel_power_off();
+ default_power_off();
}
void machine_power_off(void)
{
- if (pm_power_off != NULL)
- pm_power_off();
- else
- default_power_off();
+ do_kernel_power_off();
+ default_power_off();
}
--
2.33.1
^ permalink raw reply related [flat|nested] 52+ messages in thread* [PATCH v4 12/25] arm64: Use do_kernel_power_off()
2021-11-26 18:00 [PATCH v4 00/25] Introduce power-off+restart call chain API Dmitry Osipenko
` (9 preceding siblings ...)
2021-11-26 18:00 ` [PATCH v4 11/25] riscv: " Dmitry Osipenko
@ 2021-11-26 18:00 ` Dmitry Osipenko
2021-11-26 18:00 ` [PATCH v4 13/25] parisc: " Dmitry Osipenko
` (13 subsequent siblings)
24 siblings, 0 replies; 52+ messages in thread
From: Dmitry Osipenko @ 2021-11-26 18:00 UTC (permalink / raw)
To: Thierry Reding, Jonathan Hunter, Russell King, Catalin Marinas,
Will Deacon, Guo Ren, Geert Uytterhoeven, Greg Ungerer,
Joshua Thompson, Thomas Bogendoerfer, Sebastian Reichel,
Linus Walleij, Philipp Zabel, Greentime Hu, Vincent Chen,
James E.J. Bottomley, Helge Deller, Michael Ellerman,
Benjamin Herrenschmidt, Paul Mackerras, Paul Walmsley,
Palmer Dabbelt, Albert Ou, Yoshinori Sato, Rich Felker,
Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
H. Peter Anvin, Boris Ostrovsky, Juergen Gross,
Stefano Stabellini, Rafael J. Wysocki, Len Brown,
Santosh Shilimkar, Krzysztof Kozlowski, Liam Girdwood, Mark Brown,
Pavel Machek, Lee Jones, Andrew Morton, Guenter Roeck,
Daniel Lezcano, Andy Shevchenko, Ulf Hansson, alankao,
K . C . Kuen-Chern Lin
Cc: linux-arm-kernel, linux-kernel, linux-csky, linux-ia64,
linux-m68k, linux-mips, linux-parisc, linuxppc-dev, linux-riscv,
linux-sh, xen-devel, linux-acpi, linux-pm, linux-tegra
Kernel now supports chained power-off handlers. Use do_kernel_power_off()
that invokes chained power-off handlers. It also invokes legacy
pm_power_off() for now, which will be removed once all drivers will
be converted to the new power-off API.
Acked-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
arch/arm64/kernel/process.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c
index aacf2f5559a8..f8db031afa7d 100644
--- a/arch/arm64/kernel/process.c
+++ b/arch/arm64/kernel/process.c
@@ -110,8 +110,7 @@ void machine_power_off(void)
{
local_irq_disable();
smp_send_stop();
- if (pm_power_off)
- pm_power_off();
+ do_kernel_power_off();
}
/*
--
2.33.1
^ permalink raw reply related [flat|nested] 52+ messages in thread* [PATCH v4 13/25] parisc: Use do_kernel_power_off()
2021-11-26 18:00 [PATCH v4 00/25] Introduce power-off+restart call chain API Dmitry Osipenko
` (10 preceding siblings ...)
2021-11-26 18:00 ` [PATCH v4 12/25] arm64: " Dmitry Osipenko
@ 2021-11-26 18:00 ` Dmitry Osipenko
2021-11-26 18:00 ` [PATCH v4 14/25] xen/x86: " Dmitry Osipenko
` (12 subsequent siblings)
24 siblings, 0 replies; 52+ messages in thread
From: Dmitry Osipenko @ 2021-11-26 18:00 UTC (permalink / raw)
To: Thierry Reding, Jonathan Hunter, Russell King, Catalin Marinas,
Will Deacon, Guo Ren, Geert Uytterhoeven, Greg Ungerer,
Joshua Thompson, Thomas Bogendoerfer, Sebastian Reichel,
Linus Walleij, Philipp Zabel, Greentime Hu, Vincent Chen,
James E.J. Bottomley, Helge Deller, Michael Ellerman,
Benjamin Herrenschmidt, Paul Mackerras, Paul Walmsley,
Palmer Dabbelt, Albert Ou, Yoshinori Sato, Rich Felker,
Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
H. Peter Anvin, Boris Ostrovsky, Juergen Gross,
Stefano Stabellini, Rafael J. Wysocki, Len Brown,
Santosh Shilimkar, Krzysztof Kozlowski, Liam Girdwood, Mark Brown,
Pavel Machek, Lee Jones, Andrew Morton, Guenter Roeck,
Daniel Lezcano, Andy Shevchenko, Ulf Hansson, alankao,
K . C . Kuen-Chern Lin
Cc: linux-arm-kernel, linux-kernel, linux-csky, linux-ia64,
linux-m68k, linux-mips, linux-parisc, linuxppc-dev, linux-riscv,
linux-sh, xen-devel, linux-acpi, linux-pm, linux-tegra
Kernel now supports chained power-off handlers. Use do_kernel_power_off()
that invokes chained power-off handlers. It also invokes legacy
pm_power_off() for now, which will be removed once all drivers will
be converted to the new power-off API.
Acked-by: Helge Deller <deller@gmx.de> # parisc
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
arch/parisc/kernel/process.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/parisc/kernel/process.c b/arch/parisc/kernel/process.c
index ea3d83b6fb62..928201b1f58f 100644
--- a/arch/parisc/kernel/process.c
+++ b/arch/parisc/kernel/process.c
@@ -26,6 +26,7 @@
#include <linux/module.h>
#include <linux/personality.h>
#include <linux/ptrace.h>
+#include <linux/reboot.h>
#include <linux/sched.h>
#include <linux/sched/debug.h>
#include <linux/sched/task.h>
@@ -114,8 +115,7 @@ void machine_power_off(void)
pdc_chassis_send_status(PDC_CHASSIS_DIRECT_SHUTDOWN);
/* ipmi_poweroff may have been installed. */
- if (pm_power_off)
- pm_power_off();
+ do_kernel_power_off();
/* It seems we have no way to power the system off via
* software. The user has to press the button himself. */
--
2.33.1
^ permalink raw reply related [flat|nested] 52+ messages in thread* [PATCH v4 14/25] xen/x86: Use do_kernel_power_off()
2021-11-26 18:00 [PATCH v4 00/25] Introduce power-off+restart call chain API Dmitry Osipenko
` (11 preceding siblings ...)
2021-11-26 18:00 ` [PATCH v4 13/25] parisc: " Dmitry Osipenko
@ 2021-11-26 18:00 ` Dmitry Osipenko
2021-11-26 18:00 ` [PATCH v4 15/25] powerpc: " Dmitry Osipenko
` (11 subsequent siblings)
24 siblings, 0 replies; 52+ messages in thread
From: Dmitry Osipenko @ 2021-11-26 18:00 UTC (permalink / raw)
To: Thierry Reding, Jonathan Hunter, Russell King, Catalin Marinas,
Will Deacon, Guo Ren, Geert Uytterhoeven, Greg Ungerer,
Joshua Thompson, Thomas Bogendoerfer, Sebastian Reichel,
Linus Walleij, Philipp Zabel, Greentime Hu, Vincent Chen,
James E.J. Bottomley, Helge Deller, Michael Ellerman,
Benjamin Herrenschmidt, Paul Mackerras, Paul Walmsley,
Palmer Dabbelt, Albert Ou, Yoshinori Sato, Rich Felker,
Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
H. Peter Anvin, Boris Ostrovsky, Juergen Gross,
Stefano Stabellini, Rafael J. Wysocki, Len Brown,
Santosh Shilimkar, Krzysztof Kozlowski, Liam Girdwood, Mark Brown,
Pavel Machek, Lee Jones, Andrew Morton, Guenter Roeck,
Daniel Lezcano, Andy Shevchenko, Ulf Hansson, alankao,
K . C . Kuen-Chern Lin
Cc: linux-arm-kernel, linux-kernel, linux-csky, linux-ia64,
linux-m68k, linux-mips, linux-parisc, linuxppc-dev, linux-riscv,
linux-sh, xen-devel, linux-acpi, linux-pm, linux-tegra
Kernel now supports chained power-off handlers. Use do_kernel_power_off()
that invokes chained power-off handlers. It also invokes legacy
pm_power_off() for now, which will be removed once all drivers will
be converted to the new power-off API.
Acked-by: Juergen Gross <jgross@suse.com>
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
arch/x86/xen/enlighten_pv.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/x86/xen/enlighten_pv.c b/arch/x86/xen/enlighten_pv.c
index 5004feb16783..527fa545eb1f 100644
--- a/arch/x86/xen/enlighten_pv.c
+++ b/arch/x86/xen/enlighten_pv.c
@@ -31,6 +31,7 @@
#include <linux/gfp.h>
#include <linux/edd.h>
#include <linux/objtool.h>
+#include <linux/reboot.h>
#include <xen/xen.h>
#include <xen/events.h>
@@ -1068,8 +1069,7 @@ static void xen_machine_halt(void)
static void xen_machine_power_off(void)
{
- if (pm_power_off)
- pm_power_off();
+ do_kernel_power_off();
xen_reboot(SHUTDOWN_poweroff);
}
--
2.33.1
^ permalink raw reply related [flat|nested] 52+ messages in thread* [PATCH v4 15/25] powerpc: Use do_kernel_power_off()
2021-11-26 18:00 [PATCH v4 00/25] Introduce power-off+restart call chain API Dmitry Osipenko
` (12 preceding siblings ...)
2021-11-26 18:00 ` [PATCH v4 14/25] xen/x86: " Dmitry Osipenko
@ 2021-11-26 18:00 ` Dmitry Osipenko
2021-11-26 18:00 ` [PATCH v4 16/25] m68k: Switch to new sys-off handler API Dmitry Osipenko
` (10 subsequent siblings)
24 siblings, 0 replies; 52+ messages in thread
From: Dmitry Osipenko @ 2021-11-26 18:00 UTC (permalink / raw)
To: Thierry Reding, Jonathan Hunter, Russell King, Catalin Marinas,
Will Deacon, Guo Ren, Geert Uytterhoeven, Greg Ungerer,
Joshua Thompson, Thomas Bogendoerfer, Sebastian Reichel,
Linus Walleij, Philipp Zabel, Greentime Hu, Vincent Chen,
James E.J. Bottomley, Helge Deller, Michael Ellerman,
Benjamin Herrenschmidt, Paul Mackerras, Paul Walmsley,
Palmer Dabbelt, Albert Ou, Yoshinori Sato, Rich Felker,
Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
H. Peter Anvin, Boris Ostrovsky, Juergen Gross,
Stefano Stabellini, Rafael J. Wysocki, Len Brown,
Santosh Shilimkar, Krzysztof Kozlowski, Liam Girdwood, Mark Brown,
Pavel Machek, Lee Jones, Andrew Morton, Guenter Roeck,
Daniel Lezcano, Andy Shevchenko, Ulf Hansson, alankao,
K . C . Kuen-Chern Lin
Cc: linux-arm-kernel, linux-kernel, linux-csky, linux-ia64,
linux-m68k, linux-mips, linux-parisc, linuxppc-dev, linux-riscv,
linux-sh, xen-devel, linux-acpi, linux-pm, linux-tegra
Kernel now supports chained power-off handlers. Use do_kernel_power_off()
that invokes chained power-off handlers. It also invokes legacy
pm_power_off() for now, which will be removed once all drivers will
be converted to the new power-off API.
Acked-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
arch/powerpc/kernel/setup-common.c | 4 +---
arch/powerpc/xmon/xmon.c | 3 +--
2 files changed, 2 insertions(+), 5 deletions(-)
diff --git a/arch/powerpc/kernel/setup-common.c b/arch/powerpc/kernel/setup-common.c
index 4f1322b65760..71c4ccd9bbb1 100644
--- a/arch/powerpc/kernel/setup-common.c
+++ b/arch/powerpc/kernel/setup-common.c
@@ -161,9 +161,7 @@ void machine_restart(char *cmd)
void machine_power_off(void)
{
machine_shutdown();
- if (pm_power_off)
- pm_power_off();
-
+ do_kernel_power_off();
smp_send_stop();
machine_hang();
}
diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c
index 83100c6524cc..759e167704e6 100644
--- a/arch/powerpc/xmon/xmon.c
+++ b/arch/powerpc/xmon/xmon.c
@@ -1243,8 +1243,7 @@ static void bootcmds(void)
} else if (cmd = 'h') {
ppc_md.halt();
} else if (cmd = 'p') {
- if (pm_power_off)
- pm_power_off();
+ do_kernel_power_off();
}
}
--
2.33.1
^ permalink raw reply related [flat|nested] 52+ messages in thread* [PATCH v4 16/25] m68k: Switch to new sys-off handler API
2021-11-26 18:00 [PATCH v4 00/25] Introduce power-off+restart call chain API Dmitry Osipenko
` (13 preceding siblings ...)
2021-11-26 18:00 ` [PATCH v4 15/25] powerpc: " Dmitry Osipenko
@ 2021-11-26 18:00 ` Dmitry Osipenko
2021-11-26 18:00 ` [PATCH v4 17/25] sh: Use do_kernel_power_off() Dmitry Osipenko
` (9 subsequent siblings)
24 siblings, 0 replies; 52+ messages in thread
From: Dmitry Osipenko @ 2021-11-26 18:00 UTC (permalink / raw)
To: Thierry Reding, Jonathan Hunter, Russell King, Catalin Marinas,
Will Deacon, Guo Ren, Geert Uytterhoeven, Greg Ungerer,
Joshua Thompson, Thomas Bogendoerfer, Sebastian Reichel,
Linus Walleij, Philipp Zabel, Greentime Hu, Vincent Chen,
James E.J. Bottomley, Helge Deller, Michael Ellerman,
Benjamin Herrenschmidt, Paul Mackerras, Paul Walmsley,
Palmer Dabbelt, Albert Ou, Yoshinori Sato, Rich Felker,
Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
H. Peter Anvin, Boris Ostrovsky, Juergen Gross,
Stefano Stabellini, Rafael J. Wysocki, Len Brown,
Santosh Shilimkar, Krzysztof Kozlowski, Liam Girdwood, Mark Brown,
Pavel Machek, Lee Jones, Andrew Morton, Guenter Roeck,
Daniel Lezcano, Andy Shevchenko, Ulf Hansson, alankao,
K . C . Kuen-Chern Lin
Cc: linux-arm-kernel, linux-kernel, linux-csky, linux-ia64,
linux-m68k, linux-mips, linux-parisc, linuxppc-dev, linux-riscv,
linux-sh, xen-devel, linux-acpi, linux-pm, linux-tegra
Kernel now supports chained power-off handlers. Use
register_power_off_handler() that registers power-off handlers and
do_kernel_power_off() that invokes chained power-off handlers. Legacy
pm_power_off() will be removed once all drivers will be converted to
the new power-off API.
Normally arch code should adopt only the do_kernel_power_off() at first,
but m68k is a special case because it uses pm_power_off() "inside out",
i.e. pm_power_off() invokes machine_power_off() [in fact it does nothing],
while it's machine_power_off() that should invoke the pm_power_off(), and
thus, we can't convert platforms to the new API separately. There are only
two platforms changed here, so it's not a big deal.
Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
arch/m68k/emu/natfeat.c | 3 ++-
arch/m68k/include/asm/machdep.h | 1 -
arch/m68k/kernel/process.c | 5 ++---
arch/m68k/kernel/setup_mm.c | 1 -
arch/m68k/kernel/setup_no.c | 1 -
arch/m68k/mac/config.c | 4 +++-
6 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/arch/m68k/emu/natfeat.c b/arch/m68k/emu/natfeat.c
index 71b78ecee75c..b19dc00026d9 100644
--- a/arch/m68k/emu/natfeat.c
+++ b/arch/m68k/emu/natfeat.c
@@ -15,6 +15,7 @@
#include <linux/string.h>
#include <linux/kernel.h>
#include <linux/module.h>
+#include <linux/reboot.h>
#include <linux/io.h>
#include <asm/machdep.h>
#include <asm/natfeat.h>
@@ -90,5 +91,5 @@ void __init nf_init(void)
pr_info("NatFeats found (%s, %lu.%lu)\n", buf, version >> 16,
version & 0xffff);
- mach_power_off = nf_poweroff;
+ register_platform_power_off(nf_poweroff);
}
diff --git a/arch/m68k/include/asm/machdep.h b/arch/m68k/include/asm/machdep.h
index 8fd80ef1b77e..8d8c3ee2069f 100644
--- a/arch/m68k/include/asm/machdep.h
+++ b/arch/m68k/include/asm/machdep.h
@@ -24,7 +24,6 @@ extern int (*mach_get_rtc_pll)(struct rtc_pll_info *);
extern int (*mach_set_rtc_pll)(struct rtc_pll_info *);
extern void (*mach_reset)( void );
extern void (*mach_halt)( void );
-extern void (*mach_power_off)( void );
extern unsigned long (*mach_hd_init) (unsigned long, unsigned long);
extern void (*mach_hd_setup)(char *, int *);
extern void (*mach_heartbeat) (int);
diff --git a/arch/m68k/kernel/process.c b/arch/m68k/kernel/process.c
index a6030dbaa089..e160a7c57bd3 100644
--- a/arch/m68k/kernel/process.c
+++ b/arch/m68k/kernel/process.c
@@ -67,12 +67,11 @@ void machine_halt(void)
void machine_power_off(void)
{
- if (mach_power_off)
- mach_power_off();
+ do_kernel_power_off();
for (;;);
}
-void (*pm_power_off)(void) = machine_power_off;
+void (*pm_power_off)(void);
EXPORT_SYMBOL(pm_power_off);
void show_regs(struct pt_regs * regs)
diff --git a/arch/m68k/kernel/setup_mm.c b/arch/m68k/kernel/setup_mm.c
index 4b51bfd38e5f..50f4f120a4ff 100644
--- a/arch/m68k/kernel/setup_mm.c
+++ b/arch/m68k/kernel/setup_mm.c
@@ -98,7 +98,6 @@ EXPORT_SYMBOL(mach_get_rtc_pll);
EXPORT_SYMBOL(mach_set_rtc_pll);
void (*mach_reset)( void );
void (*mach_halt)( void );
-void (*mach_power_off)( void );
#ifdef CONFIG_HEARTBEAT
void (*mach_heartbeat) (int);
EXPORT_SYMBOL(mach_heartbeat);
diff --git a/arch/m68k/kernel/setup_no.c b/arch/m68k/kernel/setup_no.c
index 5e4104f07a44..00bf82258233 100644
--- a/arch/m68k/kernel/setup_no.c
+++ b/arch/m68k/kernel/setup_no.c
@@ -55,7 +55,6 @@ int (*mach_hwclk) (int, struct rtc_time*);
/* machine dependent reboot functions */
void (*mach_reset)(void);
void (*mach_halt)(void);
-void (*mach_power_off)(void);
#ifdef CONFIG_M68000
#if defined(CONFIG_M68328)
diff --git a/arch/m68k/mac/config.c b/arch/m68k/mac/config.c
index 5d16f9b47aa9..727320dedf08 100644
--- a/arch/m68k/mac/config.c
+++ b/arch/m68k/mac/config.c
@@ -12,6 +12,7 @@
#include <linux/errno.h>
#include <linux/module.h>
+#include <linux/reboot.h>
#include <linux/types.h>
#include <linux/mm.h>
#include <linux/tty.h>
@@ -139,7 +140,6 @@ void __init config_mac(void)
mach_hwclk = mac_hwclk;
mach_reset = mac_reset;
mach_halt = mac_poweroff;
- mach_power_off = mac_poweroff;
#if IS_ENABLED(CONFIG_INPUT_M68K_BEEP)
mach_beep = mac_mksound;
#endif
@@ -159,6 +159,8 @@ void __init config_mac(void)
if (macintosh_config->ident = MAC_MODEL_IICI)
mach_l2_flush = via_l2_flush;
+
+ register_platform_power_off(mac_poweroff);
}
--
2.33.1
^ permalink raw reply related [flat|nested] 52+ messages in thread* [PATCH v4 17/25] sh: Use do_kernel_power_off()
2021-11-26 18:00 [PATCH v4 00/25] Introduce power-off+restart call chain API Dmitry Osipenko
` (14 preceding siblings ...)
2021-11-26 18:00 ` [PATCH v4 16/25] m68k: Switch to new sys-off handler API Dmitry Osipenko
@ 2021-11-26 18:00 ` Dmitry Osipenko
2021-11-26 18:00 ` [PATCH v4 18/25] x86: " Dmitry Osipenko
` (8 subsequent siblings)
24 siblings, 0 replies; 52+ messages in thread
From: Dmitry Osipenko @ 2021-11-26 18:00 UTC (permalink / raw)
To: Thierry Reding, Jonathan Hunter, Russell King, Catalin Marinas,
Will Deacon, Guo Ren, Geert Uytterhoeven, Greg Ungerer,
Joshua Thompson, Thomas Bogendoerfer, Sebastian Reichel,
Linus Walleij, Philipp Zabel, Greentime Hu, Vincent Chen,
James E.J. Bottomley, Helge Deller, Michael Ellerman,
Benjamin Herrenschmidt, Paul Mackerras, Paul Walmsley,
Palmer Dabbelt, Albert Ou, Yoshinori Sato, Rich Felker,
Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
H. Peter Anvin, Boris Ostrovsky, Juergen Gross,
Stefano Stabellini, Rafael J. Wysocki, Len Brown,
Santosh Shilimkar, Krzysztof Kozlowski, Liam Girdwood, Mark Brown,
Pavel Machek, Lee Jones, Andrew Morton, Guenter Roeck,
Daniel Lezcano, Andy Shevchenko, Ulf Hansson, alankao,
K . C . Kuen-Chern Lin
Cc: linux-arm-kernel, linux-kernel, linux-csky, linux-ia64,
linux-m68k, linux-mips, linux-parisc, linuxppc-dev, linux-riscv,
linux-sh, xen-devel, linux-acpi, linux-pm, linux-tegra
Kernel now supports chained power-off handlers. Use do_kernel_power_off()
that invokes chained power-off handlers. It also invokes legacy
pm_power_off() for now, which will be removed once all drivers will
be converted to the new power-off API.
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
arch/sh/kernel/reboot.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/arch/sh/kernel/reboot.c b/arch/sh/kernel/reboot.c
index 5c33f036418b..e8eeedc9b182 100644
--- a/arch/sh/kernel/reboot.c
+++ b/arch/sh/kernel/reboot.c
@@ -46,8 +46,7 @@ static void native_machine_shutdown(void)
static void native_machine_power_off(void)
{
- if (pm_power_off)
- pm_power_off();
+ do_kernel_power_off();
}
static void native_machine_halt(void)
--
2.33.1
^ permalink raw reply related [flat|nested] 52+ messages in thread* [PATCH v4 18/25] x86: Use do_kernel_power_off()
2021-11-26 18:00 [PATCH v4 00/25] Introduce power-off+restart call chain API Dmitry Osipenko
` (15 preceding siblings ...)
2021-11-26 18:00 ` [PATCH v4 17/25] sh: Use do_kernel_power_off() Dmitry Osipenko
@ 2021-11-26 18:00 ` Dmitry Osipenko
[not found] ` <YaLYR24XRijSmBq3@qmqm.qmqm.pl>
2021-11-26 18:00 ` [PATCH v4 19/25] ia64: " Dmitry Osipenko
` (7 subsequent siblings)
24 siblings, 1 reply; 52+ messages in thread
From: Dmitry Osipenko @ 2021-11-26 18:00 UTC (permalink / raw)
To: Thierry Reding, Jonathan Hunter, Russell King, Catalin Marinas,
Will Deacon, Guo Ren, Geert Uytterhoeven, Greg Ungerer,
Joshua Thompson, Thomas Bogendoerfer, Sebastian Reichel,
Linus Walleij, Philipp Zabel, Greentime Hu, Vincent Chen,
James E.J. Bottomley, Helge Deller, Michael Ellerman,
Benjamin Herrenschmidt, Paul Mackerras, Paul Walmsley,
Palmer Dabbelt, Albert Ou, Yoshinori Sato, Rich Felker,
Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
H. Peter Anvin, Boris Ostrovsky, Juergen Gross,
Stefano Stabellini, Rafael J. Wysocki, Len Brown,
Santosh Shilimkar, Krzysztof Kozlowski, Liam Girdwood, Mark Brown,
Pavel Machek, Lee Jones, Andrew Morton, Guenter Roeck,
Daniel Lezcano, Andy Shevchenko, Ulf Hansson, alankao,
K . C . Kuen-Chern Lin
Cc: linux-arm-kernel, linux-kernel, linux-csky, linux-ia64,
linux-m68k, linux-mips, linux-parisc, linuxppc-dev, linux-riscv,
linux-sh, xen-devel, linux-acpi, linux-pm, linux-tegra
Kernel now supports chained power-off handlers. Use do_kernel_power_off()
that invokes chained power-off handlers. It also invokes legacy
pm_power_off() for now, which will be removed once all drivers will
be converted to the new power-off API.
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
arch/x86/kernel/reboot.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
index 0a40df66a40d..cd7d9416d81a 100644
--- a/arch/x86/kernel/reboot.c
+++ b/arch/x86/kernel/reboot.c
@@ -747,10 +747,10 @@ static void native_machine_halt(void)
static void native_machine_power_off(void)
{
- if (pm_power_off) {
+ if (kernel_can_power_off()) {
if (!reboot_force)
machine_shutdown();
- pm_power_off();
+ do_kernel_power_off();
}
/* A fallback in case there is no PM info available */
tboot_shutdown(TB_SHUTDOWN_HALT);
--
2.33.1
^ permalink raw reply related [flat|nested] 52+ messages in thread* [PATCH v4 19/25] ia64: Use do_kernel_power_off()
2021-11-26 18:00 [PATCH v4 00/25] Introduce power-off+restart call chain API Dmitry Osipenko
` (16 preceding siblings ...)
2021-11-26 18:00 ` [PATCH v4 18/25] x86: " Dmitry Osipenko
@ 2021-11-26 18:00 ` Dmitry Osipenko
2021-11-26 18:00 ` [PATCH v4 20/25] mips: " Dmitry Osipenko
` (6 subsequent siblings)
24 siblings, 0 replies; 52+ messages in thread
From: Dmitry Osipenko @ 2021-11-26 18:00 UTC (permalink / raw)
To: Thierry Reding, Jonathan Hunter, Russell King, Catalin Marinas,
Will Deacon, Guo Ren, Geert Uytterhoeven, Greg Ungerer,
Joshua Thompson, Thomas Bogendoerfer, Sebastian Reichel,
Linus Walleij, Philipp Zabel, Greentime Hu, Vincent Chen,
James E.J. Bottomley, Helge Deller, Michael Ellerman,
Benjamin Herrenschmidt, Paul Mackerras, Paul Walmsley,
Palmer Dabbelt, Albert Ou, Yoshinori Sato, Rich Felker,
Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
H. Peter Anvin, Boris Ostrovsky, Juergen Gross,
Stefano Stabellini, Rafael J. Wysocki, Len Brown,
Santosh Shilimkar, Krzysztof Kozlowski, Liam Girdwood, Mark Brown,
Pavel Machek, Lee Jones, Andrew Morton, Guenter Roeck,
Daniel Lezcano, Andy Shevchenko, Ulf Hansson, alankao,
K . C . Kuen-Chern Lin
Cc: linux-arm-kernel, linux-kernel, linux-csky, linux-ia64,
linux-m68k, linux-mips, linux-parisc, linuxppc-dev, linux-riscv,
linux-sh, xen-devel, linux-acpi, linux-pm, linux-tegra
Kernel now supports chained power-off handlers. Use do_kernel_power_off()
that invokes chained power-off handlers. It also invokes legacy
pm_power_off() for now, which will be removed once all drivers will
be converted to the new power-off API.
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
arch/ia64/kernel/process.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/ia64/kernel/process.c b/arch/ia64/kernel/process.c
index 834df24a88f1..cee4d7db2143 100644
--- a/arch/ia64/kernel/process.c
+++ b/arch/ia64/kernel/process.c
@@ -19,6 +19,7 @@
#include <linux/module.h>
#include <linux/notifier.h>
#include <linux/personality.h>
+#include <linux/reboot.h>
#include <linux/sched.h>
#include <linux/sched/debug.h>
#include <linux/sched/hotplug.h>
@@ -599,8 +600,7 @@ machine_halt (void)
void
machine_power_off (void)
{
- if (pm_power_off)
- pm_power_off();
+ do_kernel_power_off();
machine_halt();
}
--
2.33.1
^ permalink raw reply related [flat|nested] 52+ messages in thread* [PATCH v4 20/25] mips: Use do_kernel_power_off()
2021-11-26 18:00 [PATCH v4 00/25] Introduce power-off+restart call chain API Dmitry Osipenko
` (17 preceding siblings ...)
2021-11-26 18:00 ` [PATCH v4 19/25] ia64: " Dmitry Osipenko
@ 2021-11-26 18:00 ` Dmitry Osipenko
2021-11-26 18:00 ` [PATCH v4 21/25] nds32: " Dmitry Osipenko
` (5 subsequent siblings)
24 siblings, 0 replies; 52+ messages in thread
From: Dmitry Osipenko @ 2021-11-26 18:00 UTC (permalink / raw)
To: Thierry Reding, Jonathan Hunter, Russell King, Catalin Marinas,
Will Deacon, Guo Ren, Geert Uytterhoeven, Greg Ungerer,
Joshua Thompson, Thomas Bogendoerfer, Sebastian Reichel,
Linus Walleij, Philipp Zabel, Greentime Hu, Vincent Chen,
James E.J. Bottomley, Helge Deller, Michael Ellerman,
Benjamin Herrenschmidt, Paul Mackerras, Paul Walmsley,
Palmer Dabbelt, Albert Ou, Yoshinori Sato, Rich Felker,
Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
H. Peter Anvin, Boris Ostrovsky, Juergen Gross,
Stefano Stabellini, Rafael J. Wysocki, Len Brown,
Santosh Shilimkar, Krzysztof Kozlowski, Liam Girdwood, Mark Brown,
Pavel Machek, Lee Jones, Andrew Morton, Guenter Roeck,
Daniel Lezcano, Andy Shevchenko, Ulf Hansson, alankao,
K . C . Kuen-Chern Lin
Cc: linux-arm-kernel, linux-kernel, linux-csky, linux-ia64,
linux-m68k, linux-mips, linux-parisc, linuxppc-dev, linux-riscv,
linux-sh, xen-devel, linux-acpi, linux-pm, linux-tegra
Kernel now supports chained power-off handlers. Use do_kernel_power_off()
that invokes chained power-off handlers. It also invokes legacy
pm_power_off() for now, which will be removed once all drivers will
be converted to the new power-off API.
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
arch/mips/kernel/reset.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/arch/mips/kernel/reset.c b/arch/mips/kernel/reset.c
index 6288780b779e..e7ce07b3e79b 100644
--- a/arch/mips/kernel/reset.c
+++ b/arch/mips/kernel/reset.c
@@ -114,8 +114,7 @@ void machine_halt(void)
void machine_power_off(void)
{
- if (pm_power_off)
- pm_power_off();
+ do_kernel_power_off();
#ifdef CONFIG_SMP
preempt_disable();
--
2.33.1
^ permalink raw reply related [flat|nested] 52+ messages in thread* [PATCH v4 21/25] nds32: Use do_kernel_power_off()
2021-11-26 18:00 [PATCH v4 00/25] Introduce power-off+restart call chain API Dmitry Osipenko
` (18 preceding siblings ...)
2021-11-26 18:00 ` [PATCH v4 20/25] mips: " Dmitry Osipenko
@ 2021-11-26 18:00 ` Dmitry Osipenko
2021-11-26 18:00 ` [PATCH v4 23/25] ACPI: power: Switch to sys-off handler API Dmitry Osipenko
` (4 subsequent siblings)
24 siblings, 0 replies; 52+ messages in thread
From: Dmitry Osipenko @ 2021-11-26 18:00 UTC (permalink / raw)
To: Thierry Reding, Jonathan Hunter, Russell King, Catalin Marinas,
Will Deacon, Guo Ren, Geert Uytterhoeven, Greg Ungerer,
Joshua Thompson, Thomas Bogendoerfer, Sebastian Reichel,
Linus Walleij, Philipp Zabel, Greentime Hu, Vincent Chen,
James E.J. Bottomley, Helge Deller, Michael Ellerman,
Benjamin Herrenschmidt, Paul Mackerras, Paul Walmsley,
Palmer Dabbelt, Albert Ou, Yoshinori Sato, Rich Felker,
Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
H. Peter Anvin, Boris Ostrovsky, Juergen Gross,
Stefano Stabellini, Rafael J. Wysocki, Len Brown,
Santosh Shilimkar, Krzysztof Kozlowski, Liam Girdwood, Mark Brown,
Pavel Machek, Lee Jones, Andrew Morton, Guenter Roeck,
Daniel Lezcano, Andy Shevchenko, Ulf Hansson, alankao,
K . C . Kuen-Chern Lin
Cc: linux-arm-kernel, linux-kernel, linux-csky, linux-ia64,
linux-m68k, linux-mips, linux-parisc, linuxppc-dev, linux-riscv,
linux-sh, xen-devel, linux-acpi, linux-pm, linux-tegra
Kernel now supports chained power-off handlers. Use do_kernel_power_off()
that invokes chained power-off handlers. It also invokes legacy
pm_power_off() for now, which will be removed once all drivers will
be converted to the new power-off API.
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
arch/nds32/kernel/process.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/arch/nds32/kernel/process.c b/arch/nds32/kernel/process.c
index 49fab9e39cbf..0936dcd7db1b 100644
--- a/arch/nds32/kernel/process.c
+++ b/arch/nds32/kernel/process.c
@@ -54,8 +54,7 @@ EXPORT_SYMBOL(machine_halt);
void machine_power_off(void)
{
- if (pm_power_off)
- pm_power_off();
+ do_kernel_power_off();
}
EXPORT_SYMBOL(machine_power_off);
--
2.33.1
^ permalink raw reply related [flat|nested] 52+ messages in thread* [PATCH v4 23/25] ACPI: power: Switch to sys-off handler API
2021-11-26 18:00 [PATCH v4 00/25] Introduce power-off+restart call chain API Dmitry Osipenko
` (19 preceding siblings ...)
2021-11-26 18:00 ` [PATCH v4 21/25] nds32: " Dmitry Osipenko
@ 2021-11-26 18:00 ` Dmitry Osipenko
2021-11-26 18:01 ` [PATCH v4 24/25] regulator: pfuze100: Use devm_register_sys_off_handler() Dmitry Osipenko
` (3 subsequent siblings)
24 siblings, 0 replies; 52+ messages in thread
From: Dmitry Osipenko @ 2021-11-26 18:00 UTC (permalink / raw)
To: Thierry Reding, Jonathan Hunter, Russell King, Catalin Marinas,
Will Deacon, Guo Ren, Geert Uytterhoeven, Greg Ungerer,
Joshua Thompson, Thomas Bogendoerfer, Sebastian Reichel,
Linus Walleij, Philipp Zabel, Greentime Hu, Vincent Chen,
James E.J. Bottomley, Helge Deller, Michael Ellerman,
Benjamin Herrenschmidt, Paul Mackerras, Paul Walmsley,
Palmer Dabbelt, Albert Ou, Yoshinori Sato, Rich Felker,
Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
H. Peter Anvin, Boris Ostrovsky, Juergen Gross,
Stefano Stabellini, Rafael J. Wysocki, Len Brown,
Santosh Shilimkar, Krzysztof Kozlowski, Liam Girdwood, Mark Brown,
Pavel Machek, Lee Jones, Andrew Morton, Guenter Roeck,
Daniel Lezcano, Andy Shevchenko, Ulf Hansson, alankao,
K . C . Kuen-Chern Lin
Cc: linux-arm-kernel, linux-kernel, linux-csky, linux-ia64,
linux-m68k, linux-mips, linux-parisc, linuxppc-dev, linux-riscv,
linux-sh, xen-devel, linux-acpi, linux-pm, linux-tegra
Switch to sys-off API that replaces legacy pm_power_off callbacks.
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
drivers/acpi/sleep.c | 25 +++++++++++--------------
1 file changed, 11 insertions(+), 14 deletions(-)
diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c
index eaa47753b758..2e613fddd614 100644
--- a/drivers/acpi/sleep.c
+++ b/drivers/acpi/sleep.c
@@ -47,19 +47,11 @@ static void acpi_sleep_tts_switch(u32 acpi_state)
}
}
-static int tts_notify_reboot(struct notifier_block *this,
- unsigned long code, void *x)
+static void tts_reboot_prepare(struct reboot_prep_data *data)
{
acpi_sleep_tts_switch(ACPI_STATE_S5);
- return NOTIFY_DONE;
}
-static struct notifier_block tts_notifier = {
- .notifier_call = tts_notify_reboot,
- .next = NULL,
- .priority = 0,
-};
-
static int acpi_sleep_prepare(u32 acpi_state)
{
#ifdef CONFIG_ACPI_SLEEP
@@ -1020,7 +1012,7 @@ 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 void acpi_power_off_prepare(struct power_off_prep_data *data)
{
/* Prepare to power off the system */
acpi_sleep_prepare(ACPI_STATE_S5);
@@ -1028,7 +1020,7 @@ static void acpi_power_off_prepare(void)
acpi_os_wait_events_complete();
}
-static void acpi_power_off(void)
+static void acpi_power_off(struct power_off_data *data)
{
/* acpi_sleep_prepare(ACPI_STATE_S5) should have already been called */
pr_debug("%s called\n", __func__);
@@ -1036,6 +1028,11 @@ static void acpi_power_off(void)
acpi_enter_sleep_state(ACPI_STATE_S5);
}
+static struct sys_off_handler acpi_sys_off_handler = {
+ .power_off_priority = POWEROFF_PRIO_FIRMWARE,
+ .reboot_prepare_cb = tts_reboot_prepare,
+};
+
int __init acpi_sleep_init(void)
{
char supported[ACPI_S_STATE_COUNT * 3 + 1];
@@ -1052,8 +1049,8 @@ 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;
- pm_power_off = acpi_power_off;
+ acpi_sys_off_handler.power_off_cb = acpi_power_off;
+ acpi_sys_off_handler.power_off_prepare_cb = acpi_power_off_prepare;
} else {
acpi_no_s5 = true;
}
@@ -1069,6 +1066,6 @@ int __init acpi_sleep_init(void)
* Register the tts_notifier to reboot notifier list so that the _TTS
* object can also be evaluated when the system enters S5.
*/
- register_reboot_notifier(&tts_notifier);
+ register_sys_off_handler(&acpi_sys_off_handler);
return 0;
}
--
2.33.1
^ permalink raw reply related [flat|nested] 52+ messages in thread* [PATCH v4 24/25] regulator: pfuze100: Use devm_register_sys_off_handler()
2021-11-26 18:00 [PATCH v4 00/25] Introduce power-off+restart call chain API Dmitry Osipenko
` (20 preceding siblings ...)
2021-11-26 18:00 ` [PATCH v4 23/25] ACPI: power: Switch to sys-off handler API Dmitry Osipenko
@ 2021-11-26 18:01 ` Dmitry Osipenko
2021-11-26 18:01 ` [PATCH v4 25/25] reboot: Remove pm_power_off_prepare() Dmitry Osipenko
` (2 subsequent siblings)
24 siblings, 0 replies; 52+ messages in thread
From: Dmitry Osipenko @ 2021-11-26 18:01 UTC (permalink / raw)
To: Thierry Reding, Jonathan Hunter, Russell King, Catalin Marinas,
Will Deacon, Guo Ren, Geert Uytterhoeven, Greg Ungerer,
Joshua Thompson, Thomas Bogendoerfer, Sebastian Reichel,
Linus Walleij, Philipp Zabel, Greentime Hu, Vincent Chen,
James E.J. Bottomley, Helge Deller, Michael Ellerman,
Benjamin Herrenschmidt, Paul Mackerras, Paul Walmsley,
Palmer Dabbelt, Albert Ou, Yoshinori Sato, Rich Felker,
Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
H. Peter Anvin, Boris Ostrovsky, Juergen Gross,
Stefano Stabellini, Rafael J. Wysocki, Len Brown,
Santosh Shilimkar, Krzysztof Kozlowski, Liam Girdwood, Mark Brown,
Pavel Machek, Lee Jones, Andrew Morton, Guenter Roeck,
Daniel Lezcano, Andy Shevchenko, Ulf Hansson, alankao,
K . C . Kuen-Chern Lin
Cc: linux-arm-kernel, linux-kernel, linux-csky, linux-ia64,
linux-m68k, linux-mips, linux-parisc, linuxppc-dev, linux-riscv,
linux-sh, xen-devel, linux-acpi, linux-pm, linux-tegra
Use devm_register_sys_off_handler() that replaces global
pm_power_off_prepare variable and allows to register multiple
power-off handlers.
Acked-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
drivers/regulator/pfuze100-regulator.c | 38 ++++++++++----------------
1 file changed, 14 insertions(+), 24 deletions(-)
diff --git a/drivers/regulator/pfuze100-regulator.c b/drivers/regulator/pfuze100-regulator.c
index d60d7d1b7fa2..2eca8d43a097 100644
--- a/drivers/regulator/pfuze100-regulator.c
+++ b/drivers/regulator/pfuze100-regulator.c
@@ -10,6 +10,7 @@
#include <linux/of_device.h>
#include <linux/regulator/of_regulator.h>
#include <linux/platform_device.h>
+#include <linux/reboot.h>
#include <linux/regulator/driver.h>
#include <linux/regulator/machine.h>
#include <linux/regulator/pfuze100.h>
@@ -76,6 +77,7 @@ struct pfuze_chip {
struct pfuze_regulator regulator_descs[PFUZE100_MAX_REGULATOR];
struct regulator_dev *regulators[PFUZE100_MAX_REGULATOR];
struct pfuze_regulator *pfuze_regulators;
+ struct sys_off_handler sys_off;
};
static const int pfuze100_swbst[] = {
@@ -569,10 +571,10 @@ static inline struct device_node *match_of_node(int index)
return pfuze_matches[index].of_node;
}
-static struct pfuze_chip *syspm_pfuze_chip;
-
-static void pfuze_power_off_prepare(void)
+static void pfuze_power_off_prepare(struct power_off_prep_data *data)
{
+ struct pfuze_chip *syspm_pfuze_chip = data->cb_data;
+
dev_info(syspm_pfuze_chip->dev, "Configure standby mode for power off");
/* Switch from default mode: APS/APS to APS/Off */
@@ -611,24 +613,23 @@ static void pfuze_power_off_prepare(void)
static int pfuze_power_off_prepare_init(struct pfuze_chip *pfuze_chip)
{
+ int err;
+
if (pfuze_chip->chip_id != PFUZE100) {
dev_warn(pfuze_chip->dev, "Requested pm_power_off_prepare handler for not supported chip\n");
return -ENODEV;
}
- if (pm_power_off_prepare) {
- dev_warn(pfuze_chip->dev, "pm_power_off_prepare is already registered.\n");
- return -EBUSY;
- }
+ pfuze_chip->sys_off.power_off_prepare_cb = pfuze_power_off_prepare;
+ pfuze_chip->sys_off.cb_data = pfuze_chip;
- if (syspm_pfuze_chip) {
- dev_warn(pfuze_chip->dev, "syspm_pfuze_chip is already set.\n");
- return -EBUSY;
+ err = devm_register_sys_off_handler(pfuze_chip->dev, &pfuze_chip->sys_off);
+ if (err) {
+ dev_err(pfuze_chip->dev,
+ "failed to register sys-off handler: %d\n", err);
+ return err;
}
- syspm_pfuze_chip = pfuze_chip;
- pm_power_off_prepare = pfuze_power_off_prepare;
-
return 0;
}
@@ -837,23 +838,12 @@ static int pfuze100_regulator_probe(struct i2c_client *client,
return 0;
}
-static int pfuze100_regulator_remove(struct i2c_client *client)
-{
- if (syspm_pfuze_chip) {
- syspm_pfuze_chip = NULL;
- pm_power_off_prepare = NULL;
- }
-
- return 0;
-}
-
static struct i2c_driver pfuze_driver = {
.driver = {
.name = "pfuze100-regulator",
.of_match_table = pfuze_dt_ids,
},
.probe = pfuze100_regulator_probe,
- .remove = pfuze100_regulator_remove,
};
module_i2c_driver(pfuze_driver);
--
2.33.1
^ permalink raw reply related [flat|nested] 52+ messages in thread* [PATCH v4 25/25] reboot: Remove pm_power_off_prepare()
2021-11-26 18:00 [PATCH v4 00/25] Introduce power-off+restart call chain API Dmitry Osipenko
` (21 preceding siblings ...)
2021-11-26 18:01 ` [PATCH v4 24/25] regulator: pfuze100: Use devm_register_sys_off_handler() Dmitry Osipenko
@ 2021-11-26 18:01 ` Dmitry Osipenko
[not found] ` <20211126180101.27818-23-digetx@gmail.com>
[not found] ` <20211126180101.27818-9-digetx@gmail.com>
24 siblings, 0 replies; 52+ messages in thread
From: Dmitry Osipenko @ 2021-11-26 18:01 UTC (permalink / raw)
To: Thierry Reding, Jonathan Hunter, Russell King, Catalin Marinas,
Will Deacon, Guo Ren, Geert Uytterhoeven, Greg Ungerer,
Joshua Thompson, Thomas Bogendoerfer, Sebastian Reichel,
Linus Walleij, Philipp Zabel, Greentime Hu, Vincent Chen,
James E.J. Bottomley, Helge Deller, Michael Ellerman,
Benjamin Herrenschmidt, Paul Mackerras, Paul Walmsley,
Palmer Dabbelt, Albert Ou, Yoshinori Sato, Rich Felker,
Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
H. Peter Anvin, Boris Ostrovsky, Juergen Gross,
Stefano Stabellini, Rafael J. Wysocki, Len Brown,
Santosh Shilimkar, Krzysztof Kozlowski, Liam Girdwood, Mark Brown,
Pavel Machek, Lee Jones, Andrew Morton, Guenter Roeck,
Daniel Lezcano, Andy Shevchenko, Ulf Hansson, alankao,
K . C . Kuen-Chern Lin
Cc: linux-arm-kernel, linux-kernel, linux-csky, linux-ia64,
linux-m68k, linux-mips, linux-parisc, linuxppc-dev, linux-riscv,
linux-sh, xen-devel, linux-acpi, linux-pm, linux-tegra
All pm_power_off_prepare() users were converted to sys-off handler API.
Remove the obsolete callback.
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
include/linux/pm.h | 1 -
kernel/reboot.c | 11 -----------
2 files changed, 12 deletions(-)
diff --git a/include/linux/pm.h b/include/linux/pm.h
index 1d8209c09686..d9bf1426f81e 100644
--- a/include/linux/pm.h
+++ b/include/linux/pm.h
@@ -20,7 +20,6 @@
* Callbacks for platform drivers to implement.
*/
extern void (*pm_power_off)(void);
-extern void (*pm_power_off_prepare)(void);
struct device; /* we have a circular dep with device.h */
#ifdef CONFIG_VT_CONSOLE_SLEEP
diff --git a/kernel/reboot.c b/kernel/reboot.c
index 4884204f9a31..a832bb660040 100644
--- a/kernel/reboot.c
+++ b/kernel/reboot.c
@@ -48,13 +48,6 @@ int reboot_cpu;
enum reboot_type reboot_type = BOOT_ACPI;
int reboot_force;
-/*
- * If set, this is used for preparing the system to power off.
- */
-
-void (*pm_power_off_prepare)(void);
-EXPORT_SYMBOL_GPL(pm_power_off_prepare);
-
/**
* emergency_restart - reboot the system
*
@@ -807,10 +800,6 @@ void do_kernel_power_off(void)
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);
}
--
2.33.1
^ permalink raw reply related [flat|nested] 52+ messages in thread[parent not found: <20211126180101.27818-23-digetx@gmail.com>]
[parent not found: <20211126180101.27818-9-digetx@gmail.com>]