From: Alex Hung <[email protected]> [WHAT] Add a KUnit test for dm_dmub_get_vbios_bounding_box() covering the default IP-version path that returns NULL without allocating GPU memory or issuing GPINT commands.
Assisted-by: Copilot:Claude-Opus-4.8 GPT-5.5 Reviewed-by: Bhawanpreet Lakha <[email protected]> Signed-off-by: Alex Hung <[email protected]> Signed-off-by: Wayne Lin <[email protected]> --- .../amd/display/amdgpu_dm/amdgpu_dm_dmub.c | 3 ++- .../amd/display/amdgpu_dm/amdgpu_dm_dmub.h | 1 + .../amdgpu_dm/tests/amdgpu_dm_dmub_test.c | 24 +++++++++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_dmub.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_dmub.c index 992d9f525ffc..21f6a01840ef 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_dmub.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_dmub.c @@ -385,7 +385,7 @@ dm_dmub_send_vbios_gpint_command(struct amdgpu_device *adev, return DMUB_STATUS_TIMEOUT; } -static void *dm_dmub_get_vbios_bounding_box(struct amdgpu_device *adev) +STATIC_IFN_KUNIT void *dm_dmub_get_vbios_bounding_box(struct amdgpu_device *adev) { void *bb; long long addr; @@ -440,6 +440,7 @@ static void *dm_dmub_get_vbios_bounding_box(struct amdgpu_device *adev) return NULL; } +EXPORT_IF_KUNIT(dm_dmub_get_vbios_bounding_box); enum dmub_ips_disable_type dm_get_default_ips_mode( struct amdgpu_device *adev) diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_dmub.h b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_dmub.h index ba50e1af80c1..c53728d1c131 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_dmub.h +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_dmub.h @@ -69,6 +69,7 @@ int dm_init_microcode(struct amdgpu_device *adev); struct dc_context; struct dmub_cmd_fused_request; +void *dm_dmub_get_vbios_bounding_box(struct amdgpu_device *adev); void abort_fused_io(struct dc_context *ctx, const struct dmub_cmd_fused_request *request); #endif diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_dmub_test.c b/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_dmub_test.c index d75ee1c930ee..ead43eeb38c7 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_dmub_test.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_dmub_test.c @@ -932,6 +932,28 @@ static void dm_test_init_microcode_unsupported_asic(struct kunit *test) KUNIT_EXPECT_EQ(test, dm_init_microcode(adev), 0); } +/* Tests for dm_dmub_get_vbios_bounding_box() */ + +/** + * dm_test_dmub_get_vbios_bounding_box_default_null - Test default IP version returns NULL + * @test: The KUnit test context + * + * For an IP version without a bounding-box size mapping, the switch falls + * through to the default case and dm_dmub_get_vbios_bounding_box() returns + * NULL without allocating GPU memory or issuing GPINT commands. + */ +static void dm_test_dmub_get_vbios_bounding_box_default_null(struct kunit *test) +{ + struct amdgpu_device *adev; + + adev = kunit_kzalloc(test, sizeof(*adev), GFP_KERNEL); + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, adev); + + adev->ip_versions[DCE_HWIP][0] = IP_VERSION(3, 5, 0); + + KUNIT_EXPECT_NULL(test, dm_dmub_get_vbios_bounding_box(adev)); +} + /* Tests for dm_execute_dmub_cmd() */ /** @@ -1369,6 +1391,8 @@ static struct kunit_case amdgpu_dm_dmub_tests[] = { KUNIT_CASE(dm_test_dmub_sw_init_unsupported_asic), /* dm_init_microcode() */ KUNIT_CASE(dm_test_init_microcode_unsupported_asic), + /* dm_dmub_get_vbios_bounding_box() */ + KUNIT_CASE(dm_test_dmub_get_vbios_bounding_box_default_null), /* dm_execute_dmub_cmd() */ KUNIT_CASE(dm_test_execute_dmub_cmd_null_dmub_srv), /* amdgpu_dm_process_dmub_aux_transfer_sync() */ -- 2.43.0
