From: Mario Limonciello <superm1@kernel.org>
To: "Rafael J. Wysocki" <rafael@kernel.org>,
Linux PM <linux-pm@vger.kernel.org>
Cc: LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v1 2/2] PM: hibernate: Combine return paths in power_down()
Date: Fri, 26 Sep 2025 13:29:28 -0500 [thread overview]
Message-ID: <e47c4c32-faea-4b24-a77e-9a3ec0e2b757@kernel.org> (raw)
In-Reply-To: <3571055.QJadu78ljV@rafael.j.wysocki>
On 9/26/25 11:41 AM, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>
> To avoid code duplication and improve clarity, combine the code
> paths in power_down() leading to a return from that function.
>
> No intentional functional impact.
>
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
The actual change looks fine to me.
Since it's used in "both" a success and failure path would you consider
using "wakeup" for the label instead of "rollback"? Or anything else
you can think of that doesn't have a connotation of failure.
Reviewed-by: Mario Limonciello (AMD) <superm1@kernel.org>
> ---
> kernel/power/hibernate.c | 32 ++++++++++++++------------------
> 1 file changed, 14 insertions(+), 18 deletions(-)
>
> --- a/kernel/power/hibernate.c
> +++ b/kernel/power/hibernate.c
> @@ -708,21 +708,11 @@ static void power_down(void)
> if (hibernation_mode == HIBERNATION_SUSPEND) {
> pm_restore_gfp_mask();
> error = suspend_devices_and_enter(mem_sleep_current);
> - if (error) {
> - hibernation_mode = hibernation_ops ?
> - HIBERNATION_PLATFORM :
> - HIBERNATION_SHUTDOWN;
> - } else {
> - /* Match pm_restore_gfp_mask() call in hibernate() */
> - pm_restrict_gfp_mask();
> + if (!error)
> + goto rollback;
>
> - /* Restore swap signature. */
> - error = swsusp_unmark();
> - if (error)
> - pr_err("Swap will be unusable! Try swapon -a.\n");
> -
> - return;
> - }
> + hibernation_mode = hibernation_ops ? HIBERNATION_PLATFORM :
> + HIBERNATION_SHUTDOWN;
> }
> #endif
>
> @@ -733,12 +723,9 @@ static void power_down(void)
> case HIBERNATION_PLATFORM:
> error = hibernation_platform_enter();
> if (error == -EAGAIN || error == -EBUSY) {
> - /* Match pm_restore_gfp_mask() in hibernate(). */
> - pm_restrict_gfp_mask();
> - swsusp_unmark();
> events_check_enabled = false;
> pr_info("Wakeup event detected during hibernation, rolling back.\n");
> - return;
> + goto rollback;
> }
> fallthrough;
> case HIBERNATION_SHUTDOWN:
> @@ -757,6 +744,15 @@ static void power_down(void)
> pr_crit("Power down manually\n");
> while (1)
> cpu_relax();
> +
> +rollback:
> + /* Match the pm_restore_gfp_mask() call in hibernate(). */
> + pm_restrict_gfp_mask();
> +
> + /* Restore swap signature. */
> + error = swsusp_unmark();
> + if (error)
> + pr_err("Swap will be unusable! Try swapon -a.\n");
> }
>
> static int load_image_and_restore(void)
>
>
>
next prev parent reply other threads:[~2025-09-26 18:29 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-26 16:37 [PATCH v1 0/2] PM: hibernate: Fix GFP mask restoration issue and consolidate code Rafael J. Wysocki
2025-09-26 16:40 ` [PATCH v1 1/2] PM: hibernate: Restrict GFP mask in power_down() Rafael J. Wysocki
2025-09-26 16:47 ` Mario Limonciello
2025-09-26 16:41 ` [PATCH v1 2/2] PM: hibernate: Combine return paths " Rafael J. Wysocki
2025-09-26 18:29 ` Mario Limonciello [this message]
2025-09-26 18:31 ` Rafael J. Wysocki
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e47c4c32-faea-4b24-a77e-9a3ec0e2b757@kernel.org \
--to=superm1@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=rafael@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox