* [PATCH v2 1/3] drm/amd/display: Add helpers to check PSR and Replay events
2026-11-13 19:40 [PATCH v2 0/3] drm/amd/display: Leave self-refresh before an ABM level update Hugo Sales via B4 Relay
@ 2026-11-13 19:40 ` Hugo Sales via B4 Relay
2026-11-13 19:40 ` [PATCH v2 2/3] drm/amd/display: Leave self-refresh before an ABM level update Hugo Sales via B4 Relay
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Hugo Sales via B4 Relay @ 2026-11-13 19:40 UTC (permalink / raw)
To: Harry Wentland, Leo Li, Rodrigo Siqueira, Alex Deucher,
Christian König, David Airlie, Simona Vetter
Cc: Roman Li, Nicholas Kazlauskas, Chenyu Chen, amd-gfx, dri-devel,
linux-kernel, Hugo Sales
From: Hugo Sales <hugo@hsal.es>
amdgpu_dm can set and clear a PSR or Replay event on a stream, but has no
way to ask whether one is already set. An upcoming patch sets the
hw_programming events around an ABM level update. When one was already
set before the update, something else set it and will clear it, so the
patch has to leave it alone
Add amdgpu_dm_psr_event_is_set() and amdgpu_dm_replay_event_is_set(),
with KUnit tests. The Replay tests get an alloc_replay_dm() helper for
the power module setup that the existing tests repeated
Signed-off-by: Hugo Sales <hugo@hsal.es>
---
.../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_psr.c | 24 +++++
.../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_psr.h | 2 +
.../drm/amd/display/amdgpu_dm/amdgpu_dm_replay.c | 25 +++++
.../drm/amd/display/amdgpu_dm/amdgpu_dm_replay.h | 3 +
.../display/amdgpu_dm/tests/amdgpu_dm_psr_test.c | 60 ++++++++++++
.../amdgpu_dm/tests/amdgpu_dm_replay_test.c | 102 +++++++++++++++------
6 files changed, 188 insertions(+), 28 deletions(-)
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_psr.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_psr.c
index dbad0a6d3a2b4..181ddf36dde0e 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_psr.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_psr.c
@@ -194,6 +194,30 @@ bool amdgpu_dm_psr_set_event(struct amdgpu_display_manager *dm, struct dc_stream
}
EXPORT_IF_KUNIT(amdgpu_dm_psr_set_event);
+/**
+ * amdgpu_dm_psr_event_is_set() - check whether a PSR event is set for a stream
+ * @dm: pointer to amdgpu_display_manager
+ * @stream: pointer to dc_stream_state
+ * @event: PSR event type
+ *
+ * Return: true if PSR is enabled on @stream and @event is set, false otherwise
+ */
+bool amdgpu_dm_psr_event_is_set(struct amdgpu_display_manager *dm,
+ struct dc_stream_state *stream, enum psr_event event)
+{
+ unsigned int psr_events;
+
+ if (!stream || !stream->link ||
+ !stream->link->psr_settings.psr_feature_enabled)
+ return false;
+
+ if (!mod_power_get_psr_event(dm->power_module, stream, &psr_events))
+ return false;
+
+ return psr_events & event;
+}
+EXPORT_IF_KUNIT(amdgpu_dm_psr_event_is_set);
+
#if IS_ENABLED(CONFIG_DRM_AMD_DC_KUNIT_TEST)
/**
* amdgpu_dm_psr_get_dc_feature_mask() - Get DC feature mask for KUnit tests.
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_psr.h b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_psr.h
index e442e7ed82ec1..b777bc9cda1df 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_psr.h
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_psr.h
@@ -41,6 +41,8 @@ bool amdgpu_dm_psr_is_active_allowed(struct amdgpu_display_manager *dm);
bool amdgpu_dm_psr_set_event(struct amdgpu_display_manager *dm,
struct dc_stream_state *stream, bool set_event, enum psr_event event,
bool wait_for_disable);
+bool amdgpu_dm_psr_event_is_set(struct amdgpu_display_manager *dm,
+ struct dc_stream_state *stream, enum psr_event event);
#if IS_ENABLED(CONFIG_DRM_AMD_DC_KUNIT_TEST)
bool link_supports_psrsu(struct dc_link *link);
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_replay.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_replay.c
index ee2e4754b0894..3ed4b4fce50f2 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_replay.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_replay.c
@@ -208,3 +208,28 @@ bool amdgpu_dm_replay_set_event(struct amdgpu_display_manager *dm,
set_event, event, wait_for_disable);
}
EXPORT_IF_KUNIT(amdgpu_dm_replay_set_event);
+
+/**
+ * amdgpu_dm_replay_event_is_set() - check whether a replay event is set for a stream
+ * @dm: pointer to amdgpu_display_manager
+ * @stream: pointer to dc_stream_state
+ * @event: replay event type
+ *
+ * Return: true if replay is enabled on @stream and @event is set, false otherwise
+ */
+bool amdgpu_dm_replay_event_is_set(struct amdgpu_display_manager *dm,
+ struct dc_stream_state *stream,
+ enum replay_event event)
+{
+ unsigned int replay_events;
+
+ if (!stream || !stream->link ||
+ !stream->link->replay_settings.replay_feature_enabled)
+ return false;
+
+ if (!mod_power_get_replay_event(dm->power_module, stream, &replay_events))
+ return false;
+
+ return replay_events & event;
+}
+EXPORT_IF_KUNIT(amdgpu_dm_replay_event_is_set);
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_replay.h b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_replay.h
index 021bf02555166..4970911d55954 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_replay.h
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_replay.h
@@ -40,4 +40,7 @@ bool amdgpu_dm_link_setup_replay(struct dc_stream_state *stream,
bool amdgpu_dm_replay_set_event(struct amdgpu_display_manager *dm,
struct dc_stream_state *stream, bool set_event,
enum replay_event event, bool wait_for_disable);
+bool amdgpu_dm_replay_event_is_set(struct amdgpu_display_manager *dm,
+ struct dc_stream_state *stream,
+ enum replay_event event);
#endif /* AMDGPU_DM_AMDGPU_DM_REPLAY_H_ */
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_psr_test.c b/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_psr_test.c
index 0a484ea7c0e8e..19c6792b1bed5 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_psr_test.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_psr_test.c
@@ -627,6 +627,62 @@ static void dm_test_psr_set_event_updates_event(struct kunit *test)
}
/* End of tests for amdgpu_dm_psr_set_event() */
+/* Tests for amdgpu_dm_psr_event_is_set() */
+
+/**
+ * dm_test_psr_event_is_set_psr_not_enabled() - Disabled PSR reports no event.
+ * @test: KUnit test context.
+ */
+static void dm_test_psr_event_is_set_psr_not_enabled(struct kunit *test)
+{
+ struct amdgpu_display_manager *dm = dm_kunit_alloc_dm(test);
+ struct dc_stream_state *stream = alloc_test_psr_stream(test);
+ struct psr_caps caps = {0};
+ struct core_power *core_power;
+
+ caps.psr_version = 1;
+ core_power = create_test_power_module(test, stream, &caps);
+ dm->power_module = &core_power->mod_public;
+ stream->link->psr_settings.psr_feature_enabled = false;
+
+ KUNIT_EXPECT_FALSE(test, amdgpu_dm_psr_event_is_set(dm, stream, psr_event_vsync));
+}
+
+/**
+ * dm_test_psr_event_is_set_get_event_fails() - Failed power event read reports no event.
+ * @test: KUnit test context.
+ */
+static void dm_test_psr_event_is_set_get_event_fails(struct kunit *test)
+{
+ struct amdgpu_display_manager *dm = dm_kunit_alloc_dm(test);
+ struct dc_stream_state *stream = alloc_test_psr_stream(test);
+
+ dm->power_module = NULL;
+
+ KUNIT_EXPECT_FALSE(test, amdgpu_dm_psr_event_is_set(dm, stream, psr_event_vsync));
+}
+
+/**
+ * dm_test_psr_event_is_set_reports_events() - Only events in mod_power are set.
+ * @test: KUnit test context.
+ */
+static void dm_test_psr_event_is_set_reports_events(struct kunit *test)
+{
+ struct amdgpu_display_manager *dm = dm_kunit_alloc_dm(test);
+ struct dc_stream_state *stream = alloc_test_psr_stream(test);
+ struct psr_caps caps = {0};
+ struct core_power *core_power;
+
+ caps.psr_version = 1;
+ core_power = create_test_power_module(test, stream, &caps);
+ dm->power_module = &core_power->mod_public;
+
+ KUNIT_EXPECT_TRUE(test, amdgpu_dm_psr_event_is_set(dm, stream, psr_event_vsync));
+ KUNIT_EXPECT_FALSE(test,
+ amdgpu_dm_psr_event_is_set(dm, stream, psr_event_hw_programming));
+}
+/* End of tests for amdgpu_dm_psr_event_is_set() */
+
/* Tests for amdgpu_dm_psr_is_active_allowed() */
/**
@@ -738,6 +794,10 @@ static struct kunit_case dm_psr_test_cases[] = {
KUNIT_CASE(dm_test_psr_set_event_get_event_fails),
KUNIT_CASE(dm_test_psr_set_event_already_set),
KUNIT_CASE(dm_test_psr_set_event_updates_event),
+ /* amdgpu_dm_psr_event_is_set */
+ KUNIT_CASE(dm_test_psr_event_is_set_psr_not_enabled),
+ KUNIT_CASE(dm_test_psr_event_is_set_get_event_fails),
+ KUNIT_CASE(dm_test_psr_event_is_set_reports_events),
/* amdgpu_dm_psr_is_active_allowed */
KUNIT_CASE(dm_test_psr_is_active_allowed_no_streams),
KUNIT_CASE(dm_test_psr_is_active_allowed_null_link),
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_replay_test.c b/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_replay_test.c
index 6f633b1bbaca9..1849e2b6022e0 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_replay_test.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_replay_test.c
@@ -505,17 +505,11 @@ static void dm_test_replay_set_event_missing_power_module(struct kunit *test)
replay_event_vsync, false));
}
-/**
- * dm_test_replay_set_event_already_set - Verify no-op when event already active
- * @test: KUnit test context
- *
- * When the requested event is already in the desired state, the function should
- * return true without calling mod_power_set_replay_event().
- */
-static void dm_test_replay_set_event_already_set(struct kunit *test)
+static struct amdgpu_display_manager *alloc_replay_dm(struct kunit *test,
+ struct dc_stream_state *stream,
+ unsigned int replay_events)
{
struct amdgpu_display_manager *dm;
- struct replay_test_ctx *ctx = alloc_replay_ctx(test);
struct core_power *core_power;
struct power_entity *map;
@@ -528,13 +522,27 @@ static void dm_test_replay_set_event_already_set(struct kunit *test)
map = kunit_kzalloc(test, sizeof(*map), GFP_KERNEL);
KUNIT_ASSERT_NOT_NULL(test, map);
- /* Wire the power module so mod_power_get_replay_event() succeeds */
- map->stream = ctx->stream;
- map->replay_events = replay_event_vsync;
+ map->stream = stream;
+ map->replay_events = replay_events;
core_power->map = map;
core_power->num_entities = 1;
dm->power_module = &core_power->mod_public;
+ return dm;
+}
+
+/**
+ * dm_test_replay_set_event_already_set - Verify no-op when event already active
+ * @test: KUnit test context
+ *
+ * When the requested event is already in the desired state, the function should
+ * return true without calling mod_power_set_replay_event().
+ */
+static void dm_test_replay_set_event_already_set(struct kunit *test)
+{
+ struct replay_test_ctx *ctx = alloc_replay_ctx(test);
+ struct amdgpu_display_manager *dm = alloc_replay_dm(test, ctx->stream, replay_event_vsync);
+
ctx->link->replay_settings.replay_feature_enabled = true;
/* Event already set — should return true without calling set */
@@ -551,32 +559,66 @@ static void dm_test_replay_set_event_already_set(struct kunit *test)
*/
static void dm_test_replay_set_event_already_clear(struct kunit *test)
{
+ struct replay_test_ctx *ctx = alloc_replay_ctx(test);
+ struct amdgpu_display_manager *dm = alloc_replay_dm(test, ctx->stream, 0);
+
+ ctx->link->replay_settings.replay_feature_enabled = true;
+
+ /* Clearing an event that's already clear — should return true */
+ KUNIT_EXPECT_TRUE(test, amdgpu_dm_replay_set_event(dm, ctx->stream, false,
+ replay_event_vsync, false));
+}
+
+/* Tests for amdgpu_dm_replay_event_is_set() */
+
+/**
+ * dm_test_replay_event_is_set_feature_disabled - Disabled Replay reports no event
+ * @test: KUnit test context
+ */
+static void dm_test_replay_event_is_set_feature_disabled(struct kunit *test)
+{
+ struct replay_test_ctx *ctx = alloc_replay_ctx(test);
struct amdgpu_display_manager *dm;
+
+ dm = alloc_replay_dm(test, ctx->stream, replay_event_vsync);
+
+ KUNIT_EXPECT_FALSE(test, amdgpu_dm_replay_event_is_set(dm, ctx->stream,
+ replay_event_vsync));
+}
+
+/**
+ * dm_test_replay_event_is_set_missing_power_module - Missing power module reports no event
+ * @test: KUnit test context
+ */
+static void dm_test_replay_event_is_set_missing_power_module(struct kunit *test)
+{
struct replay_test_ctx *ctx = alloc_replay_ctx(test);
- struct core_power *core_power;
- struct power_entity *map;
+ struct amdgpu_display_manager *dm;
dm = kunit_kzalloc(test, sizeof(*dm), GFP_KERNEL);
KUNIT_ASSERT_NOT_NULL(test, dm);
+ ctx->link->replay_settings.replay_feature_enabled = true;
- core_power = kunit_kzalloc(test, sizeof(*core_power), GFP_KERNEL);
- KUNIT_ASSERT_NOT_NULL(test, core_power);
-
- map = kunit_kzalloc(test, sizeof(*map), GFP_KERNEL);
- KUNIT_ASSERT_NOT_NULL(test, map);
+ KUNIT_EXPECT_FALSE(test, amdgpu_dm_replay_event_is_set(dm, ctx->stream,
+ replay_event_vsync));
+}
- /* Wire the power module — replay_events has NO vsync bit */
- map->stream = ctx->stream;
- map->replay_events = 0;
- core_power->map = map;
- core_power->num_entities = 1;
- dm->power_module = &core_power->mod_public;
+/**
+ * dm_test_replay_event_is_set_reports_events - Only events in mod_power are set
+ * @test: KUnit test context
+ */
+static void dm_test_replay_event_is_set_reports_events(struct kunit *test)
+{
+ struct replay_test_ctx *ctx = alloc_replay_ctx(test);
+ struct amdgpu_display_manager *dm;
+ dm = alloc_replay_dm(test, ctx->stream, replay_event_vsync);
ctx->link->replay_settings.replay_feature_enabled = true;
- /* Clearing an event that's already clear — should return true */
- KUNIT_EXPECT_TRUE(test, amdgpu_dm_replay_set_event(dm, ctx->stream, false,
- replay_event_vsync, false));
+ KUNIT_EXPECT_TRUE(test, amdgpu_dm_replay_event_is_set(dm, ctx->stream,
+ replay_event_vsync));
+ KUNIT_EXPECT_FALSE(test, amdgpu_dm_replay_event_is_set(dm, ctx->stream,
+ replay_event_hw_programming));
}
static struct kunit_case dm_replay_test_cases[] = {
@@ -611,6 +653,10 @@ static struct kunit_case dm_replay_test_cases[] = {
KUNIT_CASE(dm_test_replay_set_event_missing_power_module),
KUNIT_CASE(dm_test_replay_set_event_already_set),
KUNIT_CASE(dm_test_replay_set_event_already_clear),
+ /* amdgpu_dm_replay_event_is_set */
+ KUNIT_CASE(dm_test_replay_event_is_set_feature_disabled),
+ KUNIT_CASE(dm_test_replay_event_is_set_missing_power_module),
+ KUNIT_CASE(dm_test_replay_event_is_set_reports_events),
{}
};
--
2.56.0
^ permalink raw reply [flat|nested] 5+ messages in thread* [PATCH v2 2/3] drm/amd/display: Leave self-refresh before an ABM level update
2026-11-13 19:40 [PATCH v2 0/3] drm/amd/display: Leave self-refresh before an ABM level update Hugo Sales via B4 Relay
2026-11-13 19:40 ` [PATCH v2 1/3] drm/amd/display: Add helpers to check PSR and Replay events Hugo Sales via B4 Relay
@ 2026-11-13 19:40 ` Hugo Sales via B4 Relay
2026-11-13 19:40 ` [PATCH v2 3/3] drm/amd/display: Send a changed ABM level once per commit Hugo Sales via B4 Relay
2026-11-16 8:58 ` [PATCH v2 0/3] drm/amd/display: Leave self-refresh before an ABM level update Chen, Chen-Yu
3 siblings, 0 replies; 5+ messages in thread
From: Hugo Sales via B4 Relay @ 2026-11-13 19:40 UTC (permalink / raw)
To: Harry Wentland, Leo Li, Rodrigo Siqueira, Alex Deucher,
Christian König, David Airlie, Simona Vetter
Cc: Roman Li, Nicholas Kazlauskas, Chenyu Chen, amd-gfx, dri-devel,
linux-kernel, Hugo Sales
From: Hugo Sales <hugo@hsal.es>
Writing panel_power_savings while the eDP is in PSR hangs DMUB on a
Cezanne laptop (DCN 2.1)
An abm_level change on its own is a fast update, so the commit skips
amdgpu_dm_commit_streams(), where amdgpu_dm_mod_power_update_streams()
sets the events that keep the panel out of self-refresh. The ABM level
then reaches DMUB through amdgpu_dm_commit_planes(), or through the
connector update loop in amdgpu_dm_atomic_commit_tail(), with the panel
still in self-refresh
Raise the PSR and Replay hw_programming events before both updates and
clear them once DC has the new level. Leaving them for
amdgpu_dm_enable_self_refresh() would keep PSR off on an idle desktop
until an unrelated commit came along. An event that a full update, a
modeset or a PSR SU dirty rect change set before the update stays set,
for that code to clear
Fixes: 8c322309e48e ("drm/amd/display: Enable PSR")
Signed-off-by: Hugo Sales <hugo@hsal.es>
---
v1 was tested on an ASUS ROG Flow X13 (GV301QH, Cezanne, DCN 2.1, PSR1 eDP)
with PSR turned on through amdgpu.dcfeaturemask=0xa and "drm/amd/display:
Don't require DMUB PSR caps before DCN 3.0" [1], which DCN 2.1 needs for
PSR to come up at all, but, as far as I can tell, the same bug would
manifest on other DMUB versions that use PSR and ABM
On 7.3 without this patch, writing 3 to panel_power_savings while
psr_state reads 6 makes DMUB fail within a second. The log fills with
"DMCUB error - collecting diagnostic data" and the panel shows vertical
lines. amdgpu doesn't attempt a GPU reset, and the errors go on until a
reboot
With the fix, I let psr_state reach 6 before each of these steps:
- turn ABM on, from level 0 to 3
- change the level, from 4 to 1
- turn ABM off, from 1 to 0, which takes the immediate disable path
- switch power-profiles-daemon to balanced and back to power-saver,
which sets a new level each time
None of them logged a DMCUB error. Both kernels had [2] applied as well
I tested v2 the same way. I let psr_state reach 6 before each of these
writes: 0 to 4, 4 to 1, 1 to 4, 4 to 0, and the back-to-back writes
1 2 3 4 and 0 3 0. None logged a DMCUB error. psr_state left 6 within
7 ms of each write, and PSR was enabled again about 115 ms later. With
ABM on, the panel went back into self-refresh about 18 seconds after the
write
Commit 8c322309e48e ("drm/amd/display: Enable PSR") only paused PSR for
full updates. The power module events used here came with commit
3c108046e1d6 ("drm/amd/display: Add power module on Linux"), so a
backport before that needs another way to leave PSR
[1] https://lore.kernel.org/r/20261029171219.2842014-1-hugo@hsal.es
[2] https://lore.kernel.org/r/20261029165420.2255749-1-hugo@hsal.es
---
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 60 +++++++++++++++++++++++
1 file changed, 60 insertions(+)
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index dfbc384fbbdb4..262170b611502 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -3841,6 +3841,56 @@ STATIC_IFN_KUNIT void dm_arm_vblank_event_pre_programming(struct amdgpu_crtc *ac
}
EXPORT_IF_KUNIT(dm_arm_vblank_event_pre_programming);
+struct dm_sr_hold {
+ bool psr;
+ bool replay;
+};
+
+/*
+ * DMUB can hang if an ABM level reaches it while the panel is in
+ * self-refresh. A commit that changes only the ABM level is a fast update and
+ * skips the hold in amdgpu_dm_mod_power_update_streams(), so hold PSR and
+ * Replay off around the DC update. Holds that something else already set stay
+ * as they are, for their owner to clear. dc_lock keeps the backlight path,
+ * amdgpu_dm_mod_power_update_streams() and the self-refresh code in
+ * amdgpu_dm_commit_planes() from changing them in between.
+ * amdgpu_dm_mod_power_setup_streams() sets them without dc_lock, but only for
+ * a modeset stream, earlier in the same commit tail
+ */
+static struct dm_sr_hold dm_hold_self_refresh(struct amdgpu_display_manager *dm,
+ struct dc_stream_state *stream)
+{
+ struct dm_sr_hold hold;
+
+ lockdep_assert_held(&dm->dc_lock);
+
+ hold.psr = !amdgpu_dm_psr_event_is_set(dm, stream, psr_event_hw_programming);
+ hold.replay = !amdgpu_dm_replay_event_is_set(dm, stream, replay_event_hw_programming);
+
+ if (hold.psr)
+ amdgpu_dm_psr_set_event(dm, stream, true, psr_event_hw_programming, true);
+ if (hold.replay)
+ amdgpu_dm_replay_set_event(dm, stream, true, replay_event_hw_programming, true);
+
+ return hold;
+}
+
+/*
+ * Nothing else may commit on an idle desktop, so drop the hold right after the
+ * update rather than leaving it to amdgpu_dm_enable_self_refresh()
+ */
+static void dm_release_self_refresh(struct amdgpu_display_manager *dm,
+ struct dc_stream_state *stream,
+ struct dm_sr_hold hold)
+{
+ lockdep_assert_held(&dm->dc_lock);
+
+ if (hold.psr)
+ amdgpu_dm_psr_set_event(dm, stream, false, psr_event_hw_programming, false);
+ if (hold.replay)
+ amdgpu_dm_replay_set_event(dm, stream, false, replay_event_hw_programming, false);
+}
+
static void amdgpu_dm_commit_planes(struct drm_atomic_commit *state,
struct drm_device *dev,
struct amdgpu_display_manager *dm,
@@ -3868,6 +3918,7 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_commit *state,
bool dirty_rects_changed = false;
bool updated_planes_and_streams = false;
bool stream_update_needed = false;
+ struct dm_sr_hold sr_hold = {};
struct {
struct dc_surface_update surface_updates[MAX_SURFACES];
struct dc_plane_info plane_infos[MAX_SURFACES];
@@ -4224,11 +4275,16 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_commit *state,
amdgpu_dm_replay_set_event(dm, acrtc_state->stream, true,
replay_event_immediate_flip, true);
}
+ if (bundle->stream_update.abm_level) {
+ dc_exit_ips_for_hw_access(dm->dc);
+ sr_hold = dm_hold_self_refresh(dm, acrtc_state->stream);
+ }
update_planes_and_stream_adapter(dm->dc,
planes_count,
acrtc_state->stream,
stream_update_needed ? &bundle->stream_update : NULL,
bundle->surface_updates);
+ dm_release_self_refresh(dm, acrtc_state->stream, sr_hold);
updated_planes_and_streams = true;
/**
@@ -5198,6 +5254,7 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_commit *state)
struct dc_info_packet hdr_packet;
struct dc_stream_status *status = NULL;
bool abm_changed, hdr_changed, scaling_changed, output_color_space_changed = false;
+ struct dm_sr_hold sr_hold = {};
memset(&stream_update, 0, sizeof(stream_update));
@@ -5280,11 +5337,14 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_commit *state)
mutex_lock(&dm->dc_lock);
dc_exit_ips_for_hw_access(dm->dc);
+ if (abm_changed)
+ sr_hold = dm_hold_self_refresh(dm, dm_new_crtc_state->stream);
dc_update_planes_and_stream(dm->dc,
dummy_updates,
status->plane_count,
dm_new_crtc_state->stream,
&stream_update);
+ dm_release_self_refresh(dm, dm_new_crtc_state->stream, sr_hold);
mutex_unlock(&dm->dc_lock);
kfree(dummy_updates);
--
2.56.0
^ permalink raw reply [flat|nested] 5+ messages in thread* [PATCH v2 3/3] drm/amd/display: Send a changed ABM level once per commit
2026-11-13 19:40 [PATCH v2 0/3] drm/amd/display: Leave self-refresh before an ABM level update Hugo Sales via B4 Relay
2026-11-13 19:40 ` [PATCH v2 1/3] drm/amd/display: Add helpers to check PSR and Replay events Hugo Sales via B4 Relay
2026-11-13 19:40 ` [PATCH v2 2/3] drm/amd/display: Leave self-refresh before an ABM level update Hugo Sales via B4 Relay
@ 2026-11-13 19:40 ` Hugo Sales via B4 Relay
2026-11-16 8:58 ` [PATCH v2 0/3] drm/amd/display: Leave self-refresh before an ABM level update Chen, Chen-Yu
3 siblings, 0 replies; 5+ messages in thread
From: Hugo Sales via B4 Relay @ 2026-11-13 19:40 UTC (permalink / raw)
To: Harry Wentland, Leo Li, Rodrigo Siqueira, Alex Deucher,
Christian König, David Airlie, Simona Vetter
Cc: Roman Li, Nicholas Kazlauskas, Chenyu Chen, amd-gfx, dri-devel,
linux-kernel, Hugo Sales
From: Hugo Sales <hugo@hsal.es>
When a commit changes the ABM level and also has planes on that CRTC,
the connector update loop in amdgpu_dm_atomic_commit_tail() sends the new
level to DC, and amdgpu_dm_commit_planes() sends it again. The panel
leaves self-refresh for each send, so one level change takes it out of
PSR or Replay twice
Record the CRTCs whose level the connector loop sent, and skip the second
send for them in amdgpu_dm_commit_planes()
Signed-off-by: Hugo Sales <hugo@hsal.es>
---
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 23 +++++++++++++++--------
1 file changed, 15 insertions(+), 8 deletions(-)
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index 262170b611502..3077744b2d2d5 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -3895,7 +3895,8 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_commit *state,
struct drm_device *dev,
struct amdgpu_display_manager *dm,
struct drm_crtc *pcrtc,
- bool wait_for_vblank)
+ bool wait_for_vblank,
+ bool abm_sent)
{
u32 i;
u64 timestamp_ns = ktime_get_ns();
@@ -4245,7 +4246,8 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_commit *state,
}
acrtc_state->stream->abm_level = acrtc_state->abm_level;
- if (acrtc_state->abm_level != dm_old_crtc_state->abm_level) {
+ /* The connector loop in amdgpu_dm_atomic_commit_tail() may have sent it */
+ if (!abm_sent && acrtc_state->abm_level != dm_old_crtc_state->abm_level) {
bundle->stream_update.abm_level = &acrtc_state->abm_level;
stream_update_needed = true;
}
@@ -5230,6 +5232,7 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_commit *state)
struct drm_connector_state *old_con_state = NULL, *new_con_state = NULL;
struct dm_crtc_state *dm_old_crtc_state, *dm_new_crtc_state;
int crtc_disable_count = 0;
+ u32 abm_sent = 0;
trace_amdgpu_dm_atomic_commit_tail_begin(state);
@@ -5255,6 +5258,7 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_commit *state)
struct dc_stream_status *status = NULL;
bool abm_changed, hdr_changed, scaling_changed, output_color_space_changed = false;
struct dm_sr_hold sr_hold = {};
+ bool updated;
memset(&stream_update, 0, sizeof(stream_update));
@@ -5339,14 +5343,16 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_commit *state)
dc_exit_ips_for_hw_access(dm->dc);
if (abm_changed)
sr_hold = dm_hold_self_refresh(dm, dm_new_crtc_state->stream);
- dc_update_planes_and_stream(dm->dc,
- dummy_updates,
- status->plane_count,
- dm_new_crtc_state->stream,
- &stream_update);
+ updated = dc_update_planes_and_stream(dm->dc,
+ dummy_updates,
+ status->plane_count,
+ dm_new_crtc_state->stream,
+ &stream_update);
dm_release_self_refresh(dm, dm_new_crtc_state->stream, sr_hold);
mutex_unlock(&dm->dc_lock);
kfree(dummy_updates);
+ if (abm_changed && updated)
+ abm_sent |= drm_crtc_mask(&acrtc->base);
drm_connector_update_privacy_screen(new_con_state);
}
@@ -5440,7 +5446,8 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_commit *state)
dm_new_crtc_state = to_dm_crtc_state(new_crtc_state);
if (dm_new_crtc_state->stream)
- amdgpu_dm_commit_planes(state, dev, dm, crtc, wait_for_vblank);
+ amdgpu_dm_commit_planes(state, dev, dm, crtc, wait_for_vblank,
+ abm_sent & drm_crtc_mask(crtc));
}
/* Enable writeback */
--
2.56.0
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH v2 0/3] drm/amd/display: Leave self-refresh before an ABM level update
2026-11-13 19:40 [PATCH v2 0/3] drm/amd/display: Leave self-refresh before an ABM level update Hugo Sales via B4 Relay
` (2 preceding siblings ...)
2026-11-13 19:40 ` [PATCH v2 3/3] drm/amd/display: Send a changed ABM level once per commit Hugo Sales via B4 Relay
@ 2026-11-16 8:58 ` Chen, Chen-Yu
3 siblings, 0 replies; 5+ messages in thread
From: Chen, Chen-Yu @ 2026-11-16 8:58 UTC (permalink / raw)
To: hugo, Harry Wentland, Leo Li, Rodrigo Siqueira, Alex Deucher,
Christian König, David Airlie, Simona Vetter
Cc: Roman Li, Nicholas Kazlauskas, amd-gfx, dri-devel, linux-kernel
Thanks for v2.
For the series:
Reviewed-by: Chenyu Chen <chen-yu.chen@amd.com>
On 11/14/2026 3:40 AM, Hugo Sales via B4 Relay wrote:
> [Some people who received this message don't often get email from devnull+hugo.hsal.es@kernel.org. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
>
> Writing panel_power_savings while the eDP is in PSR hangs DMUB on a
> Cezanne laptop (DCN 2.1). An ABM level change on its own is a fast
> update, so the new level reaches DMUB with the panel still in
> self-refresh. Chenyu Chen confirmed the same on Renoir
>
> Patch 1 adds helpers that tell whether a PSR or Replay event is already
> set on a stream. Patch 2 is the fix. It sets the PSR and Replay
> hw_programming events around the DC update that carries the new level,
> and clears only the events it set. An event that a full update, a
> modeset or a PSR SU dirty rect change set stays set, for that code to
> clear. Patch 3 stops amdgpu_dm_commit_planes() from sending the same
> level again after the connector update loop sent it, so one level change
> leaves self-refresh once
>
> "drm/amd/display: Don't force a modeset when the ABM level changes" [1]
> sends property changes down this fast path, so it needs this series first
>
> HDR metadata may have the same problem. When the HDR static metadata
> changes while HDR stays on, the commit is a fast update too, and the
> connector loop in amdgpu_dm_atomic_commit_tail() sends the new HDR
> infopacket to DC with the panel still in self-refresh. I have no panel
> with HDR and PSR or Replay to try it on, and the VRR and AVI infopackets
> already reach DC the same way. Does an infopacket update in self-refresh
> need the same pause?
>
> v2:
> - Clear the events right after the DC update, under dc_lock, instead of
> on the next fast commit (Chenyu)
> - Only clear the events this update set, so an event that a full
> update, a modeset or a dirty rect change set in the same commit stays
> set
> - Add amdgpu_dm_psr_event_is_set() and amdgpu_dm_replay_event_is_set(),
> with KUnit tests
> - Send a changed level once per commit, so it leaves self-refresh once
>
> v1: https://lore.kernel.org/r/20261031130002.2335615-1-hugo@hsal.es
>
> [1] https://lore.kernel.org/r/20261102-abm-sysfs-commit-v1-2-e5addfd9539a@hsal.es
>
> ---
> Hugo Sales (3):
> drm/amd/display: Add helpers to check PSR and Replay events
> drm/amd/display: Leave self-refresh before an ABM level update
> drm/amd/display: Send a changed ABM level once per commit
>
> drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 83 +++++++++++++++--
> .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_psr.c | 24 +++++
> .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_psr.h | 2 +
> .../drm/amd/display/amdgpu_dm/amdgpu_dm_replay.c | 25 +++++
> .../drm/amd/display/amdgpu_dm/amdgpu_dm_replay.h | 3 +
> .../display/amdgpu_dm/tests/amdgpu_dm_psr_test.c | 60 ++++++++++++
> .../amdgpu_dm/tests/amdgpu_dm_replay_test.c | 102 +++++++++++++++------
> 7 files changed, 263 insertions(+), 36 deletions(-)
> ---
> base-commit: ba496bb837882eb1af58f41572fc289e46c77b8c
> change-id: 20261113-amdgpu-psr-abm-update-next-de20bc23b12c
>
> Best regards,
> --
> Hugo Sales <hugo@hsal.es>
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread