mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Munique Feitoza <muniquefeitoz4@gmail.com>
To: Lyude Paul <lyude.paul@maintainer.cc>,
	Danilo Krummrich <dakr@kernel.org>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	Maxime Ripard <mripard@kernel.org>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
	nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
	linux-kernel@vger.kernel.org,
	Munique Feitoza <muniquefeitoz4@gmail.com>
Subject: [PATCH] drm/nouveau/dispnv50: skip vblank and timestamp constants when dotclock is 0
Date: Sat,  5 Dec 2026 14:25:32 -0300	[thread overview]
Message-ID: <20261205172532.6461-1-muniquefeitoz4@gmail.com> (raw)

During probe, nv50_display_read_hw_or_state() marks firmware-inherited
active heads as active and enabled without populating mode timings,
leaving adjusted_mode.crtc_clock at 0 until the first modeset.

If a non-modeset atomic commit such as drm_mode_gamma_set_ioctl() from
plymouthd runs before the first modeset, nv50_disp_atomic_commit_tail()
calls drm_atomic_helper_calc_timestamping_constants() and vblank helpers
with crtc_clock == 0, triggering:

  [drm] *ERROR* crtc 62: Can't calculate constants, dotclock = 0!
  WARNING: drivers/gpu/drm/drm_vblank.c:756

Guard drm_calc_timestamping_constants() and the symmetric vblank
on/get/accurate_count/put calls in nv50_disp_atomic_commit_tail() on
adjusted_mode.crtc_clock != 0.

Signed-off-by: Munique Feitoza <muniquefeitoz4@gmail.com>
---
 drivers/gpu/drm/nouveau/dispnv50/disp.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/dispnv50/disp.c b/drivers/gpu/drm/nouveau/dispnv50/disp.c
index e91130f93db670..9d73a31ba21a44 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/disp.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/disp.c
@@ -2187,7 +2187,11 @@ nv50_disp_atomic_commit_tail(struct drm_atomic_commit *state)
 	drm_atomic_helper_wait_for_dependencies(state);
 	drm_dp_mst_atomic_wait_for_dependencies(state);
 	drm_atomic_helper_update_legacy_modeset_state(dev, state);
-	drm_atomic_helper_calc_timestamping_constants(state);
+	for_each_new_crtc_in_state(state, crtc, new_crtc_state, i) {
+		if (new_crtc_state->enable && new_crtc_state->adjusted_mode.crtc_clock)
+			drm_calc_timestamping_constants(crtc,
+							&new_crtc_state->adjusted_mode);
+	}
 
 	if (atom->lock_core)
 		mutex_lock(&disp->mutex);
@@ -2290,10 +2294,11 @@ nv50_disp_atomic_commit_tail(struct drm_atomic_commit *state)
 
 		if (new_crtc_state->active) {
 			if (!old_crtc_state->active) {
-				drm_crtc_vblank_on(crtc);
+				if (new_crtc_state->adjusted_mode.crtc_clock)
+					drm_crtc_vblank_on(crtc);
 				pm_runtime_get_noresume(dev->dev);
 			}
-			if (new_crtc_state->event)
+			if (new_crtc_state->event && new_crtc_state->adjusted_mode.crtc_clock)
 				drm_crtc_vblank_get(crtc);
 		}
 	}
@@ -2388,14 +2393,14 @@ nv50_disp_atomic_commit_tail(struct drm_atomic_commit *state)
 		if (new_crtc_state->event) {
 			unsigned long flags;
 			/* Get correct count/ts if racing with vblank irq */
-			if (new_crtc_state->active)
+			if (new_crtc_state->active && new_crtc_state->adjusted_mode.crtc_clock)
 				drm_crtc_accurate_vblank_count(crtc);
 			spin_lock_irqsave(&crtc->dev->event_lock, flags);
 			drm_crtc_send_vblank_event(crtc, new_crtc_state->event);
 			spin_unlock_irqrestore(&crtc->dev->event_lock, flags);
 
 			new_crtc_state->event = NULL;
-			if (new_crtc_state->active)
+			if (new_crtc_state->active && new_crtc_state->adjusted_mode.crtc_clock)
 				drm_crtc_vblank_put(crtc);
 		}
 	}
-- 
2.56.1


             reply	other threads:[~2026-12-05 17:25 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-05 17:25 Munique Feitoza [this message]
2026-12-06  8:31 ` [PATCH v2 0/2] drm/nouveau/dispnv50: read back inherited firmware head mode timings Munique Feitoza
2026-12-06  8:31   ` [PATCH v2 1/2] drm/nouveau/nvif: add NVIF_HEAD_V0_STATE method for head timing readback Munique Feitoza
2026-12-06  8:31   ` [PATCH v2 2/2] drm/nouveau/dispnv50: read back hardware mode timings on probe Munique Feitoza

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=20261205172532.6461-1-muniquefeitoz4@gmail.com \
    --to=muniquefeitoz4@gmail.com \
    --cc=airlied@gmail.com \
    --cc=dakr@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lyude.paul@maintainer.cc \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=nouveau@lists.freedesktop.org \
    --cc=simona@ffwll.ch \
    --cc=tzimmermann@suse.de \
    /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

all inboxes | Powered by JetHome®