Offering: HULK hulk inclusion category: bugfix bugzilla: https://atomgit.com/openeuler/kernel/issues/8325 -------------------------------- Add sdei event status check in sdei pm notifier, If event is already unregistered, don't do disable/enable in pm notifier. In this way, we can prevent incorrect state transitions, e.g., disabling or enabling after unregistering. Fixes: c8f96adca7fa ("arm64/watchdog: fix watchdog failure in low power scenarios") Signed-off-by: Bowen You <youbowen2@huawei.com> --- arch/arm64/kernel/watchdog_sdei.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/arch/arm64/kernel/watchdog_sdei.c b/arch/arm64/kernel/watchdog_sdei.c index 9d63bb063718..c12b3552f68e 100644 --- a/arch/arm64/kernel/watchdog_sdei.c +++ b/arch/arm64/kernel/watchdog_sdei.c @@ -114,9 +114,27 @@ static int sdei_watchdog_pm_notifier(struct notifier_block *nb, unsigned long action, void *data) { int rv = 0; + u64 result; WARN_ON_ONCE(preemptible()); + /* + * Judge event status before disable or enable to prevent + * incorrect state transitions, e.g., disabling after + * unregistering. + */ + rv = sdei_api_event_status(sdei_watchdog_event_num, &result); + if (rv) + goto error; + if (!result) + goto success; + + /* + * After powering on/off the LPI (Low Power Idle), + * the enable function must be called to enable the + * EL3 Secure Timer, ensuring proper handling of + * secure timer functionality. + */ switch (action) { case CPU_PM_ENTER: if (per_cpu(sdei_usr_en, smp_processor_id())) @@ -131,9 +149,10 @@ static int sdei_watchdog_pm_notifier(struct notifier_block *nb, return NOTIFY_DONE; } +error: if (rv) return notifier_from_errno(rv); - +success: return NOTIFY_OK; } -- 2.34.1