Skip to content

drm/amd/display: Copy probed modes for atomic_check

Hugo Sales amd-gfx b4-sent dri-devel lkml 1 version New

Get series with b4
b4 am [email protected] change-id 20261104-amdgpu-modes-four-57aaed43ab18

Versions newest first

  1. v1 Latest8 patches 0 repliesNew

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/8drm/amd/display: Drop the unadvertised mode checkdrivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_connector.c+0 -80 replies
2/8drm/amd/display: Don't match FreeSync video modes against the last probedrivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_connector.c drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_connector_test.c+13 -180 replies
3/8drm/amd/display: Validate modes with their own timingdrivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_connector.c drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_connector.h drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_connector_test.c+249 -890 replies
4/8drm/amd/display: Copy the preferred and highest refresh modes after probedrivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_connector.c drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_connector.h +2 more+702 -360 replies
5/8drm/amd/display: Pass the sink to the FreeSync and stream timing helpersdrivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_connector.c drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_connector.h +1 more+45 -370 replies
6/8drm/amd/display: Pick the FreeSync video config for the new stream's sinkdrivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_test.c+91 -90 replies
7/8drm/amd/display: Stop reading connector->modes from atomic_checkdrivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_connector.c drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_connector.h drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_connector_test.c +1 more+474 -2150 replies
8/8drm/amd/display: Add KUnit tests for the mode copiesdrivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_connector_test.c drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_test.c+189 -00 replies

Reviews trailers per patch

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

Read the v1 thread

Cover letter [PATCH 0/8] drm/amd/display: Copy probed modes for atomic_check

mode_config.mutex protects connector->modes, but amdgpu_dm walks it from atomic_check, in create_stream_for_sink() and amdgpu_dm_get_highest_refresh_rate_mode(), without that mutex. atomic_check can't take the mutex because of lock ordering. An earlier patch I submitted moved the probe helper's sort under the modeset locks so this walk couldn't race it, and Ville pointed out that the bug is in the reader:
https://lore.kernel.org/r/[email protected]

atomic_check only needs the preferred mode and the highest refresh rate mode. This series copies both at the end of each probe, under mode_config.mutex and connection_mutex, and atomic_check reads the copies under connection_mutex. The highest refresh rate copy is the mode add_fs_modes() built the FreeSync video modes from, as upstream's cached freesync_vid_base is. It's done this way because a search of connector->modes at the end of the probe could pick a command line mode with a higher refresh rate, and amdgpu_dm_is_freesync_video_mode() would then reject the video modes

The copies also need work to stay current after a monitor swap. Until the next probe they still describe the previous monitor, as connector->modes could, and two paths read them before that probe. mode_valid runs before the probe refreshes them, and after a swap the HPD handlers commit before the next probe. Patch 3 has mode_valid validate each mode with its own timing, so it no longer needs the preferred mode. Patch 4 records the EDID of the sink the copies came from, and patch 7 uses them only for a sink with that EDID. atomic_check checks them against the sink of the stream it builds, since a hotplug can swap dc_sink under it. With another sink, atomic_check uses the requested mode's own timing until the next probe, as before the first probe

Patch 1 drops a debug check that walked probed_modes and connector->modes from atomic_check, and asks its author below the cut whether to keep it behind mutex_trylock() instead. Patch 2 stops add_fs_modes() matching against connector->modes, which dropped the FreeSync video modes on every second probe. Patch 4 adds the copies, patches 5 and 6 pass the sink of the stream being built to the code that checks them, patch 7 switches the readers to them, and patch 8 adds tests for the copies

Patch 6 also changes one behaviour, only with amdgpu.freesync_video=1, which is off by default. A CRTC turned on straight into a FreeSync video mode now gets its fixed refresh config, which it never got before

---
Hugo Sales (8):
drm/amd/display: Drop the unadvertised mode check drm/amd/display: Don't match FreeSync video modes against the last probe drm/amd/display: Validate modes with their own timing drm/amd/display: Copy the preferred and highest refresh modes after probe drm/amd/display: Pass the sink to the FreeSync and stream timing helpers drm/amd/display: Pick the FreeSync video config for the new stream's sink drm/amd/display: Stop reading connector->modes from atomic_check drm/amd/display: Add KUnit tests for the mode copies

 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c  |   38 +-
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h  |   23 +-
 .../amd/display/amdgpu_dm/amdgpu_dm_connector.c    |  499 +++++---
 .../amd/display/amdgpu_dm/amdgpu_dm_connector.h    |   13 +-
 .../amd/display/amdgpu_dm/amdgpu_dm_mst_types.c    |    2 +-
 .../amdgpu_dm/tests/amdgpu_dm_connector_test.c     | 1209 +++++++++++++++++---
 .../amd/display/amdgpu_dm/tests/amdgpu_dm_test.c   |  153 +++
 7 files changed, 1644 insertions(+), 293 deletions(-)

---
base-commit: 47df73aa49d1988c8f684b7caf8be6570e966844
change-id: 20261104-amdgpu-modes-four-57aaed43ab18

Best regards,

Signature · 1 line
Hugo Sales <[email protected]>