AMD-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Ray Wu <ray.wu@amd.com>
To: <amd-gfx@lists.freedesktop.org>
Cc: Harry Wentland <harry.wentland@amd.com>,
	Leo Li <sunpeng.li@amd.com>,
	Aurabindo Pillai <aurabindo.pillai@amd.com>,
	Roman Li <roman.li@amd.com>, Wayne Lin <wayne.lin@amd.com>,
	Tom Chung <chiahsuan.chung@amd.com>,
	"Fangzhi Zuo" <jerry.zuo@amd.com>,
	Dan Wheeler <daniel.wheeler@amd.com>, Ray Wu <Ray.Wu@amd.com>,
	Ivan Lipski <ivan.lipski@amd.com>, Alex Hung <alex.hung@amd.com>,
	Andrew Mazour <Andrew.Mazour@amd.com>,
	"Nicholas Kazlauskas" <nicholas.kazlauskas@amd.com>,
	Ray Wu <ray.wu@amd.com>
Subject: [PATCH 02/13] drm/amd/display: Extend inbox0 lock to run Replay/PSR
Date: Wed, 29 Oct 2025 11:02:50 +0800	[thread overview]
Message-ID: <20251029030935.2785560-3-ray.wu@amd.com> (raw)
In-Reply-To: <20251029030935.2785560-1-ray.wu@amd.com>

From: Andrew Mazour <Andrew.Mazour@amd.com>

[Why]
The inbox1 infrastructure is deprecated, so to support display
power features requiring a DMUB interlock moving forward extend
the inbox0 locking conditions to also include Replay or PSR.

[How]
Implemented a series of changes to improve HW lock handling:
- Deprecated should_use_dmub_inbox1_lock() and guarded it with
  DCN401 flag.
- Migrated lock checks into inbox0 helpers and added PSR/Replay
  enablement checks to ensure correct behavior.
- Updated HWSS fast update path to acquire HW lock as needed
  using the new helpers.

Reviewed-by: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com>
Signed-off-by: Andrew Mazour <Andrew.Mazour@amd.com>
Signed-off-by: Ray Wu <ray.wu@amd.com>
---
 .../drm/amd/display/dc/core/dc_hw_sequencer.c |  5 +-
 .../drm/amd/display/dc/dce/dmub_hw_lock_mgr.c | 52 +++++++++++++------
 .../drm/amd/display/dc/dce/dmub_hw_lock_mgr.h |  2 +
 3 files changed, 41 insertions(+), 18 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_hw_sequencer.c b/drivers/gpu/drm/amd/display/dc/core/dc_hw_sequencer.c
index f95cb0cf4b8a..a7ec633b26c0 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_hw_sequencer.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_hw_sequencer.c
@@ -38,6 +38,7 @@
 #include "dccg.h"
 #include "abm.h"
 #include "dcn10/dcn10_hubbub.h"
+#include "dce/dmub_hw_lock_mgr.h"
 
 #define NUM_ELEMENTS(a) (sizeof(a) / sizeof((a)[0]))
 #define MAX_NUM_MCACHE 8
@@ -764,7 +765,9 @@ void hwss_build_fast_sequence(struct dc *dc,
 	if (dc->hwss.dmub_hw_control_lock_fast) {
 		block_sequence[*num_steps].params.dmub_hw_control_lock_fast_params.dc = dc;
 		block_sequence[*num_steps].params.dmub_hw_control_lock_fast_params.lock = true;
-		block_sequence[*num_steps].params.dmub_hw_control_lock_fast_params.is_required = dc_state_is_fams2_in_use(dc, context);
+		block_sequence[*num_steps].params.dmub_hw_control_lock_fast_params.is_required =
+			dc_state_is_fams2_in_use(dc, context) ||
+			dmub_hw_lock_mgr_does_link_require_lock(dc, stream->link);
 		block_sequence[*num_steps].func = DMUB_HW_CONTROL_LOCK_FAST;
 		(*num_steps)++;
 	}
diff --git a/drivers/gpu/drm/amd/display/dc/dce/dmub_hw_lock_mgr.c b/drivers/gpu/drm/amd/display/dc/dce/dmub_hw_lock_mgr.c
index 39f5fa73c43e..5bfa2b0d2afd 100644
--- a/drivers/gpu/drm/amd/display/dc/dce/dmub_hw_lock_mgr.c
+++ b/drivers/gpu/drm/amd/display/dc/dce/dmub_hw_lock_mgr.c
@@ -61,31 +61,49 @@ void dmub_hw_lock_mgr_inbox0_cmd(struct dc_dmub_srv *dmub_srv,
 	dc_dmub_srv_wait_for_inbox0_ack(dmub_srv);
 }
 
-bool should_use_dmub_inbox1_lock(const struct dc *dc, const struct dc_link *link)
+bool dmub_hw_lock_mgr_does_link_require_lock(const struct dc *dc, const struct dc_link *link)
 {
-	/* ASIC doesn't support DMUB */
-	if (!dc->ctx->dmub_srv)
+	if (!link)
 		return false;
 
-	if (link) {
+	if (link->psr_settings.psr_version == DC_PSR_VERSION_SU_1)
+		return true;
 
-		if (link->psr_settings.psr_version == DC_PSR_VERSION_SU_1)
-			return true;
+	if (link->replay_settings.replay_feature_enabled)
+		return true;
 
-		if (link->replay_settings.replay_feature_enabled)
-			return true;
+	if (link->psr_settings.psr_version == DC_PSR_VERSION_1) {
+		struct dc_link *edp_links[MAX_NUM_EDP];
+		int edp_num;
 
-			/* only use HW lock for PSR1 on single eDP */
-		if (link->psr_settings.psr_version == DC_PSR_VERSION_1) {
-			struct dc_link *edp_links[MAX_NUM_EDP];
-			int edp_num;
+		dc_get_edp_links(dc, edp_links, &edp_num);
+		if (edp_num == 1)
+			return true;
+	}
+	return false;
+}
 
-			dc_get_edp_links(dc, edp_links, &edp_num);
+bool dmub_hw_lock_mgr_does_context_require_lock(const struct dc *dc, const struct dc_state *context)
+{
+	if (!context)
+		return false;
+	for (int i = 0; i < context->stream_count; i++) {
+		const struct dc_link *link = context->streams[i]->link;
 
-			if (edp_num == 1)
-				return true;
-		}
+		if (dmub_hw_lock_mgr_does_link_require_lock(dc, link))
+			return true;
 	}
-
 	return false;
 }
+
+bool should_use_dmub_inbox1_lock(const struct dc *dc, const struct dc_link *link)
+{
+	/* ASIC doesn't support DMUB */
+	if (!dc->ctx->dmub_srv)
+		return false;
+
+	if (dc->ctx->dce_version >= DCN_VERSION_4_01)
+		return false;
+
+	return dmub_hw_lock_mgr_does_link_require_lock(dc, link);
+}
diff --git a/drivers/gpu/drm/amd/display/dc/dce/dmub_hw_lock_mgr.h b/drivers/gpu/drm/amd/display/dc/dce/dmub_hw_lock_mgr.h
index 9f53d2ea5fa5..4c80ca8484ad 100644
--- a/drivers/gpu/drm/amd/display/dc/dce/dmub_hw_lock_mgr.h
+++ b/drivers/gpu/drm/amd/display/dc/dce/dmub_hw_lock_mgr.h
@@ -46,5 +46,7 @@ void dmub_hw_lock_mgr_inbox0_cmd(struct dc_dmub_srv *dmub_srv,
  * Return: true if the inbox1 lock should be used, false otherwise
  */
 bool should_use_dmub_inbox1_lock(const struct dc *dc, const struct dc_link *link);
+bool dmub_hw_lock_mgr_does_link_require_lock(const struct dc *dc, const struct dc_link *link);
+bool dmub_hw_lock_mgr_does_context_require_lock(const struct dc *dc, const struct dc_state *context);
 
 #endif /*_DMUB_HW_LOCK_MGR_H_ */
-- 
2.43.0


  parent reply	other threads:[~2025-10-29  3:10 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-29  3:02 [PATCH 00/13] DC Patches November 3, 2025 Ray Wu
2025-10-29  3:02 ` [PATCH 01/13] drm/amd/display: fw locality check refactors Ray Wu
2025-10-29  3:02 ` Ray Wu [this message]
2025-10-29  3:02 ` [PATCH 03/13] drm/amd/display: Add pte_buffer_mode and force_one_row_for_frame in dchub reg Ray Wu
2025-10-29  3:02 ` [PATCH 04/13] drm/amd/display: Remove old PMO options Ray Wu
2025-10-29  3:02 ` [PATCH 05/13] drm/amd/display: Update P-state naming for clarity Ray Wu
2025-10-29  3:02 ` [PATCH 06/13] drm/amd/display: Refactor VActive implementation Ray Wu
2025-10-29  3:02 ` [PATCH 07/13] drm/amd/display: Add Pstate viewport reduction Ray Wu
2025-10-29  3:02 ` [PATCH 08/13] drm/amd/display: Persist stream refcount through restore Ray Wu
2025-10-29  3:02 ` [PATCH 09/13] drm/amd/display: Revert DCN4 max buffered cursor size to 64 Ray Wu
2025-10-29  3:02 ` [PATCH 10/13] drm/amd/display: Increase IB mem size Ray Wu
2025-10-29  3:02 ` [PATCH 11/13] drm/amd/display: Fix black screen with HDMI outputs Ray Wu
2025-10-29  8:07   ` Timur Kristóf
2025-10-29 15:56     ` Alex Hung
2025-10-29  3:03 ` [PATCH 12/13] drm/amd/display: [FW Promotion] Release 0.1.34.0 Ray Wu
2025-10-29  3:03 ` [PATCH 13/13] drm/amd/display: Promote DC to 3.2.357 Ray Wu
2025-11-03 13:59 ` [PATCH 00/13] DC Patches November 3, 2025 Wheeler, Daniel

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=20251029030935.2785560-3-ray.wu@amd.com \
    --to=ray.wu@amd.com \
    --cc=Andrew.Mazour@amd.com \
    --cc=alex.hung@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=aurabindo.pillai@amd.com \
    --cc=chiahsuan.chung@amd.com \
    --cc=daniel.wheeler@amd.com \
    --cc=harry.wentland@amd.com \
    --cc=ivan.lipski@amd.com \
    --cc=jerry.zuo@amd.com \
    --cc=nicholas.kazlauskas@amd.com \
    --cc=roman.li@amd.com \
    --cc=sunpeng.li@amd.com \
    --cc=wayne.lin@amd.com \
    /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