Commit graph

1,484,914 commits

Author SHA1 Message Date
Alex Hung
eaf6816305 drm/amd/display: Test HPD handler HDCP and detect
[WHAT]
handle_hpd_irq_helper() never ran its HDCP reset, its forced
connector branch or its successful re-detect branch.

[HOW]
Add a minimal HDCP work queue fixture and three tests: an HPD on
a driver that carries an HDCP work queue, which must reset the display
and flag the connector state; a connector forced on that reports no
connection and is emulated instead of detected; and a successful
re-detect that notifies userspace.

Assisted-by: Copilot:Claude-Opus-5
Reviewed-by: Bhawanpreet Lakha <bhawanpreet.lakha@amd.com>
Signed-off-by: Alex Hung <alex.hung@amd.com>
Signed-off-by: George Zhang <george.zhang@amd.com>
Tested-by: Dan Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-09-23 13:27:36 -04:00
Alex Hung
ed32f69ac5 drm/amd/display: Test HDMI HPD debounce re-detect
[WHAT]
amdgpu_dm_hdmi_hpd_debounce_work() only ran with detection
failing, so neither outcome of the sink comparison that decides whether
an HPD toggle was spurious was covered.

[HOW]
Add a fixture for the debounce work item and two tests: a
re-detect finding the same sink, which re-enables internally without
notifying userspace, and one finding a different sink, which sends the
hotplug event.

Assisted-by: Copilot:Claude-Opus-5
Reviewed-by: Bhawanpreet Lakha <bhawanpreet.lakha@amd.com>
Signed-off-by: Alex Hung <alex.hung@amd.com>
Signed-off-by: George Zhang <george.zhang@amd.com>
Tested-by: Dan Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-09-23 13:27:33 -04:00
Alex Hung
92cfd5eb14 drm/amd/display: Test HPD RX offload work branches
[WHAT]
dm_handle_hpd_rx_offload_work() was covered only for its
automated-test and link-loss branches. The connection-type failure, the
GPU-reset drop, the MST message-ready drain and the forced reconnect
were never entered.

[HOW]
Add a fixture that builds a queued offload work item on a
DisplayPort link and four tests: a failing connection-type probe, a
device already in reset, a deferred UP_REQ_MSG_RDY drained through an
AUX that fails every transfer, and an automated test whose timing
changed, which forces the connector off and back on. The last one
registers the DRM device so the hotplug uevent helpers find a sysfs
minor on the primary node.

Assisted-by: Copilot:Claude-Opus-5
Reviewed-by: Bhawanpreet Lakha <bhawanpreet.lakha@amd.com>
Signed-off-by: Alex Hung <alex.hung@amd.com>
Signed-off-by: George Zhang <george.zhang@amd.com>
Tested-by: Dan Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-09-23 13:27:31 -04:00
Alex Hung
dd6d670069 drm/amd/display: Test VRR pageflip completion
[WHAT]
dm_pflip_high_irq() only ever ran with VRR inactive, so the
scanout position query and the front-porch path that queues the
pageflip event on the vblank event list were never reached.

[HOW]
Add a fake timing generator reporting a scanout position past the
start of the front porch, plus a fixture that puts a submitted flip on
an active-VRR stream.

Assisted-by: Copilot:Claude-Opus-5
Reviewed-by: Bhawanpreet Lakha <bhawanpreet.lakha@amd.com>
Signed-off-by: Alex Hung <alex.hung@amd.com>
Signed-off-by: George Zhang <george.zhang@amd.com>
Tested-by: Dan Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-09-23 13:27:29 -04:00
Alex Hung
a6b2fb633c drm/amd/display: Test unassigned OTG CRTC lookup
[WHAT]
amdgpu_dm_get_crtc_by_otg_inst() had no test for an OTG instance
of -1, so its WARN_ON guard and the fallback to the first CRTC were
never executed.

[HOW]
Add dm_test_get_crtc_by_otg_inst_unassigned_otg(), which installs
a CRTC as mode_info.crtcs[0] and asserts the lookup returns it rather
than walking the CRTC list.

Assisted-by: Copilot:Claude-Opus-5
Reviewed-by: Bhawanpreet Lakha <bhawanpreet.lakha@amd.com>
Signed-off-by: Alex Hung <alex.hung@amd.com>
Signed-off-by: George Zhang <george.zhang@amd.com>
Tested-by: Dan Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-09-23 13:27:27 -04:00
Alex Hung
0a2e54900a drm/amd/display: Test MST topology start
[WHAT]
Add a KUnit test to cover dm_helpers_dp_mst_start_top_mgr() its
success path.

[HOW]
Mark the topology manager as already in MST mode, so
drm_dp_mst_topology_mgr_set_mst() returns success without touching the
AUX channel or queueing the link probe work, and the helper reports
that MST was started.

