From: Alex Hung <[email protected]>

[WHY]
Writeback mode tests call drm_mode_probed_add without holding
mode_config.mutex, producing a warning for every generated mode.

[HOW]
Hold the mutex around writeback mode enumeration and release it before
checking the returned count or inspecting the generated modes.

Assisted-by: Copilot:GPT-6-Astra
Reviewed-by: Bhawanpreet Lakha <[email protected]>
Signed-off-by: Alex Hung <[email protected]>
Signed-off-by: George Zhang <[email protected]>
---
 .../gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_wb_test.c   | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_wb_test.c 
b/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_wb_test.c
index 03036f906385..4bc033fdfa97 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_wb_test.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_wb_test.c
@@ -418,7 +418,9 @@ static void dm_test_wb_get_modes_returns_modes(struct kunit 
*test)
        drmm_connector_init(drm, connector, &dm_wb_test_connector_funcs,
                            DRM_MODE_CONNECTOR_VIRTUAL, NULL);
 
+       mutex_lock(&drm->mode_config.mutex);
        count = amdgpu_dm_wb_connector_get_modes(connector);
+       mutex_unlock(&drm->mode_config.mutex);
 
        /* drm_add_modes_noedid should return at least one mode */
        KUNIT_EXPECT_GT(test, count, 0);
@@ -453,7 +455,9 @@ static void dm_test_wb_get_modes_bounded_by_max(struct 
kunit *test)
        drmm_connector_init(drm, connector, &dm_wb_test_connector_funcs,
                            DRM_MODE_CONNECTOR_VIRTUAL, NULL);
 
+       mutex_lock(&drm->mode_config.mutex);
        amdgpu_dm_wb_connector_get_modes(connector);
+       mutex_unlock(&drm->mode_config.mutex);
 
        /* All modes must fit within 3840x2160 */
        list_for_each_entry(mode, &connector->probed_modes, head) {
-- 
2.55.0

Reply via email to