提交 48b73970 编写于 作者: H Huacai Chen 提交者: Hongchen Zhang

LoongArch: Cleanup reset routines with new API

mainline inclusion
from mainline-v6.0-rc3
commit da48b67c
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I5OHOB
CVE: NA

--------------------------------

Cleanup reset routines by using new do_kernel_power_off() instead of old
pm_power_off(), and then simplify the whole file (reset.c) organization
by inlining some functions. This cleanup also fix a poweroff error if EFI
runtime is disabled.
Signed-off-by: NHuacai Chen <chenhuacai@loongson.cn>
上级 cc72b92e
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (C) 2020-2022 Loongson Technology Corporation Limited
*/
#ifndef _ASM_REBOOT_H
#define _ASM_REBOOT_H
extern void (*pm_restart)(void);
#endif /* _ASM_REBOOT_H */
...@@ -15,10 +15,16 @@ ...@@ -15,10 +15,16 @@
#include <acpi/reboot.h> #include <acpi/reboot.h>
#include <asm/idle.h> #include <asm/idle.h>
#include <asm/loongarch.h> #include <asm/loongarch.h>
#include <asm/reboot.h>
static void default_halt(void) void (*pm_power_off)(void);
EXPORT_SYMBOL(pm_power_off);
void machine_halt(void)
{ {
#ifdef CONFIG_SMP
preempt_disable();
smp_send_stop();
#endif
local_irq_disable(); local_irq_disable();
clear_csr_ecfg(ECFG0_IM); clear_csr_ecfg(ECFG0_IM);
...@@ -30,8 +36,13 @@ static void default_halt(void) ...@@ -30,8 +36,13 @@ static void default_halt(void)
} }
} }
static void default_poweroff(void) void machine_power_off(void)
{ {
#ifdef CONFIG_SMP
preempt_disable();
smp_send_stop();
#endif
#ifdef CONFIG_EFI #ifdef CONFIG_EFI
efi.reset_system(EFI_RESET_SHUTDOWN, EFI_SUCCESS, 0, NULL); efi.reset_system(EFI_RESET_SHUTDOWN, EFI_SUCCESS, 0, NULL);
#endif #endif
...@@ -40,8 +51,13 @@ static void default_poweroff(void) ...@@ -40,8 +51,13 @@ static void default_poweroff(void)
} }
} }
static void default_restart(void) void machine_restart(char *command)
{ {
#ifdef CONFIG_SMP
preempt_disable();
smp_send_stop();
#endif
do_kernel_restart(command);
#ifdef CONFIG_EFI #ifdef CONFIG_EFI
if (efi_capsule_pending(NULL)) if (efi_capsule_pending(NULL))
efi_reboot(REBOOT_WARM, NULL); efi_reboot(REBOOT_WARM, NULL);
...@@ -55,47 +71,3 @@ static void default_restart(void) ...@@ -55,47 +71,3 @@ static void default_restart(void)
__arch_cpu_idle(); __arch_cpu_idle();
} }
} }
void (*pm_restart)(void);
EXPORT_SYMBOL(pm_restart);
void (*pm_power_off)(void);
EXPORT_SYMBOL(pm_power_off);
void machine_halt(void)
{
#ifdef CONFIG_SMP
preempt_disable();
smp_send_stop();
#endif
default_halt();
}
void machine_power_off(void)
{
#ifdef CONFIG_SMP
preempt_disable();
smp_send_stop();
#endif
pm_power_off();
}
void machine_restart(char *command)
{
#ifdef CONFIG_SMP
preempt_disable();
smp_send_stop();
#endif
do_kernel_restart(command);
pm_restart();
}
static int __init loongarch_reboot_setup(void)
{
pm_restart = default_restart;
pm_power_off = default_poweroff;
return 0;
}
arch_initcall(loongarch_reboot_setup);
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册