Assisted-by: Copilot:Claude-Opus-5
Reviewed-by: Bhawanpreet Lakha <bhawanpreet.lakha@amd.com>
Signed-off-by: Alex Hung <alex.hung@amd.com>
Signed-off-by: George Zhang <george.zhang@amd.com>
Tested-by: Dan Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-09-23 13:27:25 -04:00
Alex Hung
e149c8a697 drm/amd/display: Test AUX transfer paths
[WHAT]
Add KUnit tests for the AUX paths of dm_helper_dmub_aux_transfer_sync(),
dm_helpers_read_mccs_caps() and dm_helpers_mccs_vcp_set(). Only their
early returns and the plain I2C branch were covered before.

[HOW]
dm_helper_dmub_aux_transfer_sync() is called with HPD connected so it
forwards the payload to the DMUB transfer. dc->link_count is zero, so
the async transfer is rejected and the engine-acquire error is
reported.

Both MCCS helpers pick their DDC adapter from link->aux_mode. Add a
fake AUX channel that ACKs every I2C-over-AUX transaction and counts
the sized writes, then route the shared MCCS fixture through it. The
VCP set completes on the first write. The VCP request gets an empty
reply, so every attempt is retried and the request finally fails.

Assisted-by: Copilot:Claude-Opus-5
Reviewed-by: Bhawanpreet Lakha <bhawanpreet.lakha@amd.com>
Signed-off-by: Alex Hung <alex.hung@amd.com>
Signed-off-by: George Zhang <george.zhang@amd.com>
Tested-by: Dan Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-09-23 13:27:21 -04:00
Alex Hung
4075810c43 drm/amd/display: Test EDID helper paths
[WHAT]
Add KUnit tests for three EDID paths in amdgpu_dm_helpers.c the SDC
panel PSR PHY power-down quirk in apply_edid_quirks(), the HDMI
compliance-auto branch of dm_helpers_parse_edid_caps(), and the VBIOS
fallback and corrupt-EDID paths of dm_helpers_read_local_edid().

[HOW]
apply_edid_quirks() is driven twice with the SDC panel ids, once on a
DisplayPort signal and once on eDP, showing the quirk is embedded-only.

dm_helpers_parse_edid_caps() runs against an HDMI connector whose
hdmi_comp_auto flag is set, so the FRL and FRL DSC debug options are
forced on and the quirk is recorded in the panel patch.

dm_helpers_read_local_edid() is given an embedded link with no DDC
line, so it falls back to the EDID hardcoded in the VBIOS embedded
panel info that the existing fake dc_bios supplies. A second test
corrupts the base block checksum served by the fake AUX DDC, so the
read fails, the real checksum is written back and EDID_BAD_CHECKSUM is
reported.

Assisted-by: Copilot:Claude-Opus-5
Reviewed-by: Bhawanpreet Lakha <bhawanpreet.lakha@amd.com>
Signed-off-by: Alex Hung <alex.hung@amd.com>
Signed-off-by: George Zhang <george.zhang@amd.com>
Tested-by: Dan Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-09-23 13:20:14 -04:00
Alvin Lee
08d0e9af43 drm/amd/display: Re-enable P-State message to SMU
[Description]
Re-enable P-State message to SMU now that support has been added on
SMU side

Reviewed-by: Dillon Varone <dillon.varone@amd.com>
Signed-off-by: Alvin Lee <Alvin.Lee2@amd.com>
Signed-off-by: George Zhang <george.zhang@amd.com>
Tested-by: Dan Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-09-23 13:20:11 -04:00
Alvin Lee
a767ba25a8 drm/amd/display: Wait response should be based on fw_based_mclk_switch
[Description]
When sending the indicate P-Stat message to PMFW, the wait_resp flag
should be set based on fw_based_mclk_switching in order to maintain
the logic from previous product.

Reviewed-by: Wenjing Liu <wenjing.liu@amd.com>
Signed-off-by: Alvin Lee <Alvin.Lee2@amd.com>
Signed-off-by: George Zhang <george.zhang@amd.com>
Tested-by: Dan Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-09-23 13:20:04 -04:00
Alex Hung
87c0087e88 drm/amd/display: Fix amdgpu_dm's kernel-doc warnings
[WHAT]
Document the amdgpu_dm struct members and function parameters reported
by kernel-doc. Convert non-kernel-doc prose comments to regular
comments and clarify the HDMI FRL polling fields.

Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202609051521.dVjPj9Zw-lkp@intel.com/
Assisted-by: Copilot:GPT-5.6-Luna
Reviewed-by: Jerry Zuo <jerry.zuo@amd.com>
Signed-off-by: Alex Hung <alex.hung@amd.com>
Signed-off-by: George Zhang <george.zhang@amd.com>
Tested-by: Dan Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-09-23 13:19:53 -04:00
Tony Cheng
81b3e948d6 drm/amd/display: Add inst field to struct pg_cntl
Add an inst member to struct pg_cntl and set it to 0 in
pg_cntl35_create() and pg_cntl42_create(), since PG cntl is a singleton.

No functional change; the field has no readers yet.

Reviewed-by: Jun Lei <jun.lei@amd.com>
Reviewed-by: Alex Hung <alex.hung@amd.com>
Signed-off-by: Tony Cheng <Tony.Cheng@amd.com>
Signed-off-by: George Zhang <george.zhang@amd.com>
Tested-by: Dan Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-09-23 13:19:49 -04:00
Piotr Maziarz
23c7a0a0ec drm/amd/display: Remove phantom SW state ops from block sequence
[Why]
HWS_APPLY_UPDATE_FLAGS_FOR_PHANTOM and HWS_UPDATE_PHANTOM_VP_POSITION
program no hardware. They only mutate driver state: pipe update flags,
the phantom plane viewport and the phantom scaling params.

A block sequence is built first and executed later, so both ops ran only
after the builder had already inspected pipe_ctx->update_flags to decide
which steps to emit. The phantom pipe was therefore built from stale
flags.

[How]
Call apply_update_flags_for_phantom() and update_phantom_vp_position()
directly from hwss_build_post_unlock_full_sequence(), before
program_pipe_sequence(), matching the legacy
dcn401_post_unlock_program_front_end() ordering.

Reviewed-by: Alvin Lee <alvin.lee2@amd.com>
Signed-off-by: Piotr Maziarz <piotr.maziarz@amd.com>
Signed-off-by: George Zhang <george.zhang@amd.com>
Tested-by: Dan Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-09-23 13:19:46 -04:00
Piotr Maziarz
06421edfe7 drm/amd/display: Refactor DPP_PROGRAM_UPSP to drop pipe_ctx
[Why]
Hwss executors shouldn't be coupled to complex dc structs such as
pipe_ctx. The DPP_PROGRAM_UPSP executor took a whole pipe_ctx only to
reach two fields.

[How]
Change program_upsp_params to hold the dpp and the dscl_prog_data that
dpp_program_upsp() actually needs, and extract them in the generic HWSS
layer. Add hwss_add_dpp_program_upsp() so the build site uses a helper
with the standard bounds check instead of assigning the step inline.
Update the BLS specs.

Reviewed-by: Alvin Lee <alvin.lee2@amd.com>
Signed-off-by: Piotr Maziarz <piotr.maziarz@amd.com>
Signed-off-by: George Zhang <george.zhang@amd.com>
Tested-by: Dan Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-09-23 13:19:43 -04:00
Alex Hung
ae2e917936 drm/amd/display: Fold plane state check tests
[WHAT]
Reduce the four viewport KUnit tests for
amdgpu_dm_plane_helper_check_state() to one, and the three rejection
tests for amdgpu_dm_plane_atomic_check() to one.

[HOW]
Drive the viewport cases from a table of CRTC rectangles and display
sizes, and rebuild the atomic state between the helper-check, color
pipeline conflict and scaling-info sub-cases of the atomic check test.

Assisted-by: Copilot:Claude-Opus-5
Reviewed-by: Bhawanpreet Lakha <bhawanpreet.lakha@amd.com>
Signed-off-by: Alex Hung <alex.hung@amd.com>
Signed-off-by: George Zhang <george.zhang@amd.com>
Tested-by: Dan Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-09-23 13:19:41 -04:00
Alex Hung
e1581d8144 drm/amd/display: Fold plane scaling and cursor tests
[WHAT]
Reduce the two KUnit tests for
amdgpu_dm_plane_get_min_max_dc_plane_scaling() to one, and the two for
amdgpu_dm_plane_get_cursor_position() to one.

[HOW]
Populate the fp16 scaling caps alongside the NV12 and ARGB8888 ones and
query all three formats from one device, and append the oversized cursor
rejection to the existing clipping test.

Assisted-by: Copilot:Claude-Opus-5
Reviewed-by: Bhawanpreet Lakha <bhawanpreet.lakha@amd.com>
Signed-off-by: Alex Hung <alex.hung@amd.com>
Signed-off-by: George Zhang <george.zhang@amd.com>
Tested-by: Dan Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-09-23 13:19:38 -04:00
Alex Hung
c1fbc2facc drm/amd/display: Fold DCC block mode tests
[WHAT]
Reduce the five KUnit tests for the GFX9 DCC block modes of
amdgpu_dm_plane_fill_gfx9_attrs_from_modifiers() to one, and the three
for amdgpu_dm_plane_fill_gfx12_attrs_from_modifiers() to one.

[HOW]
Drive both from a table of modifier bits and the expected HUBP
independent block mode, allocating the device, DC and framebuffer once
and resetting the tiling, DCC and address outputs per row.

Assisted-by: Copilot:Claude-Opus-5
Reviewed-by: Bhawanpreet Lakha <bhawanpreet.lakha@amd.com>
Signed-off-by: Alex Hung <alex.hung@amd.com>
Signed-off-by: George Zhang <george.zhang@amd.com>
Tested-by: Dan Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-09-23 13:19:36 -04:00
Alex Hung
fd5e57fe73 drm/amd/display: Fold DCC validation tests
[WHAT]
Reduce the seven KUnit tests for amdgpu_dm_plane_validate_dcc() to
three.

[HOW]
Split them into a table-driven test for the checks that run before the
DC capability query and a table-driven test for the rejections that come
out of it, leaving the success and scan-mapping test unchanged.

Assisted-by: Copilot:Claude-Opus-5
Reviewed-by: Bhawanpreet Lakha <bhawanpreet.lakha@amd.com>
Signed-off-by: Alex Hung <alex.hung@amd.com>
Signed-off-by: George Zhang <george.zhang@amd.com>
Tested-by: Dan Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-09-23 13:19:33 -04:00
Alex Hung
b15161b132 drm/amd/display: Fold GFX6-8 tiling and modifier tests
[WHAT]
Reduce the four KUnit tests for
amdgpu_dm_plane_fill_gfx6_tiling_info_from_modifier() to one, and the
three for amdgpu_dm_plane_calc_gfx6_mod() to one.

[HOW]
Build the linear, rejected, 1D tiled and 2D tiled modifiers as locals
and decode them in sequence, and drive the micro tiled, GFX7-8 and GFX6
modifier calculations from two devices inside a single test.

Assisted-by: Copilot:Claude-Opus-5
Reviewed-by: Bhawanpreet Lakha <bhawanpreet.lakha@amd.com>
Signed-off-by: Alex Hung <alex.hung@amd.com>
Signed-off-by: George Zhang <george.zhang@amd.com>
Tested-by: Dan Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-09-23 13:19:31 -04:00
Alex Hung
5cdf1619d9 drm/amd/display: Fold GFX9 tiling info tests
[WHAT]
Reduce the two KUnit tests for
amdgpu_dm_plane_fill_gfx9_tiling_info_from_device() to one, and the
three for amdgpu_dm_plane_fill_gfx9_tiling_info_from_modifier() to one.

[HOW]
Reprogram the device configuration and re-run the helper in sequence
inside a single test per function, so the pre-10.3, 10.3-and-later,
linear, pre-NV and NV-and-later cases all stay covered.

Assisted-by: Copilot:Claude-Opus-5
Reviewed-by: Bhawanpreet Lakha <bhawanpreet.lakha@amd.com>
Signed-off-by: Alex Hung <alex.hung@amd.com>
Signed-off-by: George Zhang <george.zhang@amd.com>
Tested-by: Dan Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-09-23 13:19:28 -04:00
Alex Hung
961c31c1c4 drm/amd/display: Fold modifier append tests
[WHAT]
Reduce the four KUnit tests for amdgpu_dm_plane_add_modifier() to two,
and the two tests for amdgpu_dm_plane_add_modifier_dedup() to one.

[HOW]
Group the append and capacity-growth cases into one test and the
NULL-list and allocation-failure cases into another, and run the
duplicate-skip and NULL-list dedup cases in sequence within a single
test.

Assisted-by: Copilot:Claude-Opus-5
Reviewed-by: Bhawanpreet Lakha <bhawanpreet.lakha@amd.com>
Signed-off-by: Alex Hung <alex.hung@amd.com>
Signed-off-by: George Zhang <george.zhang@amd.com>
Tested-by: Dan Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-09-23 13:19:25 -04:00
Alex Hung
5d95a6d2cc drm/amd/display: Fold plane modifier list tests
[WHAT]
Reduce the six KUnit tests for amdgpu_dm_plane_get_plane_modifiers() to
three, keeping every family dispatch covered.

[HOW]
Merge the GFX10.1, GFX10.3 and GFX12 cases into one table-driven test
over the family and GC IP version, and merge the two RV cases into a
table over the external revision id that selects the constant-encode
modifier variants.

Assisted-by: Copilot:Claude-Opus-5
Reviewed-by: Bhawanpreet Lakha <bhawanpreet.lakha@amd.com>
Signed-off-by: Alex Hung <alex.hung@amd.com>
Signed-off-by: George Zhang <george.zhang@amd.com>
Tested-by: Dan Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-09-23 13:19:22 -04:00
Alex Hung
323d41b49e drm/amd/display: Fold universal overlay format test
[WHAT]
Reduce the two KUnit tests for amdgpu_dm_plane_get_plane_formats() to
one.

[HOW]
Allocate a second plane cap with the DCN universal type in the existing
test and check the overlay format count against it, then drop the
standalone test.

Assisted-by: Copilot:Claude-Opus-5
Reviewed-by: Bhawanpreet Lakha <bhawanpreet.lakha@amd.com>
Signed-off-by: Alex Hung <alex.hung@amd.com>
Signed-off-by: George Zhang <george.zhang@amd.com>
Tested-by: Dan Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-09-23 13:19:18 -04:00
Alex Hung
7d7b5a0fb7 drm/amd/display: Fold blending tests into two cases
[WHAT]
Reduce the five KUnit tests for
amdgpu_dm_plane_fill_blending_from_plane_state() to two, keeping every
covered path.

[HOW]
Turn the opaque, premultiplied and coverage cases into one table-driven
test over the pixel blend mode, and fold the DCN 4.2 case into the
global alpha test as a second table row selecting the DCE IP version.

Assisted-by: Copilot:Claude-Opus-5
Reviewed-by: Bhawanpreet Lakha <bhawanpreet.lakha@amd.com>
Signed-off-by: Alex Hung <alex.hung@amd.com>
Signed-off-by: George Zhang <george.zhang@amd.com>
Tested-by: Dan Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-09-23 13:19:14 -04:00
Alex Hung
7c23fe74a1 drm/amd/display: Select KUnit helpers
[WHAT]
DRM_KUNIT_TEST_HELPERS has no prompt, so it can only be turned on by a
select.  DRM_AMD_DC_KUNIT_TEST merely depended on it, which forced the
amdgpu_dm KUnit config to enable CONFIG_DRM_KUNIT_TEST as well and drag
in the entire core DRM test suite.

[HOW]
Select DRM_KUNIT_TEST_HELPERS from DRM_AMD_DC_KUNIT_TEST, matching what
DRM_KUNIT_TEST and DRM_TTM_KUNIT_TEST already do, and drop
CONFIG_DRM_KUNIT_TEST from the amdgpu_dm kunitconfig.  The amdgpu_dm
tests now build standalone and a run executes only the amdgpu_dm suites.

Assisted-by: Copilot:Claude-Opus-5
Reviewed-by: Bhawanpreet Lakha <bhawanpreet.lakha@amd.com>
Signed-off-by: Alex Hung <alex.hung@amd.com>
Signed-off-by: George Zhang <george.zhang@amd.com>
Tested-by: Dan Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-09-23 13:19:08 -04:00
Tony Cheng
7b464181c2 drm/amd/display: Add inst field to struct dmub_replay
Add an inst member to struct dmub_replay and set it to 0 in
dmub_replay_construct(), since the replay object is a pool singleton.

Also move the (void)panel_inst cast in dmub_replay_set_coasting_vtotal()
below the local declarations, where it belongs.

No functional change; the inst field has no readers yet.

Reviewed-by: Jun Lei <jun.lei@amd.com>
Reviewed-by: Alex Hung <alex.hung@amd.com>
Signed-off-by: Tony Cheng <Tony.Cheng@amd.com>
Signed-off-by: George Zhang <george.zhang@amd.com>
Tested-by: Dan Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-09-23 13:19:03 -04:00
Tony Cheng
6657d6bbbb drm/amd/display: Add inst field to struct dmub_psr
Add an inst member to struct dmub_psr and set it to 0 in
dmub_psr_construct(), since the PSR object is a pool singleton.

No functional change; the field has no readers yet.

Reviewed-by: Jun Lei <jun.lei@amd.com>
Reviewed-by: Alex Hung <alex.hung@amd.com>
Signed-off-by: Tony Cheng <Tony.Cheng@amd.com>
Signed-off-by: George Zhang <george.zhang@amd.com>
Tested-by: Dan Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-09-23 13:18:52 -04:00
Tony Cheng
8fe96f0083 drm/amd/display: Add inst field to struct abm
Add an inst member to struct abm and set it to 0 in dce_abm_construct()
and dmub_abm_construct(), since ABM is a singleton.

No functional change; the field has no readers yet.

Reviewed-by: Jun Lei <jun.lei@amd.com>
Reviewed-by: Alex Hung <alex.hung@amd.com>
Signed-off-by: Tony Cheng <Tony.Cheng@amd.com>
Signed-off-by: George Zhang <george.zhang@amd.com>
Tested-by: Dan Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-09-23 13:15:10 -04:00
Austin Zheng
e61a01511c drm/amd/display: Add Back Unified CalculateFlipSchedule
[Why]
CalculateFlipSchedule has slightly different calculations depending on
if it was called by mode support or mode programming.

Mode support calculates the lower bound of the required bandwidth for
immediate flips. This takes into the account of the register limits to
ensure it is still programmable.

Mode programming uses the required bandwidth for immediate flips on a
per-plane basis to calculate the number of dst_y lines needed to achieve
this bandwidth.

Usually the immediate flip bandwidth per plane determined by mode
programming is above the lower bound calculated by mode support.
However, mode programming can fail if that isn't the case since a
bandwidth lower than the lower bound will end up exceeding the register
limit used by hardware. e.g. The proportion of a single plane's flip
bandwidth w.r.t to the total bandwidth available for all planes can
result in one of the planes having a lower BW than the lower bound
calculated in mode support

[How]
Update function to always use the use_lb_flip_bw path. Add calculations
for dst_y_per_vm/row_flip lines. Consolidate calculation of lb_flip_bw
by having it consider register limits: Instead of doing two steps of: 1.
Taking the max of the bandwidths without considering register limits. 2.
Taking the max of itself with the bandwidths with register limits
accounted for. Do it in one step as it is easy to miss either step 1 or
2.

Also add some local variables for intermediate values and remove no
longer referenced inputs to improve readability.

Also increase DCN401 max_flip_time_lines by 2 lines to ensure previously
supported configs remain supported as worst-case bandwidth can increase
compared to before.

Fixes: 1e719006b6 ("drm/amd/display: Unify CalculateFlipSchedule Logic")
Fixes: 285a363f8c ("Revert "drm/amd/display: Unify CalculateFlipSchedule Logic"")
Reviewed-by: Dillon Varone <dillon.varone@amd.com>
Reviewed-by: Alex Hung <alex.hung@amd.com>
Signed-off-by: Austin Zheng <Austin.Zheng@amd.com>
Signed-off-by: George Zhang <george.zhang@amd.com>
Tested-by: Dan Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-09-23 13:11:38 -04:00
Tony Cheng
1d416cf015 drm/amd/display: Add inst field to struct clk_mgr
Add an inst member to struct clk_mgr and set it to 0 in the DCN401,
DCN42, DCN42B and DCN60 construct paths, since clk_mgr is a singleton
on all of them.

No functional change; the field has no readers yet.

Reviewed-by: Jun Lei <jun.lei@amd.com>
Reviewed-by: Alex Hung <alex.hung@amd.com>
Signed-off-by: Tony Cheng <Tony.Cheng@amd.com>
Signed-off-by: George Zhang <george.zhang@amd.com>
Tested-by: Dan Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-09-23 13:11:35 -04:00
Alvin Lee
f670603d37 drm/amd/display: Enable double buffering for DSCCLK updates
[Description]
Double buffering needs to be enabled for DSCCLK updates otherwise
a frame of underflow could occur when updating the DSC pipe config
or DSC clock.

Reviewed-by: Ilya Bakoulin <ilya.bakoulin@amd.com>
Signed-off-by: Alvin Lee <Alvin.Lee2@amd.com>
Signed-off-by: George Zhang <george.zhang@amd.com>
Tested-by: Dan Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-09-23 13:11:31 -04:00
Tony Cheng
e5dae013f4 drm/amd/display: Add inst field to struct hubbub
Add an inst member and initialize it to 0 in every hubbub*_construct()
from DCN10 through DCN60.

No functional change.

Reviewed-by: Jun Lei <jun.lei@amd.com>
Reviewed-by: Alex Hung <alex.hung@amd.com>
Signed-off-by: Tony Cheng <Tony.Cheng@amd.com>
Signed-off-by: George Zhang <george.zhang@amd.com>
Tested-by: Dan Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-09-23 13:11:27 -04:00
Tony Cheng
6917cf9230 drm/amd/display: add SPDX-License-Identifier
Add the AMD Open-Source SPDX line to dc files.

Reviewed-by: Jun Lei <jun.lei@amd.com>
Reviewed-by: Alex Hung <alex.hung@amd.com>
Signed-off-by: Tony Cheng <Tony.Cheng@amd.com>
Signed-off-by: George Zhang <george.zhang@amd.com>
Tested-by: Dan Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-09-23 13:11:22 -04:00
Ivan Lipski
f2395cdd28 drm/amd/display: Expose 3 overlay planes on DCN6
[Why&How]
DCN6 has 4 pipes, so we should be able to use 3 overlay + 1 primary plane.

Reviewed-by: Alvin Lee <alvin.lee2@amd.com>
Signed-off-by: Ivan Lipski <ivan.lipski@amd.com>
Signed-off-by: George Zhang <george.zhang@amd.com>
Tested-by: Dan Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-09-23 13:11:16 -04:00
Huang, Leon
258403174d drm/amd/display: Forward periodic ABM keep-alive scenario to DMU
[Why & How]
1. The periodic ABM full-frame update for VESA PR is now owned
   by the DMU timer.
2. In PR_update_state, compute whether the current scenario allows
   the periodic keep-alive (not CTS, not front-buffer rendering,
   not force-full-frame, content actively updating) and forward it
   via the abm_periodic_ffu_allowed runtime flag only when it changes.

Reviewed-by: Robin Chen <robin.chen@amd.com>
Reviewed-by: Alex Hung <alex.hung@amd.com>
Signed-off-by: Leon Huang <Leon.Huang1@amd.com>
Signed-off-by: George Zhang <george.zhang@amd.com>
Tested-by: Dan Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-09-23 13:11:10 -04:00
Wentao Liang
ec30a576c2 drm/amdgpu: Fix runtime PM leak in amdgpu_debugfs_test_ib_show()
amdgpu_debugfs_test_ib_show() resumes the device with
pm_runtime_get_sync() before taking the reset domain semaphore with
down_write_killable().  If the write lock acquisition is interrupted,
the function returns without calling pm_runtime_put_autosuspend(),
leaking the runtime PM reference acquired for the device and keeping
the GPU awake.

Drop the runtime PM reference on the interrupted down_write_killable()
error path before returning.

Fixes: 6049db43d6 ("drm/amdgpu: change reset lock from mutex to rw_semaphore")
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-09-23 13:10:22 -04:00
Wentao Liang
e7979c84fc drm/amdgpu: Fix last_update fence leak in amdgpu_vm_init()
amdgpu_vm_init() initializes vm->last_update, vm->last_unlocked and
vm->last_tlb_flush with references to the stub fence taken via
dma_fence_get_stub().  The error label at the end of the function
releases the last_unlocked and last_tlb_flush references with
dma_fence_put(), but the reference stored in vm->last_update is never
dropped, so whenever the page table root creation, the reservation of
the root BO or the PASID registration fails, the stub fence reference
leaks.

Drop the vm->last_update reference together with the other stub fence
references on the error path.

Fixes: 187916e6ed ("drm/amdgpu: install stub fence into potential unused fence pointers")
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-09-23 13:09:27 -04:00
Wentao Liang
9211ef48b3 drm/amdgpu: Fix acpi device leak in amdgpu_acpi_enumerate_xcc()
amdgpu_acpi_enumerate_xcc() looks up each XCC ACPI device with
acpi_dev_get_first_match_dev(), which takes a reference to the device.
The reference is dropped with acpi_dev_put() after the XCC info is
initialized, but if the kzalloc_obj() allocation of the XCC info fails
the function returns -ENOMEM without releasing the reference, leaking
the last reference to the ACPI device.

Drop the ACPI device reference on the allocation failure path before
returning.

Fixes: 4d5275ab0b ("drm/amdgpu: Add parsing of acpi xcc objects")
Reviewed-by: Lijo Lazar <lijo.lazar@amd.com>
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-09-23 13:08:36 -04:00
Wentao Liang
f2b9698685 drm/amdgpu: Fix vmid_wait fence leak in amdgpu_ring_init()
amdgpu_ring_init() initializes ring->vmid_wait with a reference to the
stub fence taken via dma_fence_get_stub().  When a later step of the
initialization fails, e.g. amdgpu_fence_driver_init_ring(), a writeback
slot allocation or the ring buffer allocation, the function returns an
error without releasing the stub fence reference and the reference is
leaked if the ring is torn down without amdgpu_ring_fini().

Move the stub fence assignment to the end of the initialization, right
before the ring is registered with the GPU scheduler, where no further
failure is possible.  The stub fence is only consumed by command
submission handling in amdgpu_ids.c once the ring is up and running, so
nothing reads it during the error-prone part of the initialization.

Fixes: 48e9fbd1a2 ("drm/amdgpu: initialize the vmid_wait with the stub fence")
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-09-23 13:07:27 -04:00
Lijo Lazar
f0de458291 drm/amd/pm: Drop redundant power_context_size
The size is stored and cleared in init/fini but never used to for
anything else like copy. Drop the size and use pointer for init/fini
checks.

Signed-off-by: Lijo Lazar <lijo.lazar@amd.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-09-23 13:07:22 -04:00
Lijo Lazar
ae4e741971 drm/amd/pm: Fix SMUv14/15 power context allocation
Allocate the right power context objects in smu v14 and smu v15

Signed-off-by: Lijo Lazar <lijo.lazar@amd.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-09-23 13:07:17 -04:00
Asad Kamal
1128b4a52d drm/amdkfd: fix use-after-free and multi-container gap in kfd_dev_mapping
kfd_dev_mapping caches the address_space of the first /dev/kfd opener
so that the GPU reset path can call unmap_mapping_range() to zap all
userspace mappings of doorbell and MMIO ranges.  This design has two
bugs that both manifest under SRIOV with multiple containers:

1. Use-after-free / rwsem deadlock.  The cached pointer refers to an
   inode owned by the first opener's container.  When that container
   exits and its inode is released, kfd_dev_mapping becomes a dangling
   pointer.  A subsequent GPU reset dereferences it inside
   unmap_mapping_range(), which takes i_mmap_rwsem on the freed inode,
   causing a hard hang observable as an uninterruptible rwsem wait.

2. Multi-container gap.  Only the first opener's address_space is cached;
   VMAs created by later openers live in a different address_space and
   are never reached by unmap_mapping_range().  After a GPU reset those
   stale mappings keep doorbell and MMIO pages accessible to guest
   userspace with no GPU behind them, risking PCIe transaction timeouts
   and NMI panics.

Fix both bugs with the same approach used by DRM core (drm_drv.c):
create a private pseudo-filesystem at module init time and allocate one
anonymous inode from it.  In kfd_open() redirect every opener's
file->f_mapping to that inode's address_space.  The inode is
module-owned, lives exactly as long as the amdgpu module, and collects
VMAs from all openers in one address_space.  A single
unmap_mapping_range() call in the reset path then correctly reaches
every container's mappings with no dangling pointer risk.

The hang manifests as an NMI backtrace on the GPU reset workqueue stuck
spinning in rwsem_down_read_slowpath() with a corrupted i_mmap_rwsem:

  Workqueue: amdgpu-reset-dev xgpu_ai_mailbox_flr_work [amdgpu]
  Call Trace:
   <TASK>
   kvm_wait+0x1f/0x40
   __pv_queued_spin_lock_slowpath+0x31d/0x3a0
   _raw_spin_lock_irq+0x51/0x80
   rwsem_down_read_slowpath+0xb3/0x550
   down_read+0x48/0xd0
   unmap_mapping_range+0x71/0x140
   kfd_dev_unmap_mapping_range+0x5b/0x140 [amdgpu]
   amdgpu_amdkfd_clear_kfd_mapping+0xd8/0x190 [amdgpu]
   amdgpu_device_gpu_recover+0x232/0x450 [amdgpu]
   xgpu_ai_mailbox_flr_work+0xb5/0xc0 [amdgpu]
   process_one_work+0x18e/0x3e0
   worker_thread+0x2e3/0x420
   kthread+0x10a/0x230

Fixes: 70cadefcc6 ("drm/amdgpu: unmap all user mappings of framebuffer and doorbell before mode1 reset")
Signed-off-by: Asad Kamal <asad.kamal@amd.com>
Reviewed-by: Lijo Lazar <lijo.lazar@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-09-23 13:05:42 -04:00
Lijo Lazar
52a484f3ef drm/amdgpu: Move GC v12.1 spm vmid init to hw init
GC reset is not released during sw init and hence it shouldn't be
accessed. Move spm vmid programming to hw init phase. This programming
may later be overridden with the job's vmid.

Fixes: ad5f1ee0a9 ("drm/amdgpu: Add initial support for gfx v12_1")
Signed-off-by: Lijo Lazar <lijo.lazar@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-09-23 13:05:00 -04:00
YiPeng Chai
f8753e547a drm/amd/ras: remove obsolete ras mp1 v13 manager code
Remove obsolete ras mp1 v13 manager code.

Signed-off-by: YiPeng Chai <YiPeng.Chai@amd.com>
Reviewed-by: Tao Zhou <tao.zhou1@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-09-23 13:04:56 -04:00
YiPeng Chai
895891da97 drm/amd/ras: use common mp1 ras interface for v13
Use the common mp1 ras manager interface for MP1 v13_0.

Signed-off-by: YiPeng Chai <YiPeng.Chai@amd.com>
Reviewed-by: Tao Zhou <tao.zhou1@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-09-23 13:04:52 -04:00
YiPeng Chai
b922c91b95 drm/amd/ras: add MP1 RAS feature status query
Add a generic MP1 interface to query the status of RAS-related
SMU features, including the PMFW EEPROM feature.

Signed-off-by: YiPeng Chai <YiPeng.Chai@amd.com>
Reviewed-by: Tao Zhou <tao.zhou1@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-09-23 13:04:49 -04:00
Sunil Khatri
0bd9d38e3e drm/amdgpu/mes12.1: add more debug info on MES packet failure
When MES fails to respond to a packet, the existing failure log only
prints the op name. Add fence_wait_ret and the packet's status word to
the same message. status_ptr is written directly by MES as part of
completing the packet, independently of the ring fence that
fence_wait_ret waits on, so a nonzero status despite a timed-out
fence_wait_ret narrows the failure to the trailing ring/query-status
packet rather than the original request.

Assisted-by: Claude:claude-sonnet-5
Signed-off-by: Sunil Khatri <sunil.khatri@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-09-23 13:04:46 -04:00
Sunil Khatri
dca2c40dc9 drm/amdgpu/mes11: add more debug info on MES packet failure
When MES fails to respond to a packet, the existing failure log only
prints the op name. Add fence_wait_ret and the packet's status word to
the same message. status_ptr is written directly by MES as part of
completing the packet, independently of the ring fence that
fence_wait_ret waits on, so a nonzero status despite a timed-out
fence_wait_ret narrows the failure to the trailing ring/query-status
packet rather than the original request.

Assisted-by: Claude:claude-sonnet-5
Signed-off-by: Sunil Khatri <sunil.khatri@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-09-23 13:04:41 -04:00
Sunil Khatri
6ae5eaab20 drm/amdgpu/mes12: add more debug info on MES packet failure
When MES fails to respond to a packet, the existing failure log only
prints the op name. Add fence_wait_ret and the packet's status word to
the same message, so a fence-wait timeout (MES itself stalled) can be
told apart from a fast explicit rejection (fence signaled, but the low
status word is 0) directly from the log, along with the MES-reported
error code carried in the high status word for the latter case.

Assisted-by: Claude:claude-sonnet-5
Signed-off-by: Sunil Khatri <sunil.khatri@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-09-23 13:04:27 -04:00
Sunil Khatri
5feabbd673 drm/amdgpu/vcn4.0.3: fix video_timeout unit mismatch in jpeg reset wait
vcn_v4_0_3_reset_jpeg_pre_helper() passes adev->video_timeout directly
to amdgpu_fence_wait_polling(), whose timeout parameter is documented
and implemented in usecs (busy-wait loop decrementing by udelay(2)).

adev->video_timeout is set in jiffies by
amdgpu_device_get_job_timeout_settings(), via msecs_to_jiffies().
Passing it unconverted means the intended ~2s wait for outstanding
JPEG fences to complete before the JPEG queue is torn down actually
lasts only a couple of microseconds (HZ jiffies interpreted as usecs),
so pending jobs are almost never given a real chance to finish before
the reset path forces completion in the following helper.

Convert the jiffies value to usecs with jiffies_to_usecs() before
passing it to amdgpu_fence_wait_polling().

Fixes: d25c67fd9d ("drm/amdgpu/vcn4.0.3: rework reset handling")
Cc: Jesse.Zhang <Jesse.Zhang@amd.com>
Assisted-by: Claude:claude-sonnet-5
Signed-off-by: Sunil Khatri <sunil.khatri@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2026-09-23 13:03:59 -04:00