Skip to content

Commit 65392e2

Browse files
FlyGoatsmb49
authored andcommitted
MIPS: Loongson64: reset: Prioritise firmware service
BugLink: https://bugs.launchpad.net/bugs/2078428 commit 4e7ca0b upstream. We should always use firmware's poweroff & reboot service if it's available as firmware may need to perform more task than platform's syscon etc. However _machine_restart & poweroff hooks are registered at low priority, which means platform reboot driver can override them. Register firmware based reboot/poweroff implementation with register_sys_off_handler with appropriate priority so that they will be prioritised. Remove _machine_halt hook as it's deemed to be unnecessary. Cc: [email protected] Signed-off-by: Jiaxun Yang <[email protected]> Signed-off-by: Thomas Bogendoerfer <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]> Signed-off-by: Koichiro Den <[email protected]> Signed-off-by: Stefan Bader <[email protected]>
1 parent 44963ec commit 65392e2

File tree

1 file changed

+16
-22
lines changed

1 file changed

+16
-22
lines changed

arch/mips/loongson64/reset.c

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <linux/init.h>
1212
#include <linux/kexec.h>
1313
#include <linux/pm.h>
14+
#include <linux/reboot.h>
1415
#include <linux/slab.h>
1516

1617
#include <asm/bootinfo.h>
@@ -21,36 +22,21 @@
2122
#include <loongson.h>
2223
#include <boot_param.h>
2324

24-
static void loongson_restart(char *command)
25+
static int firmware_restart(struct sys_off_data *unusedd)
2526
{
2627

2728
void (*fw_restart)(void) = (void *)loongson_sysconf.restart_addr;
2829

2930
fw_restart();
30-
while (1) {
31-
if (cpu_wait)
32-
cpu_wait();
33-
}
31+
return NOTIFY_DONE;
3432
}
3533

36-
static void loongson_poweroff(void)
34+
static int firmware_poweroff(struct sys_off_data *unused)
3735
{
3836
void (*fw_poweroff)(void) = (void *)loongson_sysconf.poweroff_addr;
3937

4038
fw_poweroff();
41-
while (1) {
42-
if (cpu_wait)
43-
cpu_wait();
44-
}
45-
}
46-
47-
static void loongson_halt(void)
48-
{
49-
pr_notice("\n\n** You can safely turn off the power now **\n\n");
50-
while (1) {
51-
if (cpu_wait)
52-
cpu_wait();
53-
}
39+
return NOTIFY_DONE;
5440
}
5541

5642
#ifdef CONFIG_KEXEC
@@ -154,9 +140,17 @@ static void loongson_crash_shutdown(struct pt_regs *regs)
154140

155141
static int __init mips_reboot_setup(void)
156142
{
157-
_machine_restart = loongson_restart;
158-
_machine_halt = loongson_halt;
159-
pm_power_off = loongson_poweroff;
143+
if (loongson_sysconf.restart_addr) {
144+
register_sys_off_handler(SYS_OFF_MODE_RESTART,
145+
SYS_OFF_PRIO_FIRMWARE,
146+
firmware_restart, NULL);
147+
}
148+
149+
if (loongson_sysconf.poweroff_addr) {
150+
register_sys_off_handler(SYS_OFF_MODE_POWER_OFF,
151+
SYS_OFF_PRIO_FIRMWARE,
152+
firmware_poweroff, NULL);
153+
}
160154

161155
#ifdef CONFIG_KEXEC
162156
kexec_argv = kmalloc(KEXEC_ARGV_SIZE, GFP_KERNEL);

0 commit comments

Comments
 (0)