* Re: [PATCH 6/8] drm/amd/display: Pick the FreeSync video config for the new stream's sink
@ 2026-11-22 6:51 kernel test robot
0 siblings, 0 replies; 3+ messages in thread
From: kernel test robot @ 2026-11-22 6:51 UTC (permalink / raw)
To: oe-kbuild; +Cc: lkp
::::::
:::::: Manual check reason: "linux-review patch is more than 7 days old, verify it wasn't already superseded"
::::::
BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
In-Reply-To: <20261114-amdgpu-modes-four-v1-6-f11e2a6cd407@hsal.es>
References: <20261114-amdgpu-modes-four-v1-6-f11e2a6cd407@hsal.es>
TO: Hugo Sales via B4 Relay <devnull+hugo.hsal.es@kernel.org>
TO: Harry Wentland <harry.wentland@amd.com>
TO: Leo Li <sunpeng.li@amd.com>
TO: Rodrigo Siqueira <siqueira@igalia.com>
TO: Alex Deucher <alexander.deucher@amd.com>
TO: "Christian König" <christian.koenig@amd.com>
TO: David Airlie <airlied@gmail.com>
TO: Simona Vetter <simona@ffwll.ch>
TO: Ray Wu <ray.wu@amd.com>
TO: Fangzhi Zuo <jerry.zuo@amd.com>
TO: Roman Li <roman.li@amd.com>
TO: Alex Hung <alex.hung@amd.com>
CC: amd-gfx@lists.freedesktop.org
CC: dri-devel@lists.freedesktop.org
CC: linux-kernel@vger.kernel.org
CC: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
CC: Aurabindo Pillai <aurabindo.pillai@amd.com>
CC: Hugo Sales <hugo@hsal.es>
Hi Hugo,
kernel test robot noticed the following build errors:
[auto build test ERROR on 47df73aa49d1988c8f684b7caf8be6570e966844]
url: https://github.com/intel-lab-lkp/linux/commits/Hugo-Sales-via-B4-Relay/drm-amd-display-Drop-the-unadvertised-mode-check/20261114-230912
base: 47df73aa49d1988c8f684b7caf8be6570e966844
patch link: https://lore.kernel.org/r/20261114-amdgpu-modes-four-v1-6-f11e2a6cd407%40hsal.es
patch subject: [PATCH 6/8] drm/amd/display: Pick the FreeSync video config for the new stream's sink
:::::: branch date: 7 days ago
:::::: commit date: 7 days ago
config: openrisc-allmodconfig (https://download.01.org/0day-ci/archive/20261122/202611221400.3hrykDft-lkp@intel.com/config)
compiler: or1k-linux-gcc (GCC) 16.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20261122/202611221400.3hrykDft-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/r/202611221400.3hrykDft-lkp@intel.com/
All errors (new ones prefixed by >>, old ones prefixed by <<):
WARNING: modpost: drivers/net/ethernet/intel/ice/ice: section mismatch in reference: ice_adv_lnk_speed_maps+0x14 (section: .data) -> ice_adv_lnk_speed_100 (section: .init.rodata)
WARNING: modpost: drivers/net/ethernet/intel/ice/ice: section mismatch in reference: ice_adv_lnk_speed_maps+0x30 (section: .data) -> ice_adv_lnk_speed_1000 (section: .init.rodata)
WARNING: modpost: drivers/net/ethernet/intel/ice/ice: section mismatch in reference: ice_adv_lnk_speed_maps+0x4c (section: .data) -> ice_adv_lnk_speed_2500 (section: .init.rodata)
WARNING: modpost: drivers/net/ethernet/intel/ice/ice: section mismatch in reference: ice_adv_lnk_speed_maps+0x68 (section: .data) -> ice_adv_lnk_speed_5000 (section: .init.rodata)
WARNING: modpost: drivers/net/ethernet/intel/ice/ice: section mismatch in reference: ice_adv_lnk_speed_maps+0x84 (section: .data) -> ice_adv_lnk_speed_10000 (section: .init.rodata)
WARNING: modpost: drivers/net/ethernet/intel/ice/ice: section mismatch in reference: ice_adv_lnk_speed_maps+0xa0 (section: .data) -> ice_adv_lnk_speed_25000 (section: .init.rodata)
WARNING: modpost: drivers/net/ethernet/intel/ice/ice: section mismatch in reference: ice_adv_lnk_speed_maps+0xbc (section: .data) -> ice_adv_lnk_speed_40000 (section: .init.rodata)
WARNING: modpost: drivers/net/ethernet/intel/ice/ice: section mismatch in reference: ice_adv_lnk_speed_maps+0xd8 (section: .data) -> ice_adv_lnk_speed_50000 (section: .init.rodata)
WARNING: modpost: drivers/net/ethernet/intel/ice/ice: section mismatch in reference: ice_adv_lnk_speed_maps+0xf4 (section: .data) -> ice_adv_lnk_speed_100000 (section: .init.rodata)
WARNING: modpost: drivers/net/ethernet/intel/ice/ice: section mismatch in reference: ice_adv_lnk_speed_maps+0x110 (section: .data) -> ice_adv_lnk_speed_200000 (section: .init.rodata)
WARNING: modpost: drivers/net/ethernet/qlogic/qed/qed: section mismatch in reference: qed_mfw_ext_maps+0x14 (section: .data) -> qed_mfw_ext_1g (section: .init.rodata)
WARNING: modpost: drivers/net/ethernet/qlogic/qed/qed: section mismatch in reference: qed_mfw_ext_maps+0x30 (section: .data) -> qed_mfw_ext_10g (section: .init.rodata)
WARNING: modpost: drivers/net/ethernet/qlogic/qed/qed: section mismatch in reference: qed_mfw_ext_maps+0x4c (section: .data) -> qed_mfw_ext_25g (section: .init.rodata)
WARNING: modpost: drivers/net/ethernet/qlogic/qed/qed: section mismatch in reference: qed_mfw_ext_maps+0x68 (section: .data) -> qed_mfw_ext_40g (section: .init.rodata)
WARNING: modpost: drivers/net/ethernet/qlogic/qed/qed: section mismatch in reference: qed_mfw_ext_maps+0x84 (section: .data) -> qed_mfw_ext_50g_base_r (section: .init.rodata)
WARNING: modpost: drivers/net/ethernet/qlogic/qed/qed: section mismatch in reference: qed_mfw_ext_maps+0xa0 (section: .data) -> qed_mfw_ext_50g_base_r2 (section: .init.rodata)
WARNING: modpost: drivers/net/ethernet/qlogic/qed/qed: section mismatch in reference: qed_mfw_ext_maps+0xbc (section: .data) -> qed_mfw_ext_100g_base_r2 (section: .init.rodata)
WARNING: modpost: drivers/net/ethernet/qlogic/qed/qed: section mismatch in reference: qed_mfw_ext_maps+0xd8 (section: .data) -> qed_mfw_ext_100g_base_r4 (section: .init.rodata)
WARNING: modpost: drivers/net/ethernet/qlogic/qed/qed: section mismatch in reference: qed_mfw_legacy_maps+0x14 (section: .data) -> qed_mfw_legacy_1g (section: .init.rodata)
WARNING: modpost: drivers/net/ethernet/qlogic/qed/qed: section mismatch in reference: qed_mfw_legacy_maps+0x30 (section: .data) -> qed_mfw_legacy_10g (section: .init.rodata)
WARNING: modpost: drivers/net/ethernet/qlogic/qed/qed: section mismatch in reference: qed_mfw_legacy_maps+0x4c (section: .data) -> qed_mfw_legacy_20g (section: .init.rodata)
WARNING: modpost: drivers/net/ethernet/qlogic/qed/qed: section mismatch in reference: qed_mfw_legacy_maps+0x68 (section: .data) -> qed_mfw_legacy_25g (section: .init.rodata)
WARNING: modpost: drivers/net/ethernet/qlogic/qed/qed: section mismatch in reference: qed_mfw_legacy_maps+0x84 (section: .data) -> qed_mfw_legacy_40g (section: .init.rodata)
WARNING: modpost: drivers/net/ethernet/qlogic/qed/qed: section mismatch in reference: qed_mfw_legacy_maps+0xa0 (section: .data) -> qed_mfw_legacy_50g (section: .init.rodata)
WARNING: modpost: drivers/net/ethernet/qlogic/qed/qed: section mismatch in reference: qed_mfw_legacy_maps+0xbc (section: .data) -> qed_mfw_legacy_bb_100g (section: .init.rodata)
WARNING: modpost: drivers/net/ethernet/qlogic/qede/qede: section mismatch in reference: qede_forced_speed_maps+0x14 (section: .data) -> qede_forced_speed_1000 (section: .init.rodata)
WARNING: modpost: drivers/net/ethernet/qlogic/qede/qede: section mismatch in reference: qede_forced_speed_maps+0x30 (section: .data) -> qede_forced_speed_10000 (section: .init.rodata)
WARNING: modpost: drivers/net/ethernet/qlogic/qede/qede: section mismatch in reference: qede_forced_speed_maps+0x4c (section: .data) -> qede_forced_speed_20000 (section: .init.rodata)
WARNING: modpost: drivers/net/ethernet/qlogic/qede/qede: section mismatch in reference: qede_forced_speed_maps+0x68 (section: .data) -> qede_forced_speed_25000 (section: .init.rodata)
WARNING: modpost: drivers/net/ethernet/qlogic/qede/qede: section mismatch in reference: qede_forced_speed_maps+0x84 (section: .data) -> qede_forced_speed_40000 (section: .init.rodata)
WARNING: modpost: drivers/net/ethernet/qlogic/qede/qede: section mismatch in reference: qede_forced_speed_maps+0xa0 (section: .data) -> qede_forced_speed_50000 (section: .init.rodata)
WARNING: modpost: drivers/net/ethernet/qlogic/qede/qede: section mismatch in reference: qede_forced_speed_maps+0xbc (section: .data) -> qede_forced_speed_100000 (section: .init.rodata)
>> ERROR: modpost: "amdgpu_freesync_vid_mode" [drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/tests/amdgpu_dm_test.ko] undefined!
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 3+ messages in thread* [PATCH 0/8] drm/amd/display: Copy probed modes for atomic_check
@ 2026-11-14 23:09 Hugo Sales via B4 Relay
2026-11-14 23:09 ` Hugo Sales
0 siblings, 1 reply; 3+ messages in thread
From: Hugo Sales via B4 Relay @ 2026-11-14 23:09 UTC (permalink / raw)
To: Harry Wentland, Leo Li, Rodrigo Siqueira, Alex Deucher,
Christian König, David Airlie, Simona Vetter, Ray Wu,
Fangzhi Zuo, Roman Li, Alex Hung
Cc: amd-gfx, dri-devel, linux-kernel, Ville Syrjälä,
Aurabindo Pillai, Hugo Sales
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/auh8pUx_kXUYSdZ8@intel.com
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,
--
Hugo Sales <hugo@hsal.es>
^ permalink raw reply [flat|nested] 3+ messages in thread* [PATCH 6/8] drm/amd/display: Pick the FreeSync video config for the new stream's sink 2026-11-14 23:09 [PATCH 0/8] drm/amd/display: Copy probed modes for atomic_check Hugo Sales via B4 Relay @ 2026-11-14 23:09 ` Hugo Sales 0 siblings, 0 replies; 3+ messages in thread From: Hugo Sales via B4 Relay @ 2026-11-14 23:09 UTC (permalink / raw) To: Harry Wentland, Leo Li, Rodrigo Siqueira, Alex Deucher, Christian König, David Airlie, Simona Vetter, Ray Wu, Fangzhi Zuo, Roman Li, Alex Hung Cc: amd-gfx, dri-devel, linux-kernel, Ville Syrjälä, Aurabindo Pillai, Hugo Sales From: Hugo Sales <hugo@hsal.es> dm_update_crtc_state() picks the fixed refresh config for a FreeSync video mode in its first pass, while it removes the old stream, and create_stream_for_sink() picks that mode's timing in the second pass, for the new stream's sink. The two answers agree only because neither lookup depends on the sink yet. An upcoming patch makes them depend on it, and atomic_check doesn't hold mode_config.mutex, so a hotplug can swap dc_sink between the two passes Move the choice to dm_set_freesync_video_config(), called whenever a stream is added, and ask about new_stream->sink. A CRTC that the commit turns off no longer gets the fixed config A DPMS off commit now only clears the fixed config, and the DPMS on commit, which adds the stream again, sets it. Before, the DPMS on commit inherited it through the duplicated CRTC state. A CRTC turned on straight into a FreeSync video mode now gets the fixed config too, which the old code never set This only applies with the amdgpu.freesync_video=1 module parameter, which is off by default Signed-off-by: Hugo Sales <hugo@hsal.es> --- Before this patch, a CRTC turned on straight into a FreeSync video mode never got the fixed refresh config, since the first pass sets it only in a commit with an old stream. That looks like a bug from commit 6f59f229f8ed ("drm/amd/display: Skip modeset for front porch change"), but I haven't confirmed it on hardware. Was leaving it unset intended? If not, I can split the fix out into its own patch with a Fixes tag dm_set_freesync_video_config() reads new_stream->sink, which dc_stream_state marks deprecated. The stream holds the only reference to the sink it was built for, and keeping a second one in dm_crtc_state would need its own retain and release on duplicate and destroy. I can do that, or have amdgpu_dm_create_validate_stream_for_sink() return the sink, if you'd rather not read the field --- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 39 +++++++++++---- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h | 3 ++ .../amd/display/amdgpu_dm/tests/amdgpu_dm_test.c | 58 ++++++++++++++++++++++ 3 files changed, 91 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c index d67384eba1553..706a63b93ef6b 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c @@ -5516,6 +5516,33 @@ STATIC_IFN_KUNIT int do_aquire_global_lock(struct drm_device *dev, } EXPORT_IF_KUNIT(do_aquire_global_lock); +/* + * Use the fixed refresh config for a FreeSync video mode other than its base. + * create_stream_for_sink() picked @new_stream's timing for new_stream->sink, + * so decide for that sink too, even if a hotplug swapped dc_sink after the + * old stream was built. dc_stream_state marks sink deprecated, but + * dm_update_crtc_state() keeps no other record of the sink the stream was + * built for + */ +STATIC_IFN_KUNIT void +dm_set_freesync_video_config(struct amdgpu_dm_connector *aconnector, + struct dm_crtc_state *dm_new_crtc_state, + const struct dc_stream_state *new_stream) +{ + const struct drm_display_mode *mode = &dm_new_crtc_state->base.mode; + struct drm_display_mode *high_mode; + + if (!amdgpu_freesync_vid_mode || + !amdgpu_dm_is_freesync_video_mode(mode, aconnector, new_stream->sink)) + return; + + high_mode = amdgpu_dm_get_highest_refresh_rate_mode(aconnector, false, + new_stream->sink); + if (high_mode && !drm_mode_equal(mode, high_mode)) + amdgpu_dm_set_freesync_fixed_config(dm_new_crtc_state); +} +EXPORT_IF_KUNIT(dm_set_freesync_video_config); + STATIC_IFN_KUNIT int dm_update_crtc_state(struct amdgpu_display_manager *dm, struct drm_atomic_commit *state, struct drm_crtc *crtc, @@ -5664,15 +5691,6 @@ STATIC_IFN_KUNIT int dm_update_crtc_state(struct amdgpu_display_manager *dm, amdgpu_dm_set_freesync_fixed_config(dm_new_crtc_state); goto skip_modeset; - } else if (amdgpu_freesync_vid_mode && aconnector && - amdgpu_dm_is_freesync_video_mode(&new_crtc_state->mode, - aconnector, aconnector->dc_sink)) { - struct drm_display_mode *high_mode; - - high_mode = amdgpu_dm_get_highest_refresh_rate_mode(aconnector, false, - aconnector->dc_sink); - if (!drm_mode_equal(&new_crtc_state->mode, high_mode)) - amdgpu_dm_set_freesync_fixed_config(dm_new_crtc_state); } ret = dm_atomic_get_state(state, &dm_state); @@ -5735,6 +5753,9 @@ STATIC_IFN_KUNIT int dm_update_crtc_state(struct amdgpu_display_manager *dm, } *needs_dc_state_realloc = true; + + dm_set_freesync_video_config(aconnector, dm_new_crtc_state, + new_stream); } } diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h index 97a74178513a9..926f1794d24e5 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h @@ -1286,6 +1286,9 @@ void amdgpu_dm_update_hdcp(struct drm_atomic_commit *state); int amdgpu_dm_atomic_setup_commit(struct drm_atomic_commit *state); int do_aquire_global_lock(struct drm_device *dev, struct drm_atomic_commit *state); +void dm_set_freesync_video_config(struct amdgpu_dm_connector *aconnector, + struct dm_crtc_state *dm_new_crtc_state, + const struct dc_stream_state *new_stream); int dm_update_crtc_state(struct amdgpu_display_manager *dm, struct drm_atomic_commit *state, struct drm_crtc *crtc, diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_test.c b/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_test.c index b9272b28f53c7..fab6df40ed989 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_test.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_test.c @@ -3213,6 +3213,63 @@ static void dm_test_aquire_global_lock_waits_commit(struct kunit *test) KUNIT_EXPECT_EQ(test, ret, 0); } +/** + * dm_test_freesync_video_config_no_old_stream - Test the fixed config needs no old stream + * @test: The KUnit test context + * + * A DPMS off commit clears the fixed refresh config while it removes the old + * stream, so the DPMS on commit has no old stream and starts from an inactive + * config. A 50 Hz FreeSync video mode of a 1080p60 base must get the fixed + * config back from the new stream alone, and the base itself must not get it + */ +static void dm_test_freesync_video_config_no_old_stream(struct kunit *test) +{ + uint saved_vid_mode = amdgpu_freesync_vid_mode; + struct amdgpu_dm_connector *aconnector; + struct drm_display_mode *base, *mode; + struct dm_crtc_state *crtc_state; + struct dc_stream_state *stream; + + aconnector = kunit_kzalloc(test, sizeof(*aconnector), GFP_KERNEL); + KUNIT_ASSERT_NOT_NULL(test, aconnector); + crtc_state = kunit_kzalloc(test, sizeof(*crtc_state), GFP_KERNEL); + KUNIT_ASSERT_NOT_NULL(test, crtc_state); + stream = kunit_kzalloc(test, sizeof(*stream), GFP_KERNEL); + KUNIT_ASSERT_NOT_NULL(test, stream); + + aconnector->base.connector_type = DRM_MODE_CONNECTOR_HDMIA; + base = &aconnector->freesync_vid_base; + base->clock = 148500; + base->hdisplay = 1920; + base->hsync_start = 2008; + base->hsync_end = 2052; + base->htotal = 2200; + base->vdisplay = 1080; + base->vsync_start = 1084; + base->vsync_end = 1089; + base->vtotal = 1125; + + crtc_state->freesync_config.state = VRR_STATE_INACTIVE; + mode = &crtc_state->base.mode; + drm_mode_copy(mode, base); + + amdgpu_freesync_vid_mode = 1; + + dm_set_freesync_video_config(aconnector, crtc_state, stream); + KUNIT_EXPECT_EQ(test, (int)crtc_state->freesync_config.state, + (int)VRR_STATE_INACTIVE); + + mode->vsync_start += 225; + mode->vsync_end += 225; + mode->vtotal += 225; + dm_set_freesync_video_config(aconnector, crtc_state, stream); + KUNIT_EXPECT_EQ(test, (int)crtc_state->freesync_config.state, + (int)VRR_STATE_ACTIVE_FIXED); + KUNIT_EXPECT_EQ(test, crtc_state->freesync_config.fixed_refresh_in_uhz, 50000000U); + + amdgpu_freesync_vid_mode = saved_vid_mode; +} + /** * dm_test_update_crtc_state_unchanged - Test unchanged state needs no validation * @test: The KUnit test context @@ -5359,6 +5416,7 @@ static struct kunit_case amdgpu_dm_tests[] = { KUNIT_CASE(dm_test_aquire_global_lock_no_crtc), KUNIT_CASE(dm_test_aquire_global_lock_no_commit), KUNIT_CASE(dm_test_aquire_global_lock_waits_commit), + KUNIT_CASE(dm_test_freesync_video_config_no_old_stream), KUNIT_CASE(dm_test_update_crtc_state_unchanged), KUNIT_CASE(dm_test_update_plane_state_detached), KUNIT_CASE(dm_test_mod_power_update_streams_empty), -- 2.56.0 ^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 6/8] drm/amd/display: Pick the FreeSync video config for the new stream's sink @ 2026-11-14 23:09 ` Hugo Sales 0 siblings, 0 replies; 3+ messages in thread From: Hugo Sales @ 2026-11-14 23:09 UTC (permalink / raw) To: Harry Wentland, Leo Li, Rodrigo Siqueira, Alex Deucher, Christian König, David Airlie, Simona Vetter, Ray Wu, Fangzhi Zuo, Roman Li, Alex Hung Cc: amd-gfx, dri-devel, linux-kernel, Ville Syrjälä, Aurabindo Pillai, Hugo Sales dm_update_crtc_state() picks the fixed refresh config for a FreeSync video mode in its first pass, while it removes the old stream, and create_stream_for_sink() picks that mode's timing in the second pass, for the new stream's sink. The two answers agree only because neither lookup depends on the sink yet. An upcoming patch makes them depend on it, and atomic_check doesn't hold mode_config.mutex, so a hotplug can swap dc_sink between the two passes Move the choice to dm_set_freesync_video_config(), called whenever a stream is added, and ask about new_stream->sink. A CRTC that the commit turns off no longer gets the fixed config A DPMS off commit now only clears the fixed config, and the DPMS on commit, which adds the stream again, sets it. Before, the DPMS on commit inherited it through the duplicated CRTC state. A CRTC turned on straight into a FreeSync video mode now gets the fixed config too, which the old code never set This only applies with the amdgpu.freesync_video=1 module parameter, which is off by default Signed-off-by: Hugo Sales <hugo@hsal.es> --- Before this patch, a CRTC turned on straight into a FreeSync video mode never got the fixed refresh config, since the first pass sets it only in a commit with an old stream. That looks like a bug from commit 6f59f229f8ed ("drm/amd/display: Skip modeset for front porch change"), but I haven't confirmed it on hardware. Was leaving it unset intended? If not, I can split the fix out into its own patch with a Fixes tag dm_set_freesync_video_config() reads new_stream->sink, which dc_stream_state marks deprecated. The stream holds the only reference to the sink it was built for, and keeping a second one in dm_crtc_state would need its own retain and release on duplicate and destroy. I can do that, or have amdgpu_dm_create_validate_stream_for_sink() return the sink, if you'd rather not read the field --- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 39 +++++++++++---- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h | 3 ++ .../amd/display/amdgpu_dm/tests/amdgpu_dm_test.c | 58 ++++++++++++++++++++++ 3 files changed, 91 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c index d67384eba1553..706a63b93ef6b 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c @@ -5516,6 +5516,33 @@ STATIC_IFN_KUNIT int do_aquire_global_lock(struct drm_device *dev, } EXPORT_IF_KUNIT(do_aquire_global_lock); +/* + * Use the fixed refresh config for a FreeSync video mode other than its base. + * create_stream_for_sink() picked @new_stream's timing for new_stream->sink, + * so decide for that sink too, even if a hotplug swapped dc_sink after the + * old stream was built. dc_stream_state marks sink deprecated, but + * dm_update_crtc_state() keeps no other record of the sink the stream was + * built for + */ +STATIC_IFN_KUNIT void +dm_set_freesync_video_config(struct amdgpu_dm_connector *aconnector, + struct dm_crtc_state *dm_new_crtc_state, + const struct dc_stream_state *new_stream) +{ + const struct drm_display_mode *mode = &dm_new_crtc_state->base.mode; + struct drm_display_mode *high_mode; + + if (!amdgpu_freesync_vid_mode || + !amdgpu_dm_is_freesync_video_mode(mode, aconnector, new_stream->sink)) + return; + + high_mode = amdgpu_dm_get_highest_refresh_rate_mode(aconnector, false, + new_stream->sink); + if (high_mode && !drm_mode_equal(mode, high_mode)) + amdgpu_dm_set_freesync_fixed_config(dm_new_crtc_state); +} +EXPORT_IF_KUNIT(dm_set_freesync_video_config); + STATIC_IFN_KUNIT int dm_update_crtc_state(struct amdgpu_display_manager *dm, struct drm_atomic_commit *state, struct drm_crtc *crtc, @@ -5664,15 +5691,6 @@ STATIC_IFN_KUNIT int dm_update_crtc_state(struct amdgpu_display_manager *dm, amdgpu_dm_set_freesync_fixed_config(dm_new_crtc_state); goto skip_modeset; - } else if (amdgpu_freesync_vid_mode && aconnector && - amdgpu_dm_is_freesync_video_mode(&new_crtc_state->mode, - aconnector, aconnector->dc_sink)) { - struct drm_display_mode *high_mode; - - high_mode = amdgpu_dm_get_highest_refresh_rate_mode(aconnector, false, - aconnector->dc_sink); - if (!drm_mode_equal(&new_crtc_state->mode, high_mode)) - amdgpu_dm_set_freesync_fixed_config(dm_new_crtc_state); } ret = dm_atomic_get_state(state, &dm_state); @@ -5735,6 +5753,9 @@ STATIC_IFN_KUNIT int dm_update_crtc_state(struct amdgpu_display_manager *dm, } *needs_dc_state_realloc = true; + + dm_set_freesync_video_config(aconnector, dm_new_crtc_state, + new_stream); } } diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h index 97a74178513a9..926f1794d24e5 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h @@ -1286,6 +1286,9 @@ void amdgpu_dm_update_hdcp(struct drm_atomic_commit *state); int amdgpu_dm_atomic_setup_commit(struct drm_atomic_commit *state); int do_aquire_global_lock(struct drm_device *dev, struct drm_atomic_commit *state); +void dm_set_freesync_video_config(struct amdgpu_dm_connector *aconnector, + struct dm_crtc_state *dm_new_crtc_state, + const struct dc_stream_state *new_stream); int dm_update_crtc_state(struct amdgpu_display_manager *dm, struct drm_atomic_commit *state, struct drm_crtc *crtc, diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_test.c b/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_test.c index b9272b28f53c7..fab6df40ed989 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_test.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_test.c @@ -3213,6 +3213,63 @@ static void dm_test_aquire_global_lock_waits_commit(struct kunit *test) KUNIT_EXPECT_EQ(test, ret, 0); } +/** + * dm_test_freesync_video_config_no_old_stream - Test the fixed config needs no old stream + * @test: The KUnit test context + * + * A DPMS off commit clears the fixed refresh config while it removes the old + * stream, so the DPMS on commit has no old stream and starts from an inactive + * config. A 50 Hz FreeSync video mode of a 1080p60 base must get the fixed + * config back from the new stream alone, and the base itself must not get it + */ +static void dm_test_freesync_video_config_no_old_stream(struct kunit *test) +{ + uint saved_vid_mode = amdgpu_freesync_vid_mode; + struct amdgpu_dm_connector *aconnector; + struct drm_display_mode *base, *mode; + struct dm_crtc_state *crtc_state; + struct dc_stream_state *stream; + + aconnector = kunit_kzalloc(test, sizeof(*aconnector), GFP_KERNEL); + KUNIT_ASSERT_NOT_NULL(test, aconnector); + crtc_state = kunit_kzalloc(test, sizeof(*crtc_state), GFP_KERNEL); + KUNIT_ASSERT_NOT_NULL(test, crtc_state); + stream = kunit_kzalloc(test, sizeof(*stream), GFP_KERNEL); + KUNIT_ASSERT_NOT_NULL(test, stream); + + aconnector->base.connector_type = DRM_MODE_CONNECTOR_HDMIA; + base = &aconnector->freesync_vid_base; + base->clock = 148500; + base->hdisplay = 1920; + base->hsync_start = 2008; + base->hsync_end = 2052; + base->htotal = 2200; + base->vdisplay = 1080; + base->vsync_start = 1084; + base->vsync_end = 1089; + base->vtotal = 1125; + + crtc_state->freesync_config.state = VRR_STATE_INACTIVE; + mode = &crtc_state->base.mode; + drm_mode_copy(mode, base); + + amdgpu_freesync_vid_mode = 1; + + dm_set_freesync_video_config(aconnector, crtc_state, stream); + KUNIT_EXPECT_EQ(test, (int)crtc_state->freesync_config.state, + (int)VRR_STATE_INACTIVE); + + mode->vsync_start += 225; + mode->vsync_end += 225; + mode->vtotal += 225; + dm_set_freesync_video_config(aconnector, crtc_state, stream); + KUNIT_EXPECT_EQ(test, (int)crtc_state->freesync_config.state, + (int)VRR_STATE_ACTIVE_FIXED); + KUNIT_EXPECT_EQ(test, crtc_state->freesync_config.fixed_refresh_in_uhz, 50000000U); + + amdgpu_freesync_vid_mode = saved_vid_mode; +} + /** * dm_test_update_crtc_state_unchanged - Test unchanged state needs no validation * @test: The KUnit test context @@ -5359,6 +5416,7 @@ static struct kunit_case amdgpu_dm_tests[] = { KUNIT_CASE(dm_test_aquire_global_lock_no_crtc), KUNIT_CASE(dm_test_aquire_global_lock_no_commit), KUNIT_CASE(dm_test_aquire_global_lock_waits_commit), + KUNIT_CASE(dm_test_freesync_video_config_no_old_stream), KUNIT_CASE(dm_test_update_crtc_state_unchanged), KUNIT_CASE(dm_test_update_plane_state_detached), KUNIT_CASE(dm_test_mod_power_update_streams_empty), -- 2.56.0 ^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-22 6:51 UTC | newest] Thread overview: 3+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-11-22 6:51 [PATCH 6/8] drm/amd/display: Pick the FreeSync video config for the new stream's sink kernel test robot -- strict thread matches above, loose matches on Subject: below -- 2026-11-14 23:09 [PATCH 0/8] drm/amd/display: Copy probed modes for atomic_check Hugo Sales via B4 Relay 2026-11-14 23:09 ` [PATCH 6/8] drm/amd/display: Pick the FreeSync video config for the new stream's sink Hugo Sales via B4 Relay 2026-11-14 23:09 ` Hugo Sales
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.