From: Alex Hung <[email protected]>

[WHY]
A change was added in amdgpu_dm_should_create_sysfs() to
check link->panel_type instead of caps->aux_support, and removed
the OLED exclusion from the ABM property attach path in
amdgpu_dm_setup_backlight_device().

This broke three KUnit tests:
- dm_test_should_create_sysfs_no_backlight_index and
  dm_test_should_create_sysfs_pwm_backlight returned false
  because kzalloc zeroes panel_type but PANEL_TYPE_LCD is 1.
- dm_test_setup_backlight_device_oled_success crashed with a
  NULL pointer dereference in drm_object_attach_property since
  abm_level_property was NULL.

[WHY]
Set panel_type to PANEL_TYPE_LCD in the two sysfs tests and
skip the ABM property attach path in the OLED setup test by
setting amdgpu_dm_abm_level to 0.

Fixes: d8cfcca8eac1 ("dc: Enable CACP on Linux")
Cc: Chenyu Chen <[email protected]>
Assisted-by: Copilot:Claude-Opus-4.6
Reviewed-by: Bhawanpreet Lakha <[email protected]>
Signed-off-by: Alex Hung <[email protected]>
Signed-off-by: George Zhang <[email protected]>
---
 .../amd/display/amdgpu_dm/tests/amdgpu_dm_backlight_test.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git 
a/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_backlight_test.c 
b/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_backlight_test.c
index fff50c1325c6..53df4b668f2e 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_backlight_test.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_backlight_test.c
@@ -1026,6 +1026,7 @@ static void 
dm_test_should_create_sysfs_no_backlight_index(struct kunit *test)
        amdgpu_dm_set_abm_level_param(-1);
        setup_test_connector(test, &fixture, -1, SIGNAL_TYPE_EDP);
        fixture.aconnector->base.connector_type = DRM_MODE_CONNECTOR_eDP;
+       fixture.link->panel_type = PANEL_TYPE_LCD;

        KUNIT_EXPECT_TRUE(test, 
amdgpu_dm_should_create_sysfs(fixture.aconnector));

@@ -1063,6 +1064,7 @@ static void 
dm_test_should_create_sysfs_pwm_backlight(struct kunit *test)
        amdgpu_dm_set_abm_level_param(-1);
        setup_test_connector(test, &fixture, 0, SIGNAL_TYPE_EDP);
        fixture.aconnector->base.connector_type = DRM_MODE_CONNECTOR_eDP;
+       fixture.link->panel_type = PANEL_TYPE_LCD;
        fixture.adev->dm.backlight_caps[0].aux_support = false;

        KUNIT_EXPECT_TRUE(test, 
amdgpu_dm_should_create_sysfs(fixture.aconnector));
@@ -1147,11 +1149,13 @@ static void 
dm_test_setup_backlight_device_oled_success(struct kunit *test)
        struct dm_backlight_connector_fixture fixture = {};
        struct amdgpu_display_manager *dm;
        int saved_backlight = amdgpu_dm_get_backlight_param();
+       int saved_abm_level = amdgpu_dm_get_abm_level_param();

        amdgpu_dm_set_backlight_param(-1);
+       /* Skip ABM property attach (requires full DRM object setup) */
+       amdgpu_dm_set_abm_level_param(0);
        setup_test_connector(test, &fixture, -1, SIGNAL_TYPE_EDP);
        fixture.link->type = dc_connection_single;
-       /* OLED panel avoids the ABM property attach path */
        fixture.link->dpcd_sink_ext_caps.bits.oled = 1;
        dm = &fixture.adev->dm;
        dm->adev = fixture.adev;
@@ -1166,6 +1170,7 @@ static void 
dm_test_setup_backlight_device_oled_success(struct kunit *test)
        KUNIT_EXPECT_TRUE(test, dm->backlight_caps[0].aux_support);

        amdgpu_dm_set_backlight_param(saved_backlight);
+       amdgpu_dm_set_abm_level_param(saved_abm_level);
 }

 static struct kunit_case dm_backlight_test_cases[] = {
--
2.55.0

Reply via email to