From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796380685; b=o1Ddau8n7Sw9BTYzyXsGo3SATUh+CnngZ0yf31UhgD3h/fLQcqdRQBnBzE8c566nJ2ud XuLGddwp6Io5HIs33ynLeLvSWqt0gbqvcfgumuhJBYWbQFs1cbH+aMcU+mjJAYLGS0tsl y02Co7MA8MZDeX4LFvlEFEz9MKM5XnE+qa3XiyN7d9lZQ7L/bsrU8QgNjMmsSIBOuOtYU kYtxjkWTDvYJW0gJbWvLT6LVz4OfhpGbkqcDd1e0AYZZ3M2FGDQtyVGsE4tetXI5VdiwP zEsWbGsk0+F8aYqYL9inpy2xuLJuiatYjjenkg6qLQ/JMHdVZRCBCYcNOq7kmuQgn/w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796380685; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=9lNkLhStOVUF/gNmALIFfG6sf3CddblatNCJYhYqTHU=; b=benW1YgaoQ8dsoS+5MZeoh3DQmN+02WIex5YvLuoWWb7oDxKwplk7+zH8E1wVlloMjMx hyDUE0BHUWwskZcyDWHeaI4RvdRGrKU/1qwKaMWLGvK8rdeBQqTJNSPIHlMMEdVOpWj2C epQLlyUH7+uHhPoxUCkoFxoAOLvrWMbMYyAQ6NFLUEc/oStCGMgezm65aFai+9lXJjQWT hk7FyRHKpdaM5w12bpF0oQQcHOqnZSjEhmabVBTRJRqmbILLflsQhvpCCJOKYCHzblwXq fpebcOCpk2BMn45bSelFaZh0s2ozqWiLbmVjnYNGv2CSZcqfkwMjz9q1RdLPlVgzy6A== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=NlvAE8SV; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 76BC6606A32F; Fri, 4 Dec 2026 10:38:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=NlvAE8SV Received: by smtp.kernel.org (Postfix) with ESMTPSA id EA3BB1F00897; Fri, 4 Dec 2026 10:38:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796380685; bh=9lNkLhStOVUF/gNmALIFfG6sf3CddblatNCJYhYqTHU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=NlvAE8SVjZjCXAimnxLGl/0jQR/aBfhpi3b9Q5Q4lhkctlmjH6ZxO0AAYAUoxd+R0 PnmFb7Ah/J5uw5MgKcuntdusdz9c/7Amb9t94WfnTMsJTf32mUnjC1LaqdINBbkCcU tNK7c9Z9d/f7A/M/hFSNIVO4W9pnbpHfhidaYJW8= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Ray Wu , Hugo Sales , Wayne Lin , Alex Deucher Subject: [PATCH 7.3 380/742] drm/amd/display: Take every stream out of self-refresh before a modeset Date: Fri, 4 Dec 2026 19:04:04 +0900 Message-ID: <20261204100645.179917032@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100635.034361255@linuxfoundation.org> References: <20261204100635.034361255@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.3-stable review patch. If anyone has any objections, please let me know. ------------------ From: Hugo Sales commit 09b6bf1a04cc6bbcbb8bb29fa1e38fa8a9f8d1dc upstream. Commit 3c108046e1d6 ("drm/amd/display: Add power module on Linux") dropped amdgpu_dm_psr_disable_all() and amdgpu_dm_replay_disable_all() from amdgpu_dm_commit_streams(). Since then, a modeset only disables self-refresh on the CRTCs in the commit, so an eDP on another CRTC stays in PSR through dc_commit_streams() Commit 6ee90e88b976 ("drm/amd/display: PSR eDP p-state warning occurs intermittently after unplug DP") added that disable-all for this very case. With it gone, turning off or unplugging an HDMI monitor while the eDP is in PSR hangs DMUB on a Cezanne laptop (DCN 2.1), on the first try: dc_dmub_srv_log_diagnostic_data: DMCUB error Error queueing DMUB command: status=2 The eDP then stays frozen until a GPU reset Do the same through the power module's events. When a CRTC that is or was active needs a modeset, raise the PSR and Replay pause events on every stream mod_power tracks and wait for self-refresh to exit, before amdgpu_dm_mod_power_update_streams() changes the stream set. Clear them on the commit's streams after amdgpu_dm_mod_power_setup_streams(), since enabling a stream clears psr_feature_enabled until then. Use psr_event_pause and replay_event_pause rather than the hw_programming events, which a fast update on the eDP can clear in amdgpu_dm_enable_self_refresh() while the modeset is still running Fixes: 3c108046e1d6 ("drm/amd/display: Add power module on Linux") Reviewed-by: Ray Wu Signed-off-by: Hugo Sales Signed-off-by: Wayne Lin Signed-off-by: Alex Deucher (cherry picked from commit 5d90fdb959505b5f42f2dec699521ac56b4174be) Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 101 ++++++++++++++++++++++ 1 file changed, 101 insertions(+) --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c @@ -4442,6 +4442,105 @@ static void amdgpu_dm_mod_power_update_s } } +static bool amdgpu_dm_self_refresh_pause_needed(struct drm_atomic_commit *state) +{ + struct drm_crtc_state *old_crtc_state, *new_crtc_state; + struct drm_crtc *crtc; + int i; + + for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) + if (drm_atomic_crtc_needs_modeset(new_crtc_state) && + (old_crtc_state->active || new_crtc_state->active)) + return true; + + return false; +} + +static bool amdgpu_dm_is_new_modeset_stream(struct drm_atomic_commit *state, + const struct dc_stream_state *stream) +{ + struct drm_crtc_state *new_crtc_state; + struct drm_crtc *crtc; + int i; + + for_each_new_crtc_in_state(state, crtc, new_crtc_state, i) + if (drm_atomic_crtc_needs_modeset(new_crtc_state) && + to_dm_crtc_state(new_crtc_state)->stream == stream) + return true; + + return false; +} + +/* + * A modeset CRTC may have no PSR or Replay, such as an HDMI output being + * turned off, while an eDP on another CRTC is still in self-refresh. Pause + * self-refresh on every stream mod_power tracks before + * amdgpu_dm_mod_power_update_streams() changes the set: the old streams of + * the CRTCs in the commit and the unchanged streams of the new state. + * Unlike hw_programming, which a fast update on another CRTC clears, the + * pause holds until amdgpu_dm_resume_self_refresh() + */ +static void amdgpu_dm_pause_self_refresh(struct drm_atomic_commit *state, + struct amdgpu_display_manager *dm, + struct dc_state *dc_state) +{ + struct drm_crtc_state *old_crtc_state; + struct dc_stream_state *stream; + struct drm_crtc *crtc; + int i; + + if (!amdgpu_dm_self_refresh_pause_needed(state)) + return; + + guard(mutex)(&dm->dc_lock); + dc_exit_ips_for_hw_access(dm->dc); + + for_each_old_crtc_in_state(state, crtc, old_crtc_state, i) { + stream = to_dm_crtc_state(old_crtc_state)->stream; + if (!old_crtc_state->active || !stream) + continue; + + amdgpu_dm_psr_set_event(dm, stream, true, psr_event_pause, true); + amdgpu_dm_replay_set_event(dm, stream, true, replay_event_pause, true); + } + + for (i = 0; i < dc_state->stream_count; i++) { + stream = dc_state->streams[i]; + if (amdgpu_dm_is_new_modeset_stream(state, stream)) + continue; + + amdgpu_dm_psr_set_event(dm, stream, true, psr_event_pause, true); + amdgpu_dm_replay_set_event(dm, stream, true, replay_event_pause, true); + } +} + +/* + * Ends amdgpu_dm_pause_self_refresh() on the streams of the commit, which + * mod_power tracks from amdgpu_dm_mod_power_update_streams() on, even if + * dc_commit_streams() failed. mod_power keeps events across + * mod_power_replace_stream(), so the replaced streams carry the pause too. + * Runs after amdgpu_dm_mod_power_setup_streams(), since enabling a stream + * clears psr_feature_enabled and replay_feature_enabled on its link until + * then, and the set_event helpers skip a link without them + */ +static void amdgpu_dm_resume_self_refresh(struct drm_atomic_commit *state, + struct amdgpu_display_manager *dm, + struct dc_state *dc_state) +{ + int i; + + if (!dc_state || !amdgpu_dm_self_refresh_pause_needed(state)) + return; + + guard(mutex)(&dm->dc_lock); + for (i = 0; i < dc_state->stream_count; i++) { + amdgpu_dm_psr_set_event(dm, dc_state->streams[i], false, + psr_event_pause, false); + amdgpu_dm_replay_set_event(dm, dc_state->streams[i], false, + replay_event_pause, false); + } +} + /** * amdgpu_dm_mod_power_setup_streams - setup mod_power stream state post modeset * @state: the drm atomic state @@ -4532,6 +4631,7 @@ static void amdgpu_dm_commit_streams(str acrtc->wb_enabled = false; } + amdgpu_dm_pause_self_refresh(state, dm, dc_state); amdgpu_dm_mod_power_update_streams(state, dm); for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, @@ -5270,6 +5370,7 @@ static void amdgpu_dm_atomic_commit_tail } amdgpu_dm_mod_power_setup_streams(state, dm); + amdgpu_dm_resume_self_refresh(state, dm, dc_state); for_each_new_crtc_in_state(state, crtc, new_crtc_state, j) if (new_crtc_state->async_flip)