Skip to contentSkip to conversation

PM: dpm_watchdog: Improve DPM watchdog configurability

PATCH Superseded Tzung-Bi Shih 3 participants 16 messages Jun 8 – Jun 9

Subsystems (5)

v3 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v3 cover PM: dpm_watchdog: Improve DPM watchdog configurability

This series improves the configurability of the DPM watchdog.

Currently, the DPM watchdog timeouts are fixed at compile time, and the watchdog is always enabled if compiled in. Also, the module parameters defined in drivers/base/power/main.c use the generic and non-descriptive "main" prefix.

This series addresses these limitations.

Patch 1 renames the module parameter prefix for drivers/base/power/main.c from "main" to "power".

Patch 2 introduces the CONFIG_DPM_WATCHDOG_DEFAULT_ENABLED to allow the DPM watchdog to be disabled by default at compile time. It also exposes the "power.dpm_watchdog_enabled" module parameter to allow enabling/disabling the watchdog at boot time and runtime.

Patch 3 introduces sysctl knobs under /proc/sys/kernel/ to allow configuring the DPM watchdog timeouts at runtime.

---
v3:
- Address review comments on patch 2.

v2: https://lore.kernel.org/all/[email protected]
- Form a new series.

v1: Doesn't exist.

Tzung-Bi Shih (3):
PM: core: Rename module parameters prefix to "power"
PM: dpm_watchdog: Allow disabling DPM watchdog by default
PM: dpm_watchdog: Add sysctl interface for DPM watchdog timeouts

 .../admin-guide/kernel-parameters.txt         |  8 ++
 drivers/base/power/main.c                     | 75 ++++++++++++++++++-
 kernel/power/Kconfig                          | 10 +++
 3 files changed, 89 insertions(+), 4 deletions(-)
Signature · 1 line
2.54.0.1099.g489fc7bff1-goog
#1 lore raw

PATCH v3 1/3 PM: core: Rename module parameters prefix to "power"

Currently, the module parameters defined in drivers/base/power/main.c use the default prefix "main" (derived from the filename). The prefix "main" is too generic and non-descriptive for power management parameters.

Redefine MODULE_PARAM_PREFIX to "power." at the beginning of the file to group the module parameters under the "power" namespace instead. This makes the parameters more descriptive.

---
v3:
- No changes.

v2: https://lore.kernel.org/all/[email protected]
- New to the series.

v1: Doesn't exist.

 drivers/base/power/main.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/base/power/main.c +3 -0
index ed48c292f575..cd864f3a2799 100644
@@ -40,6 +40,9 @@
 #include "../base.h"
 #include "power.h"
 
+#undef MODULE_PARAM_PREFIX
+#define MODULE_PARAM_PREFIX "power."
+
 typedef int (*pm_callback_t)(struct device *);
 
 /*
Signature · 1 line
2.54.0.1099.g489fc7bff1-goog
#2 lore raw

Re: [PATCH v3 1/3] PM: core: Rename module parameters prefix to "power"

Quoted 28 lines · Tzung-Bi Shih

Currently, the module parameters defined in drivers/base/power/main.c use the default prefix "main" (derived from the filename). The prefix "main" is too generic and non-descriptive for power management parameters.

Redefine MODULE_PARAM_PREFIX to "power." at the beginning of the file to group the module parameters under the "power" namespace instead. This makes the parameters more descriptive.

---
v3:
- No changes.

v2: https://lore.kernel.org/all/[email protected]
- New to the series.

v1: Doesn't exist.

 drivers/base/power/main.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/base/power/main.c +0 -0
index ed48c292f575..cd864f3a2799 100644

drivers/base/power/main.c line 44

Quoted 5 lines
drivers/base/power/main.c +2 -0
@@ -40,6 +40,9 @@
 #include "../base.h"
 #include "power.h"
 
+#undef MODULE_PARAM_PREFIX
+#define MODULE_PARAM_PREFIX "power."

"power" may be confused with the power supply support, so I'd rather use "pm" or even "pm_sleep" (in which case the "dpm_" prefix could be dropped from the new module param name in the next patch).

Quoted 5 lines
drivers/base/power/main.c +1 -1
+
 typedef int (*pm_callback_t)(struct device *);
 
 /*
--
#3 lore raw

Re: [PATCH v3 1/3] PM: core: Rename module parameters prefix to "power"

Quoted 32 lines · Rafael J. Wysocki
Quoted 31 lines · Tzung-Bi Shih

Currently, the module parameters defined in drivers/base/power/main.c use the default prefix "main" (derived from the filename). The prefix "main" is too generic and non-descriptive for power management parameters.

Redefine MODULE_PARAM_PREFIX to "power." at the beginning of the file to group the module parameters under the "power" namespace instead. This makes the parameters more descriptive.

---
v3:
- No changes.

v2: https://lore.kernel.org/all/[email protected]
- New to the series.

v1: Doesn't exist.

 drivers/base/power/main.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/base/power/main.c +0 -0
index ed48c292f575..cd864f3a2799 100644
@@ -40,6 +40,9 @@
 #include "../base.h"
 #include "power.h"
 
Quoted 6 lines

drivers/base/power/main.c line 44

Quoted 2 lines
drivers/base/power/main.c +2 -0
+#undef MODULE_PARAM_PREFIX
+#define MODULE_PARAM_PREFIX "power."

"power" may be confused with the power supply support, so I'd rather use "pm" or even "pm_sleep" (in which case the "dpm_" prefix could be dropped from the new module param name in the next patch).

Ack, will use "pm_sleep" in the next version.

Regarding dropping the "dpm_" prefix, should this also apply to the existing dpm_watchdog_all_cpu_backtrace parameter? Or should we leave it as-is to avoid breaking existing configurations?

#4 lore raw

Re: [PATCH v3 1/3] PM: core: Rename module parameters prefix to "power"

Quoted 41 lines · Tzung-Bi Shih
Quoted 32 lines · Rafael J. Wysocki
Quoted 31 lines · Tzung-Bi Shih

Currently, the module parameters defined in drivers/base/power/main.c use the default prefix "main" (derived from the filename). The prefix "main" is too generic and non-descriptive for power management parameters.

Redefine MODULE_PARAM_PREFIX to "power." at the beginning of the file to group the module parameters under the "power" namespace instead. This makes the parameters more descriptive.

---
v3:
- No changes.

v2: https://lore.kernel.org/all/[email protected]
- New to the series.

v1: Doesn't exist.

 drivers/base/power/main.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/base/power/main.c +0 -0
index ed48c292f575..cd864f3a2799 100644
@@ -40,6 +40,9 @@
 #include "../base.h"
 #include "power.h"
 
Quoted 6 lines

drivers/base/power/main.c line 44

Quoted 2 lines
drivers/base/power/main.c +2 -0
+#undef MODULE_PARAM_PREFIX
+#define MODULE_PARAM_PREFIX "power."

"power" may be confused with the power supply support, so I'd rather use "pm" or even "pm_sleep" (in which case the "dpm_" prefix could be dropped from the new module param name in the next patch).

Quoted 5 lines

Ack, will use "pm_sleep" in the next version.

Regarding dropping the "dpm_" prefix, should this also apply to the existing dpm_watchdog_all_cpu_backtrace parameter? Or should we leave it as-is to avoid breaking existing configurations?

Breaking things for someone would be unfortunate.

For consistency, let's retain the "dpm_watchdog" part in this name and use it in the new one.

#5 lore raw

Re: [PATCH v3 1/3] PM: core: Rename module parameters prefix to "power"

Quoted 45 lines · Rafael J. Wysocki
Quoted 43 lines · Tzung-Bi Shih
Quoted 32 lines · Rafael J. Wysocki
Quoted 31 lines · Tzung-Bi Shih

Currently, the module parameters defined in drivers/base/power/main.c use the default prefix "main" (derived from the filename). The prefix "main" is too generic and non-descriptive for power management parameters.

Redefine MODULE_PARAM_PREFIX to "power." at the beginning of the file to group the module parameters under the "power" namespace instead. This makes the parameters more descriptive.

---
v3:
- No changes.

v2: https://lore.kernel.org/all/[email protected]
- New to the series.

v1: Doesn't exist.

 drivers/base/power/main.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/base/power/main.c +0 -0
index ed48c292f575..cd864f3a2799 100644
@@ -40,6 +40,9 @@
 #include "../base.h"
 #include "power.h"
 
Quoted 6 lines

drivers/base/power/main.c line 44

Quoted 2 lines
drivers/base/power/main.c +2 -0
+#undef MODULE_PARAM_PREFIX
+#define MODULE_PARAM_PREFIX "power."

"power" may be confused with the power supply support, so I'd rather use "pm" or even "pm_sleep" (in which case the "dpm_" prefix could be dropped from the new module param name in the next patch).

Ack, will use "pm_sleep" in the next version.

Quoted 8 lines
Quoted 3 lines

Regarding dropping the "dpm_" prefix, should this also apply to the existing dpm_watchdog_all_cpu_backtrace parameter? Or should we leave it as-is to avoid breaking existing configurations?

Breaking things for someone would be unfortunate.

For consistency, let's retain the "dpm_watchdog" part in this name and use it in the new one.

Hmm, doesn't the prefix change already break things?

Best,
Tomasz

#6 lore raw

Re: [PATCH v3 1/3] PM: core: Rename module parameters prefix to "power"

Quoted 50 lines · Tomasz Figa
Quoted 49 lines · Rafael J. Wysocki
Quoted 46 lines · Tzung-Bi Shih
Quoted 32 lines · Rafael J. Wysocki
Quoted 31 lines · Tzung-Bi Shih

Currently, the module parameters defined in drivers/base/power/main.c use the default prefix "main" (derived from the filename). The prefix "main" is too generic and non-descriptive for power management parameters.

Redefine MODULE_PARAM_PREFIX to "power." at the beginning of the file to group the module parameters under the "power" namespace instead. This makes the parameters more descriptive.

---
v3:
- No changes.

v2: https://lore.kernel.org/all/[email protected]
- New to the series.

v1: Doesn't exist.

 drivers/base/power/main.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/base/power/main.c +0 -0
index ed48c292f575..cd864f3a2799 100644
@@ -40,6 +40,9 @@
 #include "../base.h"
 #include "power.h"
 
Quoted 6 lines

drivers/base/power/main.c line 44

Quoted 2 lines
drivers/base/power/main.c +2 -0
+#undef MODULE_PARAM_PREFIX
+#define MODULE_PARAM_PREFIX "power."

"power" may be confused with the power supply support, so I'd rather use "pm" or even "pm_sleep" (in which case the "dpm_" prefix could be dropped from the new module param name in the next patch).

Ack, will use "pm_sleep" in the next version.

Regarding dropping the "dpm_" prefix, should this also apply to the existing dpm_watchdog_all_cpu_backtrace parameter? Or should we leave it as-is to avoid breaking existing configurations?

Quoted 6 lines
Quoted 4 lines

Breaking things for someone would be unfortunate.

For consistency, let's retain the "dpm_watchdog" part in this name and use it in the new one.

Hmm, doesn't the prefix change already break things?

Theoretically yes, though it's worth noting that this parameter is relatively new. It was introduced in v6.19 (Oct 2025) via commit a67818f74512 ("PM: dpm_watchdog: add module param to backtrace all CPUs").

To my knowledge, the flag was originally introduced for ChromeOS [1], which doesn't actually rely on this module parameter in its production configuration yet [2].

That said, I can't know the status of all other Linux distributions. If we want to be 100% safe against breaking existing setups, retaining the "main" prefix is definitely the safest.

Given its recent introduction and limited known usage, this might be the best window to rename the prefix before it gains wider adoption.

What are your thoughts?

[1] https://chromium-review.git.corp.google.com/c/chromiumos/third_party/kernel/+/7414781
[2] https://chromium-review.git.corp.google.com/c/chromiumos/third_party/kernel/+/7414721

#7 lore raw

Re: [PATCH v3 1/3] PM: core: Rename module parameters prefix to "power"

Quoted 67 lines · Tzung-Bi Shih
Quoted 50 lines · Tomasz Figa
Quoted 49 lines · Rafael J. Wysocki
Quoted 46 lines · Tzung-Bi Shih
Quoted 32 lines · Rafael J. Wysocki
Quoted 31 lines · Tzung-Bi Shih

Currently, the module parameters defined in drivers/base/power/main.c use the default prefix "main" (derived from the filename). The prefix "main" is too generic and non-descriptive for power management parameters.

Redefine MODULE_PARAM_PREFIX to "power." at the beginning of the file to group the module parameters under the "power" namespace instead. This makes the parameters more descriptive.

---
v3:
- No changes.

v2: https://lore.kernel.org/all/[email protected]
- New to the series.

v1: Doesn't exist.

 drivers/base/power/main.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/base/power/main.c +0 -0
index ed48c292f575..cd864f3a2799 100644
@@ -40,6 +40,9 @@
 #include "../base.h"
 #include "power.h"
 
Quoted 6 lines

drivers/base/power/main.c line 44

Quoted 2 lines
drivers/base/power/main.c +2 -0
+#undef MODULE_PARAM_PREFIX
+#define MODULE_PARAM_PREFIX "power."

"power" may be confused with the power supply support, so I'd rather use "pm" or even "pm_sleep" (in which case the "dpm_" prefix could be dropped from the new module param name in the next patch).

Ack, will use "pm_sleep" in the next version.

Regarding dropping the "dpm_" prefix, should this also apply to the existing dpm_watchdog_all_cpu_backtrace parameter? Or should we leave it as-is to avoid breaking existing configurations?

Quoted 6 lines
Quoted 4 lines

Breaking things for someone would be unfortunate.

For consistency, let's retain the "dpm_watchdog" part in this name and use it in the new one.

Hmm, doesn't the prefix change already break things?

Theoretically yes, though it's worth noting that this parameter is relatively new. It was introduced in v6.19 (Oct 2025) via commit a67818f74512 ("PM: dpm_watchdog: add module param to backtrace all CPUs").

To my knowledge, the flag was originally introduced for ChromeOS [1], which doesn't actually rely on this module parameter in its production configuration yet [2].

Quoted 8 lines

That said, I can't know the status of all other Linux distributions. If we want to be 100% safe against breaking existing setups, retaining the "main" prefix is definitely the safest.

Given its recent introduction and limited known usage, this might be the best window to rename the prefix before it gains wider adoption.

What are your thoughts?

If somebody complains about it, we can reconsider, but using "main" as a prefix for power management module parameters is definitely confusing.

Quoted 2 lines

[1] https://chromium-review.git.corp.google.com/c/chromiumos/third_party/kernel/+/7414781
[2] https://chromium-review.git.corp.google.com/c/chromiumos/third_party/kernel/+/7414721

#8 lore raw

Re: [PATCH v3 1/3] PM: core: Rename module parameters prefix to "power"

Quoted 73 lines · Rafael J. Wysocki
Quoted 71 lines · Tzung-Bi Shih
Quoted 50 lines · Tomasz Figa
Quoted 49 lines · Rafael J. Wysocki
Quoted 46 lines · Tzung-Bi Shih
Quoted 32 lines · Rafael J. Wysocki
Quoted 31 lines · Tzung-Bi Shih

Currently, the module parameters defined in drivers/base/power/main.c use the default prefix "main" (derived from the filename). The prefix "main" is too generic and non-descriptive for power management parameters.

Redefine MODULE_PARAM_PREFIX to "power." at the beginning of the file to group the module parameters under the "power" namespace instead. This makes the parameters more descriptive.

---
v3:
- No changes.

v2: https://lore.kernel.org/all/[email protected]
- New to the series.

v1: Doesn't exist.

 drivers/base/power/main.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/base/power/main.c +0 -0
index ed48c292f575..cd864f3a2799 100644
@@ -40,6 +40,9 @@
 #include "../base.h"
 #include "power.h"
 
Quoted 6 lines

drivers/base/power/main.c line 44

Quoted 2 lines
drivers/base/power/main.c +2 -0
+#undef MODULE_PARAM_PREFIX
+#define MODULE_PARAM_PREFIX "power."

"power" may be confused with the power supply support, so I'd rather use "pm" or even "pm_sleep" (in which case the "dpm_" prefix could be dropped from the new module param name in the next patch).

Ack, will use "pm_sleep" in the next version.

Regarding dropping the "dpm_" prefix, should this also apply to the existing dpm_watchdog_all_cpu_backtrace parameter? Or should we leave it as-is to avoid breaking existing configurations?

Quoted 6 lines
Quoted 4 lines

Breaking things for someone would be unfortunate.

For consistency, let's retain the "dpm_watchdog" part in this name and use it in the new one.

Hmm, doesn't the prefix change already break things?

Theoretically yes, though it's worth noting that this parameter is relatively new. It was introduced in v6.19 (Oct 2025) via commit a67818f74512 ("PM: dpm_watchdog: add module param to backtrace all CPUs").

To my knowledge, the flag was originally introduced for ChromeOS [1], which doesn't actually rely on this module parameter in its production configuration yet [2].

That said, I can't know the status of all other Linux distributions. If we want to be 100% safe against breaking existing setups, retaining the "main" prefix is definitely the safest.

Quoted 8 lines
Quoted 4 lines

Given its recent introduction and limited known usage, this might be the best window to rename the prefix before it gains wider adoption.

What are your thoughts?

If somebody complains about it, we can reconsider, but using "main" as a prefix for power management module parameters is definitely confusing.

Agreed.

Best,
Tomasz

Quoted 3 lines
Quoted 3 lines

[1] https://chromium-review.git.corp.google.com/c/chromiumos/third_party/kernel/+/7414781
[2] https://chromium-review.git.corp.google.com/c/chromiumos/third_party/kernel/+/7414721

#9 lore raw

PATCH v3 2/3 PM: dpm_watchdog: Allow disabling DPM watchdog by default

In reply to Tzung-Bi Shih

Introduce the CONFIG_DPM_WATCHDOG_DEFAULT_ENABLED Kconfig option to allow the device suspend/resume watchdog (DPM watchdog) to be disabled by default at compile time.

Additionally, introduce the "dpm_watchdog_enabled" module parameter to allow the watchdog to be enabled or disabled at boot time (via "power.dpm_watchdog_enabled") and at runtime (via sysfs).

This provides flexibility for systems that want the watchdog code compiled in but inactive by default, allowing it to be enabled only when needed.

---
v3:
- Add "PM" tag (was missing).
- Update the format and specify dependencies in kernel-parameters.txt.
- Update the help message in Kconfig to reflect that dpm_watchdog_enabled can be set at runtime as well.

v2: https://lore.kernel.org/all/[email protected]
- Use module parameter and bool for dpm_watchdog_enabled.
- Use IS_ENABLED().

v1: https://lore.kernel.org/all/[email protected]

 Documentation/admin-guide/kernel-parameters.txt |  8 ++++++++
 drivers/base/power/main.c                       | 11 +++++++++++
 kernel/power/Kconfig                            | 10 ++++++++++
 3 files changed, 29 insertions(+)
Documentation/admin-guide/kernel-parameters.txt +8 -0
index 00375193bd26..f2620764c28e 100644
@@ -47,6 +47,7 @@
 	PCI	PCI bus support is enabled.
 	PCIE	PCI Express support is enabled.
 	PCMCIA	The PCMCIA subsystem is enabled.
+	PM	Power Management support is enabled.
 	PNP	Plug & Play support is enabled.
 	PPC	PowerPC architecture is enabled.
 	PPT	Parallel port support is enabled.
@@ -5399,6 +5400,13 @@ Kernel parameters
 			function to NULL. On Idle the CPU just reduces
 			execution priority.
 
+	power.dpm_watchdog_enabled=
+			[PM] Enable or disable the device suspend/resume
+			watchdog (DPM watchdog).  Requires CONFIG_PM_SLEEP and
+			CONFIG_DPM_WATCHDOG enabled.
+			Format: <bool>
+			Default value is set by CONFIG_DPM_WATCHDOG_DEFAULT_ENABLED.
+
 	ppc_strict_facility_enable
 			[PPC,ENABLE] This option catches any kernel floating point,
 			Altivec, VSX and SPE outside of regions specifically
drivers/base/power/main.c +11 -0
index cd864f3a2799..7822c29b7c8d 100644
@@ -534,6 +534,11 @@ module_param(dpm_watchdog_all_cpu_backtrace, bool, 0644);
 MODULE_PARM_DESC(dpm_watchdog_all_cpu_backtrace,
 		 "Backtrace all CPUs on DPM watchdog timeout");
 
+static bool __read_mostly dpm_watchdog_enabled =
+				IS_ENABLED(CONFIG_DPM_WATCHDOG_DEFAULT_ENABLED);
+module_param(dpm_watchdog_enabled, bool, 0644);
+MODULE_PARM_DESC(dpm_watchdog_enabled, "Enable DPM watchdog");
+
 /**
  * dpm_watchdog_handler - Driver suspend / resume watchdog handler.
  * @t: The timer that PM watchdog depends on.
@@ -577,6 +582,9 @@ static void dpm_watchdog_set(struct dpm_watchdog *wd, struct device *dev)
 {
 	struct timer_list *timer = &wd->timer;
 
+	if (!dpm_watchdog_enabled)
+		return;
+
 	wd->dev = dev;
 	wd->tsk = current;
 	wd->fatal = CONFIG_DPM_WATCHDOG_TIMEOUT == CONFIG_DPM_WATCHDOG_WARNING_TIMEOUT;
@@ -595,6 +603,9 @@ static void dpm_watchdog_clear(struct dpm_watchdog *wd)
 {
 	struct timer_list *timer = &wd->timer;
 
+	if (!dpm_watchdog_enabled)
+		return;
+
 	timer_delete_sync(timer);
 	timer_destroy_on_stack(timer);
 }
kernel/power/Kconfig +10 -0
index 530c897311d4..b16bd159074a 100644
@@ -268,6 +268,16 @@ config DPM_WATCHDOG
 	  captured in pstore device for inspection in subsequent
 	  boot session.
 
+config DPM_WATCHDOG_DEFAULT_ENABLED
+	bool "Enable DPM watchdog by default"
+	depends on DPM_WATCHDOG
+	default y
+	help
+	  If you say Y here, the DPM watchdog will be enabled by default.
+	  If you say N, it will be compiled in but disabled.  It can be
+	  enabled at boot time via the "power.dpm_watchdog_enabled" kernel
+	  parameter or at runtime via sysfs.
+
 config DPM_WATCHDOG_TIMEOUT
 	int "Watchdog timeout to panic in seconds"
 	range 1 120
Signature · 1 line
2.54.0.1099.g489fc7bff1-goog
#10 lore raw

Re: [PATCH v3 2/3] PM: dpm_watchdog: Allow disabling DPM watchdog by default

Quoted 8 lines · Tzung-Bi Shih

Introduce the CONFIG_DPM_WATCHDOG_DEFAULT_ENABLED Kconfig option to allow the device suspend/resume watchdog (DPM watchdog) to be disabled by default at compile time.

Additionally, introduce the "dpm_watchdog_enabled" module parameter to allow the watchdog to be enabled or disabled at boot time (via "power.dpm_watchdog_enabled") and at runtime (via sysfs).

I think that the new module param is more important because the new config option is just its default value, so I'd rearrange the changelog.

Also, I think that the "DEFAULT_" part of the new config option name doesn't provide any additional value, so I'd just drop it.

Quoted 109 lines

This provides flexibility for systems that want the watchdog code compiled in but inactive by default, allowing it to be enabled only when needed.

---
v3:
- Add "PM" tag (was missing).
- Update the format and specify dependencies in kernel-parameters.txt.
- Update the help message in Kconfig to reflect that dpm_watchdog_enabled can be set at runtime as well.

v2: https://lore.kernel.org/all/[email protected]
- Use module parameter and bool for dpm_watchdog_enabled.
- Use IS_ENABLED().

v1: https://lore.kernel.org/all/[email protected]

 Documentation/admin-guide/kernel-parameters.txt |  8 ++++++++
 drivers/base/power/main.c                       | 11 +++++++++++
 kernel/power/Kconfig                            | 10 ++++++++++
 3 files changed, 29 insertions(+)
Documentation/admin-guide/kernel-parameters.txt +8 -0
index 00375193bd26..f2620764c28e 100644
@@ -47,6 +47,7 @@
        PCI     PCI bus support is enabled.
        PCIE    PCI Express support is enabled.
        PCMCIA  The PCMCIA subsystem is enabled.
+       PM      Power Management support is enabled.
        PNP     Plug & Play support is enabled.
        PPC     PowerPC architecture is enabled.
        PPT     Parallel port support is enabled.
@@ -5399,6 +5400,13 @@ Kernel parameters
                        function to NULL. On Idle the CPU just reduces
                        execution priority.
 
+       power.dpm_watchdog_enabled=
+                       [PM] Enable or disable the device suspend/resume
+                       watchdog (DPM watchdog).  Requires CONFIG_PM_SLEEP and
+                       CONFIG_DPM_WATCHDOG enabled.
+                       Format: <bool>
+                       Default value is set by CONFIG_DPM_WATCHDOG_DEFAULT_ENABLED.
+
        ppc_strict_facility_enable
                        [PPC,ENABLE] This option catches any kernel floating point,
                        Altivec, VSX and SPE outside of regions specifically
drivers/base/power/main.c +11 -0
index cd864f3a2799..7822c29b7c8d 100644
@@ -534,6 +534,11 @@ module_param(dpm_watchdog_all_cpu_backtrace, bool, 0644);
 MODULE_PARM_DESC(dpm_watchdog_all_cpu_backtrace,
                 "Backtrace all CPUs on DPM watchdog timeout");
 
+static bool __read_mostly dpm_watchdog_enabled =
+                               IS_ENABLED(CONFIG_DPM_WATCHDOG_DEFAULT_ENABLED);
+module_param(dpm_watchdog_enabled, bool, 0644);
+MODULE_PARM_DESC(dpm_watchdog_enabled, "Enable DPM watchdog");
+
 /**
  * dpm_watchdog_handler - Driver suspend / resume watchdog handler.
  * @t: The timer that PM watchdog depends on.
@@ -577,6 +582,9 @@ static void dpm_watchdog_set(struct dpm_watchdog *wd, struct device *dev)
 {
        struct timer_list *timer = &wd->timer;
 
+       if (!dpm_watchdog_enabled)
+               return;
+
        wd->dev = dev;
        wd->tsk = current;
        wd->fatal = CONFIG_DPM_WATCHDOG_TIMEOUT == CONFIG_DPM_WATCHDOG_WARNING_TIMEOUT;
@@ -595,6 +603,9 @@ static void dpm_watchdog_clear(struct dpm_watchdog *wd)
 {
        struct timer_list *timer = &wd->timer;
 
+       if (!dpm_watchdog_enabled)
+               return;
+
        timer_delete_sync(timer);
        timer_destroy_on_stack(timer);
 }
kernel/power/Kconfig +10 -1
index 530c897311d4..b16bd159074a 100644
@@ -268,6 +268,16 @@ config DPM_WATCHDOG
          captured in pstore device for inspection in subsequent
          boot session.
 
+config DPM_WATCHDOG_DEFAULT_ENABLED
+       bool "Enable DPM watchdog by default"
+       depends on DPM_WATCHDOG
+       default y
+       help
+         If you say Y here, the DPM watchdog will be enabled by default.
+         If you say N, it will be compiled in but disabled.  It can be
+         enabled at boot time via the "power.dpm_watchdog_enabled" kernel
+         parameter or at runtime via sysfs.
+
 config DPM_WATCHDOG_TIMEOUT
        int "Watchdog timeout to panic in seconds"
        range 1 120
--

2.54.0.1099.g489fc7bff1-goog

#11 lore raw

Re: [PATCH v3 2/3] PM: dpm_watchdog: Allow disabling DPM watchdog by default

Quoted 10 lines · Rafael J. Wysocki
Quoted 8 lines · Tzung-Bi Shih

Introduce the CONFIG_DPM_WATCHDOG_DEFAULT_ENABLED Kconfig option to allow the device suspend/resume watchdog (DPM watchdog) to be disabled by default at compile time.

Additionally, introduce the "dpm_watchdog_enabled" module parameter to allow the watchdog to be enabled or disabled at boot time (via "power.dpm_watchdog_enabled") and at runtime (via sysfs).

Quoted 6 lines

I think that the new module param is more important because the new config option is just its default value, so I'd rearrange the changelog.

Also, I think that the "DEFAULT_" part of the new config option name doesn't provide any additional value, so I'd just drop it.

Will fix them in the next version.

#12 lore raw

PATCH v3 3/3 PM: dpm_watchdog: Add sysctl interface for DPM watchdog timeouts

In reply to Tzung-Bi Shih

Introduce sysctl knobs to allow configuring DPM watchdog timeouts at runtime.

Currently, these timeouts are fixed at compile time via CONFIG_DPM_WATCHDOG_TIMEOUT and CONFIG_DPM_WATCHDOG_WARNING_TIMEOUT. This limits flexibility if the timeouts need to be adjusted for different testing scenarios or hardware behaviors without rebuilding the kernel.

Add the following sysctl files under /proc/sys/kernel/:
- dpm_watchdog_timeout_secs: The total timeout before panic. The maximum value is capped at CONFIG_DPM_WATCHDOG_TIMEOUT to prevent unreasonably large timeouts.
- dpm_watchdog_warning_timeout_secs: The warning timeout. The maximum value is capped at the current dpm_watchdog_timeout_secs.
Both sysctls have a minimum value of 1.

---
v3:
- No changes.

v2: https://lore.kernel.org/all/[email protected]
- New to the series.

v1: Doesn't exist.

 drivers/base/power/main.c | 61 ++++++++++++++++++++++++++++++++++++---
 1 file changed, 57 insertions(+), 4 deletions(-)
drivers/base/power/main.c +57 -4
index 7822c29b7c8d..c1a4b30fafb2 100644
@@ -28,6 +28,7 @@
 #include <linux/interrupt.h>
 #include <linux/sched.h>
 #include <linux/sched/debug.h>
+#include <linux/sysctl.h>
 #include <linux/async.h>
 #include <linux/suspend.h>
 #include <trace/events/power.h>
@@ -539,6 +540,58 @@ static bool __read_mostly dpm_watchdog_enabled =
 module_param(dpm_watchdog_enabled, bool, 0644);
 MODULE_PARM_DESC(dpm_watchdog_enabled, "Enable DPM watchdog");
 
+static unsigned int __read_mostly dpm_watchdog_timeout = CONFIG_DPM_WATCHDOG_TIMEOUT;
+static unsigned int __read_mostly dpm_watchdog_warning_timeout =
+						CONFIG_DPM_WATCHDOG_WARNING_TIMEOUT;
+static const unsigned int dpm_watchdog_timeout_max = CONFIG_DPM_WATCHDOG_TIMEOUT;
+
+static int proc_dodpm_watchdog_timeout_secs(const struct ctl_table *table,
+					    int write, void *buffer,
+					    size_t *lenp, loff_t *ppos)
+{
+	struct ctl_table ctl = *table;
+	unsigned int val = dpm_watchdog_timeout;
+	int ret;
+
+	ctl.data = &val;
+	ret = proc_douintvec_minmax(&ctl, write, buffer, lenp, ppos);
+	if (ret || !write)
+		return ret;
+
+	if (val < dpm_watchdog_warning_timeout)
+		dpm_watchdog_warning_timeout = val;
+	dpm_watchdog_timeout = val;
+
+	return 0;
+}
+
+static const struct ctl_table dpm_watchdog_sysctls[] = {
+	{
+		.procname	= "dpm_watchdog_timeout_secs",
+		.maxlen		= sizeof(unsigned int),
+		.mode		= 0644,
+		.proc_handler	= proc_dodpm_watchdog_timeout_secs,
+		.extra1		= SYSCTL_ONE,
+		.extra2		= (void *)&dpm_watchdog_timeout_max,
+	},
+	{
+		.procname	= "dpm_watchdog_warning_timeout_secs",
+		.data		= &dpm_watchdog_warning_timeout,
+		.maxlen		= sizeof(unsigned int),
+		.mode		= 0644,
+		.proc_handler	= proc_douintvec_minmax,
+		.extra1		= SYSCTL_ONE,
+		.extra2		= (void *)&dpm_watchdog_timeout,
+	},
+};
+
+static int __init dpm_watchdog_sysctl_init(void)
+{
+	register_sysctl_init("kernel", dpm_watchdog_sysctls);
+	return 0;
+}
+subsys_initcall(dpm_watchdog_sysctl_init);
+
 /**
  * dpm_watchdog_handler - Driver suspend / resume watchdog handler.
  * @t: The timer that PM watchdog depends on.
@@ -564,9 +617,9 @@ static void dpm_watchdog_handler(struct timer_list *t)
 			dev_driver_string(wd->dev), dev_name(wd->dev));
 	}
 
-	time_left = CONFIG_DPM_WATCHDOG_TIMEOUT - CONFIG_DPM_WATCHDOG_WARNING_TIMEOUT;
+	time_left = dpm_watchdog_timeout - dpm_watchdog_warning_timeout;
 	dev_warn(wd->dev, "**** DPM device timeout after %u seconds; %u seconds until panic ****\n",
-		 CONFIG_DPM_WATCHDOG_WARNING_TIMEOUT, time_left);
+		 dpm_watchdog_warning_timeout, time_left);
 	show_stack(wd->tsk, NULL, KERN_WARNING);
 
 	wd->fatal = true;
@@ -587,11 +640,11 @@ static void dpm_watchdog_set(struct dpm_watchdog *wd, struct device *dev)
 
 	wd->dev = dev;
 	wd->tsk = current;
-	wd->fatal = CONFIG_DPM_WATCHDOG_TIMEOUT == CONFIG_DPM_WATCHDOG_WARNING_TIMEOUT;
+	wd->fatal = dpm_watchdog_timeout == dpm_watchdog_warning_timeout;
 
 	timer_setup_on_stack(timer, dpm_watchdog_handler, 0);
 	/* use same timeout value for both suspend and resume */
-	timer->expires = jiffies + HZ * CONFIG_DPM_WATCHDOG_WARNING_TIMEOUT;
+	timer->expires = jiffies + HZ * dpm_watchdog_warning_timeout;
 	add_timer(timer);
 }
 
Signature · 1 line
2.54.0.1099.g489fc7bff1-goog
#13 lore raw

Re: [PATCH v3 3/3] PM: dpm_watchdog: Add sysctl interface for DPM watchdog timeouts

Quoted 119 lines · Tzung-Bi Shih

Introduce sysctl knobs to allow configuring DPM watchdog timeouts at runtime.

Currently, these timeouts are fixed at compile time via CONFIG_DPM_WATCHDOG_TIMEOUT and CONFIG_DPM_WATCHDOG_WARNING_TIMEOUT. This limits flexibility if the timeouts need to be adjusted for different testing scenarios or hardware behaviors without rebuilding the kernel.

Add the following sysctl files under /proc/sys/kernel/:
- dpm_watchdog_timeout_secs: The total timeout before panic. The maximum value is capped at CONFIG_DPM_WATCHDOG_TIMEOUT to prevent unreasonably large timeouts.
- dpm_watchdog_warning_timeout_secs: The warning timeout. The maximum value is capped at the current dpm_watchdog_timeout_secs.
Both sysctls have a minimum value of 1.

