public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v5 1/2] drm/atomic: attempt full modeset on page flip timeout
@ 2026-05-01 20:35 Hamza Mahfooz
  2026-05-01 20:35 ` [PATCH v5 2/2] drm/amd/display: add DMU timeout recovery support Hamza Mahfooz
  2026-05-04 21:50 ` [PATCH v5 1/2] drm/atomic: attempt full modeset on page flip timeout Mario Limonciello
  0 siblings, 2 replies; 10+ messages in thread
From: Hamza Mahfooz @ 2026-05-01 20:35 UTC (permalink / raw)
  To: dri-devel
  Cc: Hamza Mahfooz, Harry Wentland, Leo Li, Rodrigo Siqueira,
	Alex Deucher, Christian König, David Airlie, Simona Vetter,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	Mario Limonciello, Alex Hung, Ray Wu, Wayne Lin, Aurabindo Pillai,
	Timur Kristóf, Mario Limonciello (AMD), Ivan Lipski,
	Chenyu Chen, Matthew Schwartz, Yussuf Khalil, Tom Chung, Roman Li,
	Colin Ian King, Charlene Liu, Kees Cook, amd-gfx, linux-kernel

We should try to recover from page flip timeouts. Forcing
a full modeset should be generic across all atomic KMS drivers,
so try that first.

Signed-off-by: Hamza Mahfooz <someguy@effective-light.com>
---
 drivers/gpu/drm/drm_atomic_helper.c | 51 +++++++++++++++++++++++++++--
 1 file changed, 48 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
index a768398a1884..8ccc6e833c77 100644
--- a/drivers/gpu/drm/drm_atomic_helper.c
+++ b/drivers/gpu/drm/drm_atomic_helper.c
@@ -1926,6 +1926,45 @@ drm_atomic_helper_wait_for_vblanks(struct drm_device *dev,
 }
 EXPORT_SYMBOL(drm_atomic_helper_wait_for_vblanks);
 
+static int force_full_modeset(struct drm_crtc *crtc)
+{
+	struct drm_modeset_acquire_ctx ctx;
+	struct drm_crtc_state *crtc_state;
+	struct drm_atomic_state *state;
+	int ret;
+	int err;
+
+	if (drm_atomic_crtc_needs_modeset(crtc->state))
+		return -EBUSY;
+
+	DRM_MODESET_LOCK_ALL_BEGIN(crtc->dev, ctx, 0, err);
+	state = drm_atomic_state_alloc(crtc->dev);
+	if (!state)
+		return -ENOMEM;
+
+	state->acquire_ctx = &ctx;
+
+	crtc_state = drm_atomic_get_crtc_state(state, crtc);
+	if (IS_ERR(crtc_state)) {
+		ret = PTR_ERR(crtc_state);
+		goto out;
+	}
+
+	crtc_state->connectors_changed = true;
+	crtc_state->mode_changed = true;
+	crtc_state->active_changed = true;
+
+	drm_info(crtc->dev,
+		 "[CRTC:%d:%s] Attempting force full modeset...\n",
+		 crtc->base.id, crtc->name);
+
+	ret = drm_atomic_commit(state);
+out:
+	drm_atomic_state_put(state);
+	DRM_MODESET_LOCK_ALL_END(crtc->dev, ctx, err);
+	return ret;
+}
+
 /**
  * drm_atomic_helper_wait_for_flip_done - wait for all page flips to be done
  * @dev: DRM device
@@ -1949,17 +1988,23 @@ void drm_atomic_helper_wait_for_flip_done(struct drm_device *dev,
 
 	for (i = 0; i < dev->mode_config.num_crtc; i++) {
 		struct drm_crtc_commit *commit = state->crtcs[i].commit;
-		int ret;
 
 		crtc = state->crtcs[i].ptr;
 
 		if (!crtc || !commit)
 			continue;
 
-		ret = wait_for_completion_timeout(&commit->flip_done, 10 * HZ);
-		if (ret == 0)
+		if (!wait_for_completion_timeout(&commit->flip_done, 10 * HZ)) {
+			int ret;
 			drm_err(dev, "[CRTC:%d:%s] flip_done timed out\n",
 				crtc->base.id, crtc->name);
+
+			ret = force_full_modeset(crtc);
+			if (ret)
+				drm_err(dev,
+					"[CRTC:%d:%s] force full modeset failed! ret=%d\n",
+					crtc->base.id, crtc->name, ret);
+		}
 	}
 
 	if (state->fake_commit)
-- 
2.54.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2026-05-05 18:13 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-01 20:35 [PATCH v5 1/2] drm/atomic: attempt full modeset on page flip timeout Hamza Mahfooz
2026-05-01 20:35 ` [PATCH v5 2/2] drm/amd/display: add DMU timeout recovery support Hamza Mahfooz
2026-05-04 21:51   ` Mario Limonciello
2026-05-05 16:02   ` Leo Li
2026-05-05 16:36     ` Leo Li
2026-05-05 16:41       ` Leo Li
2026-05-04 21:50 ` [PATCH v5 1/2] drm/atomic: attempt full modeset on page flip timeout Mario Limonciello
2026-05-05 11:41   ` Hamza Mahfooz
2026-05-05 15:32     ` Mario Limonciello
2026-05-05 18:12       ` Hamza Mahfooz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox