When the suspend process is executed from the /sys/power/state entry,
the pm_wakeup_clear() signal is cleared in advance, and the wakeup
signal can be captured to fail the suspend process when the suspend
process is notified by the notifier;
Expanding the scope of the pm_suspend_target_state variable also allows
the device driver to know that the system has entered the suspend
process earlier.
xiongxin (2):
PM: suspend: expand the assignment scope of the
pm_suspend_target_state
PM: suspend: advanced pm_wakeup_clear() for normal suspend/hibernate
kernel/power/process.c | 5 ++++-
kernel/power/suspend.c | 13 +++++++++++++
2 files changed, 17 insertions(+), 1 deletion(-)
--
2.25.1
No virus found
Checked by Hillstone Network AntiVirus
The pm_suspend_target_state variable can be used as a suspend state
identifier and given to the specific device driver as a code judgment;
Because the suspend_prepare() function is time-consuming for the
operation of freezing processes, and this stage is actually in the suspend
stage, it is necessary to expand the scope of the pm_suspend_target_state
variable to be assigned to the suspend state at enter_state() function;
Another reason is that the specific device driver can locate whether it is
in the suspend state based on this variable, so as to determine the
validity of its wake-up source.
Signed-off-by: xiongxin <redacted>
---
kernel/power/suspend.c | 7 +++++++
1 file changed, 7 insertions(+)
pm_wakeup_clear() will clear the wakeup source, which can ensure that it
is not disturbed by useless wakeup signals when doing suspend/hibernate;
At the beginning of the suspend/hibernate process, the notifier
mechanism is used to notify other device drivers. This action is
time-consuming (second-level time-consuming). If the process fails due
to the received wakeup signal during the execution of these functions,
it can better improve the experience of failing suspend/hibernate
returns;
Therefore, it is recommended here that for the suspend/hibernate process
normally called from /sys/power/state, the pm_wakeup_clear() function
should be brought before the notifier call; for the freeze_process()
function called from other places, the original logic is kept;
The pm_suspend_target_state variable is used here to identify whether the
suspend process is going normally.
Signed-off-by: xiongxin <redacted>
---
kernel/power/process.c | 5 ++++-
kernel/power/suspend.c | 6 ++++++
2 files changed, 10 insertions(+), 1 deletion(-)
@@ -131,7 +131,10 @@ int freeze_processes(void)if(!pm_freezing)atomic_inc(&system_freezing_cnt);-pm_wakeup_clear(0);+if(pm_suspend_target_state!=PM_SUSPEND_ON)+pm_wakeup_clear(1);+else+pm_wakeup_clear(0);pr_info("Freezing user space processes ... ");pm_freezing=true;error=try_to_freeze_tasks(true);
From: "Rafael J. Wysocki" <rafael@kernel.org> Date: 2022-07-12 18:54:41
On Wed, Jun 29, 2022 at 5:35 AM xiongxin [off-list ref] wrote:
The pm_suspend_target_state variable can be used as a suspend state
identifier and given to the specific device driver as a code judgment;
Because the suspend_prepare() function is time-consuming for the
operation of freezing processes, and this stage is actually in the suspend
stage, it is necessary to expand the scope of the pm_suspend_target_state
variable to be assigned to the suspend state at enter_state() function;
I don't see why it is necessary, sorry.
Another reason is that the specific device driver can locate whether it is
in the suspend state based on this variable, so as to determine the
validity of its wake-up source.
I think you have a specific use case in mind, so please explain why
and how this change helps in your specific use case.
So far I don't see a reason for applying this patch.
From: "Rafael J. Wysocki" <rafael@kernel.org> Date: 2022-07-12 19:15:37
On Wed, Jun 29, 2022 at 5:35 AM xiongxin [off-list ref] wrote:
pm_wakeup_clear() will clear the wakeup source, which can ensure that it
is not disturbed by useless wakeup signals when doing suspend/hibernate;
At the beginning of the suspend/hibernate process, the notifier
mechanism is used to notify other device drivers. This action is
time-consuming (second-level time-consuming). If the process fails due
to the received wakeup signal during the execution of these functions,
it can better improve the experience of failing suspend/hibernate
returns;
Therefore, it is recommended here that for the suspend/hibernate process
normally called from /sys/power/state, the pm_wakeup_clear() function
should be brought before the notifier call; for the freeze_process()
function called from other places, the original logic is kept;
The pm_suspend_target_state variable is used here to identify whether the
suspend process is going normally.
You seem to be arguing that the previous wakeup IRQ should be cleared
before invoking PM notifiers. However, it is only set in
pm_system_irq_wakeup() which is only called after
suspend_device_irqs(), so clearing it anywhere before calling that
function in the given cycle should be sufficient.
@@ -569,6 +569,12 @@ static int enter_state(suspend_state_t state)*performedfromthe/sys/power/stateentry.*/pm_suspend_target_state=state;+/*+*Putpm_wakeup_clear()beforethenotifiernotificationchainto+*optimizeinthesuspendprocess,thewakeupsignalcaninterrupt+*thesuspendinadvanceandfailtoreturn.+*/
The comment above is too hard to understand for me, sorry.
+ pm_wakeup_clear(0);
if (sync_on_suspend_enabled) {
trace_suspend_resume(TPS("sync_filesystems"), 0, true);
--
2.25.1
No virus found
Checked by Hillstone Network AntiVirus