* FAILED: patch "[PATCH] drm/amd/display: Hold the VRR vblank reference only on active" failed to apply to 7.3-stable tree
@ 2026-12-02 12:34 gregkh
2026-12-02 14:30 ` [PATCH 7.3.y] drm/amd/display: Hold the VRR vblank reference only on active CRTCs Hugo Sales
0 siblings, 1 reply; 3+ messages in thread
From: gregkh @ 2026-12-02 12:34 UTC (permalink / raw)
To: hugo, Wayne.Lin, alexander.deucher, ivan.lipski; +Cc: stable
The patch below does not apply to the 7.3-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable@vger.kernel.org>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-7.3.y
git checkout FETCH_HEAD
git cherry-pick -x ad40065dc8bd5a5e16b13523d9fef6ac94cf2b66
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<stable@vger.kernel.org>' --in-reply-to '2026120245-early-dyslexia-23e5@gregkh' --subject-prefix 'PATCH 7.3.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From ad40065dc8bd5a5e16b13523d9fef6ac94cf2b66 Mon Sep 17 00:00:00 2001
From: Hugo Sales <hugo@hsal.es>
Date: Sat, 31 Oct 2026 14:33:51 +0000
Subject: [PATCH] drm/amd/display: Hold the VRR vblank reference only on active
CRTCs
amdgpu_dm_handle_vrr_transition() takes a vblank reference when a CRTC
state turns VRR on and drops it when a later state turns it off. It only
looks at freesync_config.state, and disabling a CRTC keeps that state,
so a suspend or DPMS off with VRR active keeps the reference
On resume, drm_atomic_helper_resume() first calls drm_mode_config_reset(),
which swaps the CRTC state for a zeroed one. The restored state then goes
from VRR_STATE_UNSUPPORTED to active and takes a second reference, and
the first is never dropped. The vblank irq stays on for good, so the CRTC
never idles and PSR is never entered
A VRR change on a disabled CRTC can't take the reference at all, since
vblank is off there and drm_crtc_vblank_get() fails with a WARN
On a Cezanne laptop with VRR always on, each suspend added one to the
eDP CRTC's vblank refcount, and it stayed at 1 rather than 0 after VRR
was turned off again
Treat VRR as active for the reference only while the CRTC is active too.
Disabling the CRTC then drops it and enabling it takes it again, which
balances suspend, resume and DPMS, and the get only happens once
manage_dm_interrupts() has turned vblank on
Fixes: 66b0c973d7f7 ("drm/amd/display: Prevent vblank irq disable while VRR is active. (v3)")
Reviewed-by: Ivan Lipski <ivan.lipski@amd.com>
Signed-off-by: Hugo Sales <hugo@hsal.es>
Signed-off-by: Wayne Lin <Wayne.Lin@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit 4232ec2333ab3ef16520b399b30d50f17ceb9c63)
Cc: stable@vger.kernel.org
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_freesync.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_freesync.c
index 0be4506e9ae5..2255ee5f8341 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_freesync.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_freesync.c
@@ -400,8 +400,16 @@ void amdgpu_dm_handle_vrr_transition(struct amdgpu_display_manager *dm,
struct dm_crtc_state *new_state)
{
struct amdgpu_device *adev = dm->adev;
- bool old_vrr_active = amdgpu_dm_crtc_vrr_active(old_state);
- bool new_vrr_active = amdgpu_dm_crtc_vrr_active(new_state);
+ /*
+ * A disabled CRTC keeps its freesync state, but drm_crtc_vblank_get()
+ * fails there because vblank is off. Hold the reference only while
+ * the CRTC is active as well, which also covers resume, where the
+ * reset state lost track of the reference taken before suspend
+ */
+ bool old_vrr_active = old_state->base.active &&
+ amdgpu_dm_crtc_vrr_active(old_state);
+ bool new_vrr_active = new_state->base.active &&
+ amdgpu_dm_crtc_vrr_active(new_state);
/* Only DCE gates vupdate on VRR, keep it enabled for DCN */
bool vrr_gates_vupdate = amdgpu_ip_version(adev, DCE_HWIP, 0) == 0;
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_freesync_test.c b/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_freesync_test.c
index 5ad50bc31613..658b2630923d 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_freesync_test.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_freesync_test.c
@@ -813,8 +813,10 @@ static void dm_test_handle_vrr_transition_round_trip(struct kunit *test)
mutex_init(&adev->dm.dc_lock);
old_state.base.crtc = &acrtc->base;
+ old_state.base.active = true;
old_state.stream = stream;
new_state.base.crtc = &acrtc->base;
+ new_state.base.active = true;
new_state.stream = stream;
new_state.freesync_config.state = VRR_STATE_ACTIVE_VARIABLE;
@@ -825,6 +827,99 @@ static void dm_test_handle_vrr_transition_round_trip(struct kunit *test)
KUNIT_EXPECT_EQ(test, atomic_read(&vblank->refcount), 0);
}
+/*
+ * Runs a transition on a CRTC whose vblank is on with two references held,
+ * so a get or put never has to enable or disable it, and returns the
+ * refcount afterwards
+ */
+static int dm_test_vrr_transition_refcount(struct kunit *test,
+ bool old_active, enum mod_vrr_state old_vrr,
+ bool new_active, enum mod_vrr_state new_vrr)
+{
+ struct amdgpu_device *adev = dm_kunit_alloc_adev(test);
+ struct amdgpu_display_manager *dm = dm_kunit_alloc_dm(test);
+ struct dm_crtc_state *old_state, *new_state;
+ struct drm_crtc *crtc;
+ int refcount;
+
+ KUNIT_ASSERT_EQ(test, drm_vblank_init(&adev->ddev, 1), 0);
+ adev->ip_versions[DCE_HWIP][0] = IP_VERSION(2, 1, 0);
+ dm->adev = adev;
+ mutex_init(&dm->dc_lock);
+
+ crtc = kunit_kzalloc(test, sizeof(*crtc), GFP_KERNEL);
+ KUNIT_ASSERT_NOT_NULL(test, crtc);
+ crtc->dev = &adev->ddev;
+
+ old_state = kunit_kzalloc(test, sizeof(*old_state), GFP_KERNEL);
+ new_state = kunit_kzalloc(test, sizeof(*new_state), GFP_KERNEL);
+ KUNIT_ASSERT_NOT_NULL(test, old_state);
+ KUNIT_ASSERT_NOT_NULL(test, new_state);
+ old_state->base.crtc = crtc;
+ old_state->base.active = old_active;
+ old_state->freesync_config.state = old_vrr;
+ new_state->base.crtc = crtc;
+ new_state->base.active = new_active;
+ new_state->freesync_config.state = new_vrr;
+
+ adev->ddev.vblank[0].enabled = true;
+ atomic_set(&adev->ddev.vblank[0].refcount, 2);
+
+ amdgpu_dm_handle_vrr_transition(dm, old_state, new_state);
+ refcount = atomic_read(&adev->ddev.vblank[0].refcount);
+
+ /* drm_vblank_init_release() warns if vblank is still enabled */
+ adev->ddev.vblank[0].enabled = false;
+ atomic_set(&adev->ddev.vblank[0].refcount, 0);
+
+ return refcount;
+}
+
+/**
+ * dm_test_vrr_transition_crtc_off_drops_ref - Test disabling the CRTC drops the ref
+ * @test: The KUnit test context
+ *
+ * Disabling the CRTC keeps the freesync state, as on suspend or DPMS off.
+ * The reference must still be dropped, since resume restores the state from
+ * a reset one and takes a new reference
+ */
+static void dm_test_vrr_transition_crtc_off_drops_ref(struct kunit *test)
+{
+ KUNIT_EXPECT_EQ(test,
+ dm_test_vrr_transition_refcount(test, true, VRR_STATE_ACTIVE_VARIABLE,
+ false, VRR_STATE_ACTIVE_VARIABLE),
+ 1);
+}
+
+/**
+ * dm_test_vrr_transition_crtc_on_takes_ref - Test enabling the CRTC takes the ref
+ * @test: The KUnit test context
+ *
+ * Covers resume, where the old state is a reset one, and DPMS on
+ */
+static void dm_test_vrr_transition_crtc_on_takes_ref(struct kunit *test)
+{
+ KUNIT_EXPECT_EQ(test,
+ dm_test_vrr_transition_refcount(test, false, VRR_STATE_UNSUPPORTED,
+ true, VRR_STATE_ACTIVE_VARIABLE),
+ 3);
+}
+
+/**
+ * dm_test_vrr_transition_crtc_off_keeps_ref - Test no ref change while off
+ * @test: The KUnit test context
+ *
+ * A disabled CRTC has vblank off, so a VRR change there must neither take
+ * nor drop a reference
+ */
+static void dm_test_vrr_transition_crtc_off_keeps_ref(struct kunit *test)
+{
+ KUNIT_EXPECT_EQ(test,
+ dm_test_vrr_transition_refcount(test, false, VRR_STATE_UNSUPPORTED,
+ false, VRR_STATE_ACTIVE_VARIABLE),
+ 2);
+}
+
static struct kunit_case amdgpu_dm_freesync_tests[] = {
/* amdgpu_dm_is_timing_unchanged_for_freesync */
KUNIT_CASE(dm_test_timing_unchanged_null_args),
@@ -867,6 +962,9 @@ static struct kunit_case amdgpu_dm_freesync_tests[] = {
/* amdgpu_dm_handle_vrr_transition */
KUNIT_CASE(dm_test_handle_vrr_transition_inactive),
KUNIT_CASE(dm_test_handle_vrr_transition_round_trip),
+ KUNIT_CASE(dm_test_vrr_transition_crtc_off_drops_ref),
+ KUNIT_CASE(dm_test_vrr_transition_crtc_on_takes_ref),
+ KUNIT_CASE(dm_test_vrr_transition_crtc_off_keeps_ref),
{}
};
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 7.3.y] drm/amd/display: Hold the VRR vblank reference only on active CRTCs
2026-12-02 12:34 FAILED: patch "[PATCH] drm/amd/display: Hold the VRR vblank reference only on active" failed to apply to 7.3-stable tree gregkh
@ 2026-12-02 14:30 ` Hugo Sales
2026-12-03 13:47 ` Sasha Levin
0 siblings, 1 reply; 3+ messages in thread
From: Hugo Sales @ 2026-12-02 14:30 UTC (permalink / raw)
To: stable; +Cc: Ivan Lipski, Wayne Lin, Alex Deucher
amdgpu_dm_handle_vrr_transition() takes a vblank reference when a CRTC
state turns VRR on and drops it when a later state turns it off. It only
looks at freesync_config.state, and disabling a CRTC keeps that state,
so a suspend or DPMS off with VRR active keeps the reference
On resume, drm_atomic_helper_resume() first calls drm_mode_config_reset(),
which swaps the CRTC state for a zeroed one. The restored state then goes
from VRR_STATE_UNSUPPORTED to active and takes a second reference, and
the first is never dropped. The vblank irq stays on for good, so the CRTC
never idles and PSR is never entered
A VRR change on a disabled CRTC can't take the reference at all, since
vblank is off there and drm_crtc_vblank_get() fails with a WARN
On a Cezanne laptop with VRR always on, each suspend added one to the
eDP CRTC's vblank refcount, and it stayed at 1 rather than 0 after VRR
was turned off again
Treat VRR as active for the reference only while the CRTC is active too.
Disabling the CRTC then drops it and enabling it takes it again, which
balances suspend, resume and DPMS, and the get only happens once
manage_dm_interrupts() has turned vblank on
Fixes: 66b0c973d7f7 ("drm/amd/display: Prevent vblank irq disable while VRR is active. (v3)")
Reviewed-by: Ivan Lipski <ivan.lipski@amd.com>
Signed-off-by: Hugo Sales <hugo@hsal.es>
Signed-off-by: Wayne Lin <Wayne.Lin@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit 4232ec2333ab3ef16520b399b30d50f17ceb9c63)
Cc: stable@vger.kernel.org
(cherry picked from commit ad40065dc8bd5a5e16b13523d9fef6ac94cf2b66)
[ Hugo: dropped the changes to dm_test_handle_vrr_transition_round_trip,
which this tree doesn't have ]
Signed-off-by: Hugo Sales <hugo@hsal.es>
---
.../display/amdgpu_dm/amdgpu_dm_freesync.c | 12 ++-
.../amdgpu_dm/tests/amdgpu_dm_freesync_test.c | 99 +++++++++++++++++++
2 files changed, 109 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_freesync.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_freesync.c
index a51cf46d0e448..d5c511e2a30b3 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_freesync.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_freesync.c
@@ -338,8 +338,16 @@ void amdgpu_dm_handle_vrr_transition(struct amdgpu_display_manager *dm,
struct dm_crtc_state *new_state)
{
struct amdgpu_device *adev = dm->adev;
- bool old_vrr_active = amdgpu_dm_crtc_vrr_active(old_state);
- bool new_vrr_active = amdgpu_dm_crtc_vrr_active(new_state);
+ /*
+ * A disabled CRTC keeps its freesync state, but drm_crtc_vblank_get()
+ * fails there because vblank is off. Hold the reference only while
+ * the CRTC is active as well, which also covers resume, where the
+ * reset state lost track of the reference taken before suspend
+ */
+ bool old_vrr_active = old_state->base.active &&
+ amdgpu_dm_crtc_vrr_active(old_state);
+ bool new_vrr_active = new_state->base.active &&
+ amdgpu_dm_crtc_vrr_active(new_state);
/* Only DCE gates vupdate on VRR, keep it enabled for DCN */
bool vrr_gates_vupdate = amdgpu_ip_version(adev, DCE_HWIP, 0) == 0;
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_freesync_test.c b/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_freesync_test.c
index 0ae636dcbbe4e..0667d3f3251e1 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_freesync_test.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_freesync_test.c
@@ -10,6 +10,7 @@
#include <drm/drm_connector.h>
#include <drm/drm_crtc.h>
#include <drm/drm_modes.h>
+#include <drm/drm_vblank.h>
#include "dc.h"
#include "inc/core_types.h"
@@ -416,6 +417,100 @@ static void dm_test_reset_freesync_config(struct kunit *test)
KUNIT_EXPECT_FALSE(test, crtc_state->vrr_infopacket.valid);
}
+/*
+ * Runs a transition on a CRTC whose vblank is on with two references held,
+ * so a get or put never has to enable or disable it, and returns the
+ * refcount afterwards
+ */
+static int dm_test_vrr_transition_refcount(struct kunit *test,
+ bool old_active, enum mod_vrr_state old_vrr,
+ bool new_active, enum mod_vrr_state new_vrr)
+{
+ struct amdgpu_device *adev = dm_kunit_alloc_adev(test);
+ struct amdgpu_display_manager *dm = dm_kunit_alloc_dm(test);
+ struct dm_crtc_state *old_state, *new_state;
+ struct drm_crtc *crtc;
+ int refcount;
+
+ KUNIT_ASSERT_EQ(test, drm_vblank_init(&adev->ddev, 1), 0);
+ adev->ip_versions[DCE_HWIP][0] = IP_VERSION(2, 1, 0);
+ dm->adev = adev;
+ mutex_init(&dm->dc_lock);
+
+ crtc = kunit_kzalloc(test, sizeof(*crtc), GFP_KERNEL);
+ KUNIT_ASSERT_NOT_NULL(test, crtc);
+ crtc->dev = &adev->ddev;
+
+ old_state = kunit_kzalloc(test, sizeof(*old_state), GFP_KERNEL);
+ new_state = kunit_kzalloc(test, sizeof(*new_state), GFP_KERNEL);
+ KUNIT_ASSERT_NOT_NULL(test, old_state);
+ KUNIT_ASSERT_NOT_NULL(test, new_state);
+ old_state->base.crtc = crtc;
+ old_state->base.active = old_active;
+ old_state->freesync_config.state = old_vrr;
+ new_state->base.crtc = crtc;
+ new_state->base.active = new_active;
+ new_state->freesync_config.state = new_vrr;
+
+ adev->ddev.vblank[0].enabled = true;
+ atomic_set(&adev->ddev.vblank[0].refcount, 2);
+
+ amdgpu_dm_handle_vrr_transition(dm, old_state, new_state);
+ refcount = atomic_read(&adev->ddev.vblank[0].refcount);
+
+ /* drm_vblank_init_release() warns if vblank is still enabled */
+ adev->ddev.vblank[0].enabled = false;
+ atomic_set(&adev->ddev.vblank[0].refcount, 0);
+
+ return refcount;
+}
+
+/**
+ * dm_test_vrr_transition_crtc_off_drops_ref - Test disabling the CRTC drops the ref
+ * @test: The KUnit test context
+ *
+ * Disabling the CRTC keeps the freesync state, as on suspend or DPMS off.
+ * The reference must still be dropped, since resume restores the state from
+ * a reset one and takes a new reference
+ */
+static void dm_test_vrr_transition_crtc_off_drops_ref(struct kunit *test)
+{
+ KUNIT_EXPECT_EQ(test,
+ dm_test_vrr_transition_refcount(test, true, VRR_STATE_ACTIVE_VARIABLE,
+ false, VRR_STATE_ACTIVE_VARIABLE),
+ 1);
+}
+
+/**
+ * dm_test_vrr_transition_crtc_on_takes_ref - Test enabling the CRTC takes the ref
+ * @test: The KUnit test context
+ *
+ * Covers resume, where the old state is a reset one, and DPMS on
+ */
+static void dm_test_vrr_transition_crtc_on_takes_ref(struct kunit *test)
+{
+ KUNIT_EXPECT_EQ(test,
+ dm_test_vrr_transition_refcount(test, false, VRR_STATE_UNSUPPORTED,
+ true, VRR_STATE_ACTIVE_VARIABLE),
+ 3);
+}
+
+/**
+ * dm_test_vrr_transition_crtc_off_keeps_ref - Test no ref change while off
+ * @test: The KUnit test context
+ *
+ * A disabled CRTC has vblank off, so a VRR change there must neither take
+ * nor drop a reference
+ */
+static void dm_test_vrr_transition_crtc_off_keeps_ref(struct kunit *test)
+{
+ KUNIT_EXPECT_EQ(test,
+ dm_test_vrr_transition_refcount(test, false, VRR_STATE_UNSUPPORTED,
+ false, VRR_STATE_ACTIVE_VARIABLE),
+ 2);
+}
+
+
static struct kunit_case amdgpu_dm_freesync_tests[] = {
/* amdgpu_dm_is_timing_unchanged_for_freesync */
KUNIT_CASE(dm_test_timing_unchanged_null_args),
@@ -438,6 +533,10 @@ static struct kunit_case amdgpu_dm_freesync_tests[] = {
KUNIT_CASE(dm_test_freesync_config_active_fixed),
/* amdgpu_dm_reset_freesync_config_for_crtc */
KUNIT_CASE(dm_test_reset_freesync_config),
+ /* amdgpu_dm_handle_vrr_transition */
+ KUNIT_CASE(dm_test_vrr_transition_crtc_off_drops_ref),
+ KUNIT_CASE(dm_test_vrr_transition_crtc_on_takes_ref),
+ KUNIT_CASE(dm_test_vrr_transition_crtc_off_keeps_ref),
{}
};
--
2.56.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 7.3.y] drm/amd/display: Hold the VRR vblank reference only on active CRTCs
2026-12-02 14:30 ` [PATCH 7.3.y] drm/amd/display: Hold the VRR vblank reference only on active CRTCs Hugo Sales
@ 2026-12-03 13:47 ` Sasha Levin
0 siblings, 0 replies; 3+ messages in thread
From: Sasha Levin @ 2026-12-03 13:47 UTC (permalink / raw)
To: stable; +Cc: Sasha Levin, Ivan Lipski, Wayne Lin, Alex Deucher, Hugo Sales
> .../amdgpu_dm/tests/amdgpu_dm_freesync_test.c | 99 +++++++++++++++++++
The new KUnit cases call amdgpu_dm_handle_vrr_transition(), which 7.3
doesn't export: its EXPORT_IF_KUNIT() came with 7f50f13108a4
("drm/amd/display: test VRR transitions"), which 7.3 doesn't have. With
the test built as a module, modpost fails. Could you send a v2 that adds
the export or drops the test hunk?
Also, how do you want the IPS follow-up handled on 7.3? With only the
driver change, disabling a CRTC that has VRR active reaches
dc_exit_ips_for_hw_access() in the on->off branch, and IPS stays off
with all displays off on DCN 3.5+. Your RFT
<20261202-amdgpu-vrr-ips-followup-v1-1-9ee6b801271e@hsal.es> fixes that,
but it isn't merged anywhere yet.
The 6.18, 6.12, 6.6 and 6.1 backports look fine; they'll be queued
together with the 7.3 v2.
--
Thanks,
Sasha
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-12-03 13:48 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-02 12:34 FAILED: patch "[PATCH] drm/amd/display: Hold the VRR vblank reference only on active" failed to apply to 7.3-stable tree gregkh
2026-12-02 14:30 ` [PATCH 7.3.y] drm/amd/display: Hold the VRR vblank reference only on active CRTCs Hugo Sales
2026-12-03 13:47 ` Sasha Levin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox