From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 791131E0DEA for ; Thu, 25 Sep 2025 18:03:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758823428; cv=none; b=LfMBAjGeK8pedCpN6RQXeXnXwpYGVazWalHOx6xnq0GJHaS4+YL/DN15lQyiZ/zFHuYXL6YK+F8eU+muMPNfP1TixxV/p6BydBi4buNE1uk5mR5TRTxdgMEnpafbiknc/vatIaqjiCosRosWb2DMotA8jhsl9kzFcUA4WR3dTqs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758823428; c=relaxed/simple; bh=wYt3Bbzl19VP2E4AL4yangnXFPuJ7GSgCaR18q2I6lU=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=TgHim3XlWmoY8yuw2C8ugVeF6hvR4E4rzVhVXIw2aaCyoklBFk5i7VW52aoVE2jgU9Mz8bGdVOdI6tAGMHnd03GJrQ7qnXQg89behuhCytHZy+d9ceOCsbVkTDOFK8lflky24XCa5LCPDOa6CR6sBzMHrIu6fVdZ93R+62zewWo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Ekrw+Epf; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Ekrw+Epf" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 56439C4CEF0; Thu, 25 Sep 2025 18:03:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1758823428; bh=wYt3Bbzl19VP2E4AL4yangnXFPuJ7GSgCaR18q2I6lU=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=Ekrw+Epf/MmspBPrdaB4zUYELe735w+QTA5HtzrYPulLS7Jh/JiTZuMfH3+GwObgr tcikgrO0fxAlft6S/WvNZWl6+4lV4N396TIKWwKviad7z+OLVWy4KWHEQRWPXZ9Srd p8PPElNOuxARmDgKo2JDjl8O63cE1I/iGhc5HSY4fRoIGnyfIzJ1L4VkASbOFFhBEM InDzeaqRzHiyBRiJNNysUqp8QxtKB5eU6oVXjpPLw6FEkf/DgXhZFJGC4688sydn2P 5BCMJtzi3IuKE1srs3b3ahv4bR84BcRko4/0IIOzi5FfSebGmNtqAesWIAo0L+uF+J Lymk/3AxC4zLQ== Message-ID: <1b204004-03c1-48b5-abc3-eef5084ba680@kernel.org> Date: Thu, 25 Sep 2025 13:03:46 -0500 Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 1/3] PM: hibernate: Fix hybrid-sleep To: "Rafael J. Wysocki" Cc: Alex Deucher , Samuel Zhang , "open list:RADEON and AMDGPU DRM DRIVERS" , "open list:HIBERNATION (aka Software Suspend, aka swsusp)" , Ionut Nechita , Kenneth Crudup References: <20250925155918.2725474-1-superm1@kernel.org> <20250925155918.2725474-2-superm1@kernel.org> Content-Language: en-US From: "Mario Limonciello (AMD) (kernel.org)" In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 9/25/2025 12:55 PM, Rafael J. Wysocki wrote: > On Thu, Sep 25, 2025 at 7:51 PM Rafael J. Wysocki wrote: >> >> On Thu, Sep 25, 2025 at 7:47 PM Rafael J. Wysocki wrote: >>> >>> On Thu, Sep 25, 2025 at 5:59 PM Mario Limonciello (AMD) >>> wrote: >>>> >>>> Hybrid sleep will hibernate the system followed by running through >>>> the suspend routine. Since both the hibernate and the suspend routine >>>> will call pm_restrict_gfp_mask(), pm_restore_gfp_mask() must be called >>>> before starting the suspend sequence. >>>> >>>> Add an explicit call to pm_restore_gfp_mask() to power_down() before >>>> the suspend sequence starts. Don't call pm_restore_gfp_mask() when >>>> exiting suspend sequence it is already called: >>>> >>>> ``` >>>> power_down() >>>> ->suspend_devices_and_enter() >>>> -->dpm_resume_end() >>>> ``` >>>> >>>> Reported-by: Ionut Nechita >>>> Closes: https://gitlab.freedesktop.org/drm/amd/-/issues/4573 >>>> Tested-by: Ionut Nechita >>>> Fixes: 12ffc3b1513eb ("PM: Restrict swap use to later in the suspend sequence") >>>> Tested-by: Kenneth Crudup >>>> Acked-by: Alex Deucher >>>> Signed-off-by: Mario Limonciello (AMD) >>>> --- >>>> v2: >>>> * Move under CONFIG_SUSPEND scope (LKP robot) >>>> * Add tags >>>> --- >>>> kernel/power/hibernate.c | 11 ++++++++++- >>>> 1 file changed, 10 insertions(+), 1 deletion(-) >>>> >>>> diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c >>>> index 2f66ab4538231..52c1818749724 100644 >>>> --- a/kernel/power/hibernate.c >>>> +++ b/kernel/power/hibernate.c >>>> @@ -695,6 +695,7 @@ static void power_down(void) >>>> >>>> #ifdef CONFIG_SUSPEND >>>> if (hibernation_mode == HIBERNATION_SUSPEND) { >>>> + pm_restore_gfp_mask(); >>>> error = suspend_devices_and_enter(mem_sleep_current); >>>> if (error) { >>>> hibernation_mode = hibernation_ops ? >>>> @@ -862,7 +863,15 @@ int hibernate(void) >>>> power_down(); >>>> } >>>> in_suspend = 0; >>>> - pm_restore_gfp_mask(); >>>> + switch (hibernation_mode) { >>>> +#ifdef CONFIG_SUSPEND >>>> + case HIBERNATION_SUSPEND: >>>> + break; >>>> +#endif >>>> + default: >>>> + pm_restore_gfp_mask(); >>>> + break; >>>> + } >>> >>> You're breaking HIBERNATION_TEST_RESUME here AFAICS >> >> Well, not really because of the hibernation_mode check. >> >>> and power_down() doesn't return. >> >> But this still is true. > > Well, except when it does HIBERNATION_SUSPEND. > > But can you just make power_down() call pm_restrict_gfp_mask() before > returning and leave the code in hibernate() as is? Ah good suggestion. I believe so. I'll test it and get out updated patches if that works.