From: Jayesh Choudhary <[email protected]>

[ Upstream commit cfb29225db20c56432a8525366321c0c09edfb2e ]

TIDSS uses crtc_* fields to propagate its registers and set the
clock rates. So set the CRTC modesetting timing parameters with
the adjusted mode when needed, to set correct values.

Cc: Tomi Valkeinen <[email protected]>
Signed-off-by: Jayesh Choudhary <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Tomi Valkeinen <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
---

LLM Generated explanations, may be completely bogus:

YES

- What it fixes
  - The patch computes the CRTC timing fields (crtc_clock, crtc_htotal,
    crtc_vtotal, etc.) in the adjusted mode during modesets. Without
    this, those fields remain unset, which breaks consumers that rely on
    them (notably DRM’s vblank timestamping and some bridges that expect
    crtc_* to be valid).
  - In TIDSS today, atomic enable programs the pixel clock from
    mode->clock and programs timings from mode->hsync_start/htotal etc.,
    so hardware programming itself doesn’t use crtc_* directly. However,
    the DRM core expects crtc_* in the adjusted mode to be valid for
    vblank calculations and helpers.

- Changes in this patch
  - Converts the local mode pointer to non-const so it can be passed to
    the mutating helper:
    - drivers/gpu/drm/tidss/tidss_crtc.c:94
  - After validating the adjusted mode, it initializes the crtc_* timing
    members when a modeset is needed:
    - drivers/gpu/drm/tidss/tidss_crtc.c:102
    - drivers/gpu/drm/tidss/tidss_crtc.c:104
    - New: if (drm_atomic_crtc_needs_modeset(crtc_state))
      drm_mode_set_crtcinfo(mode, 0);
  - The rest of the function remains unchanged, returning the existing
    bus check:
    - drivers/gpu/drm/tidss/tidss_crtc.c:111

- Why this matters (core interactions)
  - Atomic helpers compute vblank timestamping constants from the new
    crtc state’s adjusted mode and they explicitly use the crtc_*
    members:
    - drivers/gpu/drm/drm_atomic_helper.c:1437
    - drivers/gpu/drm/drm_vblank.c:651
  - If crtc_clock is 0 (because crtc_* fields weren’t populated), DRM
    reports it can’t calculate constants and bails:
    - drivers/gpu/drm/drm_vblank.c:728
  - By setting crtc_* in adjusted_mode before the commit helpers run,
    vblank timing setup becomes correct and robust.

- Scope and risk
  - Small, contained change in a single driver file (one variable type
    tweak + one call).
  - No architectural changes; no feature additions.
  - Safe for non-interlaced modes (TIDSS rejects interlace already:
    drivers/gpu/drm/tidss/tidss_dispc.c:1377–1380).
  - Doesn’t change how TIDSS programs hardware timings: dispc still uses
    mode->{h*, v*, flags}
    (drivers/gpu/drm/tidss/tidss_dispc.c:1218–1269), and pixel clock
    still comes from mode->clock
    (drivers/gpu/drm/tidss/tidss_crtc.c:227–229).
  - Improves correctness for DRM subsystems that rely on crtc_* (vblank,
    some bridges).

- Stable backport criteria
  - Fixes a real bug that can cause broken/missing vblank timing and
    potentially wrong rates in downstream components that use crtc_*.
  - Minimal and self-contained.
  - No user-visible API/ABI changes and low regression risk.
  - Applies to all stable trees that include TIDSS and the atomic helper
    flow; dependencies (drm_mode_set_crtcinfo and
    drm_atomic_crtc_needs_modeset) are longstanding.

Conclusion: This is a targeted bugfix with low risk and clear benefit
for correctness in the DRM atomic pipeline; it should be backported to
stable.

 drivers/gpu/drm/tidss/tidss_crtc.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/tidss/tidss_crtc.c 
b/drivers/gpu/drm/tidss/tidss_crtc.c
index 17efd77ce7f23..da89fd01c3376 100644
--- a/drivers/gpu/drm/tidss/tidss_crtc.c
+++ b/drivers/gpu/drm/tidss/tidss_crtc.c
@@ -91,7 +91,7 @@ static int tidss_crtc_atomic_check(struct drm_crtc *crtc,
        struct dispc_device *dispc = tidss->dispc;
        struct tidss_crtc *tcrtc = to_tidss_crtc(crtc);
        u32 hw_videoport = tcrtc->hw_videoport;
-       const struct drm_display_mode *mode;
+       struct drm_display_mode *mode;
        enum drm_mode_status ok;
 
        dev_dbg(ddev->dev, "%s\n", __func__);
@@ -108,6 +108,9 @@ static int tidss_crtc_atomic_check(struct drm_crtc *crtc,
                return -EINVAL;
        }
 
+       if (drm_atomic_crtc_needs_modeset(crtc_state))
+               drm_mode_set_crtcinfo(mode, 0);
+
        return dispc_vp_bus_check(dispc, hw_videoport, crtc_state);
 }
 
-- 
2.51.0

Reply via email to