drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_psr_test.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_psr_test.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_psr_test.c- Extension
.c- Size
- 8725 bytes
- Lines
- 292
- Domain
- Driver Families
- Bucket
- drivers/gpu
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
kunit/test.hamdgpu_dm_psr.h
Detected Declarations
function amdgpu_dm_psr_fill_capsfunction dm_test_psr_fill_caps_version_1function dm_test_psr_fill_caps_version_su1function dm_test_psr_fill_caps_version_unsupportedfunction dm_test_psr_fill_caps_setup_time_zerofunction dm_test_psr_fill_caps_setup_time_midfunction dm_test_psr_fill_caps_setup_time_maxfunction dm_test_psr_fill_caps_link_training_requiredfunction dm_test_psr_fill_caps_link_training_not_requiredfunction dm_test_psr_fill_caps_dpcd_fieldsfunction dm_test_psr_fill_caps_dpcd_fields_unsetfunction dm_test_psr_fill_caps_rate_control_always_zerofunction dm_test_psr_fill_caps_power_opts_z10_always_setfunction dm_test_psr_set_event_null_streamfunction dm_test_psr_set_event_null_linkfunction dm_test_psr_set_event_psr_not_enabled
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0 OR MIT
/*
* KUnit tests for amdgpu_dm_psr.c
*
* Copyright 2026 Advanced Micro Devices, Inc.
*/
#include <kunit/test.h>
#include "amdgpu_dm_psr.h"
/*
* Helper: allocate and zero-initialise a dc_link sufficient for
* amdgpu_dm_psr_fill_caps() testing. The function only accesses
* embedded members (dpcd_caps, psr_settings) so no pointer fields
* need to be wired up.
*/
static struct dc_link *alloc_test_link(struct kunit *test)
{
struct dc_link *link;
link = kunit_kzalloc(test, sizeof(*link), GFP_KERNEL);
KUNIT_ASSERT_NOT_NULL(test, link);
return link;
}
/* Tests for amdgpu_dm_psr_fill_caps() — PSR version mapping */
static void dm_test_psr_fill_caps_version_1(struct kunit *test)
{
struct dc_link *link = alloc_test_link(test);
struct psr_caps caps;
memset(&caps, 0, sizeof(caps));
link->psr_settings.psr_version = DC_PSR_VERSION_1;
amdgpu_dm_psr_fill_caps(link, &caps);
KUNIT_EXPECT_EQ(test, (int)caps.psr_version, 1);
}
static void dm_test_psr_fill_caps_version_su1(struct kunit *test)
{
struct dc_link *link = alloc_test_link(test);
struct psr_caps caps;
memset(&caps, 0, sizeof(caps));
link->psr_settings.psr_version = DC_PSR_VERSION_SU_1;
amdgpu_dm_psr_fill_caps(link, &caps);
KUNIT_EXPECT_EQ(test, (int)caps.psr_version, 2);
}
static void dm_test_psr_fill_caps_version_unsupported(struct kunit *test)
{
struct dc_link *link = alloc_test_link(test);
struct psr_caps caps;
memset(&caps, 0, sizeof(caps));
link->psr_settings.psr_version = DC_PSR_VERSION_UNSUPPORTED;
amdgpu_dm_psr_fill_caps(link, &caps);
/*
* Neither DC_PSR_VERSION_1 nor DC_PSR_VERSION_SU_1,
* so psr_version stays at its zero-initialised value.
*/
KUNIT_EXPECT_EQ(test, (int)caps.psr_version, 0);
}
/* Tests for amdgpu_dm_psr_fill_caps() — RFB setup time */
static void dm_test_psr_fill_caps_setup_time_zero(struct kunit *test)
{
struct dc_link *link = alloc_test_link(test);
struct psr_caps caps;
memset(&caps, 0, sizeof(caps));
/* PSR_SETUP_TIME = 0 → (6 - 0) * 55 = 330 */
link->dpcd_caps.psr_info.psr_dpcd_caps.bits.PSR_SETUP_TIME = 0;
amdgpu_dm_psr_fill_caps(link, &caps);
KUNIT_EXPECT_EQ(test, caps.psr_rfb_setup_time, 330U);
}
static void dm_test_psr_fill_caps_setup_time_mid(struct kunit *test)
{
Annotation
- Immediate include surface: `kunit/test.h`, `amdgpu_dm_psr.h`.
- Detected declarations: `function amdgpu_dm_psr_fill_caps`, `function dm_test_psr_fill_caps_version_1`, `function dm_test_psr_fill_caps_version_su1`, `function dm_test_psr_fill_caps_version_unsupported`, `function dm_test_psr_fill_caps_setup_time_zero`, `function dm_test_psr_fill_caps_setup_time_mid`, `function dm_test_psr_fill_caps_setup_time_max`, `function dm_test_psr_fill_caps_link_training_required`, `function dm_test_psr_fill_caps_link_training_not_required`, `function dm_test_psr_fill_caps_dpcd_fields`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.