Skip to contentSkip to conversation

power: suspend: Add suspend timeout handler

PATCH New [email protected] 1 participant 1 message Oct 16, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 power: suspend: Add suspend timeout handler

Quoted 80 lines
Quoted 6 lines · On Fri, Oct 16, 2020 at 3:22 PM <[email protected]> wrote:
Quoted 4 lines

Thank you Rafael's promptly response.

Quoted 1 line

On Fri, Oct 16, 2020 at 5:51 AM Joseph Jang <[email protected]>

Quoted 4 lines · wrote:
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

From: josephjang <[email protected]>

Add suspend timeout handler to prevent device stuck during

suspend/

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

resume process. Suspend timeout handler will dump disk sleep task at first round timeout and trigger kernel panic at second round

timeout.

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

The default timer for each round is 30 seconds.

Note: Can use following command to simulate suspend hang for

testing.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

adb shell echo 1 > /sys/power/pm_hang
adb shell echo mem > /sys/power/state

---
 include/linux/console.h |   1 +
 kernel/power/Kconfig    |   9 +++
 kernel/power/main.c     |  66 ++++++++++++++++
 kernel/power/suspend.c  | 162  

++++++++++++++++++++++++++++++++++++++++

Quoted 23 lines
Quoted 23 lines
Quoted 23 lines
Quoted 23 lines
 kernel/printk/printk.c  |   5 ++
 5 files changed, 243 insertions(+)
include/linux/console.h +1 -0
index 0670d3491e0e..ac468c602c0b 100644
@@ -192,6 +192,7 @@ static inline void console_sysfs_notify(void)
 { }
 #endif
 extern bool console_suspend_enabled;
+extern int is_console_suspended(void);
 
 /* Suspend and resume console messages over PM events */
 extern void suspend_console(void);
kernel/power/Kconfig +0 -0
index a7320f07689d..52b7a181b6d8 100644
@@ -207,6 +207,15 @@ config PM_SLEEP_DEBUG
        def_bool y
        depends on PM_DEBUG && PM_SLEEP
 
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

kernel/power/Kconfig config PM_SLEEP_DEBUG · line 214

Quoted 5 lines
kernel/power/Kconfig +5 -0
+config PM_SLEEP_MONITOR
+       bool "Linux kernel suspend/resume process monitor"
+       depends on PM_SLEEP
+       help
+       This option will enable suspend/resume monitor to prevent  

device

Quoted 1 line
Quoted 1 line
Quoted 1 line

kernel/power/Kconfig config PM_SLEEP_DEBUG · line 215

Quoted 1 line
kernel/power/Kconfig +1 -0
+       stuck during suspend/resume process. Suspend timeout  

handler

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

will

Quoted 1 line
kernel/power/Kconfig +1 -0
+       dump disk sleep task at first round timeout and trigger  

kernel

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

panic

Quoted 1 line
kernel/power/Kconfig +1 -0
+       at second round timeout. The default timer for each round  

is 30

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

seconds.

kernel/power/Kconfig config PM_SLEEP_DEBUG · line 218

Quoted 1 line
kernel/power/Kconfig +1 -0
+

The facility associated with the Kconfig entry right below is

supposed

Quoted 10 lines
Quoted 10 lines
Quoted 9 lines

to do exactly the same thing.

What's the reason to add another one? What is missing?

Quoted 3 lines
kernel/power/Kconfig +0 -0
 config DPM_WATCHDOG
        bool "Device suspend/resume watchdog"
        depends on PM_DEBUG && PSTORE && EXPERT
Quoted 10 lines
Quoted 6 lines
Quoted 2 lines

Because we found some suspend hand issue that cannot be detected by "CONFIG_DPM_WATCHDOG" (which is focus on device PM).

What's that issue?

Quoted 1 line

Our suspend timeout monitor can cover PM core and Device PM hang

issues.

Quoted 3 lines

Then I'd suggest to extend the existing watchdog instead of adding a whole new implementation.

Since kernel/power/suspend.c doesn't need "struct device *dev" like following. Can we create a new suspend_timer to cover PM core and Device PM hang issues?

/**
* dpm_watchdog_set - Enable pm watchdog for given device.
* @wd: Watchdog. Must be allocated on the stack.
* @dev: Device to handle.
*/
static void dpm_watchdog_set(struct dpm_watchdog *wd, struct device *dev)

{
	struct timer_list *timer = &wd->timer;

	wd->dev = dev;
	wd->tsk = current;

...

Thank you,
Joseph.