Skip to content

drm/sti: move commit work out of .atomic_check()

Minseo Park dri-devel 1 version New

Get series with b4
b4 am [email protected]

Versions newest first

  1. v2 Latest4 patches 0 repliesNew

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4drm/sti: cursor: do not resize the pixmap from .atomic_check()drivers/gpu/drm/sti/sti_cursor.c+28 -370 replies
2/4drm/sti: gdp: set the pixel clock from .atomic_update()drivers/gpu/drm/sti/sti_gdp.c+51 -220 replies
3/4drm/sti: hqvdp: start the XP70 from device initdrivers/gpu/drm/sti/sti_hqvdp.c+3 -40 replies
4/4drm/sti: hqvdp: register the VTG client from .atomic_update()drivers/gpu/drm/sti/sti_hqvdp.c+19 -180 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH v2 0/4] drm/sti: move commit work out of .atomic_check()

The three plane .atomic_check() implementations in drivers/gpu/drm/sti do work that belongs in the commit phase. The cursor frees and reallocates its pixmap, the GDP reparents and reclocks the pixel clock, and the HQVDP boots its coprocessor and registers a VTG notifier.

DRM_MODE_ATOMIC_TEST_ONLY runs drm_atomic_check_only(), which calls the plane .atomic_check() hooks and returns without ever calling .atomic_update(), and a commit that fails a check on any other object is dropped the same way. Either path leaves the hardware changed by a configuration that was never applied.

The cursor is the worst of the three. The buffer it frees is the one CUR_PML points at, so the display engine keeps reading it after it has gone back to the DMA pool.

I do not have STiH4xx hardware, so this comes from reading the code rather than from an observed failure. The series builds warning free with W=1 and COMPILE_TEST on x86_64. Testing on a real board would be appreciated.

Tool disclosure, per Documentation/process/generated-content.rst:

This series was produced with the help of Claude (Anthropic), used interactively over a long session rather than from one prompt. The assistant did the code reading that located these three hooks, wrote the patches and wrote the changelogs. I reviewed every hunk and checked every claim in the changelogs against the source before sending, and mine is the only Signed-off-by.

The starting point was a request to look for work done in .atomic_check() that a DRM_MODE_ATOMIC_TEST_ONLY commit would leave behind, after the same question had been put to V4L2, ALSA, DVB and fbdev. Candidates came from a script that flagged .atomic_check() implementations containing register writes, clock calls or allocations; it was calibrated against these three hooks and its output was then read by hand. Of 17 implementations it flagged in the tree, 8 were a pattern match inside the identifier writeback_job, 6 were the normal per-commit allocation idiom, and these three were the only real ones.

Testing is as described above: git am onto the base commit below, W=1 with COMPILE_TEST on x86_64, and checkpatch.pl --strict. No runtime testing and no reproducer.

Changes in v2, all from Thomas Zimmermann's review of v1:
- cursor: the new error message uses drm_err() rather than DRM_ERROR().
- gdp: .atomic_check() now validates the GDP pixel clock with clk_round_rate(), and the clk_set_rate() failure in .atomic_update() is logged with drm_err_once().
- hqvdp: split in two. The XP70 boot moves to device init, as suggested. The clock enable and the VTG registration move to .atomic_update() instead, for the reason below.

On the clk question in v1 2/3: clk_round_rate() is the interface for testing a rate without applying it -- its kerneldoc says it does not "modify the clock hardware in any way" -- and this driver already uses it that way in sti_dvo_connector_mode_valid(), sti_hdmi_connector_mode_valid() and sti_hda_connector_mode_valid(), each against a 50 Hz tolerance window. Those validate the encoder clocks and not the per-GDP clk_pix, so 2/4 does the same check on the GDP clock. The limit is that clk_round_rate() rounds against the parent selected at the time of the call, so the check is skipped when the commit would reparent the clock; only .atomic_update() can catch that case.

On v1 3/3: the XP70 boot indeed belongs in device init and 3/4 moves it there. The other two steps cannot follow it. sti_vtg_register_client() stores the CRTC the plane is attached to, which only a commit knows, and the clock enable is undone by the clk_disable_unprepare() in sti_hqvdp_disable(), so it tracks the streaming lifetime. 4/4 moves both to .atomic_update(), where sti_gdp already registers its own VTG client the same way.

3/4 turns the firmware request into a one-shot at device init. If the deferral matters for a built-in driver whose firmware lives in the root filesystem, request_firmware_nowait() would keep it without putting the load in a commit hook -- happy to respin that way.

Minseo Park (4):
drm/sti: cursor: do not resize the pixmap from .atomic_check() drm/sti: gdp: set the pixel clock from .atomic_update() drm/sti: hqvdp: start the XP70 from device init drm/sti: hqvdp: register the VTG client from .atomic_update()

 drivers/gpu/drm/sti/sti_cursor.c | 65 ++++++++++++----------------
 drivers/gpu/drm/sti/sti_gdp.c    | 73 ++++++++++++++++++++++----------
 drivers/gpu/drm/sti/sti_hqvdp.c  | 44 +++++++++----------
 3 files changed, 101 insertions(+), 81 deletions(-)

base-commit: 4dce97c6c265544342e716e62fd24bbb232590c5

Signature · 1 line
2.43.0