Skip to content

Commit f2928e2

Browse files
xnoxpalmer-dabbelt
authored andcommitted
riscv: set default pm_power_off to NULL
Set pm_power_off to NULL like on all other architectures, check if it is set in machine_halt() and machine_power_off() and fallback to default_power_off if no other power driver got registered. This brings riscv architecture inline with all other architectures, and allows to reuse exiting power drivers unmodified. Kernels without legacy SBI v0.1 extensions (CONFIG_RISCV_SBI_V01 is not set), do not set pm_power_off to sbi_shutdown(). There is no support for SBI v0.3 system reset extension either. This prevents using gpio_poweroff on SiFive HiFive Unmatched. Tested on SiFive HiFive unmatched, with a dtb specifying gpio-poweroff node and kernel complied without CONFIG_RISCV_SBI_V01. BugLink: https://bugs.launchpad.net/bugs/1942806 Signed-off-by: Dimitri John Ledkov <[email protected]> Reviewed-by: Anup Patel <[email protected]> Tested-by: Ron Economos <[email protected]> Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent dffe11e commit f2928e2

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

arch/riscv/kernel/reset.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ static void default_power_off(void)
1212
wait_for_interrupt();
1313
}
1414

15-
void (*pm_power_off)(void) = default_power_off;
15+
void (*pm_power_off)(void) = NULL;
1616
EXPORT_SYMBOL(pm_power_off);
1717

1818
void machine_restart(char *cmd)
@@ -23,10 +23,16 @@ void machine_restart(char *cmd)
2323

2424
void machine_halt(void)
2525
{
26-
pm_power_off();
26+
if (pm_power_off != NULL)
27+
pm_power_off();
28+
else
29+
default_power_off();
2730
}
2831

2932
void machine_power_off(void)
3033
{
31-
pm_power_off();
34+
if (pm_power_off != NULL)
35+
pm_power_off();
36+
else
37+
default_power_off();
3238
}

0 commit comments

Comments
 (0)