* [PATCH] drm/nouveau/dispnv50: skip vblank and timestamp constants when dotclock is 0
@ 2026-12-05 17:25 ` Munique Feitoza
0 siblings, 0 replies; 3+ messages in thread
From: Munique Feitoza @ 2026-12-05 17:25 UTC (permalink / raw)
To: Lyude Paul, Danilo Krummrich
Cc: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, nouveau, dri-devel, linux-kernel, Munique Feitoza
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH] drm/nouveau/dispnv50: skip vblank and timestamp constants when dotclock is 0
@ 2026-12-05 17:25 ` Munique Feitoza
0 siblings, 0 replies; 3+ messages in thread
From: Munique Feitoza @ 2026-12-05 17:25 UTC (permalink / raw)
To: Lyude Paul, Danilo Krummrich
Cc: Maarten Lankhorst, Maxime Ripard, Simona Vetter, nouveau,
dri-devel, linux-kernel, Munique Feitoza
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] drm/nouveau/dispnv50: skip vblank and timestamp constants when dotclock is 0
2026-12-05 17:25 ` Munique Feitoza
(?)
@ 2026-12-05 17:50 ` sashiko-bot
-1 siblings, 0 replies; 3+ messages in thread
From: sashiko-bot @ 2026-12-05 17:50 UTC (permalink / raw)
To: Munique Feitoza; +Cc: dri-devel
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] drm/nouveau: vblank refcount underflow from guarded
drm_crtc_vblank_on()
- [Low] drm/nouveau/dispnv50: missing Fixes trailer for commit
1b477f42285e
--
commit 5f217a383db7345707a800ea837434136494b11f
Author: Munique Feitoza <muniquefeitoz4@gmail.com>
> drm/nouveau/dispnv50: skip vblank and timestamp constants when dotclock is 0
>
> 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>
[Severity: Low]
This looks like a bug fix for firmware-inherited heads left without mode
timings by nv50_display_read_hw_or_state(). Should this include:
Fixes: 1b477f42285e ("drm/nouveau/kms: Add INHERIT ioctl to nvkm/nvif for reading IOR state")
> diff --git a/drivers/gpu/drm/nouveau/dispnv50/disp.c b/drivers/gpu/drm/nouveau/dispnv50/disp.c
> index 98a5188f65234..9f8f234f58e8b 100644
> --- a/drivers/gpu/drm/nouveau/dispnv50/disp.c
> +++ b/drivers/gpu/drm/nouveau/dispnv50/disp.c
[ ... ]
> @@ -2301,10 +2305,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);
> }
> }
[Severity: High]
Can skipping drm_crtc_vblank_on() here cause vblank->refcount to underflow?
Earlier in nv50_disp_atomic_commit_tail(), disabling a CRTC calls
drm_crtc_vblank_off() even when adjusted_mode.crtc_clock is 0, leaving
vblank->inmodeset and vblank->refcount at 1.
With nouveau.atomic=0, a DPMS off then DPMS on cycle on a firmware-inherited
head before the first modeset re-enables active while crtc_clock is still 0.
This guard then skips drm_crtc_vblank_on(), leaving vblank->inmodeset set.
When the first real modeset sets a non-zero crtc_clock on that active CRTC,
!old_crtc_state->active is false, so drm_crtc_vblank_on() still does not run.
drm_crtc_vblank_get() returns -EINVAL without taking a reference, yet the
later drm_crtc_vblank_put() still drops the inmodeset reference to 0.
On the next disable/enable cycle, drm_crtc_vblank_on_config() decrements
vblank->refcount from 0 to -1, triggering drm_WARN_ON splats and pinning
vblank IRQs enabled. Pairing drm_crtc_vblank_on() with the 0-to-non-zero
crtc_clock transition and checking drm_crtc_vblank_get() would prevent this.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261205172532.6461-1-muniquefeitoz4@gmail.com?part=1
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-12-05 17:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-05 17:25 [PATCH] drm/nouveau/dispnv50: skip vblank and timestamp constants when dotclock is 0 Munique Feitoza
2026-12-05 17:25 ` Munique Feitoza
2026-12-05 17:50 ` sashiko-bot
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.