Skip to contentSkip to conversation

ARM/arm64: arm_pm_restart removal

PATCH In review Thierry Reding 6 participants 16 messages Oct 15, 2019 – Jun 3, 2021 1 message not in the archive

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

cover ARM/arm64: arm_pm_restart removal

From: Thierry Reding <[email protected]>

Hi Russell, ARM SoC maintainers,

here's the full set of patches that remove arm_pm_restart as discussed earlier. There's some background on the series in this thread:

	https://lore.kernel.org/linux-arm-kernel/[email protected]/

I also have a set of patches that build on top of this and try to add something slightly more formal by adding a power/reset framework that driver can register with. If we can get this series merged, I'll find some time to refresh those patches and send out for review again.

Thierry

Guenter Roeck (6):
ARM: prima2: Register with kernel restart handler
ARM: xen: Register with kernel restart handler
drivers: firmware: psci: Register with kernel restart handler
ARM: Register with kernel restart handler
ARM64: Remove arm_pm_restart()
ARM: Remove arm_pm_restart()

 arch/arm/include/asm/system_misc.h   |  1 -
 arch/arm/kernel/reboot.c             |  6 +-----
 arch/arm/kernel/setup.c              | 20 ++++++++++++++++++--
 arch/arm/mach-prima2/rstc.c          | 11 +++++++++--
 arch/arm/xen/enlighten.c             | 12 ++++++++++--
 arch/arm64/include/asm/system_misc.h |  2 --
 arch/arm64/kernel/process.c          |  7 +------
 drivers/firmware/psci/psci.c         | 12 ++++++++++--
 8 files changed, 49 insertions(+), 22 deletions(-)
Signature · 1 line
2.23.0
#1 lore raw

PATCH 1/6 ARM: prima2: Register with kernel restart handler

From: Guenter Roeck <[email protected]>

Register with kernel restart handler instead of setting arm_pm_restart directly. By doing this, the prima2 reset handler can be prioritized among other restart methods available on a particular board.

Select a high priority of 192 since the original code overwrites the default arm restart handler.

---
 arch/arm/mach-prima2/rstc.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
arch/arm/mach-prima2/rstc.c +9 -2
index 9d56606ac87f..825dd5fcc37b 100644
@@ -64,11 +64,18 @@ static struct reset_controller_dev sirfsoc_reset_controller = {
 
 #define SIRFSOC_SYS_RST_BIT  BIT(31)
 
-static void sirfsoc_restart(enum reboot_mode mode, const char *cmd)
+static int sirfsoc_restart(struct notifier_block *nb, unsigned long action,
+			   void *data)
 {
 	writel(SIRFSOC_SYS_RST_BIT, sirfsoc_rstc_base);
+	return NOTIFY_DONE;
 }
 
+static struct notifier_block sirfsoc_restart_nb = {
+	.notifier_call  = sirfsoc_restart,
+	.priority       = 192,
+};
+
 static int sirfsoc_rstc_probe(struct platform_device *pdev)
 {
 	struct device_node *np = pdev->dev.of_node;
@@ -79,7 +86,7 @@ static int sirfsoc_rstc_probe(struct platform_device *pdev)
 	}
 
 	sirfsoc_reset_controller.of_node = np;
-	arm_pm_restart = sirfsoc_restart;
+	register_restart_handler(&sirfsoc_restart_nb);
 
 	if (IS_ENABLED(CONFIG_RESET_CONTROLLER))
 		reset_controller_register(&sirfsoc_reset_controller);
Signature · 1 line
2.23.0
#2 lore raw

PATCH 2/6 ARM: xen: Register with kernel restart handler

In reply to Thierry Reding

From: Guenter Roeck <[email protected]>

Register with kernel restart handler instead of setting arm_pm_restart directly.

Select a high priority of 192 to ensure that default restart handlers are replaced if Xen is running.

---
 arch/arm/xen/enlighten.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
arch/arm/xen/enlighten.c +10 -2
index 1e57692552d9..eb0a0edb9909 100644
@@ -30,6 +30,7 @@
 #include <linux/cpu.h>
 #include <linux/console.h>
 #include <linux/pvclock_gtod.h>
+#include <linux/reboot.h>
 #include <linux/time64.h>
 #include <linux/timekeeping.h>
 #include <linux/timekeeper_internal.h>
@@ -181,11 +182,18 @@ void xen_reboot(int reason)
 	BUG_ON(rc);
 }
 
-static void xen_restart(enum reboot_mode reboot_mode, const char *cmd)
+static int xen_restart(struct notifier_block *nb, unsigned long action,
+		       void *data)
 {
 	xen_reboot(SHUTDOWN_reboot);
+
+	return NOTIFY_DONE;
 }
 
+static struct notifier_block xen_restart_nb = {
+	.notifier_call = xen_restart,
+	.priority = 192,
+};
 
 static void xen_power_off(void)
 {
@@ -406,7 +414,7 @@ static int __init xen_pm_init(void)
 		return -ENODEV;
 
 	pm_power_off = xen_power_off;
-	arm_pm_restart = xen_restart;
+	register_restart_handler(&xen_restart_nb);
 	if (!xen_initial_domain()) {
 		struct timespec64 ts;
 		xen_read_wallclock(&ts);
Signature · 1 line
2.23.0

A message that is not in the archive (sent off-list or not yet received): CAF2Aj3hbW7+pNp+_jnMVL8zeSxAvSbV1ZFZ_4PAUj6J0TxMk7g@mail.gmail.com

#4 lore raw

Re: [PATCH 2/6] ARM: xen: Register with kernel restart handler

Quoted 21 lines · Lee Jones
Quoted 8 lines · Thierry Reding

From: Guenter Roeck <[email protected]>

Register with kernel restart handler instead of setting arm_pm_restart directly.

Select a high priority of 192 to ensure that default restart handlers are replaced if Xen is running.

Quoted 9 lines
---
 arch/arm/xen/enlighten.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
Quoted 7 lines

This patch does appear to be useful.

Is this just being solved in downstream trees at the moment?

It would be nice if we could relinquish people of this burden and get it into Mainline finally.

There must have been half a dozen attempts to send this patch series upstream. I have tried, and others have tried. Each attempt failed with someone else objecting for non-technical reasons (such as "we need more reviews") or no reaction at all, and maintainers just don't pick it up.

So, yes, this patch series can only be found in downstream trees, and it seems pointless to submit it yet again.

Guenter

#5 lore raw

Re: [PATCH 2/6] ARM: xen: Register with kernel restart handler

Quoted 26 lines · Guenter Roeck
Quoted 25 lines · Lee Jones
Quoted 8 lines · Thierry Reding

From: Guenter Roeck <[email protected]>

Register with kernel restart handler instead of setting arm_pm_restart directly.

Select a high priority of 192 to ensure that default restart handlers are replaced if Xen is running.

Quoted 9 lines
---
 arch/arm/xen/enlighten.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

This patch does appear to be useful.

Is this just being solved in downstream trees at the moment?

Quoted 8 lines
Quoted 3 lines

It would be nice if we could relinquish people of this burden and get it into Mainline finally.

There must have been half a dozen attempts to send this patch series upstream. I have tried, and others have tried. Each attempt failed with someone else objecting for non-technical reasons (such as "we need more reviews") or no reaction at all, and maintainers just don't pick it up.

Looking at the *-by tag list above, I think we have enough quality reviews to take this forward.

Quoted 2 lines

So, yes, this patch series can only be found in downstream trees, and it seems pointless to submit it yet again.

IMHO, it's unfair to burden multiple downstream trees with this purely due to poor or nervy maintainership. Functionality as broadly useful as this should be merged and maintained in Mainline.

OOI, who is blocking? As I see it, we have 2 of the key maintainers in the *-by list. With those on-board, it's difficult to envisage what the problem is.

Signature · 4 lines
Lee Jones [李琼斯]
Senior Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog
#6 lore raw

Re: [PATCH 2/6] ARM: xen: Register with kernel restart handler

Quoted 39 lines · Lee Jones
Quoted 25 lines · Guenter Roeck
Quoted 24 lines · Lee Jones
Quoted 8 lines · Thierry Reding

From: Guenter Roeck <[email protected]>

Register with kernel restart handler instead of setting arm_pm_restart directly.

Select a high priority of 192 to ensure that default restart handlers are replaced if Xen is running.

Quoted 9 lines
---
 arch/arm/xen/enlighten.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

This patch does appear to be useful.

Is this just being solved in downstream trees at the moment?

Quoted 7 lines
Quoted 3 lines

It would be nice if we could relinquish people of this burden and get it into Mainline finally.

There must have been half a dozen attempts to send this patch series upstream. I have tried, and others have tried. Each attempt failed with someone else objecting for non-technical reasons (such as "we need more reviews") or no reaction at all, and maintainers just don't pick it up.

Looking at the *-by tag list above, I think we have enough quality reviews to take this forward.

Quoted 2 lines

So, yes, this patch series can only be found in downstream trees, and it seems pointless to submit it yet again.

Quoted 7 lines

IMHO, it's unfair to burden multiple downstream trees with this purely due to poor or nervy maintainership. Functionality as broadly useful as this should be merged and maintained in Mainline.

OOI, who is blocking? As I see it, we have 2 of the key maintainers in the *-by list. With those on-board, it's difficult to envisage what the problem is.

Stefano (who is ARM Xen maintainer) left Citrix a while ago. He is at [email protected] (which I added to the CC line).

-boris

#7 lore raw

Re: [PATCH 2/6] ARM: xen: Register with kernel restart handler

Quoted 44 lines · Boris Ostrovsky
Quoted 43 lines · Lee Jones
Quoted 25 lines · Guenter Roeck
Quoted 24 lines · Lee Jones
Quoted 8 lines · Thierry Reding

From: Guenter Roeck <[email protected]>

Register with kernel restart handler instead of setting arm_pm_restart directly.

Select a high priority of 192 to ensure that default restart handlers are replaced if Xen is running.

Quoted 9 lines
---
 arch/arm/xen/enlighten.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

This patch does appear to be useful.

Is this just being solved in downstream trees at the moment?

Quoted 7 lines
Quoted 3 lines

It would be nice if we could relinquish people of this burden and get it into Mainline finally.

There must have been half a dozen attempts to send this patch series upstream. I have tried, and others have tried. Each attempt failed with someone else objecting for non-technical reasons (such as "we need more reviews") or no reaction at all, and maintainers just don't pick it up.

Looking at the *-by tag list above, I think we have enough quality reviews to take this forward.

Quoted 2 lines

So, yes, this patch series can only be found in downstream trees, and it seems pointless to submit it yet again.

IMHO, it's unfair to burden multiple downstream trees with this purely due to poor or nervy maintainership. Functionality as broadly useful as this should be merged and maintained in Mainline.

Quoted 6 lines
Quoted 3 lines

OOI, who is blocking? As I see it, we have 2 of the key maintainers in the *-by list. With those on-board, it's difficult to envisage what the problem is.

Stefano (who is ARM Xen maintainer) left Citrix a while ago. He is at [email protected] (which I added to the CC line).

Stefano already reviewed this patch, which is part of a larger series that primarily touches 32-bit ARM code, but also touches 64-bit ARM code as well.

As I said in my previous reply, I don't see that there's any problem with getting these patches merged had the usual processes been followed - either ending up in the patch system, or the pull request being sent to me directly.

Sadly, the pull request was sent to the arm-soc people excluding me, I happened to notice it and requested to see the patches that were being asked to be pulled (since I probably couldn't find them)... and it then took two further weeks before the patches were posted, which I then missed amongst all the other email.

It's a process failure and unfortunate timing rather than anything malicious.

Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
#8 lore raw

Re: [PATCH 2/6] ARM: xen: Register with kernel restart handler

Quoted 61 lines · Russell King (Oracle)
Quoted 44 lines · Boris Ostrovsky
Quoted 43 lines · Lee Jones
Quoted 25 lines · Guenter Roeck
Quoted 24 lines · Lee Jones
Quoted 8 lines · Thierry Reding

From: Guenter Roeck <[email protected]>

Register with kernel restart handler instead of setting arm_pm_restart directly.

Select a high priority of 192 to ensure that default restart handlers are replaced if Xen is running.

Quoted 9 lines
---
 arch/arm/xen/enlighten.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

This patch does appear to be useful.

Is this just being solved in downstream trees at the moment?

Quoted 7 lines
Quoted 3 lines

It would be nice if we could relinquish people of this burden and get it into Mainline finally.

There must have been half a dozen attempts to send this patch series upstream. I have tried, and others have tried. Each attempt failed with someone else objecting for non-technical reasons (such as "we need more reviews") or no reaction at all, and maintainers just don't pick it up.

Looking at the *-by tag list above, I think we have enough quality reviews to take this forward.

Quoted 2 lines

So, yes, this patch series can only be found in downstream trees, and it seems pointless to submit it yet again.

IMHO, it's unfair to burden multiple downstream trees with this purely due to poor or nervy maintainership. Functionality as broadly useful as this should be merged and maintained in Mainline.

Quoted 6 lines
Quoted 3 lines

OOI, who is blocking? As I see it, we have 2 of the key maintainers in the *-by list. With those on-board, it's difficult to envisage what the problem is.

Stefano (who is ARM Xen maintainer) left Citrix a while ago. He is at [email protected] (which I added to the CC line).

Stefano already reviewed this patch, which is part of a larger series that primarily touches 32-bit ARM code, but also touches 64-bit ARM code as well.

As I said in my previous reply, I don't see that there's any problem with getting these patches merged had the usual processes been followed - either ending up in the patch system, or the pull request being sent to me directly.

Quoted 8 lines

Sadly, the pull request was sent to the arm-soc people excluding me, I happened to notice it and requested to see the patches that were being asked to be pulled (since I probably couldn't find them)... and it then took two further weeks before the patches were posted, which I then missed amongst all the other email.

It's a process failure and unfortunate timing rather than anything malicious.

Understood.

Is there anything I can do to help this forward?

I can either collect and re-submit the patches to the MLs if that makes people's lives any easier. Or if one of the original submitters wish to retain responsibility, I have no qualms with that either.

Signature · 4 lines
Lee Jones [李琼斯]
Senior Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog
#9 lore raw

Re: [PATCH 2/6] ARM: xen: Register with kernel restart handler

Quoted 72 lines · Lee Jones
Quoted 61 lines · Russell King (Oracle)
Quoted 44 lines · Boris Ostrovsky
Quoted 43 lines · Lee Jones
Quoted 25 lines · Guenter Roeck
Quoted 24 lines · Lee Jones
Quoted 8 lines · Thierry Reding

From: Guenter Roeck <[email protected]>

Register with kernel restart handler instead of setting arm_pm_restart directly.

Select a high priority of 192 to ensure that default restart handlers are replaced if Xen is running.

Quoted 9 lines
---
 arch/arm/xen/enlighten.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

This patch does appear to be useful.

Is this just being solved in downstream trees at the moment?

Quoted 7 lines
Quoted 3 lines

It would be nice if we could relinquish people of this burden and get it into Mainline finally.

There must have been half a dozen attempts to send this patch series upstream. I have tried, and others have tried. Each attempt failed with someone else objecting for non-technical reasons (such as "we need more reviews") or no reaction at all, and maintainers just don't pick it up.

Looking at the *-by tag list above, I think we have enough quality reviews to take this forward.

Quoted 2 lines

So, yes, this patch series can only be found in downstream trees, and it seems pointless to submit it yet again.

IMHO, it's unfair to burden multiple downstream trees with this purely due to poor or nervy maintainership. Functionality as broadly useful as this should be merged and maintained in Mainline.

Quoted 6 lines
Quoted 3 lines

OOI, who is blocking? As I see it, we have 2 of the key maintainers in the *-by list. With those on-board, it's difficult to envisage what the problem is.

Stefano (who is ARM Xen maintainer) left Citrix a while ago. He is at [email protected] (which I added to the CC line).

Stefano already reviewed this patch, which is part of a larger series that primarily touches 32-bit ARM code, but also touches 64-bit ARM code as well.

As I said in my previous reply, I don't see that there's any problem with getting these patches merged had the usual processes been followed - either ending up in the patch system, or the pull request being sent to me directly.

Quoted 8 lines

Sadly, the pull request was sent to the arm-soc people excluding me, I happened to notice it and requested to see the patches that were being asked to be pulled (since I probably couldn't find them)... and it then took two further weeks before the patches were posted, which I then missed amongst all the other email.

It's a process failure and unfortunate timing rather than anything malicious.

Quoted 7 lines

Understood.

Is there anything I can do to help this forward?

I can either collect and re-submit the patches to the MLs if that makes people's lives any easier. Or if one of the original submitters wish to retain responsibility, I have no qualms with that either.

I think at this point the usual applies - to make sure that they still apply to current kernels and don't cause any regressions. I would hope there won't be anything significant to invalidate the reviews already given. If that's the case, it should just be a matter of someone putting them in the patch system or send me a pull request.

Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
#10 lore raw

Re: [PATCH 2/6] ARM: xen: Register with kernel restart handler

In reply to Lee Jones
Quoted 72 lines · Lee Jones
Quoted 61 lines · Russell King (Oracle)
Quoted 44 lines · Boris Ostrovsky
Quoted 43 lines · Lee Jones
Quoted 25 lines · Guenter Roeck
Quoted 24 lines · Lee Jones
Quoted 8 lines · Thierry Reding

From: Guenter Roeck <[email protected]>

Register with kernel restart handler instead of setting arm_pm_restart directly.

Select a high priority of 192 to ensure that default restart handlers are replaced if Xen is running.

Quoted 9 lines
---
 arch/arm/xen/enlighten.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

This patch does appear to be useful.

Is this just being solved in downstream trees at the moment?

Quoted 7 lines
Quoted 3 lines

It would be nice if we could relinquish people of this burden and get it into Mainline finally.

There must have been half a dozen attempts to send this patch series upstream. I have tried, and others have tried. Each attempt failed with someone else objecting for non-technical reasons (such as "we need more reviews") or no reaction at all, and maintainers just don't pick it up.

Looking at the *-by tag list above, I think we have enough quality reviews to take this forward.

Quoted 2 lines

So, yes, this patch series can only be found in downstream trees, and it seems pointless to submit it yet again.

IMHO, it's unfair to burden multiple downstream trees with this purely due to poor or nervy maintainership. Functionality as broadly useful as this should be merged and maintained in Mainline.

Quoted 6 lines
Quoted 3 lines

OOI, who is blocking? As I see it, we have 2 of the key maintainers in the *-by list. With those on-board, it's difficult to envisage what the problem is.

Stefano (who is ARM Xen maintainer) left Citrix a while ago. He is at [email protected] (which I added to the CC line).

Stefano already reviewed this patch, which is part of a larger series that primarily touches 32-bit ARM code, but also touches 64-bit ARM code as well.

As I said in my previous reply, I don't see that there's any problem with getting these patches merged had the usual processes been followed - either ending up in the patch system, or the pull request being sent to me directly.

Quoted 8 lines

Sadly, the pull request was sent to the arm-soc people excluding me, I happened to notice it and requested to see the patches that were being asked to be pulled (since I probably couldn't find them)... and it then took two further weeks before the patches were posted, which I then missed amongst all the other email.

It's a process failure and unfortunate timing rather than anything malicious.

Quoted 7 lines

Understood.

Is there anything I can do to help this forward?

I can either collect and re-submit the patches to the MLs if that makes people's lives any easier. Or if one of the original submitters wish to retain responsibility, I have no qualms with that either.

I had stumbled across these patches from Guenter when I was looking to solve a reboot/power-off issue on one of the boards that I was working on. This was supposed to be preparatory work to get rid of the global function pointers that drivers are simply overwriting, and the goal had been to add a "system power" framework that would allow drivers to register a chip structure to provide a bit more "formality" than overwriting function pointers or registering notifier callbacks.

There ended up not being any interest in such a subsystem, so I wanted to at least get this prep work in, because it is at least a bit of an improvement.

I vaguely recall that Arnd or perhaps Olof had mentioned that they'd pull these patches, but the timing was bad, so they asked me to remind them after the merge window. By the time we had gotten through the merge window, I probably had gotten sidetracked and forgot...

Feel free to give this a shot. This series itself is still useful, in my opinion.

Thierry

#11 lore raw

Re: [PATCH 2/6] ARM: xen: Register with kernel restart handler

In reply to Guenter Roeck
Quoted 30 lines · Guenter Roeck
Quoted 21 lines · Lee Jones
Quoted 8 lines · Thierry Reding

From: Guenter Roeck <[email protected]>

Register with kernel restart handler instead of setting arm_pm_restart directly.

Select a high priority of 192 to ensure that default restart handlers are replaced if Xen is running.

Quoted 9 lines
---
 arch/arm/xen/enlighten.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
Quoted 7 lines

This patch does appear to be useful.

Is this just being solved in downstream trees at the moment?

It would be nice if we could relinquish people of this burden and get it into Mainline finally.

Quoted 7 lines

There must have been half a dozen attempts to send this patch series upstream. I have tried, and others have tried. Each attempt failed with someone else objecting for non-technical reasons (such as "we need more reviews") or no reaction at all, and maintainers just don't pick it up.

So, yes, this patch series can only be found in downstream trees, and it seems pointless to submit it yet again.

It has plenty of reviews and acks, so that's not the problem. If you look back at the 2019 attempt:

1) there was a pull request sent on the 2 October 2019 to the arm soc guys to merge a series that quite obviously is outside of their remit as it touches mostly ARM core code - it should have been sent to me but wasn't, not even as a Cc.

2) I raised that issue, and as I could find no trace of the patches, I asked for the to be posted - which they were, eventually, two weeks later. It looks like I completely missed the patches amongst all the other email I don't bother to read anymore though. In any case, the pull request by that time would have been completely forgotten about.

And that's where it ended - no apparent follow-ups until now.

*Shrug*.

So in summary, I was expected to notice the patches amongst all the other email, and then remember that there was a pull request that wasn't even addressed to me...

Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
#12 lore raw

PATCH 3/6 drivers: firmware: psci: Register with kernel restart handler

In reply to Thierry Reding

From: Guenter Roeck <[email protected]>

Register with kernel restart handler instead of setting arm_pm_restart directly. This enables support for replacing the PSCI restart handler with a different handler if necessary for a specific board.

Select a priority of 129 to indicate a higher than default priority, but keep it as low as possible since PSCI reset is known to fail on some boards.

---
 drivers/firmware/psci/psci.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/firmware/psci/psci.c +10 -2
index 84f4ff351c62..a41c6ba043a2 100644
@@ -250,7 +250,8 @@ static int get_set_conduit_method(struct device_node *np)
 	return 0;
 }
 
-static void psci_sys_reset(enum reboot_mode reboot_mode, const char *cmd)
+static int psci_sys_reset(struct notifier_block *nb, unsigned long action,
+			  void *data)
 {
 	if ((reboot_mode == REBOOT_WARM || reboot_mode == REBOOT_SOFT) &&
 	    psci_system_reset2_supported) {
@@ -263,8 +264,15 @@ static void psci_sys_reset(enum reboot_mode reboot_mode, const char *cmd)
 	} else {
 		invoke_psci_fn(PSCI_0_2_FN_SYSTEM_RESET, 0, 0, 0);
 	}
+
+	return NOTIFY_DONE;
 }
 
+static struct notifier_block psci_sys_reset_nb = {
+	.notifier_call = psci_sys_reset,
+	.priority = 129,
+};
+
 static void psci_sys_poweroff(void)
 {
 	invoke_psci_fn(PSCI_0_2_FN_SYSTEM_OFF, 0, 0, 0);
@@ -431,7 +439,7 @@ static void __init psci_0_2_set_functions(void)
 
 	psci_ops.migrate_info_type = psci_migrate_info_type;
 
-	arm_pm_restart = psci_sys_reset;
+	register_restart_handler(&psci_sys_reset_nb);
 
 	pm_power_off = psci_sys_poweroff;
 }
Signature · 1 line
2.23.0
Reviewed-by on v1 3/6
#13 lore raw

Re: [PATCH 3/6] drivers: firmware: psci: Register with kernel restart handler

Quoted 10 lines · Thierry Reding

From: Guenter Roeck <[email protected]>

Register with kernel restart handler instead of setting arm_pm_restart directly. This enables support for replacing the PSCI restart handler with a different handler if necessary for a specific board.

Select a priority of 129 to indicate a higher than default priority, but keep it as low as possible since PSCI reset is known to fail on some boards.

Quoted 6 lines

Looks good to me! And helps also in my case, a board which has a broken PSCI reset capability.

--
Stefan

Quoted 44 lines
---
 drivers/firmware/psci/psci.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/firmware/psci/psci.c +9 -1
index 84f4ff351c62..a41c6ba043a2 100644
@@ -250,7 +250,8 @@ static int get_set_conduit_method(struct device_node *np)
 	return 0;
 }
 
-static void psci_sys_reset(enum reboot_mode reboot_mode, const char *cmd)
+static int psci_sys_reset(struct notifier_block *nb, unsigned long action,
+			  void *data)
 {
 	if ((reboot_mode == REBOOT_WARM || reboot_mode == REBOOT_SOFT) &&
 	    psci_system_reset2_supported) {
@@ -263,8 +264,15 @@ static void psci_sys_reset(enum reboot_mode
 reboot_mode, const char *cmd)
 	} else {
 		invoke_psci_fn(PSCI_0_2_FN_SYSTEM_RESET, 0, 0, 0);
 	}
+
+	return NOTIFY_DONE;
 }
 
+static struct notifier_block psci_sys_reset_nb = {
+	.notifier_call = psci_sys_reset,
+	.priority = 129,
+};
+
 static void psci_sys_poweroff(void)
 {
drivers/firmware/psci/psci.c +1 -1
 	invoke_psci_fn(PSCI_0_2_FN_SYSTEM_OFF, 0, 0, 0);
@@ -431,7 +439,7 @@ static void __init psci_0_2_set_functions(void)
 
 	psci_ops.migrate_info_type = psci_migrate_info_type;
 
-	arm_pm_restart = psci_sys_reset;
+	register_restart_handler(&psci_sys_reset_nb);
 
 	pm_power_off = psci_sys_poweroff;
 }
#14 lore raw

PATCH 4/6 ARM: Register with kernel restart handler

In reply to Thierry Reding

From: Guenter Roeck <[email protected]>

By making use of the kernel restart handler, board specific restart handlers can be prioritized amongst available mechanisms for a particular board or system.

Select the default priority of 128 to indicate that the restart callback in the machine description is the default restart mechanism.

---
 arch/arm/kernel/setup.c | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)
arch/arm/kernel/setup.c +18 -2
index d0a464e317ea..d403648195de 100644
@@ -1073,6 +1073,20 @@ void __init hyp_mode_check(void)
 #endif
 }
 
+static void (*__arm_pm_restart)(enum reboot_mode reboot_mode, const char *cmd);
+
+static int arm_restart(struct notifier_block *nb, unsigned long action,
+		       void *data)
+{
+	__arm_pm_restart(action, data);
+	return NOTIFY_DONE;
+}
+
+static struct notifier_block arm_restart_nb = {
+	.notifier_call = arm_restart,
+	.priority = 128,
+};
+
 void __init setup_arch(char **cmdline_p)
 {
 	const struct machine_desc *mdesc;
@@ -1132,8 +1146,10 @@ void __init setup_arch(char **cmdline_p)
 	paging_init(mdesc);
 	request_standard_resources(mdesc);
 
-	if (mdesc->restart)
-		arm_pm_restart = mdesc->restart;
+	if (mdesc->restart) {
+		__arm_pm_restart = mdesc->restart;
+		register_restart_handler(&arm_restart_nb);
+	}
 
 	unflatten_device_tree();
 
Signature · 1 line
2.23.0
#15 lore raw

PATCH 5/6 ARM64: Remove arm_pm_restart()

In reply to Thierry Reding

From: Guenter Roeck <[email protected]>

All users of arm_pm_restart() have been converted to use the kernel restart handler.

---
 arch/arm64/include/asm/system_misc.h | 2 --
 arch/arm64/kernel/process.c          | 7 +------
 2 files changed, 1 insertion(+), 8 deletions(-)
arch/arm64/include/asm/system_misc.h +0 -2
index 1ab63cfbbaf1..d02c5e5ea015 100644
@@ -32,8 +32,6 @@ void hook_debug_fault_code(int nr, int (*fn)(unsigned long, unsigned int,
 struct mm_struct;
 extern void __show_regs(struct pt_regs *);
 
-extern void (*arm_pm_restart)(enum reboot_mode reboot_mode, const char *cmd);
-
 #endif	/* __ASSEMBLY__ */
 
 #endif	/* __ASM_SYSTEM_MISC_H */
arch/arm64/kernel/process.c +1 -6
index a47462def04b..f11d2b261b4e 100644
@@ -64,8 +64,6 @@ EXPORT_SYMBOL(__stack_chk_guard);
 void (*pm_power_off)(void);
 EXPORT_SYMBOL_GPL(pm_power_off);
 
-void (*arm_pm_restart)(enum reboot_mode reboot_mode, const char *cmd);
-
 static void __cpu_do_idle(void)
 {
 	dsb(sy);
@@ -195,10 +193,7 @@ void machine_restart(char *cmd)
 		efi_reboot(reboot_mode, NULL);
 
 	/* Now call the architecture specific reboot code. */
-	if (arm_pm_restart)
-		arm_pm_restart(reboot_mode, cmd);
-	else
-		do_kernel_restart(cmd);
+	do_kernel_restart(cmd);
 
 	/*
 	 * Whoops - the architecture was unable to reboot.
Signature · 1 line
2.23.0
#16 lore raw

PATCH 6/6 ARM: Remove arm_pm_restart()

In reply to Thierry Reding

From: Guenter Roeck <[email protected]>

All users of arm_pm_restart() have been converted to use the kernel restart handler.

---
 arch/arm/include/asm/system_misc.h | 1 -
 arch/arm/kernel/reboot.c           | 6 +-----
 2 files changed, 1 insertion(+), 6 deletions(-)
arch/arm/include/asm/system_misc.h +0 -1
index 66f6a3ae68d2..98b37340376b 100644
@@ -13,7 +13,6 @@
 extern void cpu_init(void);
 
 void soft_restart(unsigned long);
-extern void (*arm_pm_restart)(enum reboot_mode reboot_mode, const char *cmd);
 extern void (*arm_pm_idle)(void);
 
 #ifdef CONFIG_HARDEN_BRANCH_PREDICTOR
arch/arm/kernel/reboot.c +1 -5
index bb18ed0539f4..1076b26aa699 100644
@@ -18,7 +18,6 @@ typedef void (*phys_reset_t)(unsigned long, bool);
 /*
  * Function pointers to optional machine specific functions
  */
-void (*arm_pm_restart)(enum reboot_mode reboot_mode, const char *cmd);
 void (*pm_power_off)(void);
 EXPORT_SYMBOL(pm_power_off);
 
@@ -138,10 +137,7 @@ void machine_restart(char *cmd)
 	local_irq_disable();
 	smp_send_stop();
 
-	if (arm_pm_restart)
-		arm_pm_restart(reboot_mode, cmd);
-	else
-		do_kernel_restart(cmd);
+	do_kernel_restart(cmd);
 
 	/* Give a grace period for failure to restart of 1s */
 	mdelay(1000);
Signature · 1 line
2.23.0