From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8C4DD606A322 for ; Fri, 4 Dec 2026 21:28:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=IUnduP2Q Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 27D4710E0B9; Fri, 4 Dec 2026 21:28:00 +0000 (UTC) Received: from tor.source.kernel.org (tor.source.kernel.org [172.105.4.254]) by gabe.freedesktop.org (Postfix) with ESMTPS id 619CA10E0B9 for ; Fri, 4 Dec 2026 21:27:53 +0000 (UTC) Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id A1C8D60CE2; Fri, 4 Dec 2026 21:27:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9A3311F00936; Fri, 4 Dec 2026 21:27:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796419672; bh=spEJ2ssVLh5lzmhYn/2XYhyO0g4XDg4QDVy2zXkAOMg=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=IUnduP2QIGMSxTNmXLVXxnB5M6WNG93Y6ryNq/yU2xQ6PyTPG0KHdzqWtdTFz5y+K 3IRrmFN81Y3UHf0vG4rD455VtG6LJ26JWbbxbRVnKO1j3KUQ5XUTTVxduHTiwdtDIy LNVizOJ4JZQ53048gyqfGM1bGaGSfCZA3mTUg78yOO4ctbvC68A2MXR2OoSb7HJSIx L+LpOg+0dDxHn0MDmGTH8EYwK7HJb23HxjnTlJL4JiEqgvafKGe2uSs4lQu+VFi1fe J8Ob0yHCYPV1ufTNYTgJ6K6+/y+r7Xg/mBCQuA+kDa0AOKDuZG3q4v/VVAi8kBcgDt 7xvFxtoNDXv5g== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH] drm/amdgpu: run prepare-phase eviction for hibernation on APUs To: "Mario Limonciello" Cc: amd-gfx@lists.freedesktop.org In-Reply-To: <20261204-amdgpu-apu-s4-prepare-v1-1-1658fb81d9c9@amd.com> References: <20261204-amdgpu-apu-s4-prepare-v1-1-1658fb81d9c9@amd.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Fri, 04 Dec 2026 21:27:46 +0000 X-BeenThere: amd-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion list for AMD gfx List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: sashiko-reviews@lists.linux.dev Sender: "amd-gfx" X-Spam-Status: No, score=-16.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 X-Archived-By: Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [Medium] drm/amdgpu: unpaired prepare in amdgpu_pmops_prepare() during hybrid sleep - [Low] drm/amdgpu: trailing comma in commit message Fixes trailer -- commit f21df76d47cb0f407cd0216cb0a996e7fd62337d Author: Mario Limonciello > drm/amdgpu: run prepare-phase eviction for hibernation on APUs > > amdgpu_pmops_prepare() returns early when neither s0ix nor s3 is > active. On an APU both helpers test pm_suspend_target_state, which is > only set by suspend_devices_and_enter() and so is PM_SUSPEND_ON > throughout hibernation_snapshot(). As a result amdgpu_device_prepare() > is skipped for hibernation on APUs, and with it the VRAM eviction and > ttm_device_prepare_hibernation() that the PM notifier sets in_s4 up for. > > The eviction instead happens from amdgpu_pmops_freeze(), after > hibernate_preallocate_memory() has already sized the image and after > pm_restrict_gfp_mask() has made it impossible to swap anything out. > Everything evicted into shmem/TTM pools at that point lands in the > image unaccounted for, and under memory pressure snapshot creation > fails: > > PM: hibernation: Not enough free memory for image creation > PM: hibernation: Error -12 creating image > > Discrete GPUs are unaffected as amdgpu_acpi_is_s3_active() is > unconditionally true for them. > > Don't take the early return when adev->in_s4 is set, so the eviction > runs in the prepare phase, before the image is preallocated. > > Fixes: 06f2dcc241e7 ("drm/amdgpu: fix pm notifier handling"), > Closes: https://gitlab.freedesktop.org/drm/amd/-/work_items/4711 > Signed-off-by: Mario Limonciello [Severity: Low] There is a stray trailing comma on the Fixes tag. Should it be: Fixes: 06f2dcc241e7 ("drm/amdgpu: fix pm notifier handling") > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/am= d/amdgpu/amdgpu_drv.c > index d2db20c172c69..5d081bbe52260 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c > @@ -2626,9 +2626,11 @@ static int amdgpu_pmops_prepare(struct device *dev) > return 1; > =20 > /* if we will not support s3 or s2i for the device > - * then skip suspend > + * then skip suspend, but not for hibernation: resources need to be > + * evicted here, before the hibernation image is sized. > */ > - if (!amdgpu_acpi_is_s0ix_active(adev) && > + if (!adev->in_s4 && > + !amdgpu_acpi_is_s0ix_active(adev) && > !amdgpu_acpi_is_s3_active(adev)) > return 1; [Severity: Medium] Can this run amdgpu_device_prepare() unpaired during hybrid sleep? During HIBERNATION_SUSPEND, amdgpu_pmops_thaw() resumes the GPU and clears adev->in_suspend while adev->in_s4 remains true until PM_POST_HIBERNATION. power_down() then calls suspend_devices_and_enter(), which invokes amdgpu_pmops_prepare(). On an APU where neither S0ix nor S3 is supported for the target sleep state, !adev->in_s4 is false so amdgpu_pmops_prepare() falls through to amdgpu_device_prepare(), while amdgpu_pmops_suspend() and amdgpu_pmops_resume() skip suspend and resume. This triggers a second VRAM eviction and ttm_device_prepare_hibernation() while pm_restrict_gfp_mask() is still active. On pre-Raven UVD APUs with active UVD handles it also leaks adev->uvd.inst[j].saved_bo allocated in amdgpu_uvd_prepare_suspend(), since no matching resume or complete frees it. Gating the S4 check on !pm_suspend_in_progress() would keep amdgpu_pmops_prepare() consistent with amdgpu_pmops_suspend() and amdgpu_pmops_resume() during hybrid sleep. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261204-amdgpu-apu= -s4-prepare-v1-1-1658fb81d9c9@amd.com?part=3D1