---
v3:
- No changes.

v2: https://lore.kernel.org/all/[email protected]
- New to the series.

v1: Doesn't exist.

 drivers/base/power/main.c | 61 ++++++++++++++++++++++++++++++++++++---
 1 file changed, 57 insertions(+), 4 deletions(-)
drivers/base/power/main.c +55 -3
index 7822c29b7c8d..c1a4b30fafb2 100644
@@ -28,6 +28,7 @@
 #include <linux/interrupt.h>
 #include <linux/sched.h>
 #include <linux/sched/debug.h>
+#include <linux/sysctl.h>
 #include <linux/async.h>
 #include <linux/suspend.h>
 #include <trace/events/power.h>
@@ -539,6 +540,58 @@ static bool __read_mostly dpm_watchdog_enabled =
 module_param(dpm_watchdog_enabled, bool, 0644);
 MODULE_PARM_DESC(dpm_watchdog_enabled, "Enable DPM watchdog");
 
+static unsigned int __read_mostly dpm_watchdog_timeout = CONFIG_DPM_WATCHDOG_TIMEOUT;
+static unsigned int __read_mostly dpm_watchdog_warning_timeout =
+                                               CONFIG_DPM_WATCHDOG_WARNING_TIMEOUT;
+static const unsigned int dpm_watchdog_timeout_max = CONFIG_DPM_WATCHDOG_TIMEOUT;
+
+static int proc_dodpm_watchdog_timeout_secs(const struct ctl_table *table,
+                                           int write, void *buffer,
+                                           size_t *lenp, loff_t *ppos)
+{
+       struct ctl_table ctl = *table;
+       unsigned int val = dpm_watchdog_timeout;
+       int ret;
+
+       ctl.data = &val;
+       ret = proc_douintvec_minmax(&ctl, write, buffer, lenp, ppos);
+       if (ret || !write)
+               return ret;
+
+       if (val < dpm_watchdog_warning_timeout)
+               dpm_watchdog_warning_timeout = val;
+       dpm_watchdog_timeout = val;
+
+       return 0;
+}
+
+static const struct ctl_table dpm_watchdog_sysctls[] = {
+       {
+               .procname       = "dpm_watchdog_timeout_secs",
+               .maxlen         = sizeof(unsigned int),
+               .mode           = 0644,
+               .proc_handler   = proc_dodpm_watchdog_timeout_secs,
+               .extra1         = SYSCTL_ONE,
+               .extra2         = (void *)&dpm_watchdog_timeout_max,
+       },
+       {
+               .procname       = "dpm_watchdog_warning_timeout_secs",
+               .data           = &dpm_watchdog_warning_timeout,
+               .maxlen         = sizeof(unsigned int),
+               .mode           = 0644,
+               .proc_handler   = proc_douintvec_minmax,
+               .extra1         = SYSCTL_ONE,
+               .extra2         = (void *)&dpm_watchdog_timeout,
+       },
+};
+
+static int __init dpm_watchdog_sysctl_init(void)
+{
+       register_sysctl_init("kernel", dpm_watchdog_sysctls);
+       return 0;
+}
+subsys_initcall(dpm_watchdog_sysctl_init);
+
 /**
  * dpm_watchdog_handler - Driver suspend / resume watchdog handler.
  * @t: The timer that PM watchdog depends on.
@@ -564,9 +617,9 @@ static void dpm_watchdog_handler(struct timer_list *t)
                        dev_driver_string(wd->dev), dev_name(wd->dev));
        }
 
-       time_left = CONFIG_DPM_WATCHDOG_TIMEOUT - CONFIG_DPM_WATCHDOG_WARNING_TIMEOUT;
+       time_left = dpm_watchdog_timeout - dpm_watchdog_warning_timeout;
        dev_warn(wd->dev, "**** DPM device timeout after %u seconds; %u seconds until panic ****\n",
-                CONFIG_DPM_WATCHDOG_WARNING_TIMEOUT, time_left);
+                dpm_watchdog_warning_timeout, time_left);
        show_stack(wd->tsk, NULL, KERN_WARNING);
 
        wd->fatal = true;
@@ -587,11 +640,11 @@ static void dpm_watchdog_set(struct dpm_watchdog *wd, struct device *dev)
 
        wd->dev = dev;
        wd->tsk = current;
-       wd->fatal = CONFIG_DPM_WATCHDOG_TIMEOUT == CONFIG_DPM_WATCHDOG_WARNING_TIMEOUT;

drivers/base/power/main.c static void dpm_watchdog_set(struct dpm_watchdog *wd, struct device *dev)

Quoted 10 lines
drivers/base/power/main.c +2 -2
+       wd->fatal = dpm_watchdog_timeout == dpm_watchdog_warning_timeout;
 
        timer_setup_on_stack(timer, dpm_watchdog_handler, 0);
        /* use same timeout value for both suspend and resume */
-       timer->expires = jiffies + HZ * CONFIG_DPM_WATCHDOG_WARNING_TIMEOUT;
+       timer->expires = jiffies + HZ * dpm_watchdog_warning_timeout;
        add_timer(timer);
 }
 
--

I think that this can be applied without the other two patches in the series, so please let me know if you want me to apply it separately.

Thanks!

#14 lore raw

Re: [PATCH v3 3/3] PM: dpm_watchdog: Add sysctl interface for DPM watchdog timeouts

Quoted 129 lines · Rafael J. Wysocki
Quoted 128 lines · Tzung-Bi Shih

Introduce sysctl knobs to allow configuring DPM watchdog timeouts at runtime.

Currently, these timeouts are fixed at compile time via CONFIG_DPM_WATCHDOG_TIMEOUT and CONFIG_DPM_WATCHDOG_WARNING_TIMEOUT. This limits flexibility if the timeouts need to be adjusted for different testing scenarios or hardware behaviors without rebuilding the kernel.

Add the following sysctl files under /proc/sys/kernel/:
- dpm_watchdog_timeout_secs: The total timeout before panic. The maximum value is capped at CONFIG_DPM_WATCHDOG_TIMEOUT to prevent unreasonably large timeouts.
- dpm_watchdog_warning_timeout_secs: The warning timeout. The maximum value is capped at the current dpm_watchdog_timeout_secs.
Both sysctls have a minimum value of 1.

---
v3:
- No changes.

v2: https://lore.kernel.org/all/[email protected]
- New to the series.

v1: Doesn't exist.

 drivers/base/power/main.c | 61 ++++++++++++++++++++++++++++++++++++---
 1 file changed, 57 insertions(+), 4 deletions(-)
drivers/base/power/main.c +57 -4
index 7822c29b7c8d..c1a4b30fafb2 100644
@@ -28,6 +28,7 @@
 #include <linux/interrupt.h>
 #include <linux/sched.h>
 #include <linux/sched/debug.h>
+#include <linux/sysctl.h>
 #include <linux/async.h>
 #include <linux/suspend.h>
 #include <trace/events/power.h>
@@ -539,6 +540,58 @@ static bool __read_mostly dpm_watchdog_enabled =
 module_param(dpm_watchdog_enabled, bool, 0644);
 MODULE_PARM_DESC(dpm_watchdog_enabled, "Enable DPM watchdog");
 
+static unsigned int __read_mostly dpm_watchdog_timeout = CONFIG_DPM_WATCHDOG_TIMEOUT;
+static unsigned int __read_mostly dpm_watchdog_warning_timeout =
+                                               CONFIG_DPM_WATCHDOG_WARNING_TIMEOUT;
+static const unsigned int dpm_watchdog_timeout_max = CONFIG_DPM_WATCHDOG_TIMEOUT;
+
+static int proc_dodpm_watchdog_timeout_secs(const struct ctl_table *table,
+                                           int write, void *buffer,
+                                           size_t *lenp, loff_t *ppos)
+{
+       struct ctl_table ctl = *table;
+       unsigned int val = dpm_watchdog_timeout;
+       int ret;
+
+       ctl.data = &val;
+       ret = proc_douintvec_minmax(&ctl, write, buffer, lenp, ppos);
+       if (ret || !write)
+               return ret;
+
+       if (val < dpm_watchdog_warning_timeout)
+               dpm_watchdog_warning_timeout = val;
+       dpm_watchdog_timeout = val;
+
+       return 0;
+}
+
+static const struct ctl_table dpm_watchdog_sysctls[] = {
+       {
+               .procname       = "dpm_watchdog_timeout_secs",
+               .maxlen         = sizeof(unsigned int),
+               .mode           = 0644,
+               .proc_handler   = proc_dodpm_watchdog_timeout_secs,
+               .extra1         = SYSCTL_ONE,
+               .extra2         = (void *)&dpm_watchdog_timeout_max,
+       },
+       {
+               .procname       = "dpm_watchdog_warning_timeout_secs",
+               .data           = &dpm_watchdog_warning_timeout,
+               .maxlen         = sizeof(unsigned int),
+               .mode           = 0644,
+               .proc_handler   = proc_douintvec_minmax,
+               .extra1         = SYSCTL_ONE,
+               .extra2         = (void *)&dpm_watchdog_timeout,
+       },
+};
+
+static int __init dpm_watchdog_sysctl_init(void)
+{
+       register_sysctl_init("kernel", dpm_watchdog_sysctls);
+       return 0;
+}
+subsys_initcall(dpm_watchdog_sysctl_init);
+
 /**
  * dpm_watchdog_handler - Driver suspend / resume watchdog handler.
  * @t: The timer that PM watchdog depends on.
@@ -564,9 +617,9 @@ static void dpm_watchdog_handler(struct timer_list *t)
                        dev_driver_string(wd->dev), dev_name(wd->dev));
        }
 
-       time_left = CONFIG_DPM_WATCHDOG_TIMEOUT - CONFIG_DPM_WATCHDOG_WARNING_TIMEOUT;
+       time_left = dpm_watchdog_timeout - dpm_watchdog_warning_timeout;
        dev_warn(wd->dev, "**** DPM device timeout after %u seconds; %u seconds until panic ****\n",
-                CONFIG_DPM_WATCHDOG_WARNING_TIMEOUT, time_left);
+                dpm_watchdog_warning_timeout, time_left);
        show_stack(wd->tsk, NULL, KERN_WARNING);
 
        wd->fatal = true;
@@ -587,11 +640,11 @@ static void dpm_watchdog_set(struct dpm_watchdog *wd, struct device *dev)
 
        wd->dev = dev;
        wd->tsk = current;
-       wd->fatal = CONFIG_DPM_WATCHDOG_TIMEOUT == CONFIG_DPM_WATCHDOG_WARNING_TIMEOUT;
+       wd->fatal = dpm_watchdog_timeout == dpm_watchdog_warning_timeout;
 
        timer_setup_on_stack(timer, dpm_watchdog_handler, 0);
        /* use same timeout value for both suspend and resume */
-       timer->expires = jiffies + HZ * CONFIG_DPM_WATCHDOG_WARNING_TIMEOUT;
+       timer->expires = jiffies + HZ * dpm_watchdog_warning_timeout;
        add_timer(timer);
 }
 
Quoted 4 lines
Quoted 1 line

--

I think that this can be applied without the other two patches in the series, so please let me know if you want me to apply it separately.

Ack. The patch does have adjacent hunks with the preceding patch, which might cause minor contextual conflicts if applied independently.

Would you want me to reorder the series in the next version to make this the first patch? In case the rest two patches may still take some time to review.

#15 lore raw

Re: [PATCH v3 3/3] PM: dpm_watchdog: Add sysctl interface for DPM watchdog timeouts

Quoted 131 lines · Tzung-Bi Shih
Quoted 129 lines · Rafael J. Wysocki
Quoted 128 lines · Tzung-Bi Shih

Introduce sysctl knobs to allow configuring DPM watchdog timeouts at runtime.

Currently, these timeouts are fixed at compile time via CONFIG_DPM_WATCHDOG_TIMEOUT and CONFIG_DPM_WATCHDOG_WARNING_TIMEOUT. This limits flexibility if the timeouts need to be adjusted for different testing scenarios or hardware behaviors without rebuilding the kernel.

Add the following sysctl files under /proc/sys/kernel/:
- dpm_watchdog_timeout_secs: The total timeout before panic. The maximum value is capped at CONFIG_DPM_WATCHDOG_TIMEOUT to prevent unreasonably large timeouts.
- dpm_watchdog_warning_timeout_secs: The warning timeout. The maximum value is capped at the current dpm_watchdog_timeout_secs.
Both sysctls have a minimum value of 1.

---
v3:
- No changes.

v2: https://lore.kernel.org/all/[email protected]
- New to the series.

v1: Doesn't exist.

 drivers/base/power/main.c | 61 ++++++++++++++++++++++++++++++++++++---
 1 file changed, 57 insertions(+), 4 deletions(-)
drivers/base/power/main.c +57 -4
index 7822c29b7c8d..c1a4b30fafb2 100644
@@ -28,6 +28,7 @@
 #include <linux/interrupt.h>
 #include <linux/sched.h>
 #include <linux/sched/debug.h>
+#include <linux/sysctl.h>
 #include <linux/async.h>
 #include <linux/suspend.h>
 #include <trace/events/power.h>
@@ -539,6 +540,58 @@ static bool __read_mostly dpm_watchdog_enabled =
 module_param(dpm_watchdog_enabled, bool, 0644);
 MODULE_PARM_DESC(dpm_watchdog_enabled, "Enable DPM watchdog");
 
+static unsigned int __read_mostly dpm_watchdog_timeout = CONFIG_DPM_WATCHDOG_TIMEOUT;
+static unsigned int __read_mostly dpm_watchdog_warning_timeout =
+                                               CONFIG_DPM_WATCHDOG_WARNING_TIMEOUT;
+static const unsigned int dpm_watchdog_timeout_max = CONFIG_DPM_WATCHDOG_TIMEOUT;
+
+static int proc_dodpm_watchdog_timeout_secs(const struct ctl_table *table,
+                                           int write, void *buffer,
+                                           size_t *lenp, loff_t *ppos)
+{
+       struct ctl_table ctl = *table;
+       unsigned int val = dpm_watchdog_timeout;
+       int ret;
+
+       ctl.data = &val;
+       ret = proc_douintvec_minmax(&ctl, write, buffer, lenp, ppos);
+       if (ret || !write)
+               return ret;
+
+       if (val < dpm_watchdog_warning_timeout)
+               dpm_watchdog_warning_timeout = val;
+       dpm_watchdog_timeout = val;
+
+       return 0;
+}
+
+static const struct ctl_table dpm_watchdog_sysctls[] = {
+       {
+               .procname       = "dpm_watchdog_timeout_secs",
+               .maxlen         = sizeof(unsigned int),
+               .mode           = 0644,
+               .proc_handler   = proc_dodpm_watchdog_timeout_secs,
+               .extra1         = SYSCTL_ONE,
+               .extra2         = (void *)&dpm_watchdog_timeout_max,
+       },
+       {
+               .procname       = "dpm_watchdog_warning_timeout_secs",
+               .data           = &dpm_watchdog_warning_timeout,
+               .maxlen         = sizeof(unsigned int),
+               .mode           = 0644,
+               .proc_handler   = proc_douintvec_minmax,
+               .extra1         = SYSCTL_ONE,
+               .extra2         = (void *)&dpm_watchdog_timeout,
+       },
+};
+
+static int __init dpm_watchdog_sysctl_init(void)
+{
+       register_sysctl_init("kernel", dpm_watchdog_sysctls);
+       return 0;
+}
+subsys_initcall(dpm_watchdog_sysctl_init);
+
 /**
  * dpm_watchdog_handler - Driver suspend / resume watchdog handler.
  * @t: The timer that PM watchdog depends on.
@@ -564,9 +617,9 @@ static void dpm_watchdog_handler(struct timer_list *t)
                        dev_driver_string(wd->dev), dev_name(wd->dev));
        }
 
-       time_left = CONFIG_DPM_WATCHDOG_TIMEOUT - CONFIG_DPM_WATCHDOG_WARNING_TIMEOUT;
+       time_left = dpm_watchdog_timeout - dpm_watchdog_warning_timeout;
        dev_warn(wd->dev, "**** DPM device timeout after %u seconds; %u seconds until panic ****\n",
-                CONFIG_DPM_WATCHDOG_WARNING_TIMEOUT, time_left);
+                dpm_watchdog_warning_timeout, time_left);
        show_stack(wd->tsk, NULL, KERN_WARNING);
 
        wd->fatal = true;
@@ -587,11 +640,11 @@ static void dpm_watchdog_set(struct dpm_watchdog *wd, struct device *dev)
 
        wd->dev = dev;
        wd->tsk = current;
-       wd->fatal = CONFIG_DPM_WATCHDOG_TIMEOUT == CONFIG_DPM_WATCHDOG_WARNING_TIMEOUT;
+       wd->fatal = dpm_watchdog_timeout == dpm_watchdog_warning_timeout;
 
        timer_setup_on_stack(timer, dpm_watchdog_handler, 0);
        /* use same timeout value for both suspend and resume */
-       timer->expires = jiffies + HZ * CONFIG_DPM_WATCHDOG_WARNING_TIMEOUT;
+       timer->expires = jiffies + HZ * dpm_watchdog_warning_timeout;
        add_timer(timer);
 }
 
Quoted 7 lines
Quoted 4 lines
Quoted 1 line

--

I think that this can be applied without the other two patches in the series, so please let me know if you want me to apply it separately.

Ack. The patch does have adjacent hunks with the preceding patch, which might cause minor contextual conflicts if applied independently.

That's not a problem.

Quoted 3 lines

Would you want me to reorder the series in the next version to make this the first patch? In case the rest two patches may still take some time to review.

I'll pick it up as is, so it can make it into 7.2.