* [PATCH 00/33] DC Patches November 23, 2026
@ 2026-11-16 21:50 James Lin
2026-11-16 21:50 ` [PATCH 01/33] drm/amd/display: Clear OTG_AUTO_FORCE_VSYNC_MODE on OTG disable James Lin
` (32 more replies)
0 siblings, 33 replies; 34+ messages in thread
From: James Lin @ 2026-11-16 21:50 UTC (permalink / raw)
To: amd-gfx
Cc: Harry Wentland, Leo Li, Aurabindo Pillai, Roman Li, Wayne Lin,
Tom Chung, Fangzhi Zuo, Dan Wheeler, Ray Wu, Ivan Lipski,
Alex Hung, James Lin, Chenyu Chen
This DC patchset brings improvements in multiple areas. In summary, we have:
- Rename DPMS to DPMS_v1
- Power up eDP when detect link
- Add DPMS-v2 files
- Refactor DP retrain link HW sequence
- Add extra 0.25 line reserved for TSetup/TCalc inefficiency
- Use panel luminance range for AUX backlight in power module
- Read PWM back linearly with the linear backlight curve
- Add API to set brightness percent
- Pass linear brightness percent to power module
- Add DPMS-v2 types
- Always apply 0ppm pixel clock adjustment
- Add otg versions of get_vblank_counter/scanoutpos
- Queue vblank control work to sleepable context
- Fix KUnit tests for vblank control rework
- Add urgent request and assertion probes
- Fix G7 P-state aperture addresses
- Set stream min/max refresh from VRR config
- Add DC2 wrapped initialization for DCN401
- Honor the Replay stream regeneration wait event
- Disable Replay when link off frame count is below 2
- Skip DSC padding borrow estimate for zero padding
- Drop unused DC interfaces
- Let the DC2 commit replace or keep a stream
- Support two streams in the dcn401 DC2 builders
- Add a plane beside a kept plane in DC2 update
- Keep an unchanged stream in the DC2 commit
- Change the ODM and MPC layout in DC2 update
- Give the DC2 builders State pipe facts
- Add RGBA8888 surface pixel format support
- Fix DCE crossbar for RGBA8888 surface format
Cc: Dan Wheeler <daniel.wheeler@amd.com>
Allen Pan (1):
drm/amd/display: Always apply 0ppm pixel clock adjustment
Dominik Kowalski (3):
drm/amd/display: Rename DPMS to DPMS_v1
drm/amd/display: Add DPMS-v2 files
drm/amd/display: Add DPMS-v2 types
George Shen (1):
drm/amd/display: Refactor DP retrain link HW sequence
George Zhang (3):
drm/amd/display: Add otg versions of get_vblank_counter/scanoutpos
drm/amd/display: Queue vblank control work to sleepable context
drm/amd/display: Fix KUnit tests for vblank control rework
Harry VanZyllDeJong (1):
drm/amd/display: Honor the Replay stream regeneration wait event
Harry Wentland (2):
drm/amd/display: Add RGBA8888 surface pixel format support
drm/amd/display: Fix DCE crossbar for RGBA8888 surface format
Ivan Lipski (2):
drm/amd/display: Fix G7 P-state aperture addresses
drm/amd/display: Set stream min/max refresh from VRR config
Michael Strauss (1):
drm/amd/display: Clear OTG_AUTO_FORCE_VSYNC_MODE on OTG disable
Nicholas Kazlauskas (2):
drm/amd/display: Skip DSC padding borrow estimate for zero padding
drm/amd/display: Drop unused DC interfaces
Ray Wu (5):
drm/amd/display: Use panel luminance range for AUX backlight in power
module
drm/amd/display: Read PWM back linearly with the linear backlight
curve
drm/amd/display: Add API to set brightness percent
drm/amd/display: Pass linear brightness percent to power module
drm/amd/display: Disable Replay when link off frame count is below 2
Samson Tam (1):
drm/amd/display: add extra 0.25 line reserved for TSetup/TCalc
inefficiency
Taimur Hassan (2):
drm/amd/display: [FW Promotion] Release 0.1.85.0
drm/amd/display: Promote DC to 3.2.408
Tomasz Siemek (1):
drm/amd/display: Add DC2 wrapped initialization for DCN401
Tony Cheng (6):
drm/amd/display: Let the DC2 commit replace or keep a stream
drm/amd/display: Support two streams in the dcn401 DC2 builders
drm/amd/display: Add a plane beside a kept plane in DC2 update
drm/amd/display: Keep an unchanged stream in the DC2 commit
drm/amd/display: Change the ODM and MPC layout in DC2 update
drm/amd/display: Give the DC2 builders State pipe facts
Wenjing Liu (1):
drm/amd/display: Add urgent request and assertion probes
Zhikai Zhai (1):
drm/amd/display: Power up eDP when detect link
.../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 116 +-
.../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h | 52 +
.../display/amdgpu_dm/amdgpu_dm_backlight.c | 208 +---
.../display/amdgpu_dm/amdgpu_dm_backlight.h | 9 +-
.../amd/display/amdgpu_dm/amdgpu_dm_crtc.c | 225 ++--
.../amd/display/amdgpu_dm/amdgpu_dm_dmub.c | 2 +-
.../display/amdgpu_dm/amdgpu_dm_freesync.c | 3 +
.../display/amdgpu_dm/amdgpu_dm_irq_params.h | 2 +
.../drm/amd/display/amdgpu_dm/amdgpu_dm_ism.c | 20 +-
.../amd/display/amdgpu_dm/amdgpu_dm_replay.c | 23 +-
.../tests/amdgpu_dm_backlight_test.c | 552 ++-------
.../amdgpu_dm/tests/amdgpu_dm_crtc_test.c | 219 +++-
.../amdgpu_dm/tests/amdgpu_dm_kunit_helpers.c | 2 +
.../amdgpu_dm/tests/amdgpu_dm_replay_test.c | 129 ++
.../display/amdgpu_dm/tests/amdgpu_dm_test.c | 78 ++
drivers/gpu/drm/amd/display/dc/Makefile | 3 +
.../gpu/drm/amd/display/dc/basics/dce_calcs.c | 2 +
.../amd/display/dc/bls_builder/bls_builder.c | 19 +
.../amd/display/dc/bls_builder/bls_builder.h | 86 +-
.../dc/bls_builder/bls_builder_internal.h | 3 +
.../bls_builder/bls_builder_private_types.h | 28 +-
.../dc/bls_builder/dcn401_builder_internal.h | 87 +-
.../dc/bls_builder/dcn401_init_builder.c | 812 ++++++------
.../dc/bls_builder/dcn401_init_builder.h | 16 -
.../bls_builder/dcn401_init_builder_legacy.c | 77 ++
.../bls_builder/dcn401_non_seamless_builder.c | 243 ++--
.../dc/bls_builder/dcn401_query_builder.c | 41 +
.../dc/bls_builder/dcn401_seamless_builder.c | 1091 +++++++++++------
.../display/dc/bls_executor/bls_executor.c | 79 +-
.../display/dc/bls_executor/bls_executor.h | 2 +-
drivers/gpu/drm/amd/display/dc/core/dc.c | 6 +-
.../drm/amd/display/dc/core/dc_hw_sequencer.c | 267 +++-
.../gpu/drm/amd/display/dc/core/dc_resource.c | 48 +-
.../gpu/drm/amd/display/dc/core/dc_state.c | 28 +
.../gpu/drm/amd/display/dc/core/dc_stream.c | 38 +
.../gpu/drm/amd/display/dc/core2/dc_core2.c | 142 ++-
.../drm/amd/display/dc/core2/dc_core2_init.c | 298 ++++-
drivers/gpu/drm/amd/display/dc/dc.h | 60 +-
.../amd/display/dc/dc_api_dispatch/api_shim.c | 1 +
.../amd/display/dc/dc_api_dispatch/api_shim.h | 3 +
drivers/gpu/drm/amd/display/dc/dc_hw_types.h | 8 +-
drivers/gpu/drm/amd/display/dc/dc_probe.h | 61 +-
.../gpu/drm/amd/display/dc/dc_state_priv.h | 23 +
drivers/gpu/drm/amd/display/dc/dc_stream.h | 6 +
.../drm/amd/display/dc/dce/dce_clock_source.c | 25 +
.../drm/amd/display/dc/dce/dce_mem_input.c | 42 +-
.../drm/amd/display/dc/dce/dce_mem_input.h | 6 +
.../display/dc/dce110/dce110_mem_input_v.c | 1 +
.../drm/amd/display/dc/dml/calcs/dcn_calcs.c | 1 +
.../dml2_pmo/dml2_pmo_dcn6_stage_optimizers.c | 13 +-
.../drm/amd/display/dc/dpp/dcn10/dcn10_dpp.c | 3 +
.../drm/amd/display/dc/dpp/dcn20/dcn20_dpp.c | 3 +
.../amd/display/dc/dpp/dcn201/dcn201_dpp.c | 3 +
.../drm/amd/display/dc/dpp/dcn30/dcn30_dpp.c | 3 +
.../amd/display/dc/dpp/dcn401/dcn401_dpp.c | 3 +
.../drm/amd/display/dc/dpp/dcn42/dcn42_dpp.c | 3 +
.../drm/amd/display/dc/dpp/dcn50/dcn50_dpp.c | 3 +
.../drm/amd/display/dc/dpp/dcn60/dcn60_dpp.c | 3 +
.../display/dc/hubbub/dcn10/dcn10_hubbub.c | 1 +
.../display/dc/hubbub/dcn20/dcn20_hubbub.c | 1 +
.../display/dc/hubbub/dcn401/dcn401_hubbub.c | 1 +
.../display/dc/hubbub/dcn60/dcn60_hubbub.c | 80 ++
.../amd/display/dc/hubp/dcn10/dcn10_hubp.c | 4 +
.../amd/display/dc/hubp/dcn20/dcn20_hubp.c | 4 +
.../amd/display/dc/hubp/dcn20/dcn20_hubp.h | 3 +-
.../amd/display/dc/hubp/dcn35/dcn35_hubp.c | 4 +
.../amd/display/dc/hubp/dcn42/dcn42_hubp.c | 4 +
.../amd/display/dc/hubp/dcn50/dcn50_hubp.c | 4 +
.../amd/display/dc/hubp/dcn60/dcn60_hubp.c | 35 +
.../amd/display/dc/hubp/dcn60/dcn60_hubp.h | 1 +
.../drm/amd/display/dc/hwss/dce/dce_hwseq.c | 1 +
.../amd/display/dc/hwss/dce110/dce110_hwseq.c | 1 +
.../amd/display/dc/hwss/dcn30/dcn30_hwseq.h | 8 -
.../amd/display/dc/hwss/dcn60/dcn60_hwseq.c | 243 +++-
.../drm/amd/display/dc/hwss/hw_sequencer.h | 80 +-
.../gpu/drm/amd/display/dc/inc/core_types.h | 61 +
.../amd/display/dc/inc/dc_core_interface.h | 6 +
.../gpu/drm/amd/display/dc/inc/hw/dchubbub.h | 3 +
drivers/gpu/drm/amd/display/dc/inc/hw/hubp.h | 12 +
.../amd/display/dc/inc/hw/timing_generator.h | 4 -
.../gpu/drm/amd/display/dc/inc/link_service.h | 6 +-
drivers/gpu/drm/amd/display/dc/inc/link_tx.h | 59 +
drivers/gpu/drm/amd/display/dc/link/Makefile | 9 +-
.../display/dc/link/accessories/link_dp_cts.c | 43 +-
.../drm/amd/display/dc/link/link_detection.c | 17 +-
.../dc/link/{link_dpms.c => link_dpms_v1.c} | 6 +-
.../dc/link/{link_dpms.h => link_dpms_v1.h} | 10 +-
.../drm/amd/display/dc/link/link_dpms_v2.c | 44 +
.../drm/amd/display/dc/link/link_dpms_v2.h | 38 +
.../drm/amd/display/dc/link/link_factory.c | 23 +-
.../dc/link/protocols/link_dp_irq_handler.c | 6 +-
.../display/dc/link/protocols/link_hdmi_frl.c | 8 +-
.../amd/display/dc/optc/dcn31/dcn31_optc.c | 4 +
.../amd/display/dc/optc/dcn314/dcn314_optc.c | 4 +
.../amd/display/dc/optc/dcn35/dcn35_optc.c | 4 +
.../dc/pmfw_messenger/dcn401_pmfw_messenger.c | 211 ++++
.../dc/pmfw_messenger/pmfw_messenger.c | 62 +
.../dc/pmfw_messenger/pmfw_messenger.h | 118 ++
.../amd/display/dc/state_facts/state_facts.h | 3 +
.../gpu/drm/amd/display/dmub/inc/dmub_cmd.h | 48 +
.../drm/amd/display/modules/inc/mod_power.h | 7 +
.../drm/amd/display/modules/power/power_abm.c | 83 +-
.../amd/display/modules/power/power_replay.c | 1 +
103 files changed, 4807 insertions(+), 1898 deletions(-)
create mode 100644 drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_query_builder.c
create mode 100644 drivers/gpu/drm/amd/display/dc/inc/link_tx.h
rename drivers/gpu/drm/amd/display/dc/link/{link_dpms.c => link_dpms_v1.c} (99%)
rename drivers/gpu/drm/amd/display/dc/link/{link_dpms.h => link_dpms_v1.h} (92%)
create mode 100644 drivers/gpu/drm/amd/display/dc/link/link_dpms_v2.c
create mode 100644 drivers/gpu/drm/amd/display/dc/link/link_dpms_v2.h
create mode 100644 drivers/gpu/drm/amd/display/dc/pmfw_messenger/dcn401_pmfw_messenger.c
create mode 100644 drivers/gpu/drm/amd/display/dc/pmfw_messenger/pmfw_messenger.c
create mode 100644 drivers/gpu/drm/amd/display/dc/pmfw_messenger/pmfw_messenger.h
--
2.43.0
^ permalink raw reply [flat|nested] 34+ messages in thread
* [PATCH 01/33] drm/amd/display: Clear OTG_AUTO_FORCE_VSYNC_MODE on OTG disable
2026-11-16 21:50 [PATCH 00/33] DC Patches November 23, 2026 James Lin
@ 2026-11-16 21:50 ` James Lin
2026-11-16 21:50 ` [PATCH 02/33] drm/amd/display: Rename DPMS to DPMS_v1 James Lin
` (31 subsequent siblings)
32 siblings, 0 replies; 34+ messages in thread
From: James Lin @ 2026-11-16 21:50 UTC (permalink / raw)
To: amd-gfx
Cc: Harry Wentland, Leo Li, Aurabindo Pillai, Roman Li, Wayne Lin,
Tom Chung, Fangzhi Zuo, Dan Wheeler, Ray Wu, Ivan Lipski,
Alex Hung, James Lin, Chenyu Chen, Michael Strauss, Aric Cyr,
Mario Limonciello, Alex Deucher, stable, James Lin
From: Michael Strauss <michael.strauss@amd.com>
[WHY]
A frame-lock reset trigger sets OTG_AUTO_FORCE_VSYNC_MODE. If the bit is
not cleared when the OTG is released, the OTG keeps forcing vsync on
every trigger event.
When a display stream later reuses that OTG with DRR enabled, each DRR
manual trigger forces an early vsync and cuts the frame short. The
display then runs above its programmed refresh rate and underflows,
leaving the external monitor with no signal.
[HOW]
Clear OTG_AUTO_FORCE_VSYNC_MODE in the DCN31/314/35 disable_crtc so a
released OTG is left clean.
Cc: Aric Cyr <aric.cyr@amd.com>
Cc: Mario Limonciello <mario.limonciello@amd.com>
Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: stable@vger.kernel.org
Signed-off-by: Michael Strauss <michael.strauss@amd.com>
Signed-off-by: James Lin <pinglei.lin@amd.com>
---
drivers/gpu/drm/amd/display/dc/optc/dcn31/dcn31_optc.c | 4 ++++
drivers/gpu/drm/amd/display/dc/optc/dcn314/dcn314_optc.c | 4 ++++
drivers/gpu/drm/amd/display/dc/optc/dcn35/dcn35_optc.c | 4 ++++
3 files changed, 12 insertions(+)
diff --git a/drivers/gpu/drm/amd/display/dc/optc/dcn31/dcn31_optc.c b/drivers/gpu/drm/amd/display/dc/optc/dcn31/dcn31_optc.c
index ce9cd32b807a..7706f5f16a68 100644
--- a/drivers/gpu/drm/amd/display/dc/optc/dcn31/dcn31_optc.c
+++ b/drivers/gpu/drm/amd/display/dc/optc/dcn31/dcn31_optc.c
@@ -143,6 +143,10 @@ static bool optc31_disable_crtc(struct timing_generator *optc)
1, 100000);
optc1_clear_optc_underflow(optc);
+ /* a stale frame-lock force-vsync would cut every DRR-triggered frame short on reuse */
+ REG_UPDATE(OTG_VERT_SYNC_CONTROL,
+ OTG_AUTO_FORCE_VSYNC_MODE, 0);
+
return true;
}
/*
diff --git a/drivers/gpu/drm/amd/display/dc/optc/dcn314/dcn314_optc.c b/drivers/gpu/drm/amd/display/dc/optc/dcn314/dcn314_optc.c
index f5faa49680ef..5ec70e849cce 100644
--- a/drivers/gpu/drm/amd/display/dc/optc/dcn314/dcn314_optc.c
+++ b/drivers/gpu/drm/amd/display/dc/optc/dcn314/dcn314_optc.c
@@ -142,6 +142,10 @@ static bool optc314_disable_crtc(struct timing_generator *optc)
OTG_BUSY, 0,
1, 100000);
+ /* a stale frame-lock force-vsync would cut every DRR-triggered frame short on reuse */
+ REG_UPDATE(OTG_VERT_SYNC_CONTROL,
+ OTG_AUTO_FORCE_VSYNC_MODE, 0);
+
return true;
}
diff --git a/drivers/gpu/drm/amd/display/dc/optc/dcn35/dcn35_optc.c b/drivers/gpu/drm/amd/display/dc/optc/dcn35/dcn35_optc.c
index 406446e5eae5..b4b4792167dd 100644
--- a/drivers/gpu/drm/amd/display/dc/optc/dcn35/dcn35_optc.c
+++ b/drivers/gpu/drm/amd/display/dc/optc/dcn35/dcn35_optc.c
@@ -162,6 +162,10 @@ static bool optc35_disable_crtc(struct timing_generator *optc)
optc1_clear_optc_underflow(optc);
+ /* a stale frame-lock force-vsync would cut every DRR-triggered frame short on reuse */
+ REG_UPDATE(OTG_VERT_SYNC_CONTROL,
+ OTG_AUTO_FORCE_VSYNC_MODE, 0);
+
return true;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [PATCH 02/33] drm/amd/display: Rename DPMS to DPMS_v1
2026-11-16 21:50 [PATCH 00/33] DC Patches November 23, 2026 James Lin
2026-11-16 21:50 ` [PATCH 01/33] drm/amd/display: Clear OTG_AUTO_FORCE_VSYNC_MODE on OTG disable James Lin
@ 2026-11-16 21:50 ` James Lin
2026-11-16 21:50 ` [PATCH 03/33] drm/amd/display: Power up eDP when detect link James Lin
` (30 subsequent siblings)
32 siblings, 0 replies; 34+ messages in thread
From: James Lin @ 2026-11-16 21:50 UTC (permalink / raw)
To: amd-gfx
Cc: Harry Wentland, Leo Li, Aurabindo Pillai, Roman Li, Wayne Lin,
Tom Chung, Fangzhi Zuo, Dan Wheeler, Ray Wu, Ivan Lipski,
Alex Hung, James Lin, Chenyu Chen, Dominik Kowalski, Wenjing Liu,
James Lin
From: Dominik Kowalski <dominik.kowalski@amd.com>
[Why]
Working on v2 of DPMS link protocol implementation, renaming
existing version to v1 for consistency.
[How]
* Rename files link_dpms.{c,h} to link_dpms_v1.{c,h}
* Rename functions link_dpms_set_{on,off} accordingly
* Replace direct calls to those functions with link_srv vtable
Cc: Wenjing Liu <wenjing.liu@amd.com>
Signed-off-by: Dominik Kowalski <dominik.kowalski@amd.com>
Signed-off-by: James Lin <pinglei.lin@amd.com>
---
drivers/gpu/drm/amd/display/dc/link/Makefile | 2 +-
.../drm/amd/display/dc/link/accessories/link_dp_cts.c | 4 ++--
drivers/gpu/drm/amd/display/dc/link/link_detection.c | 2 +-
.../display/dc/link/{link_dpms.c => link_dpms_v1.c} | 6 +++---
.../display/dc/link/{link_dpms.h => link_dpms_v1.h} | 10 +++++-----
drivers/gpu/drm/amd/display/dc/link/link_factory.c | 6 +++---
.../display/dc/link/protocols/link_dp_irq_handler.c | 6 +++---
.../drm/amd/display/dc/link/protocols/link_hdmi_frl.c | 4 ++--
8 files changed, 20 insertions(+), 20 deletions(-)
rename drivers/gpu/drm/amd/display/dc/link/{link_dpms.c => link_dpms_v1.c} (99%)
rename drivers/gpu/drm/amd/display/dc/link/{link_dpms.h => link_dpms_v1.h} (92%)
diff --git a/drivers/gpu/drm/amd/display/dc/link/Makefile b/drivers/gpu/drm/amd/display/dc/link/Makefile
index f558a20eceaa..0eb433b5d822 100644
--- a/drivers/gpu/drm/amd/display/dc/link/Makefile
+++ b/drivers/gpu/drm/amd/display/dc/link/Makefile
@@ -23,7 +23,7 @@
# It abstracts the control and status of back end pipe such as DIO, HPO, DPIA,
# PHY, HPD, DDC and etc).
-LINK = link_detection.o link_dpms.o link_factory.o link_resource.o \
+LINK = link_detection.o link_dpms_v1.o link_factory.o link_resource.o \
link_validation.o
AMD_DAL_LINK = $(addprefix $(AMDDALPATH)/dc/link/, \
diff --git a/drivers/gpu/drm/amd/display/dc/link/accessories/link_dp_cts.c b/drivers/gpu/drm/amd/display/dc/link/accessories/link_dp_cts.c
index 83f676a49fd1..f316337cee1b 100644
--- a/drivers/gpu/drm/amd/display/dc/link/accessories/link_dp_cts.c
+++ b/drivers/gpu/drm/amd/display/dc/link/accessories/link_dp_cts.c
@@ -29,7 +29,7 @@
#include "link/protocols/link_dp_phy.h"
#include "link/protocols/link_dp_training_fixed_vs_pe_retimer.h"
#include "link/protocols/link_dp_capability.h"
-#include "link/link_dpms.h"
+#include "link/link_dpms_v1.h"
#include "resource.h"
#include "dm_helpers.h"
#include "dc_dmub_srv.h"
@@ -91,7 +91,7 @@ static void dp_retrain_link_dp_test(struct dc_link *link,
link_get_master_pipes_with_dpms_on(link, state, &count, pipes);
for (i = 0; i < count; i++) {
- link_set_dpms_off(pipes[i]);
+ link->dc->link_srv->set_dpms_off(pipes[i]);
pipes[i]->link_config.dp_link_settings = *link_setting;
update_dp_encoder_resources_for_test_harness(
link->dc,
diff --git a/drivers/gpu/drm/amd/display/dc/link/link_detection.c b/drivers/gpu/drm/amd/display/dc/link/link_detection.c
index 5b257f003f13..9bd24b3e4291 100644
--- a/drivers/gpu/drm/amd/display/dc/link/link_detection.c
+++ b/drivers/gpu/drm/amd/display/dc/link/link_detection.c
@@ -30,7 +30,7 @@
* directly from connected receivers.
*/
-#include "link_dpms.h"
+#include "link_dpms_v1.h"
#include "link_detection.h"
#include "link_hwss.h"
#include "protocols/link_edp_panel_control.h"
diff --git a/drivers/gpu/drm/amd/display/dc/link/link_dpms.c b/drivers/gpu/drm/amd/display/dc/link/link_dpms_v1.c
similarity index 99%
rename from drivers/gpu/drm/amd/display/dc/link/link_dpms.c
rename to drivers/gpu/drm/amd/display/dc/link/link_dpms_v1.c
index 75e232ebffe8..ae94a0a2b9da 100644
--- a/drivers/gpu/drm/amd/display/dc/link/link_dpms.c
+++ b/drivers/gpu/drm/amd/display/dc/link/link_dpms_v1.c
@@ -35,7 +35,7 @@
* boundary between link and stream is not clearly defined.
*/
-#include "link_dpms.h"
+#include "link_dpms_v1.h"
#include "link_hwss.h"
#include "link_validation.h"
#include "accessories/link_dp_trace.h"
@@ -2403,7 +2403,7 @@ static struct vpg *get_vpg(struct pipe_ctx *pipe_ctx)
return pipe_ctx->stream_res.stream_enc->vpg;
}
-enum dc_status link_set_dpms_off(struct pipe_ctx *pipe_ctx)
+enum dc_status link_set_dpms_off_v1(struct pipe_ctx *pipe_ctx)
{
DC_LOGGER_INIT(pipe_ctx->stream->ctx->logger);
struct dc_stream_state *stream = pipe_ctx->stream;
@@ -2794,7 +2794,7 @@ static enum dc_status link_set_dpms_on_post_enable_link(
return DC_DPMS_SUCCESS;
}
-enum dc_status link_set_dpms_on(
+enum dc_status link_set_dpms_on_v1(
struct dc_state *state,
struct pipe_ctx *pipe_ctx
)
diff --git a/drivers/gpu/drm/amd/display/dc/link/link_dpms.h b/drivers/gpu/drm/amd/display/dc/link/link_dpms_v1.h
similarity index 92%
rename from drivers/gpu/drm/amd/display/dc/link/link_dpms.h
rename to drivers/gpu/drm/amd/display/dc/link/link_dpms_v1.h
index 6559bc04d90e..b170c9a8622d 100644
--- a/drivers/gpu/drm/amd/display/dc/link/link_dpms.h
+++ b/drivers/gpu/drm/amd/display/dc/link/link_dpms_v1.h
@@ -23,14 +23,14 @@
*
*/
-#ifndef __DC_LINK_DPMS_H__
-#define __DC_LINK_DPMS_H__
+#ifndef DC_LINK_DPMS_V1_H
+#define DC_LINK_DPMS_V1_H
#include "link_service.h"
-enum dc_status link_set_dpms_on(
+enum dc_status link_set_dpms_on_v1(
struct dc_state *state,
struct pipe_ctx *pipe_ctx);
-enum dc_status link_set_dpms_off(struct pipe_ctx *pipe_ctx);
+enum dc_status link_set_dpms_off_v1(struct pipe_ctx *pipe_ctx);
void link_resume(struct dc_link *link);
void link_blank_all_dp_displays(struct dc *dc);
void link_blank_all_edp_displays(struct dc *dc);
@@ -51,4 +51,4 @@ void link_set_dsc_on_stream(struct pipe_ctx *pipe_ctx, bool enable);
bool link_set_dsc_enable(struct pipe_ctx *pipe_ctx, bool enable);
bool link_update_dsc_config(struct pipe_ctx *pipe_ctx);
void link_wait_for_unlocked(struct dc_link *link);
-#endif /* __DC_LINK_DPMS_H__ */
+#endif
diff --git a/drivers/gpu/drm/amd/display/dc/link/link_factory.c b/drivers/gpu/drm/amd/display/dc/link/link_factory.c
index 3b192c539f8b..7bf1364659ea 100644
--- a/drivers/gpu/drm/amd/display/dc/link/link_factory.c
+++ b/drivers/gpu/drm/amd/display/dc/link/link_factory.c
@@ -30,7 +30,7 @@
#include "link_detection.h"
#include "link_resource.h"
#include "link_validation.h"
-#include "link_dpms.h"
+#include "link_dpms_v1.h"
#include "accessories/link_dp_cts.h"
#include "accessories/link_dp_trace.h"
#include "protocols/link_ddc.h"
@@ -113,8 +113,8 @@ static void construct_link_service_validation(struct link_service *link_srv)
*/
static void construct_link_service_dpms(struct link_service *link_srv)
{
- link_srv->set_dpms_on = link_set_dpms_on;
- link_srv->set_dpms_off = link_set_dpms_off;
+ link_srv->set_dpms_on = link_set_dpms_on_v1;
+ link_srv->set_dpms_off = link_set_dpms_off_v1;
link_srv->resume = link_resume;
link_srv->blank_all_dp_displays = link_blank_all_dp_displays;
link_srv->blank_all_edp_displays = link_blank_all_edp_displays;
diff --git a/drivers/gpu/drm/amd/display/dc/link/protocols/link_dp_irq_handler.c b/drivers/gpu/drm/amd/display/dc/link/protocols/link_dp_irq_handler.c
index 59f9150edf30..154595dcb618 100644
--- a/drivers/gpu/drm/amd/display/dc/link/protocols/link_dp_irq_handler.c
+++ b/drivers/gpu/drm/amd/display/dc/link/protocols/link_dp_irq_handler.c
@@ -36,7 +36,7 @@
#include "link_edp_panel_control.h"
#include "link_dp_panel_replay.h"
#include "link/accessories/link_dp_trace.h"
-#include "link/link_dpms.h"
+#include "link/link_dpms_v1.h"
#include "dm_helpers.h"
#include "link_dp_dpia_bw.h"
@@ -332,7 +332,7 @@ void dp_handle_link_loss(struct dc_link *link)
link_get_master_pipes_with_dpms_on(link, state, &count, pipes);
for (i = 0; i < count; i++)
- link_set_dpms_off(pipes[i]);
+ link->dc->link_srv->set_dpms_off(pipes[i]);
for (i = count - 1; i >= 0; i--) {
// Always use max settings here for DP 1.4a LL Compliance CTS
@@ -344,7 +344,7 @@ void dp_handle_link_loss(struct dc_link *link)
pipes[i]->link_config.dp_link_settings.link_spread =
link->verified_link_cap.link_spread;
}
- link_set_dpms_on(link->dc->current_state, pipes[i]);
+ link->dc->link_srv->set_dpms_on(link->dc->current_state, pipes[i]);
}
}
diff --git a/drivers/gpu/drm/amd/display/dc/link/protocols/link_hdmi_frl.c b/drivers/gpu/drm/amd/display/dc/link/protocols/link_hdmi_frl.c
index 3f687603a70c..2eaa830662b0 100644
--- a/drivers/gpu/drm/amd/display/dc/link/protocols/link_hdmi_frl.c
+++ b/drivers/gpu/drm/amd/display/dc/link/protocols/link_hdmi_frl.c
@@ -36,7 +36,7 @@
*/
#include "link_hdmi_frl.h"
#include "link_ddc.h"
-#include "link/link_dpms.h"
+#include "link/link_dpms_v1.h"
#include "link/link_validation.h"
#include "resource.h"
#include "dccg.h"
@@ -1040,7 +1040,7 @@ void hdmi_frl_set_preferred_link_settings(struct dc *dc,
link_stream->link->frl_verified_link_cap = *link_setting;
while (link_stat != LINK_RESULT_SUCCESS && link_stat != LINK_RESULT_NO_TIMEOUT) {
- link_set_dpms_off(pipe);
+ link->dc->link_srv->set_dpms_off(pipe);
/* For DCN3.0, can also have 4:1 combine mode.
* TODO: Add function get_odm_combine_mode that has different
* implementation for DCN2/DCN3AG and DCN3.0
--
2.43.0
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [PATCH 03/33] drm/amd/display: Power up eDP when detect link
2026-11-16 21:50 [PATCH 00/33] DC Patches November 23, 2026 James Lin
2026-11-16 21:50 ` [PATCH 01/33] drm/amd/display: Clear OTG_AUTO_FORCE_VSYNC_MODE on OTG disable James Lin
2026-11-16 21:50 ` [PATCH 02/33] drm/amd/display: Rename DPMS to DPMS_v1 James Lin
@ 2026-11-16 21:50 ` James Lin
2026-11-16 21:50 ` [PATCH 04/33] drm/amd/display: Add DPMS-v2 files James Lin
` (29 subsequent siblings)
32 siblings, 0 replies; 34+ messages in thread
From: James Lin @ 2026-11-16 21:50 UTC (permalink / raw)
To: amd-gfx
Cc: Harry Wentland, Leo Li, Aurabindo Pillai, Roman Li, Wayne Lin,
Tom Chung, Fangzhi Zuo, Dan Wheeler, Ray Wu, Ivan Lipski,
Alex Hung, James Lin, Chenyu Chen, Zhikai Zhai, Wenjing Liu,
Mario Limonciello, Alex Deucher, stable, James Lin
From: Zhikai Zhai <zhikai.zhai@amd.com>
[WHY]
Previously we would start the asynchronous detection
timer after resuming from S0i3, the sequence for
eDP power up when resume from S0i3 is:
1. eDP power up when link enable
2. Timer trigger async detect for eDP
3. The AUPI could read successfully in display detect
Currently
1. eDP detection runs from the display detect path
2. AUPI read fail as HPD low when eDP link detect
3. Link enable to power up eDP
[HOW]
Power up eDP when detect link for aux read.
Cc: Wenjing Liu <wenjing.liu@amd.com>
Cc: Mario Limonciello <mario.limonciello@amd.com>
Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: stable@vger.kernel.org
Signed-off-by: Zhikai Zhai <zhikai.zhai@amd.com>
Signed-off-by: James Lin <pinglei.lin@amd.com>
---
.../gpu/drm/amd/display/dc/link/link_detection.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/drivers/gpu/drm/amd/display/dc/link/link_detection.c b/drivers/gpu/drm/amd/display/dc/link/link_detection.c
index 9bd24b3e4291..dae9e6840272 100644
--- a/drivers/gpu/drm/amd/display/dc/link/link_detection.c
+++ b/drivers/gpu/drm/amd/display/dc/link/link_detection.c
@@ -1153,11 +1153,16 @@ static bool detect_link_and_local_sink(struct dc_link *link,
(!link->dc->config.allow_edp_hotplug_detection)) &&
link->local_sink) {
// need to re-write OUI and brightness in resume case
- if (link->connector_signal == SIGNAL_TYPE_EDP &&
- (link->dpcd_sink_ext_caps.bits.oled == 1)) {
- dpcd_set_source_specific_data(link);
- msleep(post_oui_delay);
- set_default_brightness_aux(link);
+ if (link->connector_signal == SIGNAL_TYPE_EDP) {
+ if (!link->dc->config.edp_no_power_sequencing)
+ link->dc->hwss.edp_power_control(link, true);
+ link->dc->hwss.edp_wait_for_hpd_ready(link, true);
+
+ if (link->dpcd_sink_ext_caps.bits.oled == 1) {
+ dpcd_set_source_specific_data(link);
+ msleep(post_oui_delay);
+ set_default_brightness_aux(link);
+ }
}
return true;
--
2.43.0
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [PATCH 04/33] drm/amd/display: Add DPMS-v2 files
2026-11-16 21:50 [PATCH 00/33] DC Patches November 23, 2026 James Lin
` (2 preceding siblings ...)
2026-11-16 21:50 ` [PATCH 03/33] drm/amd/display: Power up eDP when detect link James Lin
@ 2026-11-16 21:50 ` James Lin
2026-11-16 21:50 ` [PATCH 05/33] drm/amd/display: Refactor DP retrain link HW sequence James Lin
` (28 subsequent siblings)
32 siblings, 0 replies; 34+ messages in thread
From: James Lin @ 2026-11-16 21:50 UTC (permalink / raw)
To: amd-gfx
Cc: Harry Wentland, Leo Li, Aurabindo Pillai, Roman Li, Wayne Lin,
Tom Chung, Fangzhi Zuo, Dan Wheeler, Ray Wu, Ivan Lipski,
Alex Hung, James Lin, Chenyu Chen, Dominik Kowalski, James Lin
From: Dominik Kowalski <dominik.kowalski@amd.com>
[Why]
Split into smallest possible increment to allow for parallel
review of different aspects of DPMS-v2 design.
[How]
* Add DPMS-v2 files with empty DPMS-on/off functions
* Add flag to dc_config to choose between v1 and v2
* Use flag in link_create_link_service to update vtable
Signed-off-by: Dominik Kowalski <dominik.kowalski@amd.com>
Signed-off-by: James Lin <pinglei.lin@amd.com>
---
drivers/gpu/drm/amd/display/dc/core/dc.c | 6 ++-
drivers/gpu/drm/amd/display/dc/dc.h | 1 +
.../gpu/drm/amd/display/dc/inc/link_service.h | 6 ++-
drivers/gpu/drm/amd/display/dc/link/Makefile | 9 +++-
.../drm/amd/display/dc/link/link_dpms_v2.c | 44 +++++++++++++++++++
.../drm/amd/display/dc/link/link_dpms_v2.h | 38 ++++++++++++++++
.../drm/amd/display/dc/link/link_factory.c | 21 ++++++---
7 files changed, 114 insertions(+), 11 deletions(-)
create mode 100644 drivers/gpu/drm/amd/display/dc/link/link_dpms_v2.c
create mode 100644 drivers/gpu/drm/amd/display/dc/link/link_dpms_v2.h
diff --git a/drivers/gpu/drm/amd/display/dc/core/dc.c b/drivers/gpu/drm/amd/display/dc/core/dc.c
index 463a3fc2d8c2..3ca650461cb6 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc.c
@@ -1070,7 +1070,11 @@ static bool dc_construct_ctx(struct dc *dc,
dc->ctx = dc_ctx;
- dc->link_srv = link_create_link_service();
+ const struct link_service_options link_service_options = {
+ .enable_dpms_v2 = dc->config.enable_dpms_v2,
+ };
+
+ dc->link_srv = link_create_link_service(link_service_options);
if (!dc->link_srv)
return false;
diff --git a/drivers/gpu/drm/amd/display/dc/dc.h b/drivers/gpu/drm/amd/display/dc/dc.h
index b71a9a5cd424..01f549010d07 100644
--- a/drivers/gpu/drm/amd/display/dc/dc.h
+++ b/drivers/gpu/drm/amd/display/dc/dc.h
@@ -645,6 +645,7 @@ struct dc_config {
// Set by the DM around a commit that runs where allocation is not
// permitted; requires preallocate_scratch_state.
bool use_preallocated_state;
+ bool enable_dpms_v2;
};
enum visual_confirm {
diff --git a/drivers/gpu/drm/amd/display/dc/inc/link_service.h b/drivers/gpu/drm/amd/display/dc/inc/link_service.h
index b2f86c51d470..d9a9d5f9f61c 100644
--- a/drivers/gpu/drm/amd/display/dc/inc/link_service.h
+++ b/drivers/gpu/drm/amd/display/dc/inc/link_service.h
@@ -77,7 +77,11 @@
*/
#include "core_types.h"
-struct link_service *link_create_link_service(void);
+struct link_service_options {
+ bool enable_dpms_v2;
+};
+
+struct link_service *link_create_link_service(struct link_service_options options);
void link_destroy_link_service(struct link_service **link_srv);
struct link_init_data {
diff --git a/drivers/gpu/drm/amd/display/dc/link/Makefile b/drivers/gpu/drm/amd/display/dc/link/Makefile
index 0eb433b5d822..ea08f1b1e60e 100644
--- a/drivers/gpu/drm/amd/display/dc/link/Makefile
+++ b/drivers/gpu/drm/amd/display/dc/link/Makefile
@@ -23,8 +23,13 @@
# It abstracts the control and status of back end pipe such as DIO, HPO, DPIA,
# PHY, HPD, DDC and etc).
-LINK = link_detection.o link_dpms_v1.o link_factory.o link_resource.o \
-link_validation.o
+LINK = \
+ link_detection.o \
+ link_dpms_v1.o \
+ link_dpms_v2.o \
+ link_factory.o \
+ link_resource.o \
+ link_validation.o
AMD_DAL_LINK = $(addprefix $(AMDDALPATH)/dc/link/, \
$(LINK))
diff --git a/drivers/gpu/drm/amd/display/dc/link/link_dpms_v2.c b/drivers/gpu/drm/amd/display/dc/link/link_dpms_v2.c
new file mode 100644
index 000000000000..43c3f7dfa343
--- /dev/null
+++ b/drivers/gpu/drm/amd/display/dc/link/link_dpms_v2.c
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2026 Advanced Micro Devices, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Authors: AMD
+ *
+ */
+
+#include "dc/link/link_dpms_v2.h"
+
+enum dc_status link_set_dpms_off_v2(struct pipe_ctx *pipe_ctx)
+{
+ // TODO: Implement
+ (void)pipe_ctx;
+ ASSERT(false);
+ return DC_ERROR_UNEXPECTED;
+}
+
+enum dc_status link_set_dpms_on_v2(struct dc_state *state,
+ struct pipe_ctx *pipe_ctx)
+{
+ // TODO: Implement
+ (void)state;
+ (void)pipe_ctx;
+ ASSERT(false);
+ return DC_ERROR_UNEXPECTED;
+}
diff --git a/drivers/gpu/drm/amd/display/dc/link/link_dpms_v2.h b/drivers/gpu/drm/amd/display/dc/link/link_dpms_v2.h
new file mode 100644
index 000000000000..c6728932691a
--- /dev/null
+++ b/drivers/gpu/drm/amd/display/dc/link/link_dpms_v2.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2026 Advanced Micro Devices, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Authors: AMD
+ *
+ */
+#ifndef LINK_DPMS_V2_H
+#define LINK_DPMS_V2_H
+
+#include "dc/inc/core_status.h"
+
+struct dc_state;
+struct pipe_ctx;
+
+// TODO: Add RESOURCED state
+enum dc_status link_set_dpms_off_v2(struct pipe_ctx *pipe_ctx);
+enum dc_status link_set_dpms_on_v2(struct dc_state *state,
+ struct pipe_ctx *pipe_ctx);
+
+#endif
diff --git a/drivers/gpu/drm/amd/display/dc/link/link_factory.c b/drivers/gpu/drm/amd/display/dc/link/link_factory.c
index 7bf1364659ea..919f67b76f91 100644
--- a/drivers/gpu/drm/amd/display/dc/link/link_factory.c
+++ b/drivers/gpu/drm/amd/display/dc/link/link_factory.c
@@ -31,6 +31,7 @@
#include "link_resource.h"
#include "link_validation.h"
#include "link_dpms_v1.h"
+#include "link_dpms_v2.h"
#include "accessories/link_dp_cts.h"
#include "accessories/link_dp_trace.h"
#include "protocols/link_ddc.h"
@@ -111,10 +112,16 @@ static void construct_link_service_validation(struct link_service *link_srv)
* with the link and link's enable/disable sequences as result of the stream's
* dpms state change.
*/
-static void construct_link_service_dpms(struct link_service *link_srv)
+static void construct_link_service_dpms(struct link_service *link_srv, struct link_service_options options)
{
- link_srv->set_dpms_on = link_set_dpms_on_v1;
- link_srv->set_dpms_off = link_set_dpms_off_v1;
+ if (options.enable_dpms_v2) {
+ link_srv->set_dpms_on = link_set_dpms_on_v2;
+ link_srv->set_dpms_off = link_set_dpms_off_v2;
+ } else {
+ link_srv->set_dpms_on = link_set_dpms_on_v1;
+ link_srv->set_dpms_off = link_set_dpms_off_v1;
+ }
+
link_srv->resume = link_resume;
link_srv->blank_all_dp_displays = link_blank_all_dp_displays;
link_srv->blank_all_edp_displays = link_blank_all_edp_displays;
@@ -305,7 +312,7 @@ static void construct_link_service_dp_trace(struct link_service *link_srv)
link_srv->dp_trace_source_sequence = dp_trace_source_sequence;
}
-static void construct_link_service(struct link_service *link_srv)
+static void construct_link_service(struct link_service *link_srv, struct link_service_options options)
{
/* All link service functions should fall under some sub categories.
* If a new function doesn't perfectly fall under an existing sub
@@ -318,7 +325,7 @@ static void construct_link_service(struct link_service *link_srv)
construct_link_service_detection(link_srv);
construct_link_service_resource(link_srv);
construct_link_service_validation(link_srv);
- construct_link_service_dpms(link_srv);
+ construct_link_service_dpms(link_srv, options);
construct_link_service_ddc(link_srv);
construct_link_service_dp_capability(link_srv);
construct_link_service_dp_phy_or_dpia(link_srv);
@@ -330,14 +337,14 @@ static void construct_link_service(struct link_service *link_srv)
construct_link_service_dp_trace(link_srv);
}
-struct link_service *link_create_link_service(void)
+struct link_service *link_create_link_service(struct link_service_options options)
{
struct link_service *link_srv = kzalloc_obj(*link_srv);
if (link_srv == NULL)
goto fail;
- construct_link_service(link_srv);
+ construct_link_service(link_srv, options);
return link_srv;
fail:
--
2.43.0
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [PATCH 05/33] drm/amd/display: Refactor DP retrain link HW sequence
2026-11-16 21:50 [PATCH 00/33] DC Patches November 23, 2026 James Lin
` (3 preceding siblings ...)
2026-11-16 21:50 ` [PATCH 04/33] drm/amd/display: Add DPMS-v2 files James Lin
@ 2026-11-16 21:50 ` James Lin
2026-11-16 21:50 ` [PATCH 06/33] drm/amd/display: add extra 0.25 line reserved for TSetup/TCalc inefficiency James Lin
` (27 subsequent siblings)
32 siblings, 0 replies; 34+ messages in thread
From: James Lin @ 2026-11-16 21:50 UTC (permalink / raw)
To: amd-gfx
Cc: Harry Wentland, Leo Li, Aurabindo Pillai, Roman Li, Wayne Lin,
Tom Chung, Fangzhi Zuo, Dan Wheeler, Ray Wu, Ivan Lipski,
Alex Hung, James Lin, Chenyu Chen, George Shen, Michael Strauss,
James Lin
From: George Shen <george.shen@amd.com>
[Why]
Current implementation of DP retrain link test function contains an
issue where ODM combine is cleared and not reconfigured when we toggle
off/on OTG.
The function is also rigid and difficult to maintain when all the HW
programming logic is done directly within it.
[How]
Move HW programming calls to a hwss function and call it from the DP
retrain link function.
Additionaly, add a call to reprogram the ODM combine register that is
cleared when disabling OTG in the hwss function call.
Cc: Michael Strauss <michael.strauss@amd.com>
Signed-off-by: George Shen <george.shen@amd.com>
Signed-off-by: James Lin <pinglei.lin@amd.com>
---
.../drm/amd/display/dc/core/dc_hw_sequencer.c | 84 +++++++++++++++++++
.../drm/amd/display/dc/hwss/hw_sequencer.h | 8 ++
.../display/dc/link/accessories/link_dp_cts.c | 39 ++-------
3 files changed, 98 insertions(+), 33 deletions(-)
diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_hw_sequencer.c b/drivers/gpu/drm/amd/display/dc/core/dc_hw_sequencer.c
index ecf90e3a770c..061ea11cef0e 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_hw_sequencer.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_hw_sequencer.c
@@ -3195,6 +3195,90 @@ void hwss_wait_for_odm_update_pending_complete(struct dc *dc, struct dc_state *c
hwss_wait_for_all_blank_complete(dc, context);
}
+/**
+ * hwss_restart_otg_for_dp_test_link_retrain - restart the OTGs of a link retrained
+ * by a DP test request, with the stream's planes left attached
+ *
+ * Disables the OTGs, programs the pixel clock and audio if requested, restores
+ * the ODM combine configuration cleared by disable_crtc, then re-enables the
+ * OTGs. The caller must have already turned DPMS off and updated the stream and
+ * link resources in @context for the new link settings.
+ *
+ * @dc: [in] dc reference
+ * @context: [in] hardware context in use
+ * @otg_masters: [in] OTG master pipes of the streams being retrained
+ * @otg_master_count: [in] number of entries in @otg_masters
+ * @program_pix_clk: [in] program pixel clock and audio, needed when the link encoding changes
+ * @audio_output: [in] audio output per OTG master, used if @program_pix_clk
+ */
+void hwss_restart_otg_for_dp_test_link_retrain(struct dc *dc,
+ struct dc_state *context,
+ struct pipe_ctx **otg_masters,
+ uint8_t otg_master_count,
+ bool program_pix_clk,
+ struct audio_output *audio_output)
+{
+ int i;
+
+ // TODO: Confirm with HW docs if disable/re-enable is actually required here
+ for (i = 0; i < otg_master_count; i++)
+ otg_masters[i]->stream_res.tg->funcs->disable_crtc(otg_masters[i]->stream_res.tg);
+
+ if (program_pix_clk) {
+ for (i = 0; i < otg_master_count; i++) {
+ struct pipe_ctx *pipe = otg_masters[i];
+ struct audio *audio = pipe->stream_res.audio;
+
+ if (pipe->stream_res.pix_clk_params.controller_id != CONTROLLER_ID_UNDEFINED)
+ pipe->clock_source->funcs->program_pix_clk(
+ pipe->clock_source,
+ &pipe->stream_res.pix_clk_params,
+ dc->link_srv->dp_get_encoding_format(&pipe->link_config.dp_link_settings),
+ &pipe->pll_settings);
+
+ if (audio != NULL) {
+ const struct link_hwss *link_hwss = get_link_hwss(
+ pipe->stream->link, &pipe->link_res);
+
+ link_hwss->setup_audio_output(pipe, &audio_output[i], audio->inst);
+
+ audio->funcs->az_configure(
+ audio,
+ pipe->stream->signal,
+ &audio_output[i].crtc_info,
+ &pipe->stream->audio_info,
+ &audio_output[i].dp_link_info);
+
+ if (dc->config.disable_hbr_audio_dp2 &&
+ audio->funcs->az_disable_hbr_audio &&
+ dc->link_srv->dp_is_128b_132b_signal(pipe))
+ audio->funcs->az_disable_hbr_audio(audio);
+ }
+ }
+ }
+
+ for (i = 0; i < otg_master_count; i++) {
+ struct pipe_ctx *pipe = otg_masters[i];
+
+ /* disable_crtc cleared the ODM segment config */
+ if (pipe->next_odm_pipe) {
+ struct pipe_ctx *opp_heads[MAX_PIPES];
+ int opp_inst[MAX_PIPES] = {0};
+ int opp_head_count = resource_get_opp_heads_for_otg_master(pipe, &context->res_ctx, opp_heads);
+ int j;
+
+ for (j = 0; j < opp_head_count; j++)
+ opp_inst[j] = opp_heads[j]->stream_res.opp->inst;
+
+ pipe->stream_res.tg->funcs->set_odm_combine(pipe->stream_res.tg, opp_inst, opp_head_count,
+ resource_get_odm_slice_dst_width(pipe, false),
+ resource_get_odm_slice_dst_width(pipe, true));
+ }
+
+ pipe->stream_res.tg->funcs->enable_crtc(pipe->stream_res.tg);
+ }
+}
+
void hwss_reset_unused_det(struct dc *dc, struct dc_state *context)
{
struct hubbub *hubbub = dc->res_pool->hubbub;
diff --git a/drivers/gpu/drm/amd/display/dc/hwss/hw_sequencer.h b/drivers/gpu/drm/amd/display/dc/hwss/hw_sequencer.h
index bfe9afb434af..c2e256a40128 100644
--- a/drivers/gpu/drm/amd/display/dc/hwss/hw_sequencer.h
+++ b/drivers/gpu/drm/amd/display/dc/hwss/hw_sequencer.h
@@ -66,6 +66,7 @@ struct link_training_settings;
struct dc_link;
struct dc_crtc_timing;
struct dmub_srv_hw_params;
+struct audio_output;
struct tg_lock_params {
struct dc *dc;
@@ -2316,6 +2317,13 @@ void hwss_wait_for_all_blank_complete(struct dc *dc,
void hwss_wait_for_odm_update_pending_complete(struct dc *dc,
struct dc_state *context);
+void hwss_restart_otg_for_dp_test_link_retrain(struct dc *dc,
+ struct dc_state *context,
+ struct pipe_ctx **otg_masters,
+ uint8_t otg_master_count,
+ bool program_pix_clk,
+ struct audio_output *audio_output);
+
void hwss_wait_for_no_pipes_pending(struct dc *dc,
struct dc_state *context);
diff --git a/drivers/gpu/drm/amd/display/dc/link/accessories/link_dp_cts.c b/drivers/gpu/drm/amd/display/dc/link/accessories/link_dp_cts.c
index f316337cee1b..2fe7ceff1f50 100644
--- a/drivers/gpu/drm/amd/display/dc/link/accessories/link_dp_cts.c
+++ b/drivers/gpu/drm/amd/display/dc/link/accessories/link_dp_cts.c
@@ -72,6 +72,7 @@ static void dp_retrain_link_dp_test(struct dc_link *link,
struct dc_stream_update stream_update = { 0 };
bool dpms_off = false;
bool needs_divider_update = false;
+ bool program_pix_clk = false;
bool was_hpo_acquired = resource_is_hpo_acquired(link->dc->current_state);
bool is_hpo_acquired;
uint8_t count;
@@ -97,52 +98,24 @@ static void dp_retrain_link_dp_test(struct dc_link *link,
link->dc,
state,
pipes[i]);
-
- // Disable OTG and re-enable after updating clocks
- pipes[i]->stream_res.tg->funcs->disable_crtc(pipes[i]->stream_res.tg);
}
if (needs_divider_update && link->dc->res_pool->funcs->update_dc_state_for_encoder_switch) {
link->dc->res_pool->funcs->update_dc_state_for_encoder_switch(link,
link_setting, count,
*pipes, &audio_output[0]);
- for (i = 0; i < count; i++) {
- pipes[i]->clock_source->funcs->program_pix_clk(
- pipes[i]->clock_source,
- &pipes[i]->stream_res.pix_clk_params,
- link->dc->link_srv->dp_get_encoding_format(&pipes[i]->link_config.dp_link_settings),
- &pipes[i]->pll_settings);
-
- if (pipes[i]->stream_res.audio != NULL) {
- const struct link_hwss *link_hwss = get_link_hwss(
- link, &pipes[i]->link_res);
-
- link_hwss->setup_audio_output(pipes[i], &audio_output[i],
- pipes[i]->stream_res.audio->inst);
-
- pipes[i]->stream_res.audio->funcs->az_configure(
- pipes[i]->stream_res.audio,
- pipes[i]->stream->signal,
- &audio_output[i].crtc_info,
- &pipes[i]->stream->audio_info,
- &audio_output[i].dp_link_info);
-
- if (link->dc->config.disable_hbr_audio_dp2 &&
- pipes[i]->stream_res.audio->funcs->az_disable_hbr_audio &&
- link->dc->link_srv->dp_is_128b_132b_signal(pipes[i]))
- pipes[i]->stream_res.audio->funcs->az_disable_hbr_audio(pipes[i]->stream_res.audio);
- }
- }
+ program_pix_clk = true;
}
+ // Disable OTG, update clocks and re-enable OTG with its ODM configuration restored
+ hwss_restart_otg_for_dp_test_link_retrain(dc, state, pipes, count,
+ program_pix_clk, audio_output);
+
// Toggle on HPO I/O if necessary
is_hpo_acquired = resource_is_hpo_acquired(state);
if (was_hpo_acquired != is_hpo_acquired && link->dc->hwss.setup_hpo_hw_control)
link->dc->hwss.setup_hpo_hw_control(link->dc->hwseq, is_hpo_acquired);
- for (i = 0; i < count; i++)
- pipes[i]->stream_res.tg->funcs->enable_crtc(pipes[i]->stream_res.tg);
-
// Set DPMS on with stream update
// Cache all streams on current link since dc_update_planes_and_stream might kill current_state
for (i = 0; i < MAX_PIPES; i++) {
--
2.43.0
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [PATCH 06/33] drm/amd/display: add extra 0.25 line reserved for TSetup/TCalc inefficiency
2026-11-16 21:50 [PATCH 00/33] DC Patches November 23, 2026 James Lin
` (4 preceding siblings ...)
2026-11-16 21:50 ` [PATCH 05/33] drm/amd/display: Refactor DP retrain link HW sequence James Lin
@ 2026-11-16 21:50 ` James Lin
2026-11-16 21:50 ` [PATCH 07/33] drm/amd/display: Use panel luminance range for AUX backlight in power module James Lin
` (26 subsequent siblings)
32 siblings, 0 replies; 34+ messages in thread
From: James Lin @ 2026-11-16 21:50 UTC (permalink / raw)
To: amd-gfx
Cc: Harry Wentland, Leo Li, Aurabindo Pillai, Roman Li, Wayne Lin,
Tom Chung, Fangzhi Zuo, Dan Wheeler, Ray Wu, Ivan Lipski,
Alex Hung, James Lin, Chenyu Chen, Samson Tam, James Lin
From: Samson Tam <Samson.Tam@amd.com>
[Why]
Some four display configurations fail to light up all displays,
failing during prefetch validation.
[How]
Add extra 0.25 lines for min_vblank_unreserve_otg_vlines to account
for inefficiency from TSetup/TCalc
Also fix nom_vtotal and allow_end_otg_vline calculations. Not related
to display config issue.
Signed-off-by: Samson Tam <Samson.Tam@amd.com>
Signed-off-by: James Lin <pinglei.lin@amd.com>
---
.../src/dml2_pmo/dml2_pmo_dcn6_stage_optimizers.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/drivers/gpu/drm/amd/display/dc/dml2_0/dml21/src/dml2_pmo/dml2_pmo_dcn6_stage_optimizers.c b/drivers/gpu/drm/amd/display/dc/dml2_0/dml21/src/dml2_pmo/dml2_pmo_dcn6_stage_optimizers.c
index c4db8ff3ee30..71407eec2d83 100644
--- a/drivers/gpu/drm/amd/display/dc/dml2_0/dml21/src/dml2_pmo/dml2_pmo_dcn6_stage_optimizers.c
+++ b/drivers/gpu/drm/amd/display/dc/dml2_0/dml21/src/dml2_pmo/dml2_pmo_dcn6_stage_optimizers.c
@@ -409,8 +409,8 @@ static bool dcn6_update_worksheet_for_pstate_admissibility(struct dml2_optimizat
const double vblank_ratio = 0.8;
const double min_vblank_unreserved_ratio = 0.15;
const double min_vblank_unreserved_time_us = 50.0;
- // min reserved for prefetch + 1 line lost for max vstartup
- const unsigned int min_vblank_unreserved_otg_vlines = 4 + 1;
+ // min reserved for prefetch + 1 line lost for max vstartup, and +1/4 for inefficiency from TSetup/TCalc, in quarter OTG vlines
+ const unsigned int min_vblank_unreserved_otg_vlines_x4 = (4 + 1) * 4 + 1; // 5.25
unsigned int plane_index, stream_index, stream_index1;
double ideal_disallow_time_us, disallow_time_us;
@@ -464,7 +464,7 @@ static bool dcn6_update_worksheet_for_pstate_admissibility(struct dml2_optimizat
vblank_time_us = display_config->stream_descriptors[stream_index].timing.vblank_nom *
per_stream_pstate_meta[stream_index].otg_vline_time_us;
min_unreserved_vblank_time_us = math_max2(
- per_stream_pstate_meta[stream_index].otg_vline_time_us * min_vblank_unreserved_otg_vlines,
+ per_stream_pstate_meta[stream_index].otg_vline_time_us * min_vblank_unreserved_otg_vlines_x4 / 4.0,
math_min2(vblank_time_us * min_vblank_unreserved_ratio,
min_vblank_unreserved_time_us));
@@ -718,7 +718,7 @@ static void dcn6_build_pstate_meta_per_stream(const struct dml2_display_cfg *dis
/* common */
stream_pstate_meta->valid = true;
- stream_pstate_meta->nom_vtotal = stream_descriptor->timing.vblank_nom + stream_descriptor->timing.v_active;
+ stream_pstate_meta->nom_vtotal = stream_descriptor->timing.v_total;
stream_pstate_meta->otg_vline_time_us = (double)timing->h_total / timing->pixel_clock_khz * 1000.0;
stream_pstate_meta->vblank_start = timing->v_blank_end + timing->v_active;
stream_pstate_meta->nom_refresh_rate_hz = timing->pixel_clock_khz * 1000.0 /
@@ -837,7 +837,10 @@ static void dcn6_build_pstate_meta_per_stream(const struct dml2_display_cfg *dis
stream_pstate_meta->method_vactive.common.allow_start_otg_vline =
timing->v_blank_end + stream_pstate_meta->method_vactive.max_vactive_det_fill_delay_otg_vlines;
stream_pstate_meta->method_vactive.common.allow_end_otg_vline =
- stream_pstate_meta->vblank_start -
+ stream_pstate_meta->vblank_start +
+ stream_pstate_meta->nom_vtotal -
+ stream_descriptor->timing.v_active -
+ stream_descriptor->timing.vblank_nom -
stream_pstate_meta->blackout_otg_vlines +
stream_pstate_meta->method_vactive.reserved_blank_required_vlines;
} else {
--
2.43.0
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [PATCH 07/33] drm/amd/display: Use panel luminance range for AUX backlight in power module
2026-11-16 21:50 [PATCH 00/33] DC Patches November 23, 2026 James Lin
` (5 preceding siblings ...)
2026-11-16 21:50 ` [PATCH 06/33] drm/amd/display: add extra 0.25 line reserved for TSetup/TCalc inefficiency James Lin
@ 2026-11-16 21:50 ` James Lin
2026-11-16 21:50 ` [PATCH 08/33] drm/amd/display: Read PWM back linearly with the linear backlight curve James Lin
` (25 subsequent siblings)
32 siblings, 0 replies; 34+ messages in thread
From: James Lin @ 2026-11-16 21:50 UTC (permalink / raw)
To: amd-gfx
Cc: Harry Wentland, Leo Li, Aurabindo Pillai, Roman Li, Wayne Lin,
Tom Chung, Fangzhi Zuo, Dan Wheeler, Ray Wu, Ivan Lipski,
Alex Hung, James Lin, Chenyu Chen, Ray Wu, James Lin
From: Ray Wu <ray.wu@amd.com>
[Why & How]
The power module always gets the default 1..270 nits range, so VESA
AUX panels with DMUB aux_backlight_support are capped at 270 nits. For
AUX backlight panels, pass the EDID derived aux_min/max_input_signal
to the power module, and add KUnit cases for it.
Cc: ChiaHsuan Chung <chiahsuan.chung@amd.com>
Signed-off-by: Ray Wu <ray.wu@amd.com>
Signed-off-by: James Lin <pinglei.lin@amd.com>
---
.../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 20 ++++-
.../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h | 3 +
.../display/amdgpu_dm/tests/amdgpu_dm_test.c | 73 +++++++++++++++++++
3 files changed, 93 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index a7c2b0094944..2f4c6a2dd4ec 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -417,6 +417,22 @@ STATIC_IFN_KUNIT void mmhub_read_system_context(struct amdgpu_device *adev,
}
EXPORT_IF_KUNIT(mmhub_read_system_context);
+STATIC_IFN_KUNIT void
+amdgpu_dm_fill_power_nits_range(const struct amdgpu_dm_backlight_caps *caps,
+ struct mod_power_init_params *init_data)
+{
+ init_data->use_nits_based_brightness = false;
+ init_data->panel_max_millinits = 0;
+ init_data->panel_min_millinits = 0;
+ if (caps->aux_support &&
+ caps->aux_max_input_signal > caps->aux_min_input_signal) {
+ init_data->use_nits_based_brightness = true;
+ init_data->panel_max_millinits = caps->aux_max_input_signal * 1000;
+ init_data->panel_min_millinits = caps->aux_min_input_signal * 1000;
+ }
+}
+EXPORT_IF_KUNIT(amdgpu_dm_fill_power_nits_range);
+
STATIC_IFN_KUNIT int amdgpu_dm_init_power_module(struct amdgpu_display_manager *dm)
{
struct mod_power_init_params init_data[MAX_NUM_EDP];
@@ -441,9 +457,7 @@ STATIC_IFN_KUNIT int amdgpu_dm_init_power_module(struct amdgpu_display_manager *
init_data[i].def_varibright_level = 0;
init_data[i].abm_config_setting = 0;
init_data[i].num_backlight_levels = 101;
- init_data[i].use_nits_based_brightness = false;
- init_data[i].panel_max_millinits = 0;
- init_data[i].panel_min_millinits = 0;
+ amdgpu_dm_fill_power_nits_range(&dm->backlight_caps[i], &init_data[i]);
init_data[i].disable_fractional_pwm =
!(amdgpu_dc_feature_mask & DC_DISABLE_FRACTIONAL_PWM_MASK);
init_data[i].use_custom_backlight_caps = false;
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h
index f8503ebf28f4..761d2b40aece 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h
@@ -1346,9 +1346,12 @@ struct dc_plane_address;
struct dc_plane_cap;
struct dc_plane_info;
struct dsc_mst_fairness_vars;
+struct mod_power_init_params;
void mmhub_read_system_context(struct amdgpu_device *adev,
struct dc_phy_addr_space_config *pa_config);
+void amdgpu_dm_fill_power_nits_range(const struct amdgpu_dm_backlight_caps *caps,
+ struct mod_power_init_params *init_data);
int amdgpu_dm_init_power_module(struct amdgpu_display_manager *dm);
void dm_gpureset_toggle_interrupts(struct amdgpu_device *adev, struct dc_state *state, bool enable);
enum dc_status amdgpu_dm_commit_zero_streams(struct dc *dc);
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_test.c b/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_test.c
index b9272b28f53c..a7618473e207 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_test.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_test.c
@@ -37,6 +37,7 @@
#include "amdgpu_dm_hdcp.h"
#include "amdgpu_dm_mst_types.h"
#include "amdgpu_dm_kunit_test_helpers.h"
+#include "mod_power.h"
/* Tests for simple DM callbacks */
@@ -3802,6 +3803,74 @@ static void dm_test_init_power_module_alloc_failure(struct kunit *test)
KUNIT_EXPECT_NULL(test, adev->dm.power_module);
}
+/* Tests for amdgpu_dm_fill_power_nits_range() */
+
+/**
+ * dm_test_fill_power_nits_range_aux - Test AUX passes the panel nits range
+ * @test: The KUnit test context
+ *
+ * The power module sends max_brightness_millinits to DMUB, which scales the
+ * VESA AUX level with it, so it must be the panel range and not 270 nits
+ */
+static void dm_test_fill_power_nits_range_aux(struct kunit *test)
+{
+ struct amdgpu_dm_backlight_caps caps = {
+ .aux_support = true,
+ .aux_min_input_signal = 1,
+ .aux_max_input_signal = 500,
+ };
+ struct mod_power_init_params init_data;
+
+ memset(&init_data, 0xff, sizeof(init_data));
+ amdgpu_dm_fill_power_nits_range(&caps, &init_data);
+
+ KUNIT_EXPECT_TRUE(test, init_data.use_nits_based_brightness);
+ KUNIT_EXPECT_EQ(test, init_data.panel_min_millinits, 1000U);
+ KUNIT_EXPECT_EQ(test, init_data.panel_max_millinits, 500000U);
+}
+
+/**
+ * dm_test_fill_power_nits_range_aux_bad_range - Test a bad AUX range keeps the default
+ * @test: The KUnit test context
+ */
+static void dm_test_fill_power_nits_range_aux_bad_range(struct kunit *test)
+{
+ struct amdgpu_dm_backlight_caps caps = {
+ .aux_support = true,
+ .aux_min_input_signal = 500,
+ .aux_max_input_signal = 500,
+ };
+ struct mod_power_init_params init_data;
+
+ memset(&init_data, 0xff, sizeof(init_data));
+ amdgpu_dm_fill_power_nits_range(&caps, &init_data);
+
+ KUNIT_EXPECT_FALSE(test, init_data.use_nits_based_brightness);
+ KUNIT_EXPECT_EQ(test, init_data.panel_min_millinits, 0U);
+ KUNIT_EXPECT_EQ(test, init_data.panel_max_millinits, 0U);
+}
+
+/**
+ * dm_test_fill_power_nits_range_pwm - Test PWM keeps the default nits range
+ * @test: The KUnit test context
+ */
+static void dm_test_fill_power_nits_range_pwm(struct kunit *test)
+{
+ struct amdgpu_dm_backlight_caps caps = {
+ .aux_support = false,
+ .aux_min_input_signal = 1,
+ .aux_max_input_signal = 500,
+ };
+ struct mod_power_init_params init_data;
+
+ memset(&init_data, 0xff, sizeof(init_data));
+ amdgpu_dm_fill_power_nits_range(&caps, &init_data);
+
+ KUNIT_EXPECT_FALSE(test, init_data.use_nits_based_brightness);
+ KUNIT_EXPECT_EQ(test, init_data.panel_min_millinits, 0U);
+ KUNIT_EXPECT_EQ(test, init_data.panel_max_millinits, 0U);
+}
+
/* Tests for fill_dc_plane_info_and_addr() */
struct dm_test_plane_info_ctx {
@@ -5390,6 +5459,10 @@ static struct kunit_case amdgpu_dm_tests[] = {
/* amdgpu_dm_init_power_module */
KUNIT_CASE(dm_test_init_power_module_no_edp),
KUNIT_CASE(dm_test_init_power_module_alloc_failure),
+ /* amdgpu_dm_fill_power_nits_range */
+ KUNIT_CASE(dm_test_fill_power_nits_range_aux),
+ KUNIT_CASE(dm_test_fill_power_nits_range_aux_bad_range),
+ KUNIT_CASE(dm_test_fill_power_nits_range_pwm),
/* fill_dc_plane_info_and_addr */
KUNIT_CASE(dm_test_plane_info_graphics_formats),
KUNIT_CASE(dm_test_plane_info_video_formats),
--
2.43.0
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [PATCH 08/33] drm/amd/display: Read PWM back linearly with the linear backlight curve
2026-11-16 21:50 [PATCH 00/33] DC Patches November 23, 2026 James Lin
` (6 preceding siblings ...)
2026-11-16 21:50 ` [PATCH 07/33] drm/amd/display: Use panel luminance range for AUX backlight in power module James Lin
@ 2026-11-16 21:50 ` James Lin
2026-11-16 21:50 ` [PATCH 09/33] drm/amd/display: Add API to set brightness percent James Lin
` (24 subsequent siblings)
32 siblings, 0 replies; 34+ messages in thread
From: James Lin @ 2026-11-16 21:50 UTC (permalink / raw)
To: amd-gfx
Cc: Harry Wentland, Leo Li, Aurabindo Pillai, Roman Li, Wayne Lin,
Tom Chung, Fangzhi Zuo, Dan Wheeler, Ray Wu, Ivan Lipski,
Alex Hung, James Lin, Chenyu Chen, Ray Wu, James Lin
From: Ray Wu <ray.wu@amd.com>
[Why]
use_linear_backlight_curve makes the power module bypass its LUT when
setting PWM, but reading PWM back still searched the LUT, so the
percentage read back did not match the one set.
[How]
Map PWM back linearly over the same range instead. Also read the flag
for the panel being converted, not the first one.
Cc: ChiaHsuan Chung <chiahsuan.chung@amd.com>
Signed-off-by: Ray Wu <ray.wu@amd.com>
Signed-off-by: James Lin <pinglei.lin@amd.com>
---
.../drm/amd/display/modules/power/power_abm.c | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/amd/display/modules/power/power_abm.c b/drivers/gpu/drm/amd/display/modules/power/power_abm.c
index 5e86889eaa84..60930d969b9b 100644
--- a/drivers/gpu/drm/amd/display/modules/power/power_abm.c
+++ b/drivers/gpu/drm/amd/display/modules/power/power_abm.c
@@ -374,6 +374,22 @@ static unsigned int backlight_pwm_to_millipercent_legacy(
if (core_power == NULL)
return 0;
+ /* Inverse of the LUT bypass in backlight_millipercent_to_pwm_legacy() */
+ if (core_power->bl_prop[inst].use_linear_backlight_curve) {
+ const struct pwr_backlight_properties *bl_prop = &core_power->bl_prop[inst];
+
+ if (pwm <= bl_prop->min_backlight_pwm)
+ return 0;
+
+ if (pwm >= bl_prop->max_backlight_pwm)
+ return BACKLIGHT_MILLIPERCENT_MAX;
+
+ return (unsigned int)div_u64(
+ (unsigned long long)(pwm - bl_prop->min_backlight_pwm) *
+ BACKLIGHT_MILLIPERCENT_MAX + bl_prop->backlight_range / 2,
+ bl_prop->backlight_range);
+ }
+
if (!core_power->bl_prop[inst].backlight_caps_valid)
return 0;
@@ -529,7 +545,7 @@ static unsigned int backlight_millipercent_to_pwm_legacy(
return 0;
// Bypass the brightness mapping LUT
- if (core_power->bl_prop->use_linear_backlight_curve) {
+ if (core_power->bl_prop[inst].use_linear_backlight_curve) {
pwm = core_power->bl_prop[inst].min_backlight_pwm +
(unsigned int) div_u64((unsigned long long) millipercent *
core_power->bl_prop[inst].backlight_range,
--
2.43.0
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [PATCH 09/33] drm/amd/display: Add API to set brightness percent
2026-11-16 21:50 [PATCH 00/33] DC Patches November 23, 2026 James Lin
` (7 preceding siblings ...)
2026-11-16 21:50 ` [PATCH 08/33] drm/amd/display: Read PWM back linearly with the linear backlight curve James Lin
@ 2026-11-16 21:50 ` James Lin
2026-11-16 21:50 ` [PATCH 10/33] drm/amd/display: Pass linear brightness percent to power module James Lin
` (23 subsequent siblings)
32 siblings, 0 replies; 34+ messages in thread
From: James Lin @ 2026-11-16 21:50 UTC (permalink / raw)
To: amd-gfx
Cc: Harry Wentland, Leo Li, Aurabindo Pillai, Roman Li, Wayne Lin,
Tom Chung, Fangzhi Zuo, Dan Wheeler, Ray Wu, Ivan Lipski,
Alex Hung, James Lin, Chenyu Chen, Ray Wu, James Lin
From: Ray Wu <ray.wu@amd.com>
[Why & How]
Add mod_power_set_brightness() so DM can pass a percentage for every
panel type and let the power module pick the unit:
- VESA AUX takes nits, mapped linearly over the panel range.
- AMD AUX takes nits on OLED and in HDR, and follows PWM otherwise.
- PWM goes through the backlight LUT built from ATIF.
The AUX brightness mask is ORed into the nits.
Cc: ChiaHsuan Chung <chiahsuan.chung@amd.com>
Signed-off-by: Ray Wu <ray.wu@amd.com>
Signed-off-by: James Lin <pinglei.lin@amd.com>
---
.../drm/amd/display/modules/inc/mod_power.h | 7 ++
.../drm/amd/display/modules/power/power_abm.c | 65 +++++++++++++++++++
2 files changed, 72 insertions(+)
diff --git a/drivers/gpu/drm/amd/display/modules/inc/mod_power.h b/drivers/gpu/drm/amd/display/modules/inc/mod_power.h
index 25a0c96ac754..3b6eb2116636 100644
--- a/drivers/gpu/drm/amd/display/modules/inc/mod_power.h
+++ b/drivers/gpu/drm/amd/display/modules/inc/mod_power.h
@@ -221,6 +221,13 @@ bool mod_power_set_backlight_percent(struct mod_power *mod_power,
unsigned int transition_time_millisec,
bool is_hdr);
+bool mod_power_set_brightness(struct mod_power *mod_power,
+ struct dc_stream_state *stream,
+ unsigned int backlight_millipercent,
+ unsigned int transition_time_millisec,
+ unsigned int aux_brightness_mask,
+ bool is_hdr);
+
void mod_power_update_backlight(struct mod_power *mod_power,
struct dc_stream_state *stream,
unsigned int backlight_millipercent);
diff --git a/drivers/gpu/drm/amd/display/modules/power/power_abm.c b/drivers/gpu/drm/amd/display/modules/power/power_abm.c
index 60930d969b9b..a5077b43837f 100644
--- a/drivers/gpu/drm/amd/display/modules/power/power_abm.c
+++ b/drivers/gpu/drm/amd/display/modules/power/power_abm.c
@@ -1166,6 +1166,71 @@ bool mod_power_set_backlight_percent(struct mod_power *mod_power,
&backlight_level_params, panel_inst);
}
+/* AMD AUX takes nits only when the panel's AUX backlight control is on,
+ * which DC turns on for OLED and for HDR. Otherwise the panel follows PWM.
+ */
+static bool backlight_takes_nits(const struct dc_link *link, bool is_hdr)
+{
+ switch (link->backlight_control_type) {
+ case BACKLIGHT_CONTROL_VESA_AUX:
+ return true;
+ case BACKLIGHT_CONTROL_AMD_AUX:
+ return link->dpcd_sink_ext_caps.bits.oled || is_hdr;
+ default:
+ return false;
+ }
+}
+
+/* Sets the brightness as a percentage, whatever the backlight control type.
+ * When the panel takes nits, the percentage maps linearly to
+ * [min_brightness_millinits, max_brightness_millinits] with
+ * aux_brightness_mask ORed in. Otherwise it maps to PWM through the
+ * backlight LUT.
+ */
+bool mod_power_set_brightness(struct mod_power *mod_power,
+ struct dc_stream_state *stream,
+ unsigned int backlight_millipercent,
+ unsigned int transition_time_millisec,
+ unsigned int aux_brightness_mask,
+ bool is_hdr)
+{
+ struct core_power *core_power = NULL;
+ const struct dc_link *link = NULL;
+ unsigned int backlight_millinit;
+ unsigned int panel_inst = 0;
+
+ if (mod_power == NULL || stream == NULL)
+ return false;
+
+ core_power = MOD_POWER_TO_CORE(mod_power);
+ link = dc_stream_get_link(stream);
+
+ if (!dc_get_edp_link_panel_inst(core_power->dc, link, &panel_inst))
+ return false;
+
+ if (backlight_millipercent > BACKLIGHT_MILLIPERCENT_MAX)
+ backlight_millipercent = BACKLIGHT_MILLIPERCENT_MAX;
+
+ core_power->bl_state[panel_inst].isHDR = is_hdr;
+
+ if (!backlight_takes_nits(link, is_hdr))
+ return mod_power_set_backlight_percent(mod_power, stream,
+ backlight_millipercent, transition_time_millisec, is_hdr);
+
+ backlight_millinit = backlight_millipercent_to_millinit_legacy(
+ core_power, backlight_millipercent, panel_inst) |
+ aux_brightness_mask;
+
+ if (!mod_power_set_backlight_nits(mod_power, stream, backlight_millinit,
+ transition_time_millisec, false, is_hdr))
+ return false;
+
+ /* mod_power_set_backlight_nits() caches the percent read back from nits */
+ core_power->bl_state[panel_inst].backlight_millipercent = backlight_millipercent;
+
+ return true;
+}
+
void mod_power_update_backlight(struct mod_power *mod_power,
struct dc_stream_state *stream,
unsigned int backlight_millipercent)
--
2.43.0
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [PATCH 10/33] drm/amd/display: Pass linear brightness percent to power module
2026-11-16 21:50 [PATCH 00/33] DC Patches November 23, 2026 James Lin
` (8 preceding siblings ...)
2026-11-16 21:50 ` [PATCH 09/33] drm/amd/display: Add API to set brightness percent James Lin
@ 2026-11-16 21:50 ` James Lin
2026-11-16 21:50 ` [PATCH 11/33] drm/amd/display: Add DPMS-v2 types James Lin
` (22 subsequent siblings)
32 siblings, 0 replies; 34+ messages in thread
From: James Lin @ 2026-11-16 21:50 UTC (permalink / raw)
To: amd-gfx
Cc: Harry Wentland, Leo Li, Aurabindo Pillai, Roman Li, Wayne Lin,
Tom Chung, Fangzhi Zuo, Dan Wheeler, Ray Wu, Ivan Lipski,
Alex Hung, James Lin, Chenyu Chen, Ray Wu, James Lin
From: Ray Wu <ray.wu@amd.com>
[Why & How]
Pass the user level to mod_power_set_brightness() as a linear percentage
and let the power module choose nits or PWM. The ATIF curve now applies
only to PWM, through the power module's LUT. Read PWM back through the
same LUT.
Cc: ChiaHsuan Chung <chiahsuan.chung@amd.com>
Signed-off-by: Ray Wu <ray.wu@amd.com>
Signed-off-by: James Lin <pinglei.lin@amd.com>
---
.../display/amdgpu_dm/amdgpu_dm_backlight.c | 208 ++-----
.../display/amdgpu_dm/amdgpu_dm_backlight.h | 9 +-
.../tests/amdgpu_dm_backlight_test.c | 552 ++++--------------
3 files changed, 150 insertions(+), 619 deletions(-)
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_backlight.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_backlight.c
index 27546febf90d..af0047c65cf2 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_backlight.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_backlight.c
@@ -116,163 +116,35 @@ int get_brightness_range(const struct amdgpu_dm_backlight_caps *caps,
}
EXPORT_IF_KUNIT(get_brightness_range);
-/* Rescale userspace [0..max] to the firmware curve's [0..255]. */
-static inline u32 scale_input_to_fw(int max, u64 input)
-{
- return DIV_ROUND_CLOSEST_ULL(input * AMDGPU_MAX_BL_LEVEL, max);
-}
-
-/* Rescale from [0..AMDGPU_MAX_BL_LEVEL] to [min..max] */
-static inline u32 scale_fw_to_input(int min, int max, u64 input)
-{
- return min + DIV_ROUND_CLOSEST_ULL(input * (max - min), AMDGPU_MAX_BL_LEVEL);
-}
-
-static u32 backlight_signal_to_luminance(const struct amdgpu_dm_backlight_caps *caps,
- u32 signal)
-{
- u32 lower_signal, upper_signal;
- u32 lower_lum, upper_lum;
- int i;
-
- if (!caps->data_points)
- return DIV_ROUND_CLOSEST(signal * 100, AMDGPU_MAX_BL_LEVEL);
-
- if (signal < caps->luminance_data[0].input_signal) {
- lower_signal = 0;
- lower_lum = 0;
- upper_signal = caps->luminance_data[0].input_signal;
- upper_lum = caps->luminance_data[0].luminance;
- } else if (signal >=
- caps->luminance_data[caps->data_points - 1].input_signal) {
- lower_signal = caps->luminance_data[caps->data_points - 1].input_signal;
- lower_lum = caps->luminance_data[caps->data_points - 1].luminance;
- upper_signal = caps->max_input_signal;
- upper_lum = 100;
- } else {
- for (i = 1;
- i < caps->data_points &&
- signal > caps->luminance_data[i].input_signal;
- i++)
- ;
-
- lower_signal = caps->luminance_data[i - 1].input_signal;
- upper_signal = caps->luminance_data[i].input_signal;
- lower_lum = caps->luminance_data[i - 1].luminance;
- upper_lum = caps->luminance_data[i].luminance;
- }
-
- if (upper_signal == lower_signal)
- return upper_lum;
-
- return lower_lum + DIV_ROUND_CLOSEST((upper_lum - lower_lum) *
- (signal - lower_signal),
- upper_signal - lower_signal);
-}
-
-static u32 convert_brightness_to_millipercent(const struct amdgpu_dm_backlight_caps *caps,
- u32 user_brightness)
+/*
+ * The power module maps the percentage to nits or, through its LUT built from
+ * the ATIF curve, to PWM, so pass userspace's [0..max] through linearly.
+ */
+STATIC_IFN_KUNIT
+u32 convert_brightness_to_millipercent(const struct amdgpu_dm_backlight_caps *caps,
+ u32 user_brightness)
{
unsigned int min, max;
- u32 signal, luminance;
if (!get_brightness_range(caps, &min, &max))
- return DIV_ROUND_CLOSEST_ULL((u64)user_brightness * 100000,
- MAX_BACKLIGHT_LEVEL);
-
- user_brightness = clamp(user_brightness, min, max);
- if (amdgpu_dc_debug_mask & DC_DISABLE_CUSTOM_BRIGHTNESS_CURVE)
- return DIV_ROUND_CLOSEST_ULL((u64)user_brightness * 100000, max);
+ max = MAX_BACKLIGHT_LEVEL;
- signal = scale_input_to_fw(max, user_brightness);
- luminance = backlight_signal_to_luminance(caps, signal);
-
- return min_t(u32, luminance * 1000, 100000);
+ return DIV_ROUND_CLOSEST_ULL((u64)min(user_brightness, max) * 100000, max);
}
+EXPORT_IF_KUNIT(convert_brightness_to_millipercent);
STATIC_IFN_KUNIT
-void convert_custom_brightness(const struct amdgpu_dm_backlight_caps *caps,
- unsigned int min, unsigned int max,
- uint32_t *user_brightness)
-{
- u32 brightness = scale_input_to_fw(max, *user_brightness);
- u8 lower_signal, upper_signal, upper_lum, lower_lum, lum;
- int left, right;
-
- if (amdgpu_dc_debug_mask & DC_DISABLE_CUSTOM_BRIGHTNESS_CURVE)
- return;
-
- if (!caps->data_points)
- return;
-
- /*
- * Handle the case where brightness is below the first data point
- * Interpolate between (0,0) and (first_signal, first_lum)
- */
- if (brightness < caps->luminance_data[0].input_signal) {
- lum = DIV_ROUND_CLOSEST(caps->luminance_data[0].luminance * brightness,
- caps->luminance_data[0].input_signal);
- goto scale;
- }
-
- left = 0;
- right = caps->data_points - 1;
- while (left <= right) {
- int mid = left + (right - left) / 2;
- u8 signal = caps->luminance_data[mid].input_signal;
-
- /* Exact match found */
- if (signal == brightness) {
- lum = caps->luminance_data[mid].luminance;
- goto scale;
- }
-
- if (signal < brightness)
- left = mid + 1;
- else
- right = mid - 1;
- }
-
- /* verify bound */
- if (left >= caps->data_points)
- left = caps->data_points - 1;
-
- /* At this point, left > right */
- lower_signal = caps->luminance_data[right].input_signal;
- upper_signal = caps->luminance_data[left].input_signal;
- lower_lum = caps->luminance_data[right].luminance;
- upper_lum = caps->luminance_data[left].luminance;
-
- /* interpolate */
- if (right == left || !lower_lum)
- lum = upper_lum;
- else
- lum = lower_lum + DIV_ROUND_CLOSEST((upper_lum - lower_lum) *
- (brightness - lower_signal),
- upper_signal - lower_signal);
-scale:
- *user_brightness = scale_fw_to_input(min, max,
- DIV_ROUND_CLOSEST(lum * brightness, 101));
-}
-
-EXPORT_IF_KUNIT(convert_custom_brightness);
-
-STATIC_IFN_KUNIT
-u32 convert_brightness_from_user(const struct amdgpu_dm_backlight_caps *caps,
- uint32_t brightness)
+u32 convert_millipercent_to_user(const struct amdgpu_dm_backlight_caps *caps,
+ u32 millipercent)
{
unsigned int min, max;
if (!get_brightness_range(caps, &min, &max))
- return brightness;
-
- convert_custom_brightness(caps, min, max, &brightness);
+ max = MAX_BACKLIGHT_LEVEL;
- /* Rescale 0..max to min..max */
- return min + DIV_ROUND_CLOSEST_ULL((u64)(max - min) * brightness, max);
+ return DIV_ROUND_CLOSEST_ULL((u64)min(millipercent, 100000U) * max, 100000);
}
-
-EXPORT_IF_KUNIT(convert_brightness_from_user);
+EXPORT_IF_KUNIT(convert_millipercent_to_user);
STATIC_IFN_KUNIT
u32 convert_brightness_to_user(const struct amdgpu_dm_backlight_caps *caps,
@@ -310,6 +182,19 @@ struct dc_stream_state *dm_find_stream_with_link(
}
EXPORT_IF_KUNIT(dm_find_stream_with_link);
+/* Must match the panels mod_power_set_brightness() sends nits to in SDR */
+static bool dm_backlight_takes_nits(const struct dc_link *link)
+{
+ switch (link->backlight_control_type) {
+ case BACKLIGHT_CONTROL_VESA_AUX:
+ return true;
+ case BACKLIGHT_CONTROL_AMD_AUX:
+ return link->dpcd_sink_ext_caps.bits.oled;
+ default:
+ return false;
+ }
+}
+
STATIC_IFN_KUNIT
int amdgpu_dm_backlight_get_device_index(struct amdgpu_display_manager *dm,
struct backlight_device *bd)
@@ -331,8 +216,7 @@ void amdgpu_dm_backlight_set_level(struct amdgpu_display_manager *dm,
{
struct amdgpu_dm_backlight_caps *caps;
struct dc_link *link;
- u32 brightness = 0;
- u32 millipercent = 0;
+ u32 millipercent;
bool rc = false, reallow_idle = false;
struct drm_connector *connector;
struct dc_stream_state *stream;
@@ -364,20 +248,12 @@ void amdgpu_dm_backlight_set_level(struct amdgpu_display_manager *dm,
if (!stream)
return;
- if (caps->aux_support) {
- brightness = convert_brightness_from_user(caps, dm->brightness[bl_idx]);
- /* Apply brightness quirk */
- if (caps->brightness_mask)
- brightness |= caps->brightness_mask;
- } else {
- millipercent = convert_brightness_to_millipercent(caps,
- user_brightness);
- }
+ millipercent = convert_brightness_to_millipercent(caps, user_brightness);
if (trace_amdgpu_dm_brightness_enabled()) {
trace_amdgpu_dm_brightness(__builtin_return_address(0),
user_brightness,
- brightness,
+ millipercent,
caps->aux_support,
power_supply_is_system_supplied() > 0);
}
@@ -388,14 +264,10 @@ void amdgpu_dm_backlight_set_level(struct amdgpu_display_manager *dm,
reallow_idle = true;
}
- if (caps->aux_support) {
- rc = mod_power_set_backlight_nits(dm->power_module, stream, brightness,
- AUX_BL_DEFAULT_TRANSITION_TIME_MS, false, true);
- } else {
- /* power module uses millipercent */
- rc = mod_power_set_backlight_percent(dm->power_module, stream,
- millipercent, 0, false);
- }
+ rc = mod_power_set_brightness(dm->power_module, stream, millipercent,
+ dm_backlight_takes_nits(link) ?
+ AUX_BL_DEFAULT_TRANSITION_TIME_MS : 0,
+ caps->brightness_mask, false);
/*
* Some kms clients create a ramped backlight transition effect
@@ -443,11 +315,12 @@ u32 amdgpu_dm_backlight_get_level(struct amdgpu_display_manager *dm, int bl_idx)
int ret;
struct amdgpu_dm_backlight_caps caps;
struct dc_link *link = (struct dc_link *)dm->backlight_link[bl_idx];
+ unsigned int panel_inst, millipercent;
amdgpu_dm_update_backlight_caps(dm, bl_idx);
caps = dm->backlight_caps[bl_idx];
- if (caps.aux_support) {
+ if (dm_backlight_takes_nits(link)) {
u32 avg, peak;
if (!dc_link_get_backlight_level_nits(link, &avg, &peak))
@@ -460,7 +333,12 @@ u32 amdgpu_dm_backlight_get_level(struct amdgpu_display_manager *dm, int bl_idx)
if (ret == DC_ERROR_UNEXPECTED)
return dm->brightness[bl_idx];
- return convert_brightness_to_user(&caps, ret);
+ if (!dc_get_edp_link_panel_inst(dm->dc, link, &panel_inst) ||
+ !mod_power_get_hw_backlight_pwm_percent(dm->power_module, link,
+ &millipercent, panel_inst))
+ return dm->brightness[bl_idx];
+
+ return convert_millipercent_to_user(&caps, millipercent);
}
EXPORT_IF_KUNIT(amdgpu_dm_backlight_get_level);
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_backlight.h b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_backlight.h
index 9ad888d3ae7b..1807209e90e7 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_backlight.h
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_backlight.h
@@ -67,13 +67,12 @@ ssize_t panel_power_savings_store(struct device *device,
const char *buf, size_t count);
int get_brightness_range(const struct amdgpu_dm_backlight_caps *caps,
unsigned int *min, unsigned int *max);
-void convert_custom_brightness(const struct amdgpu_dm_backlight_caps *caps,
- unsigned int min, unsigned int max,
- uint32_t *user_brightness);
-u32 convert_brightness_from_user(const struct amdgpu_dm_backlight_caps *caps,
- uint32_t brightness);
u32 convert_brightness_to_user(const struct amdgpu_dm_backlight_caps *caps,
uint32_t brightness);
+u32 convert_brightness_to_millipercent(const struct amdgpu_dm_backlight_caps *caps,
+ u32 user_brightness);
+u32 convert_millipercent_to_user(const struct amdgpu_dm_backlight_caps *caps,
+ u32 millipercent);
int amdgpu_dm_backlight_get_device_index(struct amdgpu_display_manager *dm,
struct backlight_device *bd);
void amdgpu_dm_backlight_fill_props(const struct amdgpu_dm_backlight_caps *caps,
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 a60c0fbf519d..e32e8c14e05e 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
@@ -152,10 +152,9 @@ static void dm_test_backlight_set_level_no_stream(struct kunit *test)
* @test: The KUnit test context
*
* With a matching stream present, set_level() walks into the DC programming
- * path. A NULL power_module makes mod_power_set_backlight_nits() a safe
+ * path. A NULL power_module makes mod_power_set_brightness() a safe
* early-false, and ips_support disabled leaves idle optimizations untouched.
- * A non-matching connector exercises the connector-list skip, and a non-zero
- * brightness_mask exercises the quirk-OR path.
+ * A non-matching connector exercises the connector-list skip.
*/
static void dm_test_backlight_set_level_aux_programs_power_module(struct kunit *test)
{
@@ -195,26 +194,15 @@ static void dm_test_backlight_set_level_aux_programs_power_module(struct kunit *
* dm_test_backlight_set_level_pwm_programs_power_module - Test PWM programming path
* @test: The KUnit test context
*
- * With aux_support cleared, set_level() takes the millipercent branch:
- * get_brightness_range() + mod_power_set_backlight_percent(). A NULL
- * power_module keeps the call a safe early-false. The cases walk each segment of
- * the custom luminance curve; DC_DISABLE_CUSTOM_BRIGHTNESS_CURVE then bypasses it.
+ * With aux_support cleared, set_level() passes the PWM range to
+ * mod_power_set_brightness() as a percentage. A NULL power_module keeps the
+ * call a safe early-false.
*/
static void dm_test_backlight_set_level_pwm_programs_power_module(struct kunit *test)
{
- static const struct amdgpu_dm_luminance_data curve[] = {
- { .input_signal = 50, .luminance = 10 },
- { .input_signal = 100, .luminance = 40 },
- { .input_signal = 200, .luminance = 80 },
- { .input_signal = 255, .luminance = 90 },
- };
- /* { data_points, brightness }: no curve, below/between/above points, zero-width end */
- static const u32 cases[][2] = {
- { 0, 2000 }, { 3, 0 }, { 3, 38550 }, { 3, 65535 }, { 4, 65535 },
- };
+ static const u32 cases[] = { 0, 2000, 38550, 65535 };
struct amdgpu_display_manager *dm = dm_kunit_alloc_dm(test);
struct dc_link *link = dm_kunit_alloc_link(test);
- uint saved_mask = amdgpu_dm_get_dc_debug_mask();
int i;
setup_test_dm_ddev(test, dm);
@@ -225,22 +213,14 @@ static void dm_test_backlight_set_level_pwm_programs_power_module(struct kunit *
dm->backlight_caps[1].aux_support = false;
dm->backlight_caps[1].min_input_signal = AMDGPU_DM_DEFAULT_MIN_BACKLIGHT;
dm->backlight_caps[1].max_input_signal = AMDGPU_DM_DEFAULT_MAX_BACKLIGHT;
- memcpy(dm->backlight_caps[1].luminance_data, curve, sizeof(curve));
dm->backlight_link[1] = link;
dm_kunit_add_stream_to_state(test, dm->dc->current_state, 0, link);
- amdgpu_dm_set_dc_debug_mask(saved_mask & ~DC_DISABLE_CUSTOM_BRIGHTNESS_CURVE);
for (i = 0; i < ARRAY_SIZE(cases); i++) {
- dm->backlight_caps[1].data_points = cases[i][0];
- amdgpu_dm_backlight_set_level(dm, 1, cases[i][1]);
- KUNIT_EXPECT_EQ_MSG(test, dm->brightness[1], cases[i][1], "case %d", i);
+ amdgpu_dm_backlight_set_level(dm, 1, cases[i]);
+ KUNIT_EXPECT_EQ_MSG(test, dm->brightness[1], cases[i], "case %d", i);
}
- amdgpu_dm_set_dc_debug_mask(saved_mask | DC_DISABLE_CUSTOM_BRIGHTNESS_CURVE);
- amdgpu_dm_backlight_set_level(dm, 1, 2000);
- amdgpu_dm_set_dc_debug_mask(saved_mask);
-
- KUNIT_EXPECT_EQ(test, dm->brightness[1], 2000U);
KUNIT_EXPECT_EQ(test, dm->actual_brightness[1], 0U);
}
@@ -374,21 +354,24 @@ static bool dm_test_get_backlight_level_nits_fail(struct dc_link *link,
/* Tests for amdgpu_dm_backlight_get_level()/get_brightness() */
/**
- * dm_test_backlight_get_level_pwm_success - Test PWM brightness readback
+ * dm_test_backlight_get_level_pwm_no_power_module - Test PWM readback fallback
* @test: The KUnit test context
+ *
+ * PWM readback goes through the power module's LUT. Without a power module
+ * for the link, get_level() must return the cached brightness.
*/
-static void dm_test_backlight_get_level_pwm_success(struct kunit *test)
+static void dm_test_backlight_get_level_pwm_no_power_module(struct kunit *test)
{
struct amdgpu_display_manager *dm = dm_kunit_alloc_dm(test);
struct dc_link *link = dm_kunit_alloc_link(test);
- u32 hw_level = dm_test_get_backlight_level_mid(link);
setup_test_link_service(test, link);
link->dc->link_srv->edp_get_backlight_level = dm_test_get_backlight_level_mid;
+ dm->power_module = NULL;
+ dm->brightness[0] = 1234;
dm->backlight_link[0] = link;
- KUNIT_EXPECT_EQ(test, amdgpu_dm_backlight_get_level(dm, 0),
- convert_brightness_to_user(&dm->backlight_caps[0], hw_level));
+ KUNIT_EXPECT_EQ(test, amdgpu_dm_backlight_get_level(dm, 0), 1234U);
}
/**
@@ -420,6 +403,8 @@ static void dm_test_backlight_get_level_aux_success(struct kunit *test)
setup_test_link_service(test, link);
link->dc->link_srv->edp_get_backlight_level_nits = dm_test_get_backlight_level_nits;
+ link->backlight_control_type = BACKLIGHT_CONTROL_AMD_AUX;
+ link->dpcd_sink_ext_caps.bits.oled = 1;
dm->backlight_link[0] = link;
caps->caps_valid = true;
caps->aux_support = true;
@@ -430,6 +415,35 @@ static void dm_test_backlight_get_level_aux_success(struct kunit *test)
convert_brightness_to_user(caps, 250000));
}
+/**
+ * dm_test_backlight_get_level_amd_aux_lcd_reads_pwm - Test forced AMD AUX LCD readback
+ * @test: The KUnit test context
+ *
+ * amdgpu.backlight=1 forces AMD AUX on an LCD, which the power module still
+ * drives through PWM in SDR. get_level() must read PWM back, not the AUX nits
+ * nobody wrote, so without a power module it returns the cached brightness.
+ */
+static void dm_test_backlight_get_level_amd_aux_lcd_reads_pwm(struct kunit *test)
+{
+ struct amdgpu_display_manager *dm = dm_kunit_alloc_dm(test);
+ struct dc_link *link = dm_kunit_alloc_link(test);
+ struct amdgpu_dm_backlight_caps *caps = &dm->backlight_caps[0];
+
+ setup_test_link_service(test, link);
+ link->dc->link_srv->edp_get_backlight_level = dm_test_get_backlight_level_mid;
+ link->dc->link_srv->edp_get_backlight_level_nits = dm_test_get_backlight_level_nits;
+ link->backlight_control_type = BACKLIGHT_CONTROL_AMD_AUX;
+ dm->power_module = NULL;
+ dm->brightness[0] = 1234;
+ dm->backlight_link[0] = link;
+ caps->caps_valid = true;
+ caps->aux_support = true;
+ caps->aux_min_input_signal = 1;
+ caps->aux_max_input_signal = 512;
+
+ KUNIT_EXPECT_EQ(test, amdgpu_dm_backlight_get_level(dm, 0), 1234U);
+}
+
/**
* dm_test_backlight_get_level_aux_error - Test AUX readback fallback
* @test: The KUnit test context
@@ -442,6 +456,8 @@ static void dm_test_backlight_get_level_aux_error(struct kunit *test)
setup_test_link_service(test, link);
link->dc->link_srv->edp_get_backlight_level_nits = dm_test_get_backlight_level_nits_fail;
+ link->backlight_control_type = BACKLIGHT_CONTROL_AMD_AUX;
+ link->dpcd_sink_ext_caps.bits.oled = 1;
dm->brightness[0] = 6789;
dm->backlight_link[0] = link;
caps->caps_valid = true;
@@ -558,7 +574,9 @@ static void dm_test_register_backlight_device_custom_curve_readback(struct kunit
amdgpu_dm_set_dc_debug_mask(saved_mask & ~DC_DISABLE_CUSTOM_BRIGHTNESS_CURVE);
setup_test_link_service(test, link);
- link->dc->link_srv->edp_get_backlight_level = dm_test_get_backlight_level_mid;
+ link->dc->link_srv->edp_get_backlight_level_nits = dm_test_get_backlight_level_nits;
+ link->backlight_control_type = BACKLIGHT_CONTROL_AMD_AUX;
+ link->dpcd_sink_ext_caps.bits.oled = 1;
primary = kunit_kzalloc(test, sizeof(*primary), GFP_KERNEL);
KUNIT_ASSERT_NOT_NULL(test, primary);
adev->ddev.primary = primary;
@@ -568,6 +586,9 @@ static void dm_test_register_backlight_device_custom_curve_readback(struct kunit
aconnector->bl_idx = 0;
aconnector->base.kdev = adev->ddev.dev;
caps = &adev->dm.backlight_caps[0];
+ caps->aux_support = true;
+ caps->aux_min_input_signal = 1;
+ caps->aux_max_input_signal = 512;
caps->min_input_signal = AMDGPU_DM_DEFAULT_MIN_BACKLIGHT;
caps->max_input_signal = AMDGPU_DM_DEFAULT_MAX_BACKLIGHT;
caps->data_points = 1;
@@ -1034,379 +1055,83 @@ static void dm_test_brightness_to_user_midpoint_pwm(struct kunit *test)
KUNIT_EXPECT_EQ(test, result, (u32)expected);
}
-/* Tests for convert_brightness_from_user() — no custom curve */
-
-/**
- * dm_test_brightness_from_user_null_caps - Test Brightness from user null caps
- * @test: The KUnit test context
- */
-static void dm_test_brightness_from_user_null_caps(struct kunit *test)
-{
- KUNIT_EXPECT_EQ(test, convert_brightness_from_user(NULL, 100), 100U);
-}
-
-/**
- * dm_test_brightness_from_user_zero - Test Brightness from user zero
- * @test: The KUnit test context
- */
-static void dm_test_brightness_from_user_zero(struct kunit *test)
-{
- struct amdgpu_dm_backlight_caps caps = {};
- unsigned int min, max;
-
- caps.aux_support = false;
- caps.min_input_signal = AMDGPU_DM_DEFAULT_MIN_BACKLIGHT;
- caps.max_input_signal = AMDGPU_DM_DEFAULT_MAX_BACKLIGHT;
- /* no custom curve */
- caps.data_points = 0;
-
- get_brightness_range(&caps, &min, &max);
-
- /* brightness=0 → min + 0 = min */
- KUNIT_EXPECT_EQ(test, convert_brightness_from_user(&caps, 0), (u32)min);
-}
-
/**
- * dm_test_brightness_from_user_max - Test Brightness from user max
+ * dm_test_brightness_to_millipercent_pwm - Test PWM brightness to millipercent
* @test: The KUnit test context
+ *
+ * The user level maps linearly from 0..max to 0..100%, with no curve and no
+ * clamp at min_input_signal, and a level above max is capped at 100%
*/
-static void dm_test_brightness_from_user_max(struct kunit *test)
+static void dm_test_brightness_to_millipercent_pwm(struct kunit *test)
{
struct amdgpu_dm_backlight_caps caps = {};
- unsigned int min, max;
- caps.aux_support = false;
caps.min_input_signal = AMDGPU_DM_DEFAULT_MIN_BACKLIGHT;
caps.max_input_signal = AMDGPU_DM_DEFAULT_MAX_BACKLIGHT;
- caps.data_points = 0;
-
- get_brightness_range(&caps, &min, &max);
+ caps.data_points = 1;
+ caps.luminance_data[0].input_signal = 128;
+ caps.luminance_data[0].luminance = 10;
- /*
- * brightness=max → min + DIV_ROUND_CLOSEST((max-min)*max, max)
- * = min + (max - min) = max
- */
- KUNIT_EXPECT_EQ(test, convert_brightness_from_user(&caps, max), (u32)max);
+ KUNIT_EXPECT_EQ(test, convert_brightness_to_millipercent(&caps, 0), 0U);
+ KUNIT_EXPECT_EQ(test, convert_brightness_to_millipercent(&caps, 1000), 1526U);
+ KUNIT_EXPECT_EQ(test, convert_brightness_to_millipercent(&caps, 32768), 50001U);
+ KUNIT_EXPECT_EQ(test, convert_brightness_to_millipercent(&caps, 65535), 100000U);
+ KUNIT_EXPECT_EQ(test, convert_brightness_to_millipercent(&caps, 70000), 100000U);
+ KUNIT_EXPECT_EQ(test, convert_brightness_to_millipercent(NULL, 32768), 50001U);
}
/**
- * dm_test_brightness_from_user_aux - Test Brightness from user aux
+ * dm_test_brightness_to_millipercent_aux - Test AUX brightness to millipercent
* @test: The KUnit test context
+ *
+ * Over AUX the user level runs over 0..1000 * aux_max_input_signal and maps
+ * linearly to 0..100%, with no curve even when ATIF gives one
*/
-static void dm_test_brightness_from_user_aux(struct kunit *test)
+static void dm_test_brightness_to_millipercent_aux(struct kunit *test)
{
struct amdgpu_dm_backlight_caps caps = {};
- unsigned int min, max;
caps.aux_support = true;
caps.aux_min_input_signal = 1;
caps.aux_max_input_signal = 512;
- caps.data_points = 0;
-
- get_brightness_range(&caps, &min, &max);
-
- /* brightness=0 → min */
- KUNIT_EXPECT_EQ(test, convert_brightness_from_user(&caps, 0), (u32)min);
- /* brightness=max → max */
- KUNIT_EXPECT_EQ(test, convert_brightness_from_user(&caps, max), (u32)max);
-}
-
-/* Tests for convert_custom_brightness() */
-
-/**
- * dm_test_custom_brightness_no_data_points - Test Custom brightness no data points
- * @test: The KUnit test context
- */
-static void dm_test_custom_brightness_no_data_points(struct kunit *test)
-{
- struct amdgpu_dm_backlight_caps caps = {};
- uint32_t brightness = 128;
- uint32_t saved = brightness;
-
- caps.data_points = 0;
-
- convert_custom_brightness(&caps, 3084, 65535, &brightness);
-
- /* No data points → no-op */
- KUNIT_EXPECT_EQ(test, brightness, saved);
-}
-
-/**
- * dm_test_custom_brightness_debug_mask_disables - Test Custom brightness debug mask disables
- * @test: The KUnit test context
- */
-static void dm_test_custom_brightness_debug_mask_disables(struct kunit *test)
-{
- struct amdgpu_dm_backlight_caps caps = {};
- uint32_t brightness = 128;
- uint32_t saved = brightness;
- uint saved_mask = amdgpu_dm_get_dc_debug_mask();
-
- caps.data_points = 3;
- caps.luminance_data[0].input_signal = 50;
- caps.luminance_data[0].luminance = 10;
-
- /* Set the disable flag */
- amdgpu_dm_set_dc_debug_mask(amdgpu_dm_get_dc_debug_mask() | DC_DISABLE_CUSTOM_BRIGHTNESS_CURVE);
-
- convert_custom_brightness(&caps, 3084, 65535, &brightness);
-
- /* Should be no-op due to debug mask */
- KUNIT_EXPECT_EQ(test, brightness, saved);
-
- amdgpu_dm_set_dc_debug_mask(saved_mask);
-}
-
-/**
- * dm_test_custom_brightness_exact_match - Test Custom brightness exact match
- * @test: The KUnit test context
- */
-static void dm_test_custom_brightness_exact_match(struct kunit *test)
-{
- struct amdgpu_dm_backlight_caps caps = {};
- uint32_t brightness;
- unsigned int min, max;
- uint saved_mask = amdgpu_dm_get_dc_debug_mask();
-
- amdgpu_dm_set_dc_debug_mask(amdgpu_dm_get_dc_debug_mask() & ~DC_DISABLE_CUSTOM_BRIGHTNESS_CURVE);
-
- caps.aux_support = false;
- caps.min_input_signal = 0;
- caps.max_input_signal = AMDGPU_DM_DEFAULT_MAX_BACKLIGHT;
- caps.data_points = 3;
- caps.luminance_data[0].input_signal = 50;
- caps.luminance_data[0].luminance = 20;
- caps.luminance_data[1].input_signal = 128;
- caps.luminance_data[1].luminance = 50;
- caps.luminance_data[2].input_signal = 200;
- caps.luminance_data[2].luminance = 90;
-
- get_brightness_range(&caps, &min, &max);
-
- /*
- * Set brightness so that scale_input_to_fw yields exactly 128.
- * scale_input_to_fw(min, max, x) = DIV_ROUND_CLOSEST(x * 255, max - min)
- * With min=0, max=0x101*255=65535:
- * We need x such that DIV_ROUND_CLOSEST(x * 255, 65535) = 128
- * → x = 128 * 65535 / 255 = 32896
- */
- brightness = 32896;
-
- convert_custom_brightness(&caps, min, max, &brightness);
-
- /*
- * Exact match: lum=50, brightness_scaled=128
- * result = scale_fw_to_input(min, max, DIV_ROUND_CLOSEST(50*128, 101))
- * = scale_fw_to_input(0, 65535, DIV_ROUND_CLOSEST(6400, 101))
- * = scale_fw_to_input(0, 65535, 63)
- * = 0 + DIV_ROUND_CLOSEST(63 * 65535, 255) = 16191 (approx)
- */
- KUNIT_EXPECT_TRUE(test, brightness != 32896);
- KUNIT_EXPECT_TRUE(test, brightness < 32896);
-
- amdgpu_dm_set_dc_debug_mask(saved_mask);
-}
-
-/**
- * dm_test_custom_brightness_below_first - Test Custom brightness below first
- * @test: The KUnit test context
- */
-static void dm_test_custom_brightness_below_first(struct kunit *test)
-{
- struct amdgpu_dm_backlight_caps caps = {};
- uint32_t brightness;
- unsigned int min, max;
- uint saved_mask = amdgpu_dm_get_dc_debug_mask();
-
- amdgpu_dm_set_dc_debug_mask(amdgpu_dm_get_dc_debug_mask() & ~DC_DISABLE_CUSTOM_BRIGHTNESS_CURVE);
-
- caps.aux_support = false;
- caps.min_input_signal = 0;
- caps.max_input_signal = AMDGPU_DM_DEFAULT_MAX_BACKLIGHT;
- caps.data_points = 2;
- caps.luminance_data[0].input_signal = 100;
- caps.luminance_data[0].luminance = 40;
- caps.luminance_data[1].input_signal = 200;
- caps.luminance_data[1].luminance = 80;
-
- get_brightness_range(&caps, &min, &max);
-
- /*
- * Set brightness low enough that scaled value < 100.
- * scale_input_to_fw(0, 65535, x) = DIV_ROUND_CLOSEST(x*255, 65535)
- * For result=50: x = 50*65535/255 = 12850
- */
- brightness = 12850;
-
- convert_custom_brightness(&caps, min, max, &brightness);
-
- /*
- * Below first data point: lum = DIV_ROUND_CLOSEST(40 * 50, 100) = 20
- * Then: scale_fw_to_input(0, 65535, DIV_ROUND_CLOSEST(20 * 50, 101))
- * = scale_fw_to_input(0, 65535, DIV_ROUND_CLOSEST(1000, 101))
- * = scale_fw_to_input(0, 65535, 10)
- * The output should be significantly less than input.
- */
- KUNIT_EXPECT_TRUE(test, brightness < 12850);
-
- amdgpu_dm_set_dc_debug_mask(saved_mask);
-}
-
-/**
- * dm_test_custom_brightness_interpolation - Test Custom brightness interpolation
- * @test: The KUnit test context
- */
-static void dm_test_custom_brightness_interpolation(struct kunit *test)
-{
- struct amdgpu_dm_backlight_caps caps = {};
- uint32_t brightness;
- unsigned int min, max;
- uint saved_mask = amdgpu_dm_get_dc_debug_mask();
-
- amdgpu_dm_set_dc_debug_mask(amdgpu_dm_get_dc_debug_mask() & ~DC_DISABLE_CUSTOM_BRIGHTNESS_CURVE);
-
- caps.aux_support = false;
- caps.min_input_signal = 0;
- caps.max_input_signal = AMDGPU_DM_DEFAULT_MAX_BACKLIGHT;
- caps.data_points = 2;
- caps.luminance_data[0].input_signal = 50;
- caps.luminance_data[0].luminance = 20;
- caps.luminance_data[1].input_signal = 200;
- caps.luminance_data[1].luminance = 80;
-
- get_brightness_range(&caps, &min, &max);
-
- /*
- * Choose a value between data points 50 and 200.
- * scale_input_to_fw(0, 65535, x) = 125 when x = 125*65535/255 = 32125
- */
- brightness = 32125;
-
- convert_custom_brightness(&caps, min, max, &brightness);
-
- /*
- * The function should interpolate between data points and produce
- * a remapped value different from the input.
- */
- KUNIT_EXPECT_TRUE(test, brightness != 32125);
-
- amdgpu_dm_set_dc_debug_mask(saved_mask);
-}
-
-/**
- * dm_test_custom_brightness_above_last - Test Custom brightness above last data point
- * @test: The KUnit test context
- */
-static void dm_test_custom_brightness_above_last(struct kunit *test)
-{
- struct amdgpu_dm_backlight_caps caps = {};
- uint32_t brightness;
- unsigned int min, max;
- uint saved_mask = amdgpu_dm_get_dc_debug_mask();
-
- amdgpu_dm_set_dc_debug_mask(amdgpu_dm_get_dc_debug_mask() & ~DC_DISABLE_CUSTOM_BRIGHTNESS_CURVE);
-
- caps.aux_support = false;
- caps.min_input_signal = 0;
- caps.max_input_signal = AMDGPU_DM_DEFAULT_MAX_BACKLIGHT;
- caps.data_points = 2;
- caps.luminance_data[0].input_signal = 50;
- caps.luminance_data[0].luminance = 20;
- caps.luminance_data[1].input_signal = 150;
- caps.luminance_data[1].luminance = 60;
-
- get_brightness_range(&caps, &min, &max);
-
- /*
- * Choose brightness above the last data point (150).
- * scale_input_to_fw(0, 65535, x) = 220 when x = 220*65535/255 = 56533
- * After binary search, left >= data_points, clamped → right==left,
- * so lum = upper_lum = 60.
- */
- brightness = 56533;
-
- convert_custom_brightness(&caps, min, max, &brightness);
-
- /* Output should differ from input (remapped via curve) */
- KUNIT_EXPECT_TRUE(test, brightness != 56533);
- KUNIT_EXPECT_TRUE(test, brightness < 56533);
-
- amdgpu_dm_set_dc_debug_mask(saved_mask);
-}
-
-/**
- * dm_test_custom_brightness_single_data_point - Test Custom brightness with single data point
- * @test: The KUnit test context
- */
-static void dm_test_custom_brightness_single_data_point(struct kunit *test)
-{
- struct amdgpu_dm_backlight_caps caps = {};
- uint32_t brightness;
- unsigned int min, max;
- uint saved_mask = amdgpu_dm_get_dc_debug_mask();
-
- amdgpu_dm_set_dc_debug_mask(amdgpu_dm_get_dc_debug_mask() & ~DC_DISABLE_CUSTOM_BRIGHTNESS_CURVE);
-
- caps.aux_support = false;
- caps.min_input_signal = 0;
- caps.max_input_signal = AMDGPU_DM_DEFAULT_MAX_BACKLIGHT;
caps.data_points = 1;
caps.luminance_data[0].input_signal = 128;
- caps.luminance_data[0].luminance = 50;
-
- get_brightness_range(&caps, &min, &max);
-
- /*
- * Brightness below the single data point triggers the
- * "below first" path: lum = DIV_ROUND_CLOSEST(50 * scaled, 128).
- * scale_input_to_fw(0, 65535, x) = 64 when x = 64*65535/255 = 16448
- */
- brightness = 16448;
-
- convert_custom_brightness(&caps, min, max, &brightness);
-
- KUNIT_EXPECT_TRUE(test, brightness < 16448);
+ caps.luminance_data[0].luminance = 10;
- amdgpu_dm_set_dc_debug_mask(saved_mask);
+ KUNIT_EXPECT_EQ(test, convert_brightness_to_millipercent(&caps, 0), 0U);
+ KUNIT_EXPECT_EQ(test, convert_brightness_to_millipercent(&caps, 256000), 50000U);
+ KUNIT_EXPECT_EQ(test, convert_brightness_to_millipercent(&caps, 512000), 100000U);
}
/**
- * dm_test_custom_brightness_lower_lum_zero - Test Custom brightness with zero lower luminance
+ * dm_test_millipercent_to_user_pwm - Test PWM millipercent back to brightness
* @test: The KUnit test context
+ *
+ * Every user level must come back unchanged from its millipercent, and a
+ * millipercent above 100% is capped at max
*/
-static void dm_test_custom_brightness_lower_lum_zero(struct kunit *test)
+static void dm_test_millipercent_to_user_pwm(struct kunit *test)
{
struct amdgpu_dm_backlight_caps caps = {};
- uint32_t brightness;
- unsigned int min, max;
- uint saved_mask = amdgpu_dm_get_dc_debug_mask();
-
- amdgpu_dm_set_dc_debug_mask(amdgpu_dm_get_dc_debug_mask() & ~DC_DISABLE_CUSTOM_BRIGHTNESS_CURVE);
+ u32 level;
- caps.aux_support = false;
- caps.min_input_signal = 0;
+ caps.min_input_signal = AMDGPU_DM_DEFAULT_MIN_BACKLIGHT;
caps.max_input_signal = AMDGPU_DM_DEFAULT_MAX_BACKLIGHT;
- caps.data_points = 2;
- caps.luminance_data[0].input_signal = 50;
- caps.luminance_data[0].luminance = 0; /* zero lower luminance */
- caps.luminance_data[1].input_signal = 200;
- caps.luminance_data[1].luminance = 80;
- get_brightness_range(&caps, &min, &max);
+ KUNIT_EXPECT_EQ(test, convert_millipercent_to_user(&caps, 0), 0U);
+ KUNIT_EXPECT_EQ(test, convert_millipercent_to_user(&caps, 50000), 32768U);
+ KUNIT_EXPECT_EQ(test, convert_millipercent_to_user(&caps, 100000), 65535U);
+ KUNIT_EXPECT_EQ(test, convert_millipercent_to_user(&caps, 150000), 65535U);
- /*
- * Choose brightness between data points to trigger interpolation.
- * scale_input_to_fw(0, 65535, x) = 125 when x = 125*65535/255 = 32125
- * With lower_lum == 0, code takes shortcut: lum = upper_lum = 80.
- */
- brightness = 32125;
+ for (level = 0; level <= 65535; level++) {
+ u32 millipercent = convert_brightness_to_millipercent(&caps, level);
- convert_custom_brightness(&caps, min, max, &brightness);
-
- /* Should remap; result should differ from input */
- KUNIT_EXPECT_TRUE(test, brightness != 32125);
-
- amdgpu_dm_set_dc_debug_mask(saved_mask);
+ if (convert_millipercent_to_user(&caps, millipercent) != level) {
+ KUNIT_FAIL(test, "level %u came back as %u", level,
+ convert_millipercent_to_user(&caps, millipercent));
+ break;
+ }
+ }
}
/**
@@ -1430,66 +1155,6 @@ static void dm_test_brightness_to_user_above_max(struct kunit *test)
KUNIT_EXPECT_GT(test, result, max);
}
-/**
- * dm_test_brightness_from_user_midrange - Test Brightness from user mid-range value
- * @test: The KUnit test context
- */
-static void dm_test_brightness_from_user_midrange(struct kunit *test)
-{
- struct amdgpu_dm_backlight_caps caps = {};
- unsigned int min, max;
- u32 result;
-
- caps.aux_support = false;
- caps.min_input_signal = AMDGPU_DM_DEFAULT_MIN_BACKLIGHT;
- caps.max_input_signal = AMDGPU_DM_DEFAULT_MAX_BACKLIGHT;
- caps.data_points = 0;
-
- get_brightness_range(&caps, &min, &max);
-
- /* Mid-range brightness should map to between min and max */
- result = convert_brightness_from_user(&caps, max / 2);
-
- KUNIT_EXPECT_GE(test, result, min);
- KUNIT_EXPECT_LE(test, result, max);
-}
-
-/**
- * dm_test_brightness_from_user_with_curve - Test Brightness from user with custom curve active
- * @test: The KUnit test context
- */
-static void dm_test_brightness_from_user_with_curve(struct kunit *test)
-{
- struct amdgpu_dm_backlight_caps caps = {};
- unsigned int min, max;
- u32 with_curve, without_curve;
- uint saved_mask = amdgpu_dm_get_dc_debug_mask();
-
- amdgpu_dm_set_dc_debug_mask(amdgpu_dm_get_dc_debug_mask() & ~DC_DISABLE_CUSTOM_BRIGHTNESS_CURVE);
-
- caps.aux_support = false;
- caps.min_input_signal = 0;
- caps.max_input_signal = AMDGPU_DM_DEFAULT_MAX_BACKLIGHT;
- caps.data_points = 2;
- caps.luminance_data[0].input_signal = 50;
- caps.luminance_data[0].luminance = 20;
- caps.luminance_data[1].input_signal = 200;
- caps.luminance_data[1].luminance = 80;
-
- get_brightness_range(&caps, &min, &max);
-
- with_curve = convert_brightness_from_user(&caps, max / 2);
-
- /* Now disable the curve and compare */
- amdgpu_dm_set_dc_debug_mask(amdgpu_dm_get_dc_debug_mask() | DC_DISABLE_CUSTOM_BRIGHTNESS_CURVE);
- without_curve = convert_brightness_from_user(&caps, max / 2);
-
- /* Custom curve should produce a different mapping */
- KUNIT_EXPECT_NE(test, with_curve, without_curve);
-
- amdgpu_dm_set_dc_debug_mask(saved_mask);
-}
-
/**
* dm_test_brightness_range_zero_signals - Test Brightness range with zero min and max signals
* @test: The KUnit test context
@@ -2002,9 +1667,10 @@ static struct kunit_case dm_backlight_test_cases[] = {
KUNIT_CASE(dm_test_backlight_set_level_reallows_idle),
KUNIT_CASE(dm_test_backlight_update_status_no_stream),
/* amdgpu_dm_backlight_get_level / get_brightness */
- KUNIT_CASE(dm_test_backlight_get_level_pwm_success),
+ KUNIT_CASE(dm_test_backlight_get_level_pwm_no_power_module),
KUNIT_CASE(dm_test_backlight_get_level_pwm_error),
KUNIT_CASE(dm_test_backlight_get_level_aux_success),
+ KUNIT_CASE(dm_test_backlight_get_level_amd_aux_lcd_reads_pwm),
KUNIT_CASE(dm_test_backlight_get_level_aux_error),
KUNIT_CASE(dm_test_backlight_get_brightness_uses_device_index),
/* amdgpu_dm_register_backlight_device */
@@ -2036,23 +1702,11 @@ static struct kunit_case dm_backlight_test_cases[] = {
KUNIT_CASE(dm_test_brightness_to_user_at_max),
KUNIT_CASE(dm_test_brightness_to_user_at_min),
KUNIT_CASE(dm_test_brightness_to_user_midpoint_pwm),
- /* convert_brightness_from_user */
- KUNIT_CASE(dm_test_brightness_from_user_null_caps),
- KUNIT_CASE(dm_test_brightness_from_user_zero),
- KUNIT_CASE(dm_test_brightness_from_user_max),
- KUNIT_CASE(dm_test_brightness_from_user_aux),
- /* convert_custom_brightness */
- KUNIT_CASE(dm_test_custom_brightness_no_data_points),
- KUNIT_CASE(dm_test_custom_brightness_debug_mask_disables),
- KUNIT_CASE(dm_test_custom_brightness_exact_match),
- KUNIT_CASE(dm_test_custom_brightness_below_first),
- KUNIT_CASE(dm_test_custom_brightness_interpolation),
- KUNIT_CASE(dm_test_custom_brightness_above_last),
- KUNIT_CASE(dm_test_custom_brightness_single_data_point),
- KUNIT_CASE(dm_test_custom_brightness_lower_lum_zero),
+ /* convert_brightness_to_millipercent / convert_millipercent_to_user */
+ KUNIT_CASE(dm_test_brightness_to_millipercent_pwm),
+ KUNIT_CASE(dm_test_brightness_to_millipercent_aux),
+ KUNIT_CASE(dm_test_millipercent_to_user_pwm),
KUNIT_CASE(dm_test_brightness_to_user_above_max),
- KUNIT_CASE(dm_test_brightness_from_user_midrange),
- KUNIT_CASE(dm_test_brightness_from_user_with_curve),
KUNIT_CASE(dm_test_brightness_range_zero_signals),
/* amdgpu_dm_backlight_fill_props */
KUNIT_CASE(dm_test_backlight_fill_props_ac_linear),
--
2.43.0
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [PATCH 11/33] drm/amd/display: Add DPMS-v2 types
2026-11-16 21:50 [PATCH 00/33] DC Patches November 23, 2026 James Lin
` (9 preceding siblings ...)
2026-11-16 21:50 ` [PATCH 10/33] drm/amd/display: Pass linear brightness percent to power module James Lin
@ 2026-11-16 21:50 ` James Lin
2026-11-16 21:50 ` [PATCH 12/33] drm/amd/display: Always apply 0ppm pixel clock adjustment James Lin
` (21 subsequent siblings)
32 siblings, 0 replies; 34+ messages in thread
From: James Lin @ 2026-11-16 21:50 UTC (permalink / raw)
To: amd-gfx
Cc: Harry Wentland, Leo Li, Aurabindo Pillai, Roman Li, Wayne Lin,
Tom Chung, Fangzhi Zuo, Dan Wheeler, Ray Wu, Ivan Lipski,
Alex Hung, James Lin, Chenyu Chen, Dominik Kowalski, James Lin
From: Dominik Kowalski <dominik.kowalski@amd.com>
[Why]
DPMS-v2 replaces pipe_ctx with link_dpms_ctx, aiming to narrow its
reach and responsibilities, enabling more precise and safe design.
[How]
* Add link_tx in dedicated file as new vtable for DPMS-v2 to call
* Add link_dpms_ctx in core_types
* Place link_dpms_ctx in dc_link
* No initialization or other use logic yet, TBD
Signed-off-by: Dominik Kowalski <dominik.kowalski@amd.com>
Signed-off-by: James Lin <pinglei.lin@amd.com>
---
drivers/gpu/drm/amd/display/dc/dc.h | 2 +
.../gpu/drm/amd/display/dc/inc/core_types.h | 58 ++++++++++++++++++
drivers/gpu/drm/amd/display/dc/inc/link_tx.h | 59 +++++++++++++++++++
3 files changed, 119 insertions(+)
create mode 100644 drivers/gpu/drm/amd/display/dc/inc/link_tx.h
diff --git a/drivers/gpu/drm/amd/display/dc/dc.h b/drivers/gpu/drm/amd/display/dc/dc.h
index 01f549010d07..c9bdfba11a01 100644
--- a/drivers/gpu/drm/amd/display/dc/dc.h
+++ b/drivers/gpu/drm/amd/display/dc/dc.h
@@ -556,6 +556,7 @@ struct dc_update_descriptor {
struct dc;
struct dc_plane_state;
struct dc_state;
+struct link_dpms_ctx;
struct dc_cap_funcs {
bool (*get_dcc_compression_cap)(const struct dc *dc,
@@ -1931,6 +1932,7 @@ struct dc_scratch_space {
void *priv;
struct ddc_service *ddc;
+ struct link_dpms_ctx *dpms_ctx;
enum dp_panel_mode panel_mode;
bool panel_mode_initialized;
diff --git a/drivers/gpu/drm/amd/display/dc/inc/core_types.h b/drivers/gpu/drm/amd/display/dc/inc/core_types.h
index 695eaa5cbf65..1d6bb41312b7 100644
--- a/drivers/gpu/drm/amd/display/dc/inc/core_types.h
+++ b/drivers/gpu/drm/amd/display/dc/inc/core_types.h
@@ -31,6 +31,7 @@
#include "dcn_calcs.h"
#include "ddc_service_types.h"
#include "dc_bios_types.h"
+#include "dsc/dsc.h"
#include "mem_input.h"
#include "hubp.h"
#include "hw/dchubbub.h"
@@ -807,4 +808,61 @@ struct dc_update_scratch_space {
int intermediate_count;
};
+/**
+ * Snapshot of fields from dc_stream_state relevant to link_set_dpms_on_v2().
+ *
+ * Removes dependency on mutable stream object, which would otherwise create
+ * synchronization hazards.
+ */
+struct link_dpms_stream_descriptor {
+ // TODO: Implement
+ int dummy;
+};
+
+/**
+ * DPMS operation context variables.
+ *
+ * This struct is owned by dc_link, sharing its lifetime.
+ * The caller populates the context with update details and validates it.
+ * No other code aside from DPMS sequence itself is allowed to modify it during
+ * execution, while DPMS serialization prevents concurrent reuse.
+ *
+ * This struct is used by top-level link_set_dpms_on/off_v2() and the sequence
+ * steps link_dpms_step_xxx(). The step functions unpack relevant values
+ * and pass them directly as arguments into TX and HWSS. This is done to make
+ * TX and HWSS independent from DPMS, while preventing them from backtracking
+ * to shared state like DC and its state structs.
+ */
+struct link_dpms_ctx {
+ /**
+ * Mutable link state.
+ *
+ * Steps use it to record protocol results and evaluate preconditions.
+ * Should not be used to access dc_state, dc_stream_state, pipe_ctx.
+ */
+ struct dc_link *link;
+
+ /**
+ * Snapshot of relevant fields from dc_stream_state.
+ *
+ * Removes dependency on mutable stream object.
+ */
+ struct link_dpms_stream_descriptor stream_descriptor;
+
+ /**
+ * Stable validated link configuration.
+ *
+ * If unable to reach desired state, DPMS reports failure instead
+ * of rewriting alternative configuration.
+ */
+ struct link_config link_config;
+
+ /**
+ * Source-side link HW transmitter.
+ *
+ * This is sole interface used to program all protocol operations.
+ */
+ const struct link_tx *tx;
+};
+
#endif /* _CORE_TYPES_H_ */
diff --git a/drivers/gpu/drm/amd/display/dc/inc/link_tx.h b/drivers/gpu/drm/amd/display/dc/inc/link_tx.h
new file mode 100644
index 000000000000..3b671eea15ef
--- /dev/null
+++ b/drivers/gpu/drm/amd/display/dc/inc/link_tx.h
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2026 Advanced Micro Devices, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Authors: AMD
+ *
+ */
+#ifndef LINK_TX_H
+#define LINK_TX_H
+
+#include "dc/inc/core_types.h"
+#include "dc/inc/core_status.h"
+
+struct dc_link;
+struct link_resource;
+struct link_tx;
+struct link_tx_funcs;
+
+/**
+ * Private DPMS v2 context, opaque type forward-declared only.
+ */
+struct link_tx_v2_ctx;
+
+struct link_tx {
+ const struct link_tx_funcs *funcs;
+ struct dc_link *link;
+ struct link_tx_v2_ctx *ctx;
+};
+
+/**
+ * Virtual table of function pointers for link protocol programming.
+ *
+ * Analogous to HWSS, but takes link_tx instead of pipe_ctx, as the latter
+ * was deemed too broad and open, resulting in synchronization hazards.
+ */
+struct link_tx_funcs {
+ // TODO: Implement
+ void (*destroy)(struct link_tx *tx);
+};
+
+#endif
+
--
2.43.0
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [PATCH 12/33] drm/amd/display: Always apply 0ppm pixel clock adjustment
2026-11-16 21:50 [PATCH 00/33] DC Patches November 23, 2026 James Lin
` (10 preceding siblings ...)
2026-11-16 21:50 ` [PATCH 11/33] drm/amd/display: Add DPMS-v2 types James Lin
@ 2026-11-16 21:50 ` James Lin
2026-11-16 21:50 ` [PATCH 13/33] drm/amd/display: Add otg versions of get_vblank_counter/scanoutpos James Lin
` (20 subsequent siblings)
32 siblings, 0 replies; 34+ messages in thread
From: James Lin @ 2026-11-16 21:50 UTC (permalink / raw)
To: amd-gfx
Cc: Harry Wentland, Leo Li, Aurabindo Pillai, Roman Li, Wayne Lin,
Tom Chung, Fangzhi Zuo, Dan Wheeler, Ray Wu, Ivan Lipski,
Alex Hung, James Lin, Chenyu Chen, Allen Pan, Charlene Liu,
James Lin
From: Allen Pan <Allen.Pan@amd.com>
[Why]
program_pix_clk() pairs with dcn3_get_pix_clk_dividers(), which did not
apply the video optimized pixel rate table. pll_settings and
requested_pix_clk_100hz then kept the rounded pixel clock, so audio was
set up for a different clock than the one the hardware runs.
[How]
program_pix_clk() pairs with dcn3_get_pix_clk_dividers(), which did not
apply the video optimized pixel rate table. pll_settings and
requested_pix_clk_100hz then kept the rounded pixel clock, so audio was
set up for a different clock than the one the hardware runs.
Cc: Charlene Liu <charlene.liu@amd.com>
Signed-off-by: Allen Pan <Allen.Pan@amd.com>
Signed-off-by: James Lin <pinglei.lin@amd.com>
---
.../drm/amd/display/dc/dce/dce_clock_source.c | 25 +++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.c b/drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.c
index 145c993342bd..298e28befdd6 100644
--- a/drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.c
+++ b/drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.c
@@ -1444,6 +1444,7 @@ static uint32_t dcn3_get_pix_clk_dividers(
struct pll_settings *pll_settings)
{
unsigned long long actual_pix_clk_100Hz = pix_clk_params ? pix_clk_params->requested_pix_clk_100hz : 0;
+ const struct pixel_rate_range_table_entry *e;
struct dce110_clk_src *clk_src = TO_DCE110_CLK_SRC(cs);
if (pix_clk_params == NULL || pll_settings == NULL
@@ -1454,6 +1455,30 @@ static uint32_t dcn3_get_pix_clk_dividers(
}
memset(pll_settings, 0, sizeof(*pll_settings));
+ e = look_up_in_video_optimized_rate_tlb(pix_clk_params->requested_pix_clk_100hz / 10);
+
+ if (e) {
+ switch (e->target_pixel_rate_khz) {
+ //Do not modify (no need) for *1.001 rates
+ case 27000:
+ case 54000:
+ case 108000:
+ break;
+
+ default:
+ //Should override pll_settings->actual_pix_clk_100hz here when entry found in table to
+ //increase Pixel clock precision for one digit (in KHz units -> 100Hz unit that VBIOS
+ //accepts) for refresh rates like 59.94 / 29.97 Hz etc.
+ actual_pix_clk_100Hz = e->target_pixel_rate_khz;
+ actual_pix_clk_100Hz *= 10;
+ actual_pix_clk_100Hz *= e->mult_factor;
+ actual_pix_clk_100Hz = div_u64(actual_pix_clk_100Hz, e->div_factor);
+ pll_settings->actual_pix_clk_100hz = (unsigned int) actual_pix_clk_100Hz;
+ //Loop back so Audio will get same precisison for Audio DTO for Audio Wall clock
+ pix_clk_params->requested_pix_clk_100hz = (unsigned int) actual_pix_clk_100Hz;
+ break;
+ }
+ }
/* Adjust for HDMI Type A deep color */
if (pix_clk_params->signal_type == SIGNAL_TYPE_HDMI_TYPE_A) {
switch (pix_clk_params->color_depth) {
--
2.43.0
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [PATCH 13/33] drm/amd/display: Add otg versions of get_vblank_counter/scanoutpos
2026-11-16 21:50 [PATCH 00/33] DC Patches November 23, 2026 James Lin
` (11 preceding siblings ...)
2026-11-16 21:50 ` [PATCH 12/33] drm/amd/display: Always apply 0ppm pixel clock adjustment James Lin
@ 2026-11-16 21:50 ` James Lin
2026-11-16 21:50 ` [PATCH 14/33] drm/amd/display: Queue vblank control work to sleepable context James Lin
` (19 subsequent siblings)
32 siblings, 0 replies; 34+ messages in thread
From: James Lin @ 2026-11-16 21:50 UTC (permalink / raw)
To: amd-gfx
Cc: Harry Wentland, Leo Li, Aurabindo Pillai, Roman Li, Wayne Lin,
Tom Chung, Fangzhi Zuo, Dan Wheeler, Ray Wu, Ivan Lipski,
Alex Hung, James Lin, Chenyu Chen, George Zhang, James Lin
From: George Zhang <george.zhang@amd.com>
[why & how]
Add functions to access the vblank_counter and scanoutpos of OTGs by
instance number.
Cc: Sun peng Li <sunpeng.li@amd.com>
Signed-off-by: George Zhang <george.zhang@amd.com>
Signed-off-by: James Lin <pinglei.lin@amd.com>
---
.../gpu/drm/amd/display/dc/core/dc_stream.c | 38 +++++++++++++++++++
drivers/gpu/drm/amd/display/dc/dc_stream.h | 6 +++
2 files changed, 44 insertions(+)
diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_stream.c b/drivers/gpu/drm/amd/display/dc/core/dc_stream.c
index 56c7d97733a6..01b5ddd87289 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_stream.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_stream.c
@@ -862,6 +862,20 @@ uint32_t dc_stream_get_vblank_counter(const struct dc_stream_state *stream)
return 0;
}
+uint32_t dc_otg_get_vblank_counter(struct dc *dc, int otg_inst)
+{
+ struct resource_context *res_ctx = &dc->current_state->res_ctx;
+
+ dc_exit_ips_for_hw_access(dc);
+
+ struct timing_generator *tg = res_ctx->pipe_ctx[otg_inst].stream_res.tg;
+
+ if (!tg)
+ return 0;
+
+ return tg->funcs->get_frame_count(tg);
+}
+
bool dc_stream_send_dp_sdp(const struct dc_stream_state *stream,
const uint8_t *custom_sdp_message,
unsigned int sdp_message_size)
@@ -937,6 +951,30 @@ bool dc_stream_get_scanoutpos(const struct dc_stream_state *stream,
return ret;
}
+bool dc_otg_get_scanoutpos(struct dc *dc, int otg_inst,
+ uint32_t *v_blank_start,
+ uint32_t *v_blank_end,
+ uint32_t *h_position,
+ uint32_t *v_position)
+{
+ struct resource_context *res_ctx = &dc->current_state->res_ctx;
+
+ dc_exit_ips_for_hw_access(dc);
+
+ struct timing_generator *tg = res_ctx->pipe_ctx[otg_inst].stream_res.tg;
+
+ if (!tg)
+ return false;
+
+ tg->funcs->get_scanoutpos(tg,
+ v_blank_start,
+ v_blank_end,
+ h_position,
+ v_position);
+
+ return true;
+}
+
bool dc_stream_dmdata_status_done(struct dc *dc, struct dc_stream_state *stream)
{
struct pipe_ctx *pipe = NULL;
diff --git a/drivers/gpu/drm/amd/display/dc/dc_stream.h b/drivers/gpu/drm/amd/display/dc/dc_stream.h
index 94eccb87cbde..e507d334d598 100644
--- a/drivers/gpu/drm/amd/display/dc/dc_stream.h
+++ b/drivers/gpu/drm/amd/display/dc/dc_stream.h
@@ -452,6 +452,7 @@ struct dc_stream_state *dc_get_stream_at_index(struct dc *dc, uint8_t i);
* Return the current frame counter.
*/
uint32_t dc_stream_get_vblank_counter(const struct dc_stream_state *stream);
+uint32_t dc_otg_get_vblank_counter(struct dc *dc, int otg_inst);
/*
* Send dp sdp message.
@@ -469,6 +470,11 @@ bool dc_stream_get_scanoutpos(const struct dc_stream_state *stream,
uint32_t *v_blank_end,
uint32_t *h_position,
uint32_t *v_position);
+bool dc_otg_get_scanoutpos(struct dc *dc, int otg_inst,
+ uint32_t *v_blank_start,
+ uint32_t *v_blank_end,
+ uint32_t *h_position,
+ uint32_t *v_position);
bool dc_stream_add_writeback(struct dc *dc,
struct dc_stream_state *stream,
--
2.43.0
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [PATCH 14/33] drm/amd/display: Queue vblank control work to sleepable context
2026-11-16 21:50 [PATCH 00/33] DC Patches November 23, 2026 James Lin
` (12 preceding siblings ...)
2026-11-16 21:50 ` [PATCH 13/33] drm/amd/display: Add otg versions of get_vblank_counter/scanoutpos James Lin
@ 2026-11-16 21:50 ` James Lin
2026-11-16 21:50 ` [PATCH 15/33] drm/amd/display: Fix KUnit tests for vblank control rework James Lin
` (18 subsequent siblings)
32 siblings, 0 replies; 34+ messages in thread
From: James Lin @ 2026-11-16 21:50 UTC (permalink / raw)
To: amd-gfx
Cc: Harry Wentland, Leo Li, Aurabindo Pillai, Roman Li, Wayne Lin,
Tom Chung, Fangzhi Zuo, Dan Wheeler, Ray Wu, Ivan Lipski,
Alex Hung, James Lin, Chenyu Chen, George Zhang, James Lin
From: George Zhang <george.zhang@amd.com>
[why & how]
Currently, vblank control exits idle to program HW, but it does not (and
cannot) hold dc_lock to prevent another thread from entering device-wide
idle.
Add a flag to check if we are able to use the HW vblank counter or not.
If not, assume that we are in idle, and queue a worker to enable/disable
vblank in a sleepable context. Update the value of the flag accordingly
in the ISM.
In the gap between returning from vblank_control and the worker enabling
HW, use the flag to determine if we should output a virtual vblank
counter or not.
Finally, lock DM internal callers of dm_vblank_get_counter.
Cc: Sun peng Li <sunpeng.li@amd.com>
Signed-off-by: George Zhang <george.zhang@amd.com>
Signed-off-by: James Lin <pinglei.lin@amd.com>
---
.../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 93 +++++++-
.../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h | 49 ++++
.../amd/display/amdgpu_dm/amdgpu_dm_crtc.c | 225 ++++++++++++------
.../display/amdgpu_dm/amdgpu_dm_irq_params.h | 2 +
.../drm/amd/display/amdgpu_dm/amdgpu_dm_ism.c | 20 +-
5 files changed, 302 insertions(+), 87 deletions(-)
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index 2f4c6a2dd4ec..29d7c87a94ef 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -172,6 +172,7 @@ static inline void amdgpu_dm_exit_ips_for_hw_access(struct dc *dc)
STATIC_IFN_KUNIT u32 dm_vblank_get_counter(struct amdgpu_device *adev, int crtc)
{
struct amdgpu_crtc *acrtc = NULL;
+ struct amdgpu_display_manager *dm = &adev->dm;
if (crtc >= adev->mode_info.num_crtc)
return 0;
@@ -184,7 +185,19 @@ STATIC_IFN_KUNIT u32 dm_vblank_get_counter(struct amdgpu_device *adev, int crtc)
return 0;
}
- return dc_stream_get_vblank_counter(acrtc->dm_irq_params.stream);
+ guard(spinlock_irqsave)(&adev->dm.sw_counter_lock);
+
+ if (acrtc->otg_inst < 0) {
+ drm_err(adev_to_drm(adev), "dm_vblank_get_counter: no otg_inst for crtc '%d'!\n",
+ crtc);
+ return 0;
+ }
+
+ if (dm->use_sw_vblank_counter)
+ return dm->otg_sw_counter[acrtc->otg_inst].frozen;
+
+ return (dc_stream_get_vblank_counter(acrtc->dm_irq_params.stream) +
+ dm->otg_sw_counter[acrtc->otg_inst].offset) & 0xffffff;
}
EXPORT_IF_KUNIT(dm_vblank_get_counter);
@@ -192,8 +205,8 @@ STATIC_IFN_KUNIT int dm_crtc_get_scanoutpos(struct amdgpu_device *adev, int crtc
u32 *vbl, u32 *position)
{
u32 v_blank_start = 0, v_blank_end = 0, h_position = 0, v_position = 0;
+ struct amdgpu_display_manager *dm = &adev->dm;
struct amdgpu_crtc *acrtc = NULL;
- struct dc *dc = adev->dm.dc;
if ((crtc < 0) || (crtc >= adev->mode_info.num_crtc))
return -EINVAL;
@@ -206,8 +219,20 @@ STATIC_IFN_KUNIT int dm_crtc_get_scanoutpos(struct amdgpu_device *adev, int crtc
return 0;
}
- if (dc && dc->caps.ips_support && dc->idle_optimizations_allowed)
- dc_allow_idle_optimizations(dc, false);
+ guard(spinlock_irqsave)(&adev->dm.sw_counter_lock);
+
+ if (acrtc->otg_inst < 0) {
+ drm_err(adev_to_drm(adev), "dm_crtc_get_scanoutpos: no otg_inst for crtc '%d'!\n",
+ crtc);
+ return 0;
+ }
+
+ if (dm->use_sw_vblank_counter) {
+ *vbl = dm->otg_sw_counter[acrtc->otg_inst].vblank_start |
+ (dm->otg_sw_counter[acrtc->otg_inst].vblank_end << 16);
+ *position = dm->otg_sw_counter[acrtc->otg_inst].vblank_end;
+ return 0;
+ }
/*
* TODO rework base driver to use values directly.
@@ -226,6 +251,61 @@ STATIC_IFN_KUNIT int dm_crtc_get_scanoutpos(struct amdgpu_device *adev, int crtc
}
EXPORT_IF_KUNIT(dm_crtc_get_scanoutpos);
+/* active_vblank_irq_count must be 0 before calling this function */
+void amdgpu_dm_sw_counter_freeze(struct amdgpu_display_manager *dm)
+{
+ struct dc *dc = dm->dc;
+
+ lockdep_assert_held(&dm->dc_lock);
+
+ if (!dc->caps.ips_support || dc->config.disable_ips == DMUB_IPS_DISABLE_ALL)
+ return;
+
+ guard(spinlock_irqsave)(&dm->sw_counter_lock);
+
+ if (dm->use_sw_vblank_counter)
+ return;
+
+ for (int i = 0; i < MAX_PIPES; i++) {
+ u32 hw, h_position, v_position;
+
+ hw = dc_otg_get_vblank_counter(dc, i);
+ dm->otg_sw_counter[i].frozen = (hw + dm->otg_sw_counter[i].offset + 1) & 0xffffff;
+ dc_otg_get_scanoutpos(dc, i,
+ &dm->otg_sw_counter[i].vblank_start,
+ &dm->otg_sw_counter[i].vblank_end,
+ &h_position, &v_position);
+ }
+
+ dm->use_sw_vblank_counter = true;
+
+}
+
+/* should only be called after IPS exit */
+void amdgpu_dm_sw_counter_resume(struct amdgpu_display_manager *dm)
+{
+ struct dc *dc = dm->dc;
+
+ lockdep_assert_held(&dm->dc_lock);
+
+ if (!dc->caps.ips_support || dc->config.disable_ips == DMUB_IPS_DISABLE_ALL)
+ return;
+
+ guard(spinlock_irqsave)(&dm->sw_counter_lock);
+
+ if (!dm->use_sw_vblank_counter)
+ return;
+
+ for (int i = 0; i < MAX_PIPES; i++) {
+ u32 hw;
+
+ hw = dc_otg_get_vblank_counter(dc, i);
+ dm->otg_sw_counter[i].offset = (dm->otg_sw_counter[i].frozen - hw) & 0xffffff;
+ }
+
+ dm->use_sw_vblank_counter = false;
+}
+
STATIC_IFN_KUNIT int dm_wait_for_idle(struct amdgpu_ip_block *ip_block)
{
/* XXX todo */
@@ -516,6 +596,7 @@ static int amdgpu_dm_init(struct amdgpu_device *adev)
mutex_init(&adev->dm.audio_lock);
spin_lock_init(&adev->dm.dmub_lock);
+ spin_lock_init(&adev->dm.sw_counter_lock);
if (amdgpu_dm_irq_init(adev)) {
drm_err(adev_to_drm(adev), "failed to initialize DM IRQ support.\n");
@@ -768,8 +849,10 @@ static int amdgpu_dm_init(struct amdgpu_device *adev)
if (adev->dm.dc->caps.max_links > 0) {
adev->dm.vblank_control_workqueue =
create_singlethread_workqueue("dm_vblank_control_workqueue");
- if (!adev->dm.vblank_control_workqueue)
+ if (!adev->dm.vblank_control_workqueue) {
drm_err(adev_to_drm(adev), "failed to initialize vblank_workqueue.\n");
+ goto error;
+ }
}
if (adev->dm.dc->caps.ips_support &&
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h
index 761d2b40aece..63c1c2ea80aa 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h
@@ -319,6 +319,28 @@ struct hpd_rx_irq_offload_work {
struct amdgpu_device *adev;
};
+/**
+ * struct dm_otg_sw_counter - Per-OTG sw vblank counter state
+ * @frozen: Frozen vblank counter snapshot, valid while
+ * dm->use_sw_vblank_counter is set.
+ * @offset: Offset applied to the live hw vblank counter to keep it
+ * continuous across a freeze/resume cycle.
+ * @vblank_start: Frozen scanout vblank start position, valid while
+ * dm->use_sw_vblank_counter is set.
+ * @vblank_end: Frozen scanout vblank end position, valid while
+ * dm->use_sw_vblank_counter is set.
+ *
+ * Indexed by otg_inst rather than by CRTC, so a value survives a CRTC's
+ * stream being reassigned to a different OTG. Guarded by
+ * dm->sw_counter_lock.
+ */
+struct dm_otg_sw_counter {
+ u32 frozen;
+ u32 offset;
+ u32 vblank_start;
+ u32 vblank_end;
+};
+
/**
* struct amdgpu_display_manager - Central amdgpu display manager device
*
@@ -467,6 +489,30 @@ struct amdgpu_display_manager {
*/
struct mutex dc_lock;
+ /**
+ * @sw_counter_lock
+ *
+ * Guards sw_vblank counter.
+ */
+ spinlock_t sw_counter_lock;
+
+ /**
+ * @use_sw_vblank_counter
+ *
+ * use sw vblank counter instead of hw vblank counter. Can only be set
+ * under dc_lock and sw_counter_lock.
+ * Set implies active_vblank_irq_count == 0.
+ */
+ bool use_sw_vblank_counter;
+
+ /**
+ * @otg_sw_counter:
+ *
+ * Per-OTG sw vblank counter state, indexed by otg_inst. Guarded by
+ * sw_counter_lock. See &struct dm_otg_sw_counter.
+ */
+ struct dm_otg_sw_counter otg_sw_counter[AMDGPU_MAX_CRTCS];
+
/**
* @dmub_lock:
*
@@ -1171,6 +1217,9 @@ bool amdgpu_dm_execute_fused_io(
int amdgpu_dm_process_dmub_set_config_sync(struct dc_context *ctx, unsigned int link_index,
struct set_config_cmd_payload *payload, enum set_config_status *operation_result);
+void amdgpu_dm_sw_counter_freeze(struct amdgpu_display_manager *dm);
+void amdgpu_dm_sw_counter_resume(struct amdgpu_display_manager *dm);
+
int dm_atomic_get_state(struct drm_atomic_commit *state,
struct dm_atomic_state **dm_state);
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_crtc.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_crtc.c
index 8d31c673817c..8d25b034111f 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_crtc.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_crtc.c
@@ -223,33 +223,6 @@ struct idle_workqueue *idle_create_workqueue(struct amdgpu_device *adev)
}
EXPORT_IF_KUNIT(idle_create_workqueue);
-STATIC_IFN_KUNIT void amdgpu_dm_crtc_vblank_control_worker(struct work_struct *work)
-{
- struct vblank_control_work *vblank_work =
- container_of(work, struct vblank_control_work, work);
- struct amdgpu_display_manager *dm = vblank_work->dm;
-
- mutex_lock(&dm->dc_lock);
-
- if (vblank_work->enable) {
- dm->active_vblank_irq_count++;
- amdgpu_dm_ism_commit_event(&vblank_work->acrtc->ism,
- DM_ISM_EVENT_EXIT_IDLE_REQUESTED);
- } else {
- if (dm->active_vblank_irq_count > 0)
- dm->active_vblank_irq_count--;
- amdgpu_dm_ism_commit_event(&vblank_work->acrtc->ism,
- DM_ISM_EVENT_ENTER_IDLE_REQUESTED);
- }
-
- mutex_unlock(&dm->dc_lock);
-
- dc_stream_release(vblank_work->stream);
-
- kfree(vblank_work);
-}
-EXPORT_IF_KUNIT(amdgpu_dm_crtc_vblank_control_worker);
-
#if defined(CONFIG_DRM_AMD_SECURE_DISPLAY) || IS_ENABLED(CONFIG_DRM_AMD_DC_KUNIT_TEST)
STATIC_IFN_KUNIT int amdgpu_dm_crtc_set_vline0_irq(struct drm_crtc *crtc, int irq_type,
bool enable)
@@ -274,45 +247,20 @@ STATIC_IFN_KUNIT int amdgpu_dm_crtc_set_vline0_irq(struct drm_crtc *crtc, int ir
EXPORT_IF_KUNIT(amdgpu_dm_crtc_set_vline0_irq);
#endif
-static inline int amdgpu_dm_crtc_set_vblank(struct drm_crtc *crtc, bool enable)
+static int amdgpu_dm_program_vblank_irq(struct amdgpu_crtc *acrtc, bool enable)
{
- struct amdgpu_crtc *acrtc = to_amdgpu_crtc(crtc);
+ struct drm_crtc *crtc = &acrtc->base;
struct amdgpu_device *adev = drm_to_adev(crtc->dev);
- struct dm_crtc_state *acrtc_state = to_dm_crtc_state(crtc->state);
struct amdgpu_display_manager *dm = &adev->dm;
- struct vblank_control_work *work;
- int irq_type;
+ struct dm_crtc_state *acrtc_state = to_dm_crtc_state(crtc->state);
int rc = 0;
+ int irq_type = amdgpu_display_crtc_idx_to_irq_type(adev, acrtc->crtc_id);
- if (enable && !acrtc->base.enabled) {
- drm_dbg_vbl(crtc->dev,
- "Reject vblank enable on unconfigured CRTC %d (enabled=%d)\n",
- acrtc->crtc_id, acrtc->base.enabled);
- return -EINVAL;
- }
-
- irq_type = amdgpu_display_crtc_idx_to_irq_type(adev, acrtc->crtc_id);
-
- if (enable && acrtc_state->stream) {
- struct dc *dc = adev->dm.dc;
- struct drm_vblank_crtc *vblank = drm_crtc_vblank_crtc(crtc);
- struct psr_settings *psr = &acrtc_state->stream->link->psr_settings;
- struct replay_settings *pr = &acrtc_state->stream->link->replay_settings;
- bool sr_supported = (psr->psr_version != DC_PSR_VERSION_UNSUPPORTED) ||
- pr->config.replay_supported;
-
- /*
- * IPS & self-refresh feature can cause vblank counter resets between
- * vblank disable and enable.
- * It may cause system stuck due to waiting for the vblank counter.
- * Call this function to estimate missed vblanks by using timestamps and
- * update the vblank counter in DRM.
- */
- if (dc->caps.ips_support &&
- dc->config.disable_ips != DMUB_IPS_DISABLE_ALL &&
- sr_supported && vblank->config.disable_immediate)
- drm_crtc_vblank_restore(crtc);
- }
+#if defined(CONFIG_DRM_AMD_SECURE_DISPLAY)
+ rc = amdgpu_dm_crtc_set_vline0_irq(crtc, irq_type, enable);
+ if (rc)
+ return rc;
+#endif
/*
* On DCN, VUPDATE_NO_LOCK is the single OTG interrupt used to deliver
@@ -382,33 +330,154 @@ static inline int amdgpu_dm_crtc_set_vblank(struct drm_crtc *crtc, bool enable)
return rc;
}
-#if defined(CONFIG_DRM_AMD_SECURE_DISPLAY)
- rc = amdgpu_dm_crtc_set_vline0_irq(crtc, irq_type, enable);
+ return 0;
+}
+
+static int amdgpu_dm_sync_vblank_irq(struct amdgpu_crtc *acrtc, bool enable)
+{
+ struct amdgpu_display_manager *dm = &drm_to_adev(acrtc->base.dev)->dm;
+ int rc = 0;
+
+ lockdep_assert_held(&dm->ddev->vbl_lock);
+
+ if (enable == acrtc->dm_irq_params.vblank_irq_programmed)
+ return 0;
+
+ rc = amdgpu_dm_program_vblank_irq(acrtc, enable);
if (rc)
return rc;
-#endif
- if (amdgpu_in_reset(adev))
- return 0;
+ acrtc->dm_irq_params.vblank_irq_programmed = enable;
- if (dm->vblank_control_workqueue) {
- work = kzalloc_obj(*work, GFP_ATOMIC);
- if (!work)
- return -ENOMEM;
+ if (enable)
+ dm->active_vblank_irq_count++;
+ else if (!WARN_ON(!dm->active_vblank_irq_count))
+ dm->active_vblank_irq_count--;
- INIT_WORK(&work->work, amdgpu_dm_crtc_vblank_control_worker);
- work->dm = dm;
- work->acrtc = acrtc;
- work->enable = enable;
+ return 0;
+}
+
+STATIC_IFN_KUNIT void amdgpu_dm_crtc_vblank_control_worker(struct work_struct *work)
+{
+ struct vblank_control_work *vblank_work =
+ container_of(work, struct vblank_control_work, work);
+ struct amdgpu_display_manager *dm = vblank_work->dm;
+ struct amdgpu_crtc *acrtc = vblank_work->acrtc;
+ bool program;
+
+ mutex_lock(&dm->dc_lock);
+
+ if (vblank_work->enable) {
+ amdgpu_dm_ism_commit_event(&vblank_work->acrtc->ism,
+ DM_ISM_EVENT_EXIT_IDLE_REQUESTED);
+ }
+
+ scoped_guard(spinlock_irqsave, &dm->sw_counter_lock) {
+ WARN_ON(!acrtc->dm_irq_params.vblank_irq_desired &&
+ acrtc->dm_irq_params.vblank_irq_programmed);
+ program = acrtc->dm_irq_params.vblank_irq_desired &&
+ !acrtc->dm_irq_params.vblank_irq_programmed;
+ }
- if (acrtc_state->stream) {
- dc_stream_retain(acrtc_state->stream);
- work->stream = acrtc_state->stream;
+ if (program) {
+ /*
+ * The ISM has corner cases where an idle exit event
+ * (EXIT_IDLE_REQUESTED, BEGIN_CURSOR_UPDATE) does not call
+ * dc_allow_idle_optimizations(false). E.g. another CRTC's ISM
+ * can do the release while this ISM is in FULL_POWER_RUNNING,
+ * where EXIT commits nothing. Acquire and resume here until HW
+ * ref counting resolves this.
+ */
+ if (dm->use_sw_vblank_counter) {
+ dc_allow_idle_optimizations(dm->dc, false);
+ amdgpu_dm_sw_counter_resume(dm);
+ }
+
+ scoped_guard(spinlock_irqsave, &dm->ddev->vbl_lock) {
+ if (acrtc->dm_irq_params.vblank_irq_desired &&
+ !acrtc->dm_irq_params.vblank_irq_programmed)
+ WARN_ON(amdgpu_dm_sync_vblank_irq(acrtc, true));
}
+ }
- queue_work(dm->vblank_control_workqueue, &work->work);
+ if (!vblank_work->enable) {
+ amdgpu_dm_ism_commit_event(&vblank_work->acrtc->ism,
+ DM_ISM_EVENT_ENTER_IDLE_REQUESTED);
}
+ mutex_unlock(&dm->dc_lock);
+
+ dc_stream_release(vblank_work->stream);
+
+ kfree(vblank_work);
+}
+EXPORT_IF_KUNIT(amdgpu_dm_crtc_vblank_control_worker);
+
+static inline int amdgpu_dm_crtc_set_vblank(struct drm_crtc *crtc, bool enable)
+{
+ struct amdgpu_crtc *acrtc = to_amdgpu_crtc(crtc);
+ struct amdgpu_device *adev = drm_to_adev(crtc->dev);
+ struct dm_crtc_state *acrtc_state = to_dm_crtc_state(crtc->state);
+ struct amdgpu_display_manager *dm = &adev->dm;
+ struct vblank_control_work *work;
+ int rc = 0;
+
+ lockdep_assert_held(&crtc->dev->vbl_lock);
+
+ if (enable && !acrtc->base.enabled) {
+ drm_dbg_vbl(crtc->dev,
+ "Reject vblank enable on unconfigured CRTC %d (enabled=%d)\n",
+ acrtc->crtc_id, acrtc->base.enabled);
+ return -EINVAL;
+ }
+
+ work = kzalloc_obj(*work, GFP_ATOMIC);
+ if (!work && enable)
+ return -ENOMEM;
+
+ if (enable) {
+ if (acrtc_state->stream && dm->dc->caps.ips_support &&
+ dm->dc->config.disable_ips != DMUB_IPS_DISABLE_ALL &&
+ drm_crtc_vblank_crtc(crtc)->config.disable_immediate)
+ drm_crtc_vblank_restore(crtc);
+
+ acrtc->dm_irq_params.vblank_irq_desired = true;
+
+ scoped_guard(spinlock_irqsave, &dm->sw_counter_lock) {
+ if (!dm->use_sw_vblank_counter) {
+ rc = amdgpu_dm_sync_vblank_irq(acrtc, enable);
+ if (rc) {
+ acrtc->dm_irq_params.vblank_irq_desired = false;
+ kfree(work);
+ return rc;
+ }
+ }
+ }
+ } else {
+ acrtc->dm_irq_params.vblank_irq_desired = false;
+
+ scoped_guard(spinlock_irqsave, &dm->sw_counter_lock)
+ WARN_ON(dm->use_sw_vblank_counter &&
+ acrtc->dm_irq_params.vblank_irq_programmed);
+
+ amdgpu_dm_sync_vblank_irq(acrtc, enable);
+ }
+
+ if (!work)
+ return -ENOMEM;
+
+ INIT_WORK(&work->work, amdgpu_dm_crtc_vblank_control_worker);
+ work->dm = dm;
+ work->acrtc = acrtc;
+ work->enable = enable;
+
+ if (acrtc_state->stream) {
+ dc_stream_retain(acrtc_state->stream);
+ work->stream = acrtc_state->stream;
+ }
+
+ queue_work(dm->vblank_control_workqueue, &work->work);
+
return 0;
}
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_irq_params.h b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_irq_params.h
index f0c1b0c1faa9..94a3e2f4161c 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_irq_params.h
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_irq_params.h
@@ -36,6 +36,8 @@ struct dm_irq_params {
int active_planes;
bool allow_sr_entry;
struct mod_freesync_config freesync_config;
+ bool vblank_irq_desired;
+ bool vblank_irq_programmed;
#ifdef CONFIG_DEBUG_FS
enum amdgpu_dm_pipe_crc_source crc_src;
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_ism.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_ism.c
index 127eaba4de60..74b33d9d8833 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_ism.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_ism.c
@@ -293,8 +293,10 @@ static void dm_ism_commit_idle_optimization_state(struct amdgpu_dm_ism *ism,
* If there is an active vblank requestor, or if SSO is being engaged,
* then disallow idle optimizations.
*/
- if (vblank_enabled || allow_panel_sso)
+ if (vblank_enabled || allow_panel_sso) {
dc_allow_idle_optimizations(dm->dc, false);
+ amdgpu_dm_sw_counter_resume(dm);
+ }
/*
* Control PSR based on vblank requirements from OS
@@ -326,9 +328,19 @@ static void dm_ism_commit_idle_optimization_state(struct amdgpu_dm_ism *ism,
* optimizations at the start of this func -- we should disallow
* whenever there's *an* active CRTC.
*/
- if (!vblank_enabled && dm->active_vblank_irq_count == 0) {
- dc_post_update_surfaces_to_stream(dm->dc);
- dc_allow_idle_optimizations(dm->dc, true);
+ if (!vblank_enabled) {
+ bool allow;
+
+ scoped_guard(spinlock_irqsave, &dm->ddev->vbl_lock) {
+ allow = !dm->active_vblank_irq_count;
+ if (allow)
+ amdgpu_dm_sw_counter_freeze(dm);
+ }
+
+ if (allow) {
+ dc_post_update_surfaces_to_stream(dm->dc);
+ dc_allow_idle_optimizations(dm->dc, true);
+ }
}
}
--
2.43.0
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [PATCH 15/33] drm/amd/display: Fix KUnit tests for vblank control rework
2026-11-16 21:50 [PATCH 00/33] DC Patches November 23, 2026 James Lin
` (13 preceding siblings ...)
2026-11-16 21:50 ` [PATCH 14/33] drm/amd/display: Queue vblank control work to sleepable context James Lin
@ 2026-11-16 21:50 ` James Lin
2026-11-16 21:50 ` [PATCH 16/33] drm/amd/display: Add urgent request and assertion probes James Lin
` (17 subsequent siblings)
32 siblings, 0 replies; 34+ messages in thread
From: James Lin @ 2026-11-16 21:50 UTC (permalink / raw)
To: amd-gfx
Cc: Harry Wentland, Leo Li, Aurabindo Pillai, Roman Li, Wayne Lin,
Tom Chung, Fangzhi Zuo, Dan Wheeler, Ray Wu, Ivan Lipski,
Alex Hung, James Lin, Chenyu Chen, George Zhang, James Lin
From: George Zhang <george.zhang@amd.com>
[why & how]
The per-CRTC vblank_toggle_lock was replaced by a device-wide sw_counter_lock,
and the vblank-control-worker no longer touches active_vblank_irq_count on
disable (that now happens synchronously in amdgpu_dm_crtc_set_vblank() before
the worker is queued) -- seed the new lock across the affected fixtures and
rework the worker tests accordingly, also seeding reset_domain where
amdgpu_dm_crtc_set_vblank() now calls amdgpu_in_reset() unconditionally.
Cc: Sun peng Li <sunpeng.li@amd.com>
Signed-off-by: George Zhang <george.zhang@amd.com>
Signed-off-by: James Lin <pinglei.lin@amd.com>
---
.../amdgpu_dm/tests/amdgpu_dm_crtc_test.c | 219 +++++++++++++-----
.../amdgpu_dm/tests/amdgpu_dm_kunit_helpers.c | 2 +
.../display/amdgpu_dm/tests/amdgpu_dm_test.c | 5 +
3 files changed, 171 insertions(+), 55 deletions(-)
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_crtc_test.c b/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_crtc_test.c
index 20ad887979f7..ff73931a8c4d 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_crtc_test.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_crtc_test.c
@@ -909,6 +909,38 @@ static void dm_test_crtc_cleanup(void *data)
list_del_init(&acrtc->base.head);
}
+static void dm_test_crtc_destroy_vblank_wq(void *data)
+{
+ struct amdgpu_device *adev = data;
+
+ destroy_workqueue(adev->dm.vblank_control_workqueue);
+ adev->dm.vblank_control_workqueue = NULL;
+}
+
+/*
+ * dm_test_crtc_init_vblank_wq - Give @adev a live vblank control workqueue.
+ * @test: The KUnit test context
+ * @adev: The device to equip
+ *
+ * amdgpu_dm_crtc_set_vblank() queues unconditionally, as amdgpu_dm_init()
+ * fails driver init when the workqueue cannot be created. The worker takes
+ * dc_lock, so initialize that too. The workqueue is drained and destroyed at
+ * teardown; tests that assert on state the worker touches must flush it
+ * first.
+ */
+static void dm_test_crtc_init_vblank_wq(struct kunit *test,
+ struct amdgpu_device *adev)
+{
+ mutex_init(&adev->dm.dc_lock);
+ adev->dm.vblank_control_workqueue =
+ create_singlethread_workqueue("dm_test_vblank");
+ KUNIT_ASSERT_NOT_ERR_OR_NULL(test, adev->dm.vblank_control_workqueue);
+ KUNIT_ASSERT_EQ(test,
+ kunit_add_action_or_reset(test,
+ dm_test_crtc_destroy_vblank_wq,
+ adev), 0);
+}
+
/*
* dm_test_crtc_arm_irq_src - Prime an IRQ source so get()/put() short-circuit.
* @test: The KUnit test context
@@ -978,6 +1010,9 @@ dm_test_crtc_setup_enable(struct kunit *test, struct amdgpu_device **adev_out,
acrtc->base.funcs = &dm_test_crtc_funcs;
acrtc->base.enabled = true;
acrtc->crtc_id = 0;
+ /* amdgpu_dm_crtc_set_vblank() takes this; amdgpu_dm_crtc_init() is bypassed. */
+ spin_lock_init(&adev->dm.sw_counter_lock);
+ dm_test_crtc_init_vblank_wq(test, adev);
INIT_LIST_HEAD(&acrtc->base.head);
list_add_tail(&acrtc->base.head, &adev->ddev.mode_config.crtc_list);
KUNIT_ASSERT_EQ(test,
@@ -1148,22 +1183,56 @@ static void dm_test_crtc_enable_vblank_queues_work(struct kunit *test)
dm_test_crtc_arm_irq_src(test, &adev->crtc_irq, 1);
dm_test_crtc_arm_irq_src(test, &adev->pageflip_irq, 1);
- /* Real workqueue so the queue_work() branch runs the control worker. */
- mutex_init(&adev->dm.dc_lock);
- adev->dm.vblank_control_workqueue =
- create_singlethread_workqueue("dm_test_vblank");
- KUNIT_ASSERT_NOT_ERR_OR_NULL(test, adev->dm.vblank_control_workqueue);
-
KUNIT_EXPECT_EQ(test, amdgpu_dm_crtc_enable_vblank(&acrtc->base), 0);
- /* Drain the queued worker before the fixture is torn down, then tidy up. */
- destroy_workqueue(adev->dm.vblank_control_workqueue);
- adev->dm.vblank_control_workqueue = NULL;
+ /* Drain the queued worker so the count below is observed deterministically. */
+ flush_workqueue(adev->dm.vblank_control_workqueue);
/* The queued worker ran and accounted the active vblank IRQ. */
KUNIT_EXPECT_EQ(test, adev->dm.active_vblank_irq_count, 1);
}
+/**
+ * dm_test_crtc_enable_vblank_idempotent - Test a redundant enable programs nothing
+ * @test: The KUnit test context
+ *
+ * amdgpu_dm_sync_vblank_irq() short-circuits when the request already matches
+ * vblank_irq_programmed, so a second enable must leave the crtc and pageflip
+ * IRQ references untouched rather than taking a second one.
+ */
+static void dm_test_crtc_enable_vblank_idempotent(struct kunit *test)
+{
+ struct dm_crtc_state *acrtc_state;
+ struct amdgpu_device *adev;
+ struct amdgpu_crtc *acrtc;
+ int crtc_refs, pflip_refs;
+
+ /* DCE_VERSION_8_0 supports VRR -> the vupdate-irq branch is walked. */
+ acrtc = dm_test_crtc_setup_enable(test, &adev, DCE_VERSION_8_0);
+
+ /* OTG unassigned -> amdgpu_dm_crtc_set_vupdate_irq() returns 0 early. */
+ acrtc->otg_inst = -1;
+ acrtc_state = to_dm_crtc_state(acrtc->base.state);
+ acrtc_state->freesync_config.state = VRR_STATE_ACTIVE_VARIABLE;
+
+ adev->irq.installed = true;
+ dm_test_crtc_arm_irq_src(test, &adev->crtc_irq, 1);
+ dm_test_crtc_arm_irq_src(test, &adev->pageflip_irq, 1);
+
+ KUNIT_EXPECT_EQ(test, amdgpu_dm_crtc_enable_vblank(&acrtc->base), 0);
+ KUNIT_EXPECT_TRUE(test, acrtc->dm_irq_params.vblank_irq_programmed);
+
+ crtc_refs = atomic_read(&adev->crtc_irq.enabled_types[0]);
+ pflip_refs = atomic_read(&adev->pageflip_irq.enabled_types[0]);
+
+ KUNIT_EXPECT_EQ(test, amdgpu_dm_crtc_enable_vblank(&acrtc->base), 0);
+
+ KUNIT_EXPECT_EQ(test, atomic_read(&adev->crtc_irq.enabled_types[0]),
+ crtc_refs);
+ KUNIT_EXPECT_EQ(test, atomic_read(&adev->pageflip_irq.enabled_types[0]),
+ pflip_refs);
+}
+
/**
* dm_test_crtc_enable_vblank_ips_restore - Test IPS/self-refresh vblank restore
* @test: The KUnit test context
@@ -1881,12 +1950,15 @@ static void dm_test_crtc_handle_vblank_completes_cursor_only(struct kunit *test)
/**
* dm_test_vblank_control_worker_setup - Build a vblank_control_work for the worker
* @test: The KUnit test context
- * @enable: Value for vblank_work->enable
+ * @enable: Value for vblank_work->enable; also seeds vblank_irq_desired so the
+ * worker's own program-decision ("desired && !programmed") matches it
* @count: Initial dm->active_vblank_irq_count
*
- * Returns a work item wired to a freshly allocated adev/crtc/stream. The CRTC is
- * left without an atomic state so amdgpu_dm_ism_commit_event() short-circuits and
- * only the vblank IRQ accounting in the worker runs.
+ * Returns a work item wired to a freshly allocated adev/crtc/stream, with the
+ * crtc/pageflip IRQ sources armed so amdgpu_dm_sync_vblank_irq() can actually
+ * program on the enable path. The CRTC is left without an atomic state so
+ * amdgpu_dm_ism_commit_event() short-circuits and only the vblank IRQ
+ * programming in the worker runs.
*/
static struct vblank_control_work *
dm_test_vblank_control_worker_setup(struct kunit *test, bool enable,
@@ -1901,14 +1973,24 @@ dm_test_vblank_control_worker_setup(struct kunit *test, bool enable,
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, adev);
mutex_init(&adev->dm.dc_lock);
+ spin_lock_init(&adev->dm.sw_counter_lock);
adev->dm.dc = dm_kunit_alloc_dc_with_ctx(test);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, adev->dm.dc);
adev->dm.active_vblank_irq_count = count;
+ adev->mode_info.num_crtc = 1;
+ adev->irq.installed = true;
+
acrtc = kunit_kzalloc(test, sizeof(*acrtc), GFP_KERNEL);
KUNIT_ASSERT_NOT_NULL(test, acrtc);
acrtc->base.dev = &adev->ddev;
acrtc->base.state = NULL;
+ acrtc->crtc_id = 0;
+ /* OTG unassigned -> amdgpu_dm_crtc_set_vupdate_irq() returns 0 early. */
+ acrtc->otg_inst = -1;
+ acrtc->dm_irq_params.vblank_irq_desired = enable;
+ dm_test_crtc_arm_irq_src(test, &adev->crtc_irq, 1);
+ dm_test_crtc_arm_irq_src(test, &adev->pageflip_irq, 1);
stream = dm_kunit_alloc_stream(test, NULL);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, stream);
@@ -1930,7 +2012,9 @@ dm_test_vblank_control_worker_setup(struct kunit *test, bool enable,
* dm_test_vblank_control_worker_enable_increments - Test enable bumps IRQ count
* @test: The KUnit test context
*
- * Running the worker with enable set must increment the active vblank IRQ count.
+ * With vblank_irq_desired seeded true and nothing yet programmed, the worker's
+ * program decision is true, so it calls amdgpu_dm_sync_vblank_irq(), which
+ * programs the IRQ and increments the active vblank IRQ count.
*/
static void dm_test_vblank_control_worker_enable_increments(struct kunit *test)
{
@@ -1943,16 +2027,22 @@ static void dm_test_vblank_control_worker_enable_increments(struct kunit *test)
amdgpu_dm_crtc_vblank_control_worker(&work->work);
KUNIT_EXPECT_EQ(test, dm->active_vblank_irq_count, 1);
+ KUNIT_EXPECT_TRUE(test, work->acrtc->dm_irq_params.vblank_irq_programmed);
}
/**
- * dm_test_vblank_control_worker_disable_decrements - Test disable drops IRQ count
+ * dm_test_vblank_control_worker_disable_leaves_count_unchanged - Test disable is a no-op here
* @test: The KUnit test context
*
- * Running the worker with enable clear must decrement a non-zero active vblank
- * IRQ count.
+ * amdgpu_dm_crtc_set_vblank()'s disable branch calls amdgpu_dm_sync_vblank_irq()
+ * synchronously, inline, before ever queuing this worker -- so by the time the
+ * worker runs, the real decrement has already happened elsewhere. With
+ * vblank_irq_desired seeded false and vblank_irq_programmed defaulting false,
+ * the worker's own program decision is false, so it must leave the count
+ * untouched; its only remaining job on disable is the (short-circuited) ISM
+ * ENTER_IDLE_REQUESTED dispatch.
*/
-static void dm_test_vblank_control_worker_disable_decrements(struct kunit *test)
+static void dm_test_vblank_control_worker_disable_leaves_count_unchanged(struct kunit *test)
{
struct vblank_control_work *work;
struct amdgpu_display_manager *dm;
@@ -1962,26 +2052,7 @@ static void dm_test_vblank_control_worker_disable_decrements(struct kunit *test)
amdgpu_dm_crtc_vblank_control_worker(&work->work);
- KUNIT_EXPECT_EQ(test, dm->active_vblank_irq_count, 1);
-}
-
-/**
- * dm_test_vblank_control_worker_disable_clamps_zero - Test disable clamps at zero
- * @test: The KUnit test context
- *
- * Disabling when the active vblank IRQ count is already zero must not underflow.
- */
-static void dm_test_vblank_control_worker_disable_clamps_zero(struct kunit *test)
-{
- struct vblank_control_work *work;
- struct amdgpu_display_manager *dm;
-
- work = dm_test_vblank_control_worker_setup(test, false, 0);
- dm = work->dm;
-
- amdgpu_dm_crtc_vblank_control_worker(&work->work);
-
- KUNIT_EXPECT_EQ(test, dm->active_vblank_irq_count, 0);
+ KUNIT_EXPECT_EQ(test, dm->active_vblank_irq_count, 2);
}
/**
@@ -1990,10 +2061,12 @@ static void dm_test_vblank_control_worker_disable_clamps_zero(struct kunit *test
*
* Disabling vblank walks amdgpu_dm_crtc_set_vblank()'s disable path. With the
* IRQ subsystem not installed, amdgpu_irq_put() returns early so the routine
- * completes without touching the vblank workqueue or the active IRQ count.
+ * completes without changing the active IRQ count.
*/
static void dm_test_crtc_disable_vblank_no_irq_installed(struct kunit *test)
{
+ struct amdgpu_reset_domain *reset_domain;
+ struct dm_crtc_state *dm_state;
struct amdgpu_device *adev;
struct amdgpu_crtc *acrtc;
@@ -2006,6 +2079,11 @@ static void dm_test_crtc_disable_vblank_no_irq_installed(struct kunit *test)
adev->dm.dc->ctx->dce_version = DCE_VERSION_6_0;
adev->dm.active_vblank_irq_count = 0;
+ /* amdgpu_dm_crtc_set_vblank() calls amdgpu_in_reset(adev) unconditionally. */
+ reset_domain = kunit_kzalloc(test, sizeof(*reset_domain), GFP_KERNEL);
+ KUNIT_ASSERT_NOT_NULL(test, reset_domain);
+ adev->reset_domain = reset_domain;
+
/* No CRTCs registered and IRQs not installed -> irq_put returns early. */
adev->mode_info.num_crtc = 0;
adev->irq.installed = false;
@@ -2014,8 +2092,23 @@ static void dm_test_crtc_disable_vblank_no_irq_installed(struct kunit *test)
KUNIT_ASSERT_NOT_NULL(test, acrtc);
acrtc->base.dev = &adev->ddev;
acrtc->crtc_id = 0;
+ spin_lock_init(&adev->dm.sw_counter_lock);
+ dm_test_crtc_init_vblank_wq(test, adev);
+ /* Without this the disable is a no-op: the IRQ is already not programmed. */
+ acrtc->dm_irq_params.vblank_irq_programmed = true;
+ /*
+ * Seed the ISM in a state where ENTER_IDLE_REQUESTED does not transition
+ * so the worker skips the ISM power-state dispatch and its timers.
+ */
+ acrtc->ism.current_state = DM_ISM_STATE_HYSTERESIS_WAITING;
+
+ /* CRTC state with no stream -> the stream-retain branch is skipped. */
+ dm_state = kunit_kzalloc(test, sizeof(*dm_state), GFP_KERNEL);
+ KUNIT_ASSERT_NOT_NULL(test, dm_state);
+ acrtc->base.state = &dm_state->base;
amdgpu_dm_crtc_disable_vblank(&acrtc->base);
+ flush_workqueue(adev->dm.vblank_control_workqueue);
KUNIT_EXPECT_EQ(test, adev->dm.active_vblank_irq_count, 0);
}
@@ -2025,12 +2118,13 @@ static void dm_test_crtc_disable_vblank_no_irq_installed(struct kunit *test)
* @test: The KUnit test context
*
* On a VRR-capable DC the disable path turns the vupdate IRQ off (OTG
- * unassigned so it returns early), releases the armed crtc and pageflip IRQ
- * references and completes without queuing vblank control work.
+ * unassigned so it returns early) and releases the armed crtc and pageflip
+ * IRQ references.
*/
static void dm_test_crtc_disable_vblank_vrr(struct kunit *test)
{
struct amdgpu_reset_domain *reset_domain;
+ struct dm_crtc_state *dm_state;
struct amdgpu_device *adev;
struct amdgpu_crtc *acrtc;
@@ -2059,8 +2153,23 @@ static void dm_test_crtc_disable_vblank_vrr(struct kunit *test)
acrtc->crtc_id = 0;
/* OTG unassigned -> amdgpu_dm_crtc_set_vupdate_irq() returns 0 early. */
acrtc->otg_inst = -1;
+ spin_lock_init(&adev->dm.sw_counter_lock);
+ dm_test_crtc_init_vblank_wq(test, adev);
+ /* Without this the disable is a no-op: the IRQ is already not programmed. */
+ acrtc->dm_irq_params.vblank_irq_programmed = true;
+ /*
+ * Seed the ISM in a state where ENTER_IDLE_REQUESTED does not transition
+ * so the worker skips the ISM power-state dispatch and its timers.
+ */
+ acrtc->ism.current_state = DM_ISM_STATE_HYSTERESIS_WAITING;
+
+ /* CRTC state with no stream -> the stream-retain branch is skipped. */
+ dm_state = kunit_kzalloc(test, sizeof(*dm_state), GFP_KERNEL);
+ KUNIT_ASSERT_NOT_NULL(test, dm_state);
+ acrtc->base.state = &dm_state->base;
amdgpu_dm_crtc_disable_vblank(&acrtc->base);
+ flush_workqueue(adev->dm.vblank_control_workqueue);
/* Both IRQ references were released without underflow. */
KUNIT_EXPECT_EQ(test, atomic_read(&adev->crtc_irq.enabled_types[0]), 1);
@@ -2073,9 +2182,12 @@ static void dm_test_crtc_disable_vblank_vrr(struct kunit *test)
*
* With a vblank control workqueue installed and a CRTC state carrying no
* stream, the disable path queues the control worker without retaining a
- * stream. Draining the queue runs the worker, which drops the active vblank IRQ
- * count. The ISM is seeded in a state with no ENTER_IDLE_REQUESTED transition
- * so the worker only exercises the vblank accounting.
+ * stream. amdgpu_dm_crtc_set_vblank()'s disable branch calls
+ * amdgpu_dm_sync_vblank_irq() synchronously (not via the worker), so the
+ * active vblank IRQ count has already dropped by the time this call returns.
+ * The ISM is seeded in a state with no ENTER_IDLE_REQUESTED transition so
+ * draining the queued worker only exercises its (short-circuited) ISM
+ * dispatch, leaving the count as this call already left it.
*/
static void dm_test_crtc_disable_vblank_queues_work(struct kunit *test)
{
@@ -2109,28 +2221,25 @@ static void dm_test_crtc_disable_vblank_queues_work(struct kunit *test)
acrtc->base.dev = &adev->ddev;
acrtc->crtc_id = 0;
acrtc->otg_inst = -1;
+ spin_lock_init(&adev->dm.sw_counter_lock);
+ /* Without this the disable is a no-op: the IRQ is already not programmed. */
+ acrtc->dm_irq_params.vblank_irq_programmed = true;
/*
* Seed the ISM in a state where ENTER_IDLE_REQUESTED does not transition
* so the worker skips the ISM power-state dispatch and its timers.
*/
acrtc->ism.current_state = DM_ISM_STATE_HYSTERESIS_WAITING;
+ dm_test_crtc_init_vblank_wq(test, adev);
/* CRTC state with no stream -> the stream-retain branch is skipped. */
dm_state = kunit_kzalloc(test, sizeof(*dm_state), GFP_KERNEL);
KUNIT_ASSERT_NOT_NULL(test, dm_state);
acrtc->base.state = &dm_state->base;
- /* Real workqueue so the queue_work() branch runs the control worker. */
- mutex_init(&adev->dm.dc_lock);
- adev->dm.vblank_control_workqueue =
- create_singlethread_workqueue("dm_test_vblank");
- KUNIT_ASSERT_NOT_ERR_OR_NULL(test, adev->dm.vblank_control_workqueue);
-
amdgpu_dm_crtc_disable_vblank(&acrtc->base);
- /* Drain the queued worker before the fixture is torn down, then tidy up. */
- destroy_workqueue(adev->dm.vblank_control_workqueue);
- adev->dm.vblank_control_workqueue = NULL;
+ /* Drain the queued worker so the count below is observed deterministically. */
+ flush_workqueue(adev->dm.vblank_control_workqueue);
/* The queued worker ran and decremented the active vblank IRQ count. */
KUNIT_EXPECT_EQ(test, adev->dm.active_vblank_irq_count, 1);
@@ -2667,6 +2776,7 @@ static struct kunit_case amdgpu_dm_crtc_tests[] = {
KUNIT_CASE(dm_test_crtc_enable_vblank_crtc_irq_error),
KUNIT_CASE(dm_test_crtc_enable_vblank_in_reset),
KUNIT_CASE(dm_test_crtc_enable_vblank_queues_work),
+ KUNIT_CASE(dm_test_crtc_enable_vblank_idempotent),
KUNIT_CASE(dm_test_crtc_enable_vblank_ips_restore),
KUNIT_CASE(dm_test_crtc_enable_vblank_ips_restore_replay),
/* amdgpu_dm_crtc_set_vline0_irq */
@@ -2696,8 +2806,7 @@ static struct kunit_case amdgpu_dm_crtc_tests[] = {
KUNIT_CASE(dm_test_crtc_handle_vblank_completes_cursor_only),
/* amdgpu_dm_crtc_vblank_control_worker */
KUNIT_CASE(dm_test_vblank_control_worker_enable_increments),
- KUNIT_CASE(dm_test_vblank_control_worker_disable_decrements),
- KUNIT_CASE(dm_test_vblank_control_worker_disable_clamps_zero),
+ KUNIT_CASE(dm_test_vblank_control_worker_disable_leaves_count_unchanged),
/* amdgpu_dm_crtc_disable_vblank */
KUNIT_CASE(dm_test_crtc_disable_vblank_no_irq_installed),
KUNIT_CASE(dm_test_crtc_disable_vblank_vrr),
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_kunit_helpers.c b/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_kunit_helpers.c
index f844b644bb77..6031d9c9c29f 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_kunit_helpers.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_kunit_helpers.c
@@ -95,6 +95,8 @@ struct amdgpu_display_manager *dm_kunit_alloc_dm(struct kunit *test)
dm->dc = dc;
dc->current_state = state;
+ /* Guards otg_sw_counter[]; amdgpu_dm_init() is bypassed here. */
+ spin_lock_init(&dm->sw_counter_lock);
return dm;
}
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_test.c b/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_test.c
index a7618473e207..85f2e78c54af 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_test.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_test.c
@@ -1292,6 +1292,11 @@ static void dm_test_crtc_with_stream(struct kunit *test,
adev->mode_info.num_crtc = 1;
adev->mode_info.crtcs[0] = acrtc;
acrtc->dm_irq_params.stream = stream;
+
+ /* dm_vblank_get_counter()/dm_crtc_get_scanoutpos() take this unconditionally
+ * once a stream is set.
+ */
+ spin_lock_init(&adev->dm.sw_counter_lock);
}
/**
--
2.43.0
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [PATCH 16/33] drm/amd/display: Add urgent request and assertion probes
2026-11-16 21:50 [PATCH 00/33] DC Patches November 23, 2026 James Lin
` (14 preceding siblings ...)
2026-11-16 21:50 ` [PATCH 15/33] drm/amd/display: Fix KUnit tests for vblank control rework James Lin
@ 2026-11-16 21:50 ` James Lin
2026-11-16 21:50 ` [PATCH 17/33] drm/amd/display: Fix G7 P-state aperture addresses James Lin
` (16 subsequent siblings)
32 siblings, 0 replies; 34+ messages in thread
From: James Lin @ 2026-11-16 21:50 UTC (permalink / raw)
To: amd-gfx
Cc: Harry Wentland, Leo Li, Aurabindo Pillai, Roman Li, Wayne Lin,
Tom Chung, Fangzhi Zuo, Dan Wheeler, Ray Wu, Ivan Lipski,
Alex Hung, James Lin, Chenyu Chen, Wenjing Liu, Alvin Lee,
James Lin
From: Wenjing Liu <wenjing.liu@amd.com>
[Why]
Display debug needs to count urgent signals and data requests
over a selectable part of a frame. The existing probes can only
measure a whole frame.
[How]
Add a stream scope to the probe model, with the stream id and a
start and end line in a union keyed on the scope type.
The urgent assertion count and the new urgent request count poll
with MEASURING, which has no window, or run as a one shot with
MEASURED. A one shot measures one frame of the stream, or a
window when the lines are set. A zero start line is the vblank
start, derived from the stream timing.
Switching to a different polled probe type resets and programs
the new counter first.
The one shot assertion count in a window also reports the
deassertion count and the HUBP requests outstanding, sampled
once after the counter was read. Make the urgent assertion
result a struct to carry them.
A window the position already left when the counter is armed is
missed, and its result is not valid.
Add a wrap-aware, bounded block sequence step to wait for an OTG
line, the hubbub request count start and get steps, and a step to
get the HUBP outstanding requests. Read the outstanding
requests through the register fields.
Cc: Alvin Lee <alvin.lee2@amd.com>
Signed-off-by: Wenjing Liu <wenjing.liu@amd.com>
Signed-off-by: James Lin <pinglei.lin@amd.com>
---
.../drm/amd/display/dc/core/dc_hw_sequencer.c | 183 ++++++++++++-
.../gpu/drm/amd/display/dc/core/dc_resource.c | 44 +++-
drivers/gpu/drm/amd/display/dc/dc.h | 46 +++-
drivers/gpu/drm/amd/display/dc/dc_probe.h | 61 ++++-
.../display/dc/hubbub/dcn60/dcn60_hubbub.c | 80 ++++++
.../amd/display/dc/hubp/dcn20/dcn20_hubp.h | 3 +-
.../amd/display/dc/hubp/dcn60/dcn60_hubp.c | 35 +++
.../amd/display/dc/hubp/dcn60/dcn60_hubp.h | 1 +
.../amd/display/dc/hwss/dcn60/dcn60_hwseq.c | 243 ++++++++++++++++--
.../drm/amd/display/dc/hwss/hw_sequencer.h | 53 +++-
.../gpu/drm/amd/display/dc/inc/hw/dchubbub.h | 3 +
drivers/gpu/drm/amd/display/dc/inc/hw/hubp.h | 12 +
12 files changed, 721 insertions(+), 43 deletions(-)
diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_hw_sequencer.c b/drivers/gpu/drm/amd/display/dc/core/dc_hw_sequencer.c
index 061ea11cef0e..241cbe19056d 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_hw_sequencer.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_hw_sequencer.c
@@ -1895,6 +1895,12 @@ void hwss_execute_sequence(struct dc *dc,
case TG_WAIT_FOR_STATE:
hwss_tg_wait_for_state(params);
break;
+ case TG_WAIT_FOR_POSITION:
+ hwss_tg_wait_for_position(params);
+ break;
+ case HUBP_GET_OUTSTANDING_REQ:
+ hwss_hubp_get_outstanding_req(params);
+ break;
case TG_SET_VTG_PARAMS:
hwss_tg_set_vtg_params(params);
break;
@@ -2025,6 +2031,9 @@ void hwss_execute_sequence(struct dc *dc,
case HUBBUB_PERFMON_START_URGENT_ASSERTION_COUNT:
hwss_hubbub_perfmon_start_urgent_assertion_count(params);
break;
+ case HUBBUB_PERFMON_START_URGENT_REQUEST_COUNT:
+ hwss_hubbub_perfmon_start_urgent_request_count(params);
+ break;
case HUBBUB_PERFMON_START_URGENT_RAMP_LATENCY:
hwss_hubbub_perfmon_start_urgent_ramp_latency(params);
break;
@@ -2043,6 +2052,9 @@ void hwss_execute_sequence(struct dc *dc,
case HUBBUB_PERFMON_GET_URGENT_ASSERTION_COUNT:
hwss_hubbub_perfmon_get_urgent_assertion_count(params);
break;
+ case HUBBUB_PERFMON_GET_URGENT_REQUEST_COUNT:
+ hwss_hubbub_perfmon_get_urgent_request_count(params);
+ break;
case HUBBUB_PERFMON_GET_PREFETCH_DATA_SIZE:
hwss_hubbub_perfmon_get_prefetch_data_size(params);
break;
@@ -2726,6 +2738,46 @@ void hwss_add_tg_wait_for_state(struct block_sequence_state *seq_state,
}
}
+/*
+ * Helper function to add TG wait for a vertical position (OTG line) to block sequence
+ */
+/*
+ * Helper function to add a wait for an OTG line to block sequence. When
+ * window_valid is set, line is the end of the window that starts at window_start,
+ * and if the position has already left the window when the step runs, the window
+ * is missed: *window_valid is cleared and the step does not wait out a whole frame.
+ */
+void hwss_add_tg_wait_for_position(struct block_sequence_state *seq_state,
+ struct timing_generator *tg,
+ unsigned int line,
+ unsigned int window_start,
+ bool *window_valid)
+{
+ if (*seq_state->num_steps < MAX_HWSS_BLOCK_SEQUENCE_SIZE) {
+ seq_state->steps[*seq_state->num_steps].params.tg_wait_for_position_params.tg = tg;
+ seq_state->steps[*seq_state->num_steps].params.tg_wait_for_position_params.line = line;
+ seq_state->steps[*seq_state->num_steps].params.tg_wait_for_position_params.window_start = window_start;
+ seq_state->steps[*seq_state->num_steps].params.tg_wait_for_position_params.window_valid = window_valid;
+ seq_state->steps[*seq_state->num_steps].func = TG_WAIT_FOR_POSITION;
+ (*seq_state->num_steps)++;
+ }
+}
+
+/*
+ * Helper function to add a HUBP outstanding request sample to block sequence
+ */
+void hwss_add_hubp_get_outstanding_req(struct block_sequence_state *seq_state,
+ struct hubp *hubp,
+ uint32_t *status)
+{
+ if (*seq_state->num_steps < MAX_HWSS_BLOCK_SEQUENCE_SIZE) {
+ seq_state->steps[*seq_state->num_steps].params.hubp_get_outstanding_req_params.hubp = hubp;
+ seq_state->steps[*seq_state->num_steps].params.hubp_get_outstanding_req_params.status = status;
+ seq_state->steps[*seq_state->num_steps].func = HUBP_GET_OUTSTANDING_REQ;
+ (*seq_state->num_steps)++;
+ }
+}
+
/*
* Helper function to add TG set VTG params to block sequence
*/
@@ -3529,6 +3581,93 @@ void hwss_tg_wait_for_state(union block_sequence_params *params)
tg->funcs->wait_for_state(tg, state);
}
+/*
+ * Poll the TG vertical position until it reaches the target OTG line, at its
+ * next occurrence approached from below. The OTG vertical counter is 0-based
+ * and wraps at v_total, with active starting at OTG_V_BLANK_END (not 0), so the
+ * vblank region can straddle the wrap. The initial position decides the phases,
+ * and is not sampled again to change that decision:
+ * below target_line - skip phase 1, only phase 2 is needed,
+ * at or above it - phase 1 first, which waits out the wrap.
+ * and then the phases:
+ * phase 1 - advance until the counter is below target_line,
+ * phase 2 - advance until the counter reaches target_line.
+ * With a window, the initial position must be inside the window, so being at or
+ * above the end line is only valid for a window that crosses the wrap.
+ * target_line must be in [1, v_total-1], 0 and v_total are degenerate and will
+ * simply run out the guard. Each phase is bounded so a stalled or non-moving TG
+ * can never hang the block sequence.
+ */
+void hwss_tg_wait_for_position(union block_sequence_params *params)
+{
+ struct timing_generator *tg = params->tg_wait_for_position_params.tg;
+ unsigned int target_line = params->tg_wait_for_position_params.line;
+ struct crtc_position position = {0};
+ unsigned int initial_line;
+ unsigned int guard;
+
+ if (!tg->funcs->get_position)
+ return;
+
+ tg->funcs->get_position(tg, &position);
+ initial_line = position.vertical_count;
+
+ /*
+ * Arming takes longer than a line. If the position already left the window,
+ * the end line would only be reached a whole frame later, so report the window
+ * as missed instead. A window with start at or after end crosses the wrap.
+ */
+ if (params->tg_wait_for_position_params.window_valid) {
+ unsigned int start_line = params->tg_wait_for_position_params.window_start;
+ bool in_window;
+
+ if (start_line < target_line)
+ in_window = initial_line >= start_line
+ && initial_line < target_line;
+ else
+ in_window = initial_line >= start_line
+ || initial_line < target_line;
+
+ if (!in_window) {
+ *params->tg_wait_for_position_params.window_valid = false;
+ return;
+ }
+ }
+
+ /* phase 1: only if the initial position is at or above the target, wait out the wrap */
+ if (initial_line >= target_line) {
+ guard = 100000; /* 100000 * 1us = 100ms cap */
+ do {
+ tg->funcs->get_position(tg, &position);
+ if (position.vertical_count < target_line)
+ break;
+ udelay(1);
+ } while (--guard);
+ }
+
+ /* phase 2: climb to the target */
+ guard = 100000;
+ do {
+ tg->funcs->get_position(tg, &position);
+ if (position.vertical_count >= target_line)
+ break;
+ udelay(1);
+ } while (--guard);
+}
+
+/*
+ * Get the HUBP outstanding request status once and OR it into the caller's
+ * sink, so a sink cleared before a window accumulates everything seen in it.
+ */
+void hwss_hubp_get_outstanding_req(union block_sequence_params *params)
+{
+ struct hubp *hubp = params->hubp_get_outstanding_req_params.hubp;
+ uint32_t *status = params->hubp_get_outstanding_req_params.status;
+
+ if (hubp && status && hubp->funcs->hubp_get_outstanding_req_status)
+ *status |= hubp->funcs->hubp_get_outstanding_req_status(hubp);
+}
+
void hwss_tg_set_vtg_params(union block_sequence_params *params)
{
struct timing_generator *tg = params->tg_set_vtg_params_params.tg;
@@ -3974,6 +4113,14 @@ void hwss_hubbub_perfmon_start_urgent_assertion_count(union block_sequence_param
hubbub->funcs->perfmon.start_measuring_urgent_assertion_count(hubbub);
}
+void hwss_hubbub_perfmon_start_urgent_request_count(union block_sequence_params *params)
+{
+ struct hubbub *hubbub = params->hubbub_perfmon_start_urgent_request_count_params.hubbub;
+
+ if (hubbub && hubbub->funcs->perfmon.start_measuring_urgent_request_count)
+ hubbub->funcs->perfmon.start_measuring_urgent_request_count(hubbub);
+}
+
void hwss_hubbub_perfmon_start_urgent_ramp_latency(union block_sequence_params *params)
{
struct hubbub *hubbub = params->hubbub_perfmon_start_urgent_ramp_latency_params.hubbub;
@@ -4033,10 +4180,20 @@ void hwss_hubbub_perfmon_get_urgent_assertion_count(union block_sequence_params
struct hubbub *hubbub = params->hubbub_perfmon_get_urgent_assertion_count_params.hubbub;
uint32_t refclk_mhz = params->hubbub_perfmon_get_urgent_assertion_count_params.refclk_mhz;
uint32_t *count = params->hubbub_perfmon_get_urgent_assertion_count_params.assertion_count;
+ uint32_t *deassertion_count = params->hubbub_perfmon_get_urgent_assertion_count_params.deassertion_count;
if (hubbub && hubbub->funcs->perfmon.get_urgent_assertion_count)
hubbub->funcs->perfmon.get_urgent_assertion_count(
- hubbub, refclk_mhz, count, NULL, NULL);
+ hubbub, refclk_mhz, count, deassertion_count, NULL);
+}
+
+void hwss_hubbub_perfmon_get_urgent_request_count(union block_sequence_params *params)
+{
+ struct hubbub *hubbub = params->hubbub_perfmon_get_urgent_request_count_params.hubbub;
+ uint32_t *count = params->hubbub_perfmon_get_urgent_request_count_params.request_count;
+
+ if (hubbub && count && hubbub->funcs->perfmon.get_urgent_request_count)
+ *count = hubbub->funcs->perfmon.get_urgent_request_count(hubbub);
}
void hwss_hubbub_perfmon_get_prefetch_data_size(union block_sequence_params *params)
@@ -5415,6 +5572,16 @@ void hwss_add_hubbub_perfmon_start_urgent_assertion_count(struct block_sequence_
}
}
+void hwss_add_hubbub_perfmon_start_urgent_request_count(struct block_sequence_state *seq_state,
+ struct hubbub *hubbub)
+{
+ if (*seq_state->num_steps < MAX_HWSS_BLOCK_SEQUENCE_SIZE) {
+ seq_state->steps[*seq_state->num_steps].func = HUBBUB_PERFMON_START_URGENT_REQUEST_COUNT;
+ seq_state->steps[*seq_state->num_steps].params.hubbub_perfmon_start_urgent_request_count_params.hubbub = hubbub;
+ (*seq_state->num_steps)++;
+ }
+}
+
void hwss_add_hubbub_perfmon_start_urgent_ramp_latency(struct block_sequence_state *seq_state,
struct hubbub *hubbub,
const struct hubbub_urgent_latency_params *latency_params)
@@ -5482,13 +5649,25 @@ void hwss_add_hubbub_perfmon_get_memory_latencies(struct block_sequence_state *s
void hwss_add_hubbub_perfmon_get_urgent_assertion_count(struct block_sequence_state *seq_state,
struct hubbub *hubbub, uint32_t refclk_mhz,
- uint32_t *assertion_count)
+ uint32_t *assertion_count, uint32_t *deassertion_count)
{
if (*seq_state->num_steps < MAX_HWSS_BLOCK_SEQUENCE_SIZE) {
seq_state->steps[*seq_state->num_steps].func = HUBBUB_PERFMON_GET_URGENT_ASSERTION_COUNT;
seq_state->steps[*seq_state->num_steps].params.hubbub_perfmon_get_urgent_assertion_count_params.hubbub = hubbub;
seq_state->steps[*seq_state->num_steps].params.hubbub_perfmon_get_urgent_assertion_count_params.refclk_mhz = refclk_mhz;
seq_state->steps[*seq_state->num_steps].params.hubbub_perfmon_get_urgent_assertion_count_params.assertion_count = assertion_count;
+ seq_state->steps[*seq_state->num_steps].params.hubbub_perfmon_get_urgent_assertion_count_params.deassertion_count = deassertion_count;
+ (*seq_state->num_steps)++;
+ }
+}
+
+void hwss_add_hubbub_perfmon_get_urgent_request_count(struct block_sequence_state *seq_state,
+ struct hubbub *hubbub, uint32_t *request_count)
+{
+ if (*seq_state->num_steps < MAX_HWSS_BLOCK_SEQUENCE_SIZE) {
+ seq_state->steps[*seq_state->num_steps].func = HUBBUB_PERFMON_GET_URGENT_REQUEST_COUNT;
+ seq_state->steps[*seq_state->num_steps].params.hubbub_perfmon_get_urgent_request_count_params.hubbub = hubbub;
+ seq_state->steps[*seq_state->num_steps].params.hubbub_perfmon_get_urgent_request_count_params.request_count = request_count;
(*seq_state->num_steps)++;
}
}
diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_resource.c b/drivers/gpu/drm/amd/display/dc/core/dc_resource.c
index 7f770a43e1fe..b09490c84438 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_resource.c
@@ -4635,33 +4635,53 @@ enum dc_status resource_validate_probe_set(struct dc *dc,
return DC_NOT_SUPPORTED;
for (i = 0; i < probe_count; i++) {
- switch (probes[i].type) {
+ const struct dc_probe_state *probe = &probes[i];
+ bool supports_polling = false;
+ bool supports_stream = false;
+
+ switch (probe->type) {
/* These global probes support a one-frame measurement and reset. */
case DC_PROBE_PEAK_MEM_BW:
case DC_PROBE_PEAK_MEM_BW_STRESSED:
case DC_PROBE_AVG_MEM_BW:
case DC_PROBE_MEM_LATENCY:
case DC_PROBE_PREFETCH_DATA_SIZE:
- if (probes[i].scope.type != DC_PROBE_SCOPE_GLOBAL)
- return DC_NOT_SUPPORTED;
- if (probes[i].target_state != DC_PROBE_NOT_MEASURING &&
- probes[i].target_state != DC_PROBE_MEASURED)
- return DC_NOT_SUPPORTED;
break;
- /* The global urgent assertion counter additionally supports polling. */
+ /* The urgent counters additionally support polling, and a stream scope. */
case DC_PROBE_URGENT_ASSERTION_COUNT:
- if (probes[i].scope.type != DC_PROBE_SCOPE_GLOBAL)
+ case DC_PROBE_URGENT_REQUEST_COUNT:
+ supports_polling = true;
+ supports_stream = true;
+ break;
+ default:
+ return DC_NOT_SUPPORTED;
+ }
+
+ if (probe->scope.type != DC_PROBE_SCOPE_GLOBAL
+ && !(probe->scope.type == DC_PROBE_SCOPE_STREAM && supports_stream))
+ return DC_NOT_SUPPORTED;
+
+ switch (probe->target_state) {
+ case DC_PROBE_NOT_MEASURING:
+ /* A release names the probe by its type only, so it has no stream. */
+ if (probe->scope.type != DC_PROBE_SCOPE_GLOBAL)
return DC_NOT_SUPPORTED;
- if (probes[i].target_state != DC_PROBE_NOT_MEASURING &&
- probes[i].target_state != DC_PROBE_MEASURING &&
- probes[i].target_state != DC_PROBE_MEASURED)
+ break;
+ case DC_PROBE_MEASURING:
+ /* Polling cannot be limited to a window, a counter only stops when it is reset. */
+ if (!supports_polling || dc_probe_scope_is_windowed(&probe->scope))
+ return DC_NOT_SUPPORTED;
+ break;
+ case DC_PROBE_MEASURED:
+ /* A window must end on a line. Without lines, one whole frame is measured. */
+ if (dc_probe_scope_is_windowed(&probe->scope) && probe->scope.u.stream.end_line == 0)
return DC_NOT_SUPPORTED;
break;
default:
return DC_NOT_SUPPORTED;
}
- if (probes[i].type == DC_PROBE_PEAK_MEM_BW_STRESSED &&
+ if (probe->type == DC_PROBE_PEAK_MEM_BW_STRESSED &&
!dc->res_pool->lsdma_scratch.buffer)
return DC_NO_DRAM_BUFFER_RESOURCE;
}
diff --git a/drivers/gpu/drm/amd/display/dc/dc.h b/drivers/gpu/drm/amd/display/dc/dc.h
index c9bdfba11a01..4c235520b908 100644
--- a/drivers/gpu/drm/amd/display/dc/dc.h
+++ b/drivers/gpu/drm/amd/display/dc/dc.h
@@ -2228,6 +2228,44 @@ struct dc_probe_latencies {
uint32_t min_latency_ns;
};
+/**
+ * union dc_probe_outstanding_req - HUBP requests outstanding after an OTG window.
+ *
+ * @bits.any: a request is outstanding in HUBP.
+ * @bits.data: a data request is outstanding.
+ * @bits.chunk_meta_trans: a chunk, meta or translation request is outstanding.
+ * @bits.not_in_blank: HUBP has not finished requesting for the frame.
+ * @raw: DC internal, holds the HW status while the probe sequence
+ * executes and is decoded into @bits afterwards.
+ */
+union dc_probe_outstanding_req {
+ struct {
+ uint32_t any : 1;
+ uint32_t data : 1;
+ uint32_t chunk_meta_trans : 1;
+ uint32_t not_in_blank : 1;
+ uint32_t reserved : 28;
+ } bits;
+ uint32_t raw;
+};
+
+/**
+ * struct dc_probe_urgent_assertion - result of an urgent assertion count probe.
+ *
+ * The fields after @count are only filled for a window of a stream scope, and
+ * are zero otherwise.
+ *
+ * @count: number of urgent assertion events.
+ * @deassertion_count: number of falling edges of the urgent signal.
+ * @outstanding: HUBP requests outstanding, sampled once after the
+ * window counter was read.
+ */
+struct dc_probe_urgent_assertion {
+ uint32_t count;
+ uint32_t deassertion_count;
+ union dc_probe_outstanding_req outstanding;
+};
+
/**
* struct dc_probe_status - results for a probe.
* @valid: true if a measurement was latched.
@@ -2236,7 +2274,10 @@ struct dc_probe_latencies {
* @u.bandwidth_mbps: peak BW in Mbps (DC_PROBE_PEAK_MEM_BW).
* @u.latency: min/max/avg memory latency in ns (DC_PROBE_MEM_LATENCY),
* stored as struct dc_probe_latencies.
- * @u.urgent_assertion_count: number of urgent assertion events (DC_PROBE_URGENT_ASSERTION_COUNT).
+ * @u.urgent_assertion: urgent assertion events and outstanding requests
+ * (DC_PROBE_URGENT_ASSERTION_COUNT).
+ * @u.urgent_request_count: number of urgent requests in the window
+ * (DC_PROBE_URGENT_REQUEST_COUNT).
* @u.prefetch_data_size: total prefetch data in bytes (DC_PROBE_PREFETCH_DATA_SIZE).
*/
struct dc_probe_status {
@@ -2246,7 +2287,8 @@ struct dc_probe_status {
union {
uint32_t bandwidth_mbps;
struct dc_probe_latencies latency;
- uint32_t urgent_assertion_count;
+ struct dc_probe_urgent_assertion urgent_assertion;
+ uint32_t urgent_request_count;
uint32_t prefetch_data_size;
} u;
};
diff --git a/drivers/gpu/drm/amd/display/dc/dc_probe.h b/drivers/gpu/drm/amd/display/dc/dc_probe.h
index 52bffbebf7ad..14ecb871c3d0 100644
--- a/drivers/gpu/drm/amd/display/dc/dc_probe.h
+++ b/drivers/gpu/drm/amd/display/dc/dc_probe.h
@@ -12,6 +12,13 @@
*
* Each value names a measurable quantity as an abstraction. DC resolves it to
* whatever HW measurement block fulfills it. DM never selects the HW block.
+ *
+ * DC_PROBE_URGENT_ASSERTION_COUNT and DC_PROBE_URGENT_REQUEST_COUNT are
+ * measured continuously with DC_PROBE_MEASURING, or as a one shot with
+ * DC_PROBE_MEASURED, which can be scoped to one frame or to a window of one
+ * stream with DC_PROBE_SCOPE_STREAM. With a window, the urgent assertion count
+ * result also carries the HUBP outstanding requests, sampled once after the
+ * counter was read so the sample does not disturb the window.
*/
enum dc_probe_type {
DC_PROBE_PEAK_MEM_BW = 0,
@@ -21,6 +28,7 @@ enum dc_probe_type {
DC_PROBE_URGENT_ASSERTION_COUNT,
DC_PROBE_PREFETCH_DATA_SIZE,
DC_PROBE_PEAK_MEM_BW_STRESSED, /* peak BW under synthetic memory contention */
+ DC_PROBE_URGENT_REQUEST_COUNT,
};
/**
@@ -44,23 +52,66 @@ enum dc_probe_target_state {
/**
* enum dc_probe_scope_type - What the probe is scoped to.
* @DC_PROBE_SCOPE_GLOBAL: whole memory subsystem, no stream/plane selector.
+ * @DC_PROBE_SCOPE_STREAM: lines of one stream, selected by u.stream of
+ * struct dc_probe_scope.
*
- * Only GLOBAL is implemented. Per-stream/plane scoping must select targets by
- * stable id, not object pointer — dc_state copy semantics would dangle a raw
- * pointer when the absolute-set commit removes or replaces the target.
+ * Per-stream/plane scoping must select targets by stable id, not object
+ * pointer — dc_state copy semantics would dangle a raw pointer when the
+ * absolute-set commit removes or replaces the target.
*/
enum dc_probe_scope_type {
DC_PROBE_SCOPE_GLOBAL = 0,
+ DC_PROBE_SCOPE_STREAM,
};
/**
* struct dc_probe_scope - Selects what a probe measures against.
- * @type: scope kind, only DC_PROBE_SCOPE_GLOBAL is implemented.
+ * @type: scope kind. It selects which member of @u is valid.
+ * @u.stream.stream_id: stream_id of the stream to measure. A probe on a stream
+ * that is not in the committed state has nothing to measure, and its status
+ * is not valid.
+ * @u.stream.start_line: first line of the window, as an OTG vertical position
+ * of the stream (0-based, wraps at v_total). Zero starts the window at vblank
+ * start. Otherwise keep it in [1, v_total - 1].
+ * @u.stream.end_line: last line of the window. A window may cross the v_total
+ * wrap. Arming the counter takes a few lines. A window the position has
+ * already left when the counter is armed is missed, and its status is not
+ * valid, so a window needs to be longer than the arm latency.
+ *
+ * The lines and the target state select what is measured:
+ *
+ * - start_line and end_line both zero is no window. DC_PROBE_MEASURING measures
+ * continuously, and DC_PROBE_MEASURED measures one whole frame.
+ * - A nonzero end_line is a window from start_line to end_line.
+ * DC_PROBE_MEASURED measures the next window once, and then stops.
+ * DC_PROBE_MEASURING is not valid for a window, because a continuous
+ * measurement cannot be limited to one. A counter only stops when it is
+ * reset.
+ * - A nonzero start_line with a zero end_line is not valid.
*/
struct dc_probe_scope {
enum dc_probe_scope_type type;
+ union {
+ struct {
+ uint32_t stream_id;
+ uint32_t start_line;
+ uint32_t end_line;
+ } stream;
+ } u;
};
+/**
+ * dc_probe_scope_is_windowed() - Whether a scope selects lines of a stream.
+ * @scope: scope to check
+ *
+ * Return: true if start_line or end_line of a stream scope is set
+ */
+static inline bool dc_probe_scope_is_windowed(const struct dc_probe_scope *scope)
+{
+ return scope->type == DC_PROBE_SCOPE_STREAM
+ && (scope->u.stream.start_line || scope->u.stream.end_line);
+}
+
/**
* struct dc_probe_state - DM-authored descriptor of a single probe.
*
@@ -70,7 +121,7 @@ struct dc_probe_scope {
*
* @type: what to measure.
* @target_state: desired lifecycle state for this probe.
- * @scope: what the probe is scoped to (GLOBAL only for now).
+ * @scope: what the probe is scoped to.
*/
struct dc_probe_state {
enum dc_probe_type type;
diff --git a/drivers/gpu/drm/amd/display/dc/hubbub/dcn60/dcn60_hubbub.c b/drivers/gpu/drm/amd/display/dc/hubbub/dcn60/dcn60_hubbub.c
index db29e56f2367..ab3a63cb2042 100644
--- a/drivers/gpu/drm/amd/display/dc/hubbub/dcn60/dcn60_hubbub.c
+++ b/drivers/gpu/drm/amd/display/dc/hubbub/dcn60/dcn60_hubbub.c
@@ -1097,6 +1097,82 @@ static bool hubbub60_perfmon_get_urgent_assertion_count(
return updated;
}
+/**
+ * hubbub60_perfmon_start_measuring_urgent_request_count() - Start counting urgent DF requests.
+ * @hubbub: hubbub instance
+ *
+ * Counts SDPIF request-valid events whose UTM QoS profile matches the urgent
+ * profile (event 256, filtered_sdpif_req_vld), over all request types and all
+ * Unit IDs. Counter 0 accumulates at level mode and runs from the moment
+ * PERFMON_STATE is set to run until the counters are reset, so the caller
+ * defines the measurement window in software.
+ */
+static void hubbub60_perfmon_start_measuring_urgent_request_count(
+ struct hubbub *hubbub)
+{
+ struct dcn20_hubbub *hubbub2 = TO_DCN20_HUBBUB(hubbub);
+
+ /* configure measurement control */
+ REG_SET_5(DCHUBBUB_PERFORMANCE_MEASUREMENT_CNTL, 0,
+ DCHUBBUB_LATENCY_CNT_EN, 0x1,
+ DCHUBBUB_DF_REQ_CMD_LATENCY_SEL, 0x1, // cacheable
+ ARB_LATENCY_REQ_TYPE_SEL, 0x7, // all request types
+ REQ_UNIT_ID_MASK, 0x0, // all Unit IDs
+ REQ_UNIT_ID_SEL, 0x0);
+ REG_SET_2(DCHUBBUB_PERFORMANCE_MEASUREMENT_CNTL2, 0,
+ LATENCY_SOURCE_SEL, 0x2, // df latency
+ UTM_FILTER_SEL, 0x1); // urgent only
+
+ /* program counter 0 to count filtered urgent requests */
+ REG_SET_8(DC_PERFMON5_PERFCOUNTER_CNTL, 0,
+ PERFCOUNTER_CNTL_SEL, 0x0,
+ PERFCOUNTER_EVENT_SEL, 256, // filtered_sdpif_req_vld
+ PERFCOUNTER_CVALUE_SEL, 0x0,
+ PERFCOUNTER_INC_MODE, 0x2, // count LSB level
+ PERFCOUNTER_HW_CNTL_SEL, 0x0,
+ PERFCOUNTER_RUNEN_MODE, 0x0,
+ PERFCOUNTER_RESTART_EN, 0x0,
+ PERFCOUNTER_ACTIVE, 1);
+ REG_SET_4(DC_PERFMON5_PERFCOUNTER_CNTL2, 0,
+ PERFCOUNTER_CNTL2_SEL, 0x0,
+ PERFCOUNTER_COUNTED_VALUE_TYPE, 0x0, // accumulated
+ PERFCOUNTER_HW_STOP1_SEL, 0x0,
+ PERFCOUNTER_HW_STOP2_SEL, 0x0);
+
+ REG_WRITE(DC_PERFMON5_PERFCOUNTER_STATE, 0);
+
+ /* software controlled window, no OTG start/stop event */
+ REG_SET_2(DC_PERFMON5_PERFMON_CNTL2, 0,
+ PERFMON_RUN_ENABLE_START_SEL, 0x0,
+ PERFMON_RUN_ENABLE_STOP_SEL, 0x0);
+
+ /* start the counter */
+ REG_SET_2(DC_PERFMON5_PERFMON_CNTL, 0,
+ PERFMON_STATE, 0x1,
+ PERFMON_RPT_COUNT, 0xFFFFF);
+}
+
+/**
+ * hubbub60_perfmon_get_urgent_request_count() - Read the urgent request count.
+ * @hubbub: hubbub instance
+ *
+ * Reads the running counter, which keeps counting until the counters are reset.
+ *
+ * Return: number of urgent requests counted since
+ * hubbub60_perfmon_start_measuring_urgent_request_count().
+ */
+static uint32_t hubbub60_perfmon_get_urgent_request_count(
+ struct hubbub *hubbub)
+{
+ struct dcn20_hubbub *hubbub2 = TO_DCN20_HUBBUB(hubbub);
+ uint32_t count0 = 0;
+
+ REG_SET(DC_PERFMON5_PERFMON_HI, 0, PERFMON_READ_SEL, 0x0);
+ REG_GET(DC_PERFMON5_PERFMON_LOW, PERFMON_LOW, &count0);
+
+ return count0;
+}
+
/**
* @brief Configures the performance monitor to measure the urgent ramp
* latency.
@@ -1952,6 +2028,10 @@ static const struct hubbub_funcs hubbub60_funcs = {
hubbub60_perfmon_start_measuring_urgent_assertion_count,
.get_urgent_assertion_count =
hubbub60_perfmon_get_urgent_assertion_count,
+ .start_measuring_urgent_request_count =
+ hubbub60_perfmon_start_measuring_urgent_request_count,
+ .get_urgent_request_count =
+ hubbub60_perfmon_get_urgent_request_count,
.start_measuring_urgent_ramp_latency =
hubbub60_perfmon_start_measuring_urgent_ramp_latency,
.get_urgent_ramp_latency_ns =
diff --git a/drivers/gpu/drm/amd/display/dc/hubp/dcn20/dcn20_hubp.h b/drivers/gpu/drm/amd/display/dc/hubp/dcn20/dcn20_hubp.h
index 3ae06bf89f79..a0bd134c37b3 100644
--- a/drivers/gpu/drm/amd/display/dc/hubp/dcn20/dcn20_hubp.h
+++ b/drivers/gpu/drm/amd/display/dc/hubp/dcn20/dcn20_hubp.h
@@ -313,7 +313,8 @@
type URGENT_FORCE_EN;\
type FORCE_DISP_PREF_TO_VBLANK;\
type DST_Y_ALT_CH_DRQ_LIMIT;\
- type FORCE_CURSOR_TO_DISP_PREF
+ type FORCE_CURSOR_TO_DISP_PREF;\
+ type HUBP_XRQ_NO_OUTSTANDING_REQ
/*
type HUBP_3DLUT_CROSSBAR_SEL_B;\
type HUBP_3DLUT_CROSSBAR_SEL_G;\
diff --git a/drivers/gpu/drm/amd/display/dc/hubp/dcn60/dcn60_hubp.c b/drivers/gpu/drm/amd/display/dc/hubp/dcn60/dcn60_hubp.c
index 7c2ff310ea99..6604fb880341 100644
--- a/drivers/gpu/drm/amd/display/dc/hubp/dcn60/dcn60_hubp.c
+++ b/drivers/gpu/drm/amd/display/dc/hubp/dcn60/dcn60_hubp.c
@@ -409,6 +409,40 @@ void hubp60_read_state(struct hubp *hubp)
s->flip_control = REG_READ(DCSURF_FLIP_CONTROL);
}
+/**
+ * hubp60_get_outstanding_req_status() - Sample the outstanding request status of HUBP.
+ * @hubp: hubp instance
+ *
+ * Reads DCHUBP_CNTL once. The no-outstanding fields read 1 when idle, so they are inverted
+ * into HUBP_OUTSTANDING_* bits that are set when something is outstanding.
+ *
+ * Return: HUBP_OUTSTANDING_* and HUBP_NOT_IN_BLANK bits
+ */
+static uint32_t hubp60_get_outstanding_req_status(struct hubp *hubp)
+{
+ struct dcn20_hubp *hubp2 = TO_DCN20_HUBP(hubp);
+ uint32_t no_outstanding_req = 0;
+ uint32_t xrq_no_outstanding_req = 0;
+ uint32_t in_blank = 0;
+ uint32_t status = 0;
+
+ REG_GET_3(DCHUBP_CNTL,
+ HUBP_NO_OUTSTANDING_REQ, &no_outstanding_req,
+ HUBP_XRQ_NO_OUTSTANDING_REQ, &xrq_no_outstanding_req,
+ HUBP_IN_BLANK, &in_blank);
+
+ if (!no_outstanding_req)
+ status |= HUBP_OUTSTANDING_ANY;
+ if (!(xrq_no_outstanding_req & HUBP_XRQ_NO_OUTSTANDING_DRQ))
+ status |= HUBP_OUTSTANDING_DRQ;
+ if (!(xrq_no_outstanding_req & HUBP_XRQ_NO_OUTSTANDING_CRQ_TRQ))
+ status |= HUBP_OUTSTANDING_CRQ_TRQ;
+ if (!in_blank)
+ status |= HUBP_NOT_IN_BLANK;
+
+ return status;
+}
+
static struct hubp_funcs dcn60_hubp_funcs = {
.hubp_enable_tripleBuffer = hubp2_enable_triplebuffer,
.hubp_is_triplebuffer_enabled = hubp2_is_triplebuffer_enabled,
@@ -438,6 +472,7 @@ static struct hubp_funcs dcn60_hubp_funcs = {
.hubp_soft_reset = hubp31_soft_reset,
.hubp_set_flip_int = hubp401_set_flip_int,
.hubp_in_blank = hubp401_in_blank,
+ .hubp_get_outstanding_req_status = hubp60_get_outstanding_req_status,
.phantom_hubp_post_enable = hubp32_phantom_hubp_post_enable,
.hubp_update_mall_sel = NULL,
.hubp_prepare_subvp_buffering = hubp32_prepare_subvp_buffering,
diff --git a/drivers/gpu/drm/amd/display/dc/hubp/dcn60/dcn60_hubp.h b/drivers/gpu/drm/amd/display/dc/hubp/dcn60/dcn60_hubp.h
index e502c9330cef..dac20ed6bb0c 100644
--- a/drivers/gpu/drm/amd/display/dc/hubp/dcn60/dcn60_hubp.h
+++ b/drivers/gpu/drm/amd/display/dc/hubp/dcn60/dcn60_hubp.h
@@ -34,6 +34,7 @@
HUBP_SF(HUBP0_DCHUBP_CNTL, HUBP_UNBOUNDED_REQ_MODE, mask_sh),\
HUBP_SF(HUBP0_DCHUBP_CNTL, HUBP_IN_BLANK, mask_sh),\
HUBP_SF(HUBP0_DCHUBP_CNTL, HUBP_SOFT_RESET, mask_sh),\
+ HUBP_SF(HUBP0_DCHUBP_CNTL, HUBP_XRQ_NO_OUTSTANDING_REQ, mask_sh),\
HUBP_SF(HUBP0_DCSURF_ADDR_CONFIG, NUM_PIPES, mask_sh),\
HUBP_SF(HUBP0_DCSURF_ADDR_CONFIG, PIPE_INTERLEAVE, mask_sh),\
HUBP_SF(HUBP0_DCSURF_ADDR_CONFIG, MAX_COMPRESSED_FRAGS, mask_sh),\
diff --git a/drivers/gpu/drm/amd/display/dc/hwss/dcn60/dcn60_hwseq.c b/drivers/gpu/drm/amd/display/dc/hwss/dcn60/dcn60_hwseq.c
index 8a38b7f0bef0..67b778001bce 100644
--- a/drivers/gpu/drm/amd/display/dc/hwss/dcn60/dcn60_hwseq.c
+++ b/drivers/gpu/drm/amd/display/dc/hwss/dcn60/dcn60_hwseq.c
@@ -48,7 +48,6 @@
hws->regs->reg
#define DC_LOGGER \
dc->ctx->logger
-
#undef FN
#define FN(reg_name, field_name) \
hws->shifts->field_name, hws->masks->field_name
@@ -966,29 +965,140 @@ void dcn60_update_cursor_offload_pipe(struct dmub_srv *dmub, uint32_t stream_idx
cs->offload_streams[stream_idx].payloads[payload_idx].pipe_mask |= (1u << pipe_idx);
}
+/**
+ * dcn60_get_otg_master_pipe - Resolve the OTG master pipe of a stream.
+ * @context: committed dc state to resolve streams from
+ * @stream_id: stream_id of the stream to look for
+ *
+ * Returns the OTG master pipe driving the stream, or NULL when the stream is
+ * not in the committed state.
+ */
+static struct pipe_ctx *dcn60_get_otg_master_pipe(
+ struct dc_state *context,
+ uint32_t stream_id)
+{
+ struct dc_stream_state *stream;
+
+ if (!context)
+ return NULL;
+
+ stream = dc_state_get_stream_from_id(context, stream_id);
+ if (!stream)
+ return NULL;
+
+ return resource_get_otg_master_for_stream(&context->res_ctx, stream);
+}
+
/**
* dcn60_get_ref_tg_for_hubbub_probe - Resolve the OTG master for hubbub probing.
* @context: committed dc state to resolve streams from
+ * @probe: probe to resolve the OTG master for
*
* All probe types gate their measurement window to frame edges of the OTG
- * master of stream 0. Returns NULL when no active stream is present.
+ * master of the probe's stream, or of stream 0 when the probe has no stream.
+ * Returns NULL when that stream is not active.
*/
static struct timing_generator *dcn60_get_ref_tg_for_hubbub_probe(
- struct dc_state *context)
+ struct dc_state *context,
+ const struct dc_probe_state *probe)
{
struct pipe_ctx *otg_pipe;
if (!context || !context->stream_count)
return NULL;
- otg_pipe = resource_get_otg_master_for_stream(&context->res_ctx,
- context->streams[0]);
+ if (probe->scope.type == DC_PROBE_SCOPE_STREAM)
+ otg_pipe = dcn60_get_otg_master_pipe(context, probe->scope.u.stream.stream_id);
+ else
+ otg_pipe = resource_get_otg_master_for_stream(&context->res_ctx,
+ context->streams[0]);
if (!otg_pipe)
return NULL;
return otg_pipe->stream_res.tg;
}
+/**
+ * dcn60_build_urgent_window_sequence - Build the BLS sequence for one urgent window.
+ * @dc: DC structure
+ * @context: Committed dc state to resolve streams from
+ * @probe: Urgent probe state scoped to a window of a stream
+ * @status: Result sink for the sequence
+ * @seq_state: Sequence to append steps to
+ *
+ * Measures one window between the start and end lines of the probe scope, as a one
+ * shot. The perfmon counter is armed at the start line and stopped at the end line.
+ * A zero start line is the vblank start of the stream, which the OTG programs at
+ * v_total - v_front_porch. The waits approach each line from below and are
+ * wrap-aware, so they self-sync to a fresh edge and support a window that crosses
+ * the v_total wrap. Arming takes longer than a line, so a window that is already
+ * over when the end line is waited on is missed, and its status is not valid
+ * instead of a whole frame being measured. For the urgent assertion count, HUBP is
+ * sampled once after the counter has been read, so the sample does not disturb the
+ * window. No steps are added when prerequisites are not met.
+ */
+static void dcn60_build_urgent_window_sequence(
+ struct dc *dc,
+ struct dc_state *context,
+ const struct dc_probe_state *probe,
+ struct dc_probe_status *status,
+ struct block_sequence_state *seq_state)
+{
+ struct hubbub *hubbub = dc->res_pool->hubbub;
+ uint32_t refclk_mhz = dc->res_pool->ref_clocks.dchub_ref_clock_inKhz / 1000;
+ struct pipe_ctx *otg_pipe = dcn60_get_otg_master_pipe(context,
+ probe->scope.u.stream.stream_id);
+ struct timing_generator *ref_tg = otg_pipe ? otg_pipe->stream_res.tg : NULL;
+ struct hubp *ref_hubp = otg_pipe ? otg_pipe->plane_res.hubp : NULL;
+ unsigned int start_line = probe->scope.u.stream.start_line;
+ unsigned int end_line = probe->scope.u.stream.end_line;
+ struct dc_probe_urgent_assertion *assertion = &status->u.urgent_assertion;
+
+ status->valid = false;
+
+ if (probe->target_state != DC_PROBE_MEASURED || !ref_tg)
+ return;
+
+ if (!start_line)
+ start_line = otg_pipe->stream->timing.v_total - otg_pipe->stream->timing.v_front_porch;
+
+ if (probe->type == DC_PROBE_URGENT_REQUEST_COUNT) {
+ if (!hubbub->funcs->perfmon.start_measuring_urgent_request_count ||
+ !hubbub->funcs->perfmon.get_urgent_request_count)
+ return;
+
+ status->valid = true;
+ hwss_add_hubbub_perfmon_reset(seq_state, hubbub);
+ hwss_add_tg_wait_for_position(seq_state, ref_tg, start_line, 0, NULL);
+ hwss_add_hubbub_perfmon_start_urgent_request_count(seq_state, hubbub);
+ hwss_add_tg_wait_for_position(seq_state, ref_tg, end_line, start_line,
+ &status->valid);
+ hwss_add_hubbub_perfmon_get_urgent_request_count(seq_state, hubbub,
+ &status->u.urgent_request_count);
+ return;
+ }
+
+ if (probe->type != DC_PROBE_URGENT_ASSERTION_COUNT ||
+ !hubbub->funcs->perfmon.start_measuring_urgent_assertion_count ||
+ !hubbub->funcs->perfmon.get_urgent_assertion_count)
+ return;
+
+ assertion->outstanding.raw = 0;
+ status->valid = true;
+
+ hwss_add_tg_wait_for_position(seq_state, ref_tg, start_line, 0, NULL);
+ hwss_add_hubbub_perfmon_reset(seq_state, hubbub);
+ hwss_add_hubbub_perfmon_start_urgent_assertion_count(seq_state, hubbub);
+ hwss_add_tg_wait_for_position(seq_state, ref_tg, end_line, start_line,
+ &status->valid);
+ hwss_add_hubbub_perfmon_get_urgent_assertion_count(seq_state, hubbub,
+ refclk_mhz, &assertion->count,
+ &assertion->deassertion_count);
+ if (ref_hubp)
+ hwss_add_hubp_get_outstanding_req(seq_state, ref_hubp,
+ &assertion->outstanding.raw);
+}
+
/**
* dcn60_build_hubbub_perfmon_sequence - Build the hubbub perfmon BLS sequence.
* @dc: DC structure
@@ -1011,9 +1121,10 @@ static void dcn60_build_hubbub_perfmon_sequence(
{
struct hubbub *hubbub = dc->res_pool->hubbub;
uint32_t refclk_mhz = dc->res_pool->ref_clocks.dchub_ref_clock_inKhz / 1000;
- struct timing_generator *ref_tg = dcn60_get_ref_tg_for_hubbub_probe(context);
+ struct timing_generator *ref_tg = dcn60_get_ref_tg_for_hubbub_probe(context, probe);
struct block_sequence_state seq_state = { .steps = block_sequence, .num_steps = num_steps };
- bool was_measuring = status->measuring;
+ /* The running counter can only be reused by a probe of the same type. */
+ bool continuing = status->measuring && status->type == probe->type;
if (!hubbub || !hubbub->funcs || !hubbub->funcs->perfmon.reset)
return;
@@ -1023,20 +1134,49 @@ static void dcn60_build_hubbub_perfmon_sequence(
return;
}
+ if (dc_probe_scope_is_windowed(&probe->scope)) {
+ dcn60_build_urgent_window_sequence(dc, context, probe, status, &seq_state);
+ return;
+ }
+
+ /*
+ * Polling starts the counter once, then every poll reads the running counter
+ * without stopping it. Switching to a different probe type resets the counter
+ * and programs the new configuration first.
+ */
if (probe->target_state == DC_PROBE_MEASURING) {
- if (probe->type != DC_PROBE_URGENT_ASSERTION_COUNT ||
- !hubbub->funcs->perfmon.start_measuring_urgent_assertion_count ||
- !hubbub->funcs->perfmon.get_urgent_assertion_count)
+ switch (probe->type) {
+ case DC_PROBE_URGENT_ASSERTION_COUNT:
+ if (!hubbub->funcs->perfmon.start_measuring_urgent_assertion_count ||
+ !hubbub->funcs->perfmon.get_urgent_assertion_count)
+ return;
+
+ if (!continuing) {
+ hwss_add_hubbub_perfmon_reset(&seq_state, hubbub);
+ hwss_add_hubbub_perfmon_start_urgent_assertion_count(&seq_state, hubbub);
+ }
+
+ hwss_add_hubbub_perfmon_get_urgent_assertion_count(&seq_state, hubbub,
+ refclk_mhz, &status->u.urgent_assertion.count, NULL);
return;
- if (!was_measuring) {
- hwss_add_hubbub_perfmon_reset(&seq_state, hubbub);
- hwss_add_hubbub_perfmon_start_urgent_assertion_count(&seq_state, hubbub);
- }
+ case DC_PROBE_URGENT_REQUEST_COUNT:
+ if (!hubbub->funcs->perfmon.start_measuring_urgent_request_count ||
+ !hubbub->funcs->perfmon.get_urgent_request_count)
+ return;
- hwss_add_hubbub_perfmon_get_urgent_assertion_count(&seq_state, hubbub,
- refclk_mhz, &status->u.urgent_assertion_count);
- return;
+ if (!continuing) {
+ hwss_add_hubbub_perfmon_reset(&seq_state, hubbub);
+ hwss_add_hubbub_perfmon_start_urgent_request_count(&seq_state, hubbub);
+ }
+
+ hwss_add_hubbub_perfmon_get_urgent_request_count(&seq_state, hubbub,
+ &status->u.urgent_request_count);
+ return;
+
+ default:
+ return;
+ }
}
if (probe->target_state != DC_PROBE_MEASURED || !ref_tg)
@@ -1124,7 +1264,22 @@ static void dcn60_build_hubbub_perfmon_sequence(
hwss_add_tg_wait_for_state(&seq_state, ref_tg, CRTC_STATE_VACTIVE);
hwss_add_tg_wait_for_state(&seq_state, ref_tg, CRTC_STATE_VBLANK);
hwss_add_hubbub_perfmon_get_urgent_assertion_count(&seq_state, hubbub,
- refclk_mhz, &status->u.urgent_assertion_count);
+ refclk_mhz, &status->u.urgent_assertion.count, NULL);
+ return;
+
+ case DC_PROBE_URGENT_REQUEST_COUNT:
+ if (!hubbub->funcs->perfmon.start_measuring_urgent_request_count ||
+ !hubbub->funcs->perfmon.get_urgent_request_count)
+ return;
+
+ hwss_add_hubbub_perfmon_reset(&seq_state, hubbub);
+ hwss_add_tg_wait_for_state(&seq_state, ref_tg, CRTC_STATE_VACTIVE);
+ hwss_add_tg_wait_for_state(&seq_state, ref_tg, CRTC_STATE_VBLANK);
+ hwss_add_hubbub_perfmon_start_urgent_request_count(&seq_state, hubbub);
+ hwss_add_tg_wait_for_state(&seq_state, ref_tg, CRTC_STATE_VACTIVE);
+ hwss_add_tg_wait_for_state(&seq_state, ref_tg, CRTC_STATE_VBLANK);
+ hwss_add_hubbub_perfmon_get_urgent_request_count(&seq_state, hubbub,
+ &status->u.urgent_request_count);
return;
case DC_PROBE_PREFETCH_DATA_SIZE:
@@ -1143,7 +1298,9 @@ static void dcn60_build_hubbub_perfmon_sequence(
return;
case DC_PROBE_URGENT_RAMP_LATENCY:
- /* Requires caller-supplied window params not available in probe model. */
+ /* Window params are available in dc_probe_scope, but the ramp latency measurement
+ * is not implemented.
+ */
return;
default:
@@ -1151,10 +1308,31 @@ static void dcn60_build_hubbub_perfmon_sequence(
}
}
+/**
+ * dcn60_decode_outstanding_req - Decode the HUBP outstanding request status.
+ * @outstanding: raw holds HUBP_OUTSTANDING_* and HUBP_NOT_IN_BLANK bits on entry,
+ * and the decoded bits on return
+ */
+static void dcn60_decode_outstanding_req(union dc_probe_outstanding_req *outstanding)
+{
+ uint32_t hw_status = outstanding->raw;
+
+ outstanding->raw = 0;
+ outstanding->bits.any = !!(hw_status & HUBP_OUTSTANDING_ANY);
+ outstanding->bits.data = !!(hw_status & HUBP_OUTSTANDING_DRQ);
+ outstanding->bits.chunk_meta_trans = !!(hw_status & HUBP_OUTSTANDING_CRQ_TRQ);
+ outstanding->bits.not_in_blank = !!(hw_status & HUBP_NOT_IN_BLANK);
+}
+
/**
* dcn60_update_probe_status - Set the valid flag on a latched probe result.
* @status: result sink whose u was written by the GET BLS step during execute
* @probe: current probe state used to determine measurement type and validity
+ *
+ * TODO: the status has no single owner. The builders read the previous status
+ * (measuring), pass pointers into it as the execute output sinks (u, and valid
+ * for a window), and this function then rebuilds it. Build into a scratch result
+ * instead, keep the previous status read-only, and finalize the status once here.
*/
static void dcn60_update_probe_status(
struct dc_probe_status *status,
@@ -1171,6 +1349,17 @@ static void dcn60_update_probe_status(
status->measuring = probe->target_state == DC_PROBE_MEASURING;
status->u = result.u;
+ if (probe->type == DC_PROBE_URGENT_ASSERTION_COUNT) {
+ struct dc_probe_urgent_assertion *assertion = &status->u.urgent_assertion;
+
+ if (dc_probe_scope_is_windowed(&probe->scope)) {
+ dcn60_decode_outstanding_req(&assertion->outstanding);
+ } else {
+ assertion->deassertion_count = 0;
+ assertion->outstanding.raw = 0;
+ }
+ }
+
switch (probe->type) {
case DC_PROBE_PEAK_MEM_BW:
case DC_PROBE_PEAK_MEM_BW_STRESSED:
@@ -1181,12 +1370,17 @@ static void dcn60_update_probe_status(
case DC_PROBE_MEM_LATENCY:
case DC_PROBE_URGENT_ASSERTION_COUNT:
case DC_PROBE_PREFETCH_DATA_SIZE:
+ case DC_PROBE_URGENT_REQUEST_COUNT:
status->valid = true;
break;
default:
status->valid = false;
break;
}
+
+ /* A window is valid only if its sequence was built and the end line was not missed. */
+ if (probe->target_state == DC_PROBE_MEASURED && dc_probe_scope_is_windowed(&probe->scope))
+ status->valid = result.valid;
}
/**
@@ -1204,6 +1398,7 @@ static bool is_probe_measurement_type_for_hubbub(enum dc_probe_type type)
case DC_PROBE_URGENT_ASSERTION_COUNT:
case DC_PROBE_PREFETCH_DATA_SIZE:
case DC_PROBE_URGENT_RAMP_LATENCY:
+ case DC_PROBE_URGENT_REQUEST_COUNT:
return true;
default:
return false;
@@ -1240,8 +1435,16 @@ void dcn60_program_perfmon(struct dc *dc, struct dc_state *context)
hwss_execute_sequence(dc, context->block_sequence, context->block_sequence_steps);
- for (i = 0; i < context->probe_count; i++)
+ for (i = 0; i < context->probe_count; i++) {
dcn60_update_probe_status(&context->probe_status[i], &context->probes[i]);
+
+ /* A stream that is not in the committed state has nothing to measure. */
+ if (context->probes[i].scope.type == DC_PROBE_SCOPE_STREAM
+ && context->probes[i].target_state != DC_PROBE_NOT_MEASURING
+ && !dcn60_get_otg_master_pipe(context,
+ context->probes[i].scope.u.stream.stream_id))
+ context->probe_status[i].valid = false;
+ }
}
static bool dcn60_has_active_memory_request(const struct dc *dc)
diff --git a/drivers/gpu/drm/amd/display/dc/hwss/hw_sequencer.h b/drivers/gpu/drm/amd/display/dc/hwss/hw_sequencer.h
index c2e256a40128..e447dd2c69ec 100644
--- a/drivers/gpu/drm/amd/display/dc/hwss/hw_sequencer.h
+++ b/drivers/gpu/drm/amd/display/dc/hwss/hw_sequencer.h
@@ -671,6 +671,18 @@ struct tg_wait_for_state_params {
enum crtc_state state;
};
+struct tg_wait_for_position_params {
+ struct timing_generator *tg;
+ unsigned int line;
+ unsigned int window_start; /* start line of the window that line ends, used with window_valid */
+ bool *window_valid; /* optional, cleared when line was already passed on entry */
+};
+
+struct hubp_get_outstanding_req_params {
+ struct hubp *hubp;
+ uint32_t *status;
+};
+
struct tg_set_vtg_params_params {
struct timing_generator *tg;
struct dc_crtc_timing *timing;
@@ -926,6 +938,10 @@ struct hubbub_perfmon_start_urgent_assertion_count_params {
struct hubbub *hubbub;
};
+struct hubbub_perfmon_start_urgent_request_count_params {
+ struct hubbub *hubbub;
+};
+
struct hubbub_perfmon_start_urgent_ramp_latency_params {
struct hubbub *hubbub;
struct hubbub_urgent_latency_params latency_params;
@@ -960,6 +976,12 @@ struct hubbub_perfmon_get_urgent_assertion_count_params {
struct hubbub *hubbub;
uint32_t refclk_mhz;
uint32_t *assertion_count;
+ uint32_t *deassertion_count;
+};
+
+struct hubbub_perfmon_get_urgent_request_count_params {
+ struct hubbub *hubbub;
+ uint32_t *request_count;
};
struct hubbub_perfmon_get_prefetch_data_size_params {
@@ -1407,6 +1429,8 @@ union block_sequence_params {
struct dsc_enable_with_opp_params dsc_enable_with_opp_params;
struct tg_program_global_sync_params tg_program_global_sync_params;
struct tg_wait_for_state_params tg_wait_for_state_params;
+ struct tg_wait_for_position_params tg_wait_for_position_params;
+ struct hubp_get_outstanding_req_params hubp_get_outstanding_req_params;
struct tg_set_vtg_params_params tg_set_vtg_params_params;
struct tg_setup_vertical_interrupt2_params tg_setup_vertical_interrupt2_params;
struct dpp_set_hdr_multiplier_params dpp_set_hdr_multiplier_params;
@@ -1450,12 +1474,14 @@ union block_sequence_params {
struct hubbub_perfmon_start_in_order_bw_params hubbub_perfmon_start_in_order_bw_params;
struct hubbub_perfmon_start_memory_latencies_params hubbub_perfmon_start_memory_latencies_params;
struct hubbub_perfmon_start_urgent_assertion_count_params hubbub_perfmon_start_urgent_assertion_count_params;
+ struct hubbub_perfmon_start_urgent_request_count_params hubbub_perfmon_start_urgent_request_count_params;
struct hubbub_perfmon_start_urgent_ramp_latency_params hubbub_perfmon_start_urgent_ramp_latency_params;
struct hubbub_perfmon_start_prefetch_data_size_params hubbub_perfmon_start_prefetch_data_size_params;
struct hubbub_perfmon_get_out_of_order_bw_params hubbub_perfmon_get_out_of_order_bw_params;
struct hubbub_perfmon_get_in_order_bw_params hubbub_perfmon_get_in_order_bw_params;
struct hubbub_perfmon_get_memory_latencies_params hubbub_perfmon_get_memory_latencies_params;
struct hubbub_perfmon_get_urgent_assertion_count_params hubbub_perfmon_get_urgent_assertion_count_params;
+ struct hubbub_perfmon_get_urgent_request_count_params hubbub_perfmon_get_urgent_request_count_params;
struct hubbub_perfmon_get_prefetch_data_size_params hubbub_perfmon_get_prefetch_data_size_params;
struct hubbub_perfmon_get_urgent_ramp_latency_params hubbub_perfmon_get_urgent_ramp_latency_params;
struct hubp_clk_cntl_params hubp_clk_cntl_params;
@@ -1657,6 +1683,8 @@ enum block_sequence_func {
DSC_ENABLE_WITH_OPP,
TG_PROGRAM_GLOBAL_SYNC,
TG_WAIT_FOR_STATE,
+ TG_WAIT_FOR_POSITION,
+ HUBP_GET_OUTSTANDING_REQ,
TG_SET_VTG_PARAMS,
TG_SETUP_VERTICAL_INTERRUPT2,
HUBP_PROGRAM_DET_SIZE,
@@ -1767,12 +1795,14 @@ enum block_sequence_func {
HUBBUB_PERFMON_START_IN_ORDER_BW,
HUBBUB_PERFMON_START_MEMORY_LATENCIES,
HUBBUB_PERFMON_START_URGENT_ASSERTION_COUNT,
+ HUBBUB_PERFMON_START_URGENT_REQUEST_COUNT,
HUBBUB_PERFMON_START_URGENT_RAMP_LATENCY,
HUBBUB_PERFMON_START_PREFETCH_DATA_SIZE,
HUBBUB_PERFMON_GET_OUT_OF_ORDER_BW,
HUBBUB_PERFMON_GET_IN_ORDER_BW,
HUBBUB_PERFMON_GET_MEMORY_LATENCIES,
HUBBUB_PERFMON_GET_URGENT_ASSERTION_COUNT,
+ HUBBUB_PERFMON_GET_URGENT_REQUEST_COUNT,
HUBBUB_PERFMON_GET_PREFETCH_DATA_SIZE,
HUBBUB_PERFMON_GET_URGENT_RAMP_LATENCY,
LEGACY_CLK_MGR_INIT_CLOCKS,
@@ -2425,6 +2455,10 @@ void hwss_tg_program_global_sync(union block_sequence_params *params);
void hwss_tg_wait_for_state(union block_sequence_params *params);
+void hwss_tg_wait_for_position(union block_sequence_params *params);
+
+void hwss_hubp_get_outstanding_req(union block_sequence_params *params);
+
void hwss_tg_set_vtg_params(union block_sequence_params *params);
void hwss_hubp_enable_3dlut_fl(union block_sequence_params *params);
@@ -2518,6 +2552,8 @@ void hwss_hubbub_perfmon_start_memory_latencies(union block_sequence_params *par
void hwss_hubbub_perfmon_start_urgent_assertion_count(union block_sequence_params *params);
+void hwss_hubbub_perfmon_start_urgent_request_count(union block_sequence_params *params);
+
void hwss_hubbub_perfmon_start_urgent_ramp_latency(union block_sequence_params *params);
void hwss_hubbub_perfmon_start_prefetch_data_size(union block_sequence_params *params);
@@ -2530,6 +2566,8 @@ void hwss_hubbub_perfmon_get_memory_latencies(union block_sequence_params *param
void hwss_hubbub_perfmon_get_urgent_assertion_count(union block_sequence_params *params);
+void hwss_hubbub_perfmon_get_urgent_request_count(union block_sequence_params *params);
+
void hwss_hubbub_perfmon_get_prefetch_data_size(union block_sequence_params *params);
void hwss_hubbub_perfmon_get_urgent_ramp_latency(union block_sequence_params *params);
@@ -2711,6 +2749,13 @@ void hwss_add_tg_program_global_sync(struct block_sequence_state *seq_state,
void hwss_add_tg_wait_for_state(struct block_sequence_state *seq_state,
struct timing_generator *tg, enum crtc_state state);
+void hwss_add_tg_wait_for_position(struct block_sequence_state *seq_state,
+ struct timing_generator *tg, unsigned int line,
+ unsigned int window_start, bool *window_valid);
+
+void hwss_add_hubp_get_outstanding_req(struct block_sequence_state *seq_state,
+ struct hubp *hubp, uint32_t *status);
+
void hwss_add_tg_set_vtg_params(struct block_sequence_state *seq_state,
struct timing_generator *tg, struct dc_crtc_timing *dc_crtc_timing, bool program_fp2);
@@ -2895,6 +2940,9 @@ void hwss_add_hubbub_perfmon_start_memory_latencies(struct block_sequence_state
void hwss_add_hubbub_perfmon_start_urgent_assertion_count(struct block_sequence_state *seq_state,
struct hubbub *hubbub);
+void hwss_add_hubbub_perfmon_start_urgent_request_count(struct block_sequence_state *seq_state,
+ struct hubbub *hubbub);
+
void hwss_add_hubbub_perfmon_start_urgent_ramp_latency(struct block_sequence_state *seq_state,
struct hubbub *hubbub,
const struct hubbub_urgent_latency_params *latency_params);
@@ -2916,7 +2964,10 @@ void hwss_add_hubbub_perfmon_get_memory_latencies(struct block_sequence_state *s
void hwss_add_hubbub_perfmon_get_urgent_assertion_count(struct block_sequence_state *seq_state,
struct hubbub *hubbub, uint32_t refclk_mhz,
- uint32_t *assertion_count);
+ uint32_t *assertion_count, uint32_t *deassertion_count);
+
+void hwss_add_hubbub_perfmon_get_urgent_request_count(struct block_sequence_state *seq_state,
+ struct hubbub *hubbub, uint32_t *request_count);
void hwss_add_hubbub_perfmon_get_prefetch_data_size(struct block_sequence_state *seq_state,
struct hubbub *hubbub, uint32_t *prefetch_data_size);
diff --git a/drivers/gpu/drm/amd/display/dc/inc/hw/dchubbub.h b/drivers/gpu/drm/amd/display/dc/inc/hw/dchubbub.h
index 7280f57f75bf..0b5fe1ca04e0 100644
--- a/drivers/gpu/drm/amd/display/dc/inc/hw/dchubbub.h
+++ b/drivers/gpu/drm/amd/display/dc/inc/hw/dchubbub.h
@@ -294,6 +294,9 @@ struct hubbub_funcs {
uint32_t *assertion_count,
uint32_t *deassertion_count,
uint32_t *timestamp_us);
+ void (*start_measuring_urgent_request_count)(
+ struct hubbub *hubbub);
+ uint32_t (*get_urgent_request_count)(struct hubbub *hubbub);
void (*start_measuring_urgent_ramp_latency)(
struct hubbub *hubbub,
const struct hubbub_urgent_latency_params *params);
diff --git a/drivers/gpu/drm/amd/display/dc/inc/hw/hubp.h b/drivers/gpu/drm/amd/display/dc/inc/hw/hubp.h
index d1cbcb87d271..d6b23bd3cdce 100644
--- a/drivers/gpu/drm/amd/display/dc/inc/hw/hubp.h
+++ b/drivers/gpu/drm/amd/display/dc/inc/hw/hubp.h
@@ -100,6 +100,16 @@ enum hubp_3dlut_fl_crossbar_bit_slice {
hubp_3dlut_fl_crossbar_bit_slice_48_63 = 3
};
+/* Bits returned by hubp_get_outstanding_req_status(), decoded from DCHUBP_CNTL. */
+#define HUBP_OUTSTANDING_ANY 0x1 /* a request is outstanding in HUBP */
+#define HUBP_OUTSTANDING_DRQ 0x2 /* a data request is outstanding */
+#define HUBP_OUTSTANDING_CRQ_TRQ 0x4 /* a chunk/meta or translation request is outstanding */
+#define HUBP_NOT_IN_BLANK 0x8 /* HUBP has not finished requesting for the frame */
+
+/* Request types in the HUBP_XRQ_NO_OUTSTANDING_REQ field of DCHUBP_CNTL, a bit reads 1 when idle. */
+#define HUBP_XRQ_NO_OUTSTANDING_DRQ 0x1
+#define HUBP_XRQ_NO_OUTSTANDING_CRQ_TRQ 0x8
+
struct hubp {
const struct hubp_funcs *funcs;
struct dc_context *ctx;
@@ -261,6 +271,8 @@ struct hubp_funcs {
struct hubp *hubp,
bool enable);
bool (*hubp_in_blank)(struct hubp *hubp);
+ /* Decoded outstanding request and blank status, see HUBP_OUTSTANDING_*. */
+ uint32_t (*hubp_get_outstanding_req_status)(struct hubp *hubp);
void (*hubp_soft_reset)(struct hubp *hubp, bool reset);
void (*hubp_set_flip_int)(struct hubp *hubp);
--
2.43.0
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [PATCH 17/33] drm/amd/display: Fix G7 P-state aperture addresses
2026-11-16 21:50 [PATCH 00/33] DC Patches November 23, 2026 James Lin
` (15 preceding siblings ...)
2026-11-16 21:50 ` [PATCH 16/33] drm/amd/display: Add urgent request and assertion probes James Lin
@ 2026-11-16 21:50 ` James Lin
2026-11-16 21:50 ` [PATCH 18/33] drm/amd/display: Set stream min/max refresh from VRR config James Lin
` (15 subsequent siblings)
32 siblings, 0 replies; 34+ messages in thread
From: James Lin @ 2026-11-16 21:50 UTC (permalink / raw)
To: amd-gfx
Cc: Harry Wentland, Leo Li, Aurabindo Pillai, Roman Li, Wayne Lin,
Tom Chung, Fangzhi Zuo, Dan Wheeler, Ray Wu, Ivan Lipski,
Alex Hung, James Lin, Chenyu Chen, Alvin Lee, James Lin
From: Ivan Lipski <ivan.lipski@amd.com>
[Why&How]
On GMC v13, fb_start can differ from vram_start. Use vram_start when
translating firmware aperture addresses to MC addresses.
Cc: Alvin Lee <alvin.lee2@amd.com>
Signed-off-by: Ivan Lipski <ivan.lipski@amd.com>
Signed-off-by: James Lin <pinglei.lin@amd.com>
---
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_dmub.c | 2 +-
1 file changed, 1 insertion(+), 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 ebd8130cb04d..b251351fdfec 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
@@ -213,7 +213,7 @@ dm_get_alt_channel_pstate_switch_aperture(struct amdgpu_device *adev,
/* DML2 requires the reserved-region base in MC address space. */
aperture_mc_bases[i] = apertures[i].reserved_region_start +
- adev->gmc.fb_start - adev->vm_manager.vram_base_offset;
+ adev->gmc.vram_start - adev->vm_manager.vram_base_offset;
}
for (i = 0; i < ARRAY_SIZE(region_ids); i++) {
--
2.43.0
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [PATCH 18/33] drm/amd/display: Set stream min/max refresh from VRR config
2026-11-16 21:50 [PATCH 00/33] DC Patches November 23, 2026 James Lin
` (16 preceding siblings ...)
2026-11-16 21:50 ` [PATCH 17/33] drm/amd/display: Fix G7 P-state aperture addresses James Lin
@ 2026-11-16 21:50 ` James Lin
2026-11-16 21:50 ` [PATCH 19/33] drm/amd/display: Add DC2 wrapped initialization for DCN401 James Lin
` (14 subsequent siblings)
32 siblings, 0 replies; 34+ messages in thread
From: James Lin @ 2026-11-16 21:50 UTC (permalink / raw)
To: amd-gfx
Cc: Harry Wentland, Leo Li, Aurabindo Pillai, Roman Li, Wayne Lin,
Tom Chung, Fangzhi Zuo, Dan Wheeler, Ray Wu, Ivan Lipski,
Alex Hung, James Lin, Chenyu Chen, James Lin
From: Ivan Lipski <ivan.lipski@amd.com>
[Why]
FAMS2 on DCN6 uses the stream's max_vtotal to estimate the DRR prepare
time against the remaining PPT window before allowing a UCLK switch.
amdgpu_dm never set stream->timing.min/max_refresh_in_uhz, so DML
derived max_vtotal from the HW vtotal limit (~0x7FFF), causing DMUB to
incorrectly reject P-state switches.
[How]
Populate stream timing min/max refresh from the freesync config when
VRR is supported.
Cc: Jerry Zuo <jerry.zuo@amd.com>
Signed-off-by: Ivan Lipski <ivan.lipski@amd.com>
Signed-off-by: James Lin <pinglei.lin@amd.com>
---
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_freesync.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_freesync.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_freesync.c
index 40f1dd8af21c..78dbdbce8c04 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_freesync.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_freesync.c
@@ -187,6 +187,9 @@ void amdgpu_dm_get_freesync_config_for_crtc(
config.vsif_supported = true;
config.btr = true;
+ new_crtc_state->stream->timing.min_refresh_in_uhz = config.min_refresh_in_uhz;
+ new_crtc_state->stream->timing.max_refresh_in_uhz = config.max_refresh_in_uhz;
+
if (fs_vid_mode) {
config.state = VRR_STATE_ACTIVE_FIXED;
config.fixed_refresh_in_uhz = new_crtc_state->freesync_config.fixed_refresh_in_uhz;
--
2.43.0
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [PATCH 19/33] drm/amd/display: Add DC2 wrapped initialization for DCN401
2026-11-16 21:50 [PATCH 00/33] DC Patches November 23, 2026 James Lin
` (17 preceding siblings ...)
2026-11-16 21:50 ` [PATCH 18/33] drm/amd/display: Set stream min/max refresh from VRR config James Lin
@ 2026-11-16 21:50 ` James Lin
2026-11-16 21:50 ` [PATCH 20/33] drm/amd/display: Honor the Replay stream regeneration wait event James Lin
` (13 subsequent siblings)
32 siblings, 0 replies; 34+ messages in thread
From: James Lin @ 2026-11-16 21:50 UTC (permalink / raw)
To: amd-gfx
Cc: Harry Wentland, Leo Li, Aurabindo Pillai, Roman Li, Wayne Lin,
Tom Chung, Fangzhi Zuo, Dan Wheeler, Ray Wu, Ivan Lipski,
Alex Hung, James Lin, Chenyu Chen, Tomasz Siemek, Jun Lei,
James Lin
From: Tomasz Siemek <tomasz.siemek@amd.com>
[why]
DC2 needs a wrapped hardware initialization path with software state
management separated from hardware sequencing.
[how]
- Add staged DCN401 initialization with builder postprocessing and
workaround application before each sequence is executed.
- Add a PMFW messenger for firmware communication and DPM clock queries.
- Resolve DMUB capabilities, reference clocks, DPM limits, bandwidth
parameters and watermark ranges in core2 instead of clk_mgr.
- Add wrapped initialization selection through DAL_DC2_INIT while
retaining legacy initialization as the default.
Cc: Jun Lei <jun.lei@amd.com>
Signed-off-by: Tomasz Siemek <tomasz.siemek@amd.com>
Signed-off-by: James Lin <pinglei.lin@amd.com>
---
drivers/gpu/drm/amd/display/dc/Makefile | 3 +
.../amd/display/dc/bls_builder/bls_builder.c | 19 +
.../amd/display/dc/bls_builder/bls_builder.h | 68 +-
.../dc/bls_builder/bls_builder_internal.h | 3 +
.../dc/bls_builder/dcn401_init_builder.c | 812 ++++++++++--------
.../dc/bls_builder/dcn401_init_builder.h | 16 -
.../bls_builder/dcn401_init_builder_legacy.c | 77 ++
.../dc/bls_builder/dcn401_query_builder.c | 41 +
.../display/dc/bls_executor/bls_executor.c | 79 +-
.../display/dc/bls_executor/bls_executor.h | 2 +-
.../gpu/drm/amd/display/dc/core2/dc_core2.c | 2 +
.../drm/amd/display/dc/core2/dc_core2_init.c | 298 ++++++-
drivers/gpu/drm/amd/display/dc/dc.h | 1 +
.../amd/display/dc/dc_api_dispatch/api_shim.c | 1 +
.../amd/display/dc/dc_api_dispatch/api_shim.h | 3 +
.../drm/amd/display/dc/hwss/hw_sequencer.h | 19 +-
.../gpu/drm/amd/display/dc/inc/core_types.h | 3 +
.../amd/display/dc/inc/dc_core_interface.h | 6 +
.../dc/pmfw_messenger/dcn401_pmfw_messenger.c | 211 +++++
.../dc/pmfw_messenger/pmfw_messenger.c | 62 ++
.../dc/pmfw_messenger/pmfw_messenger.h | 118 +++
21 files changed, 1395 insertions(+), 449 deletions(-)
create mode 100644 drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_query_builder.c
create mode 100644 drivers/gpu/drm/amd/display/dc/pmfw_messenger/dcn401_pmfw_messenger.c
create mode 100644 drivers/gpu/drm/amd/display/dc/pmfw_messenger/pmfw_messenger.c
create mode 100644 drivers/gpu/drm/amd/display/dc/pmfw_messenger/pmfw_messenger.h
diff --git a/drivers/gpu/drm/amd/display/dc/Makefile b/drivers/gpu/drm/amd/display/dc/Makefile
index a7dd6a7ba492..4dac84158822 100644
--- a/drivers/gpu/drm/amd/display/dc/Makefile
+++ b/drivers/gpu/drm/amd/display/dc/Makefile
@@ -91,9 +91,12 @@ FILES += bls_builder/dcn401_init_builder.o
FILES += bls_builder/dcn401_init_builder_legacy.o
FILES += bls_builder/dcn401_non_seamless_builder.o
FILES += state_facts/state_facts.o
+FILES += bls_builder/dcn401_query_builder.o
FILES += bls_executor/bls_executor.o
FILES += workaround_manager/workaround_manager.o
FILES += dmub_messenger/dmub_messenger.o
+FILES += pmfw_messenger/pmfw_messenger.o
+FILES += pmfw_messenger/dcn401_pmfw_messenger.o
AMD_DISPLAY_FILES += $(addprefix $(AMDDALPATH)/dc/, $(FILES))
diff --git a/drivers/gpu/drm/amd/display/dc/bls_builder/bls_builder.c b/drivers/gpu/drm/amd/display/dc/bls_builder/bls_builder.c
index 8ac202487189..80771e7751bb 100644
--- a/drivers/gpu/drm/amd/display/dc/bls_builder/bls_builder.c
+++ b/drivers/gpu/drm/amd/display/dc/bls_builder/bls_builder.c
@@ -6,6 +6,25 @@
#include "dm_services.h"
#include "bls_builder/bls_builder_internal.h"
+const struct bls_builder *dcn401_bls_builder_create(
+ enum bls_builder_name name)
+{
+ switch (name) {
+ case DCN_DECL_INITIALIZATION:
+ return dcn401_initialization_builder();
+ case DCN_DECL_INITIALIZATION_LEGACY:
+ return dcn401_legacy_initialization_builder();
+ case DCN_DECL_NON_SEAMLESS_COMMIT:
+ return dcn401_non_seamless_commit_builder();
+ case DCN_DECL_SEAMLESS_UPDATE:
+ return dcn401_seamless_update_builder();
+ case DCN_DECL_QUERY_ACCELERATED_MODE:
+ return dcn401_accelerated_mode_query_builder();
+ default:
+ return NULL;
+ }
+}
+
const struct bls_builder *bls_builder_create(struct dc *dc,
enum bls_builder_name name)
{
diff --git a/drivers/gpu/drm/amd/display/dc/bls_builder/bls_builder.h b/drivers/gpu/drm/amd/display/dc/bls_builder/bls_builder.h
index ad0348b3cae5..627c6186d135 100644
--- a/drivers/gpu/drm/amd/display/dc/bls_builder/bls_builder.h
+++ b/drivers/gpu/drm/amd/display/dc/bls_builder/bls_builder.h
@@ -11,6 +11,7 @@
#include "hwss/hw_sequencer.h"
#include "bls_builder/dmub_abi.h"
#include "bls_builder/bls_builder_legacy_init.h"
+#include "pmfw_messenger/pmfw_messenger.h"
#define DC2_BLS_MAX_STEPS 192
@@ -18,7 +19,6 @@ enum bls_builder_result {
BLS_BUILD_SUCCESS,
BLS_BUILD_ERROR_UNSUPPORTED_STATE_UPDATE,
BLS_BUILD_ERROR_RESOURCE_MAPPING,
- BLS_BUILD_ERROR_DMUB_ABI_UNRESOLVED,
};
enum bls_builder_name {
@@ -35,22 +35,59 @@ enum bls_builder_kind {
BLS_BUILDER_IMPERATIVE,
};
-struct bls_builder_output_init {
+#define BLS_BUILDER_INIT_MAX_STAGE_COUNT 4
+
+struct bls_builder_dpm {
+ uint32_t num_levels;
+ uint32_t dpm_level[PMFW_MAX_NUM_DPM_LVL];
+ uint32_t dc_mode_max;
+};
+
+struct bls_builder_dpm_levels {
+ uint32_t levels[PMFW_MAX_NUM_DPM_LVL];
+};
+
+struct dcn401_bls_builder_initialization_stage_1 {
unsigned int xtalin_clock_inKhz;
unsigned int dccg_ref_clock_inKhz;
+ struct dmub_feature_caps feature_caps;
+ uint32_t smu_version;
+ uint32_t num_umc_channels;
+ uint32_t dpm_level_count[PMFW_CLOCK_COUNT];
+ int32_t dc_mode_max[PMFW_CLOCK_COUNT];
+};
+
+struct dcn401_bls_builder_initialization_stage_2 {
unsigned int dchub_ref_clock_inKhz;
- unsigned int dchub_ref_clock_inKhz_before;
- unsigned int backlight;
- bool dcmode_power_limits_present;
- unsigned int dmub_stop_fw_response;
+ struct bls_builder_dpm_levels dpm_levels[PMFW_CLOCK_COUNT];
+};
+
+struct bls_builder_initialization_output {
struct dmub_abi dmub_abi;
- union dmub_rb_cmd dmub_query_feature_caps_cmd;
- union dmub_rb_cmd dmub_initialize_dcn_cmd;
+ uint32_t smu_version;
+ uint32_t num_umc_channels;
+ unsigned int xtalin_clock_inKhz;
+ unsigned int dccg_ref_clock_inKhz;
+ unsigned int dchub_ref_clock_inKhz;
+ struct bls_builder_dpm dpm_clocks[PMFW_CLOCK_COUNT];
+};
+
+struct dcn401_bls_builder_initialization_stages {
+ struct dcn401_bls_builder_initialization_stage_1 stage_1;
+ struct dcn401_bls_builder_initialization_stage_2 stage_2;
+};
+
+struct bls_builder_initialization {
+ uint32_t stage;
+ union {
+ struct dcn401_bls_builder_initialization_stages dcn401_stages;
+ };
+ struct bls_builder_initialization_output output;
};
struct bls_builder_output_targets {
union {
- struct bls_builder_output_init *DCN_DECL_INITIALIZATION;
+ struct bls_builder_initialization *DCN_DECL_INITIALIZATION;
struct bls_builder_legacy_hw_init_info *DCN_DECL_INITIALIZATION_LEGACY;
bool *DCN_DECL_QUERY_ACCELERATED_MODE;
};
@@ -66,16 +103,6 @@ struct bls_builder_declarative_params {
struct dc *dc;
const struct dc_state *current_state;
const struct dc_state *new_state;
- const struct dmub_abi *dmub_abi;
- const struct dmub_srv_hw_params *dmub_hw_params;
- /*
- * Filled when the caller does not pass dmub_hw_params and dmub_srv
- * already retained framebuffer windows. fb_info on dmub_srv is
- * const, so the window table is copied here before the PSP entry
- * points at owned_dmub_hw_params.
- */
- struct dmub_srv_hw_params owned_dmub_hw_params;
- struct dmub_srv_fb_info owned_dmub_fb_info;
struct bls_builder_output_targets *out_targets;
struct block_sequence head_sequence[DC2_BLS_MAX_STEPS];
unsigned int head_num_steps;
@@ -89,6 +116,8 @@ typedef bool (*bls_builder_check_capability)(
typedef enum bls_builder_result (*bls_builder_build_declarative)(
struct bls_builder_declarative_params *params);
+typedef void (*bls_builder_postprocess)(struct bls_builder_declarative_params *params);
+
struct bls_builder {
enum bls_builder_name name;
enum bls_builder_kind kind;
@@ -96,6 +125,7 @@ struct bls_builder {
union {
bls_builder_build_declarative declarative;
} build;
+ bls_builder_postprocess postprocess;
};
const struct bls_builder *bls_builder_create(struct dc *dc,
diff --git a/drivers/gpu/drm/amd/display/dc/bls_builder/bls_builder_internal.h b/drivers/gpu/drm/amd/display/dc/bls_builder/bls_builder_internal.h
index ebf315e31ad8..265c4c2b4b9e 100644
--- a/drivers/gpu/drm/amd/display/dc/bls_builder/bls_builder_internal.h
+++ b/drivers/gpu/drm/amd/display/dc/bls_builder/bls_builder_internal.h
@@ -9,5 +9,8 @@
const struct bls_builder *dcn401_bls_builder_create(
enum bls_builder_name name);
+const struct bls_builder *dcn401_initialization_builder(void);
+const struct bls_builder *dcn401_legacy_initialization_builder(void);
+const struct bls_builder *dcn401_accelerated_mode_query_builder(void);
const struct bls_builder *dcn401_non_seamless_commit_builder(void);
const struct bls_builder *dcn401_seamless_update_builder(void);
diff --git a/drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_init_builder.c b/drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_init_builder.c
index 1dc502c0839c..cdf5e7ee04fd 100644
--- a/drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_init_builder.c
+++ b/drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_init_builder.c
@@ -9,441 +9,521 @@
#include "dccg.h"
#include "resource.h"
#include "dc_dmub_srv.h"
+#include "dc_bios_types.h"
#include "dmub_cmd.h"
#include "bls_builder/bls_builder_internal.h"
#include "bls_builder/dcn401_init_builder.h"
#include "bls_builder/dcn401_init_builder_legacy.h"
-static const enum block_sequence_func dcn401_dc2_init_sequence[] = {
- LEGACY_CLK_MGR_INIT_CLOCKS,
- LEGACY_CLK_MGR_IS_DC_MODE_PRESENT,
- DCCG_INITIALIZE_CLOCKS,
- DMUB_HALT_FW,
- PSP_RELOAD_DMUB_FW,
- DMUB_GPINT_SEND_AND_WAIT,
- DMUB_SEND_DMCUB_CMD,
- DMUB_INITIALIZE_DCN,
+enum dcn401_init_builder_stages {
+ DCN401_INIT_BUILDER_STAGE1,
+ DCN401_INIT_BUILDER_STAGE2,
+ DCN401_INIT_BUILDER_DONE,
+ DCN401_INIT_BUILDER_STAGE_COUNT,
};
-static enum bls_builder_result dcn401_check_initialization_support(
- const struct bls_builder_check_capability_params *params)
-{
- struct dc *dc;
-
- if (!params || !params->dc)
- return BLS_BUILD_ERROR_UNSUPPORTED_STATE_UPDATE;
+static_assert(DCN401_INIT_BUILDER_DONE <= BLS_BUILDER_INIT_MAX_STAGE_COUNT,
+ "Core runs at most BLS_BUILDER_INIT_MAX_STAGE_COUNT stages");
+
+enum dcn401_pmfw_clk {
+ DCN401_PMFW_CLK_SOCCLK = 1,
+ DCN401_PMFW_CLK_UCLK = 2,
+ DCN401_PMFW_CLK_FCLK = 3,
+ DCN401_PMFW_CLK_DISPCLK = 6,
+ DCN401_PMFW_CLK_DPPCLK = 7,
+ DCN401_PMFW_CLK_DCFCLK = 9,
+ DCN401_PMFW_CLK_DTBCLK = 10,
+};
- dc = params->dc;
- if (!dc->ctx || !dc->res_pool || !dc->res_pool->dccg)
- return BLS_BUILD_ERROR_RESOURCE_MAPPING;
- if (dc->config.seamless_boot_edp_requested)
- return BLS_BUILD_ERROR_UNSUPPORTED_STATE_UPDATE;
+#define DCN401_PMFW_CLK_PARAM(clk) ((uint32_t)(clk) << 16)
+#define DCN401_PMFW_DPM_FREQ_PARAM(clk, level) (DCN401_PMFW_CLK_PARAM(clk) | ((uint32_t)(level) & 0xFF))
+
+#define DCN401_PMFW_LEVEL_COUNT_INDEX 0xFF
+#define DCN401_PMFW_LEVEL_COUNT(clk) DCN401_PMFW_DPM_FREQ_PARAM(clk, DCN401_PMFW_LEVEL_COUNT_INDEX)
+
+#define DCN401_PMFW_SOCCLK_LEVEL_COUNT DCN401_PMFW_LEVEL_COUNT(DCN401_PMFW_CLK_SOCCLK)
+#define DCN401_PMFW_UCLK_LEVEL_COUNT DCN401_PMFW_LEVEL_COUNT(DCN401_PMFW_CLK_UCLK)
+#define DCN401_PMFW_FCLK_LEVEL_COUNT DCN401_PMFW_LEVEL_COUNT(DCN401_PMFW_CLK_FCLK)
+#define DCN401_PMFW_DISPCLK_LEVEL_COUNT DCN401_PMFW_LEVEL_COUNT(DCN401_PMFW_CLK_DISPCLK)
+#define DCN401_PMFW_DPPCLK_LEVEL_COUNT DCN401_PMFW_LEVEL_COUNT(DCN401_PMFW_CLK_DPPCLK)
+#define DCN401_PMFW_DCFCLK_LEVEL_COUNT DCN401_PMFW_LEVEL_COUNT(DCN401_PMFW_CLK_DCFCLK)
+#define DCN401_PMFW_DTBCLK_LEVEL_COUNT DCN401_PMFW_LEVEL_COUNT(DCN401_PMFW_CLK_DTBCLK)
+
+static const enum dcn401_pmfw_clk dcn401_pmfw_clocks[PMFW_CLOCK_COUNT] = {
+ [PMFW_CLOCK_DCFCLK] = DCN401_PMFW_CLK_DCFCLK,
+ [PMFW_CLOCK_SOCCLK] = DCN401_PMFW_CLK_SOCCLK,
+ [PMFW_CLOCK_DTBCLK] = DCN401_PMFW_CLK_DTBCLK,
+ [PMFW_CLOCK_DISPCLK] = DCN401_PMFW_CLK_DISPCLK,
+ [PMFW_CLOCK_DPPCLK] = DCN401_PMFW_CLK_DPPCLK,
+ [PMFW_CLOCK_UCLK] = DCN401_PMFW_CLK_UCLK,
+ [PMFW_CLOCK_FCLK] = DCN401_PMFW_CLK_FCLK,
+};
- return BLS_BUILD_SUCCESS;
-}
+static const struct block_sequence dcn401_init_stage1_sequence[] = {
+ {
+ .func = DMUB_SEND_DMCUB_CMD2,
+ .params.send_dmcub_cmd2_params.cmd.cmd_common.header = {
+ .type = DMUB_CMD__DC_BLS,
+ .sub_type = DMUB_CMD__DC_BLS_DCN_INIT,
+ .payload_bytes = 0,
+ },
+ .params.send_dmcub_cmd2_params.wait_type = DM_DMUB_WAIT_TYPE_WAIT,
+ },
+ {
+ .func = DMUB_SEND_DMCUB_CMD2,
+ .params.send_dmcub_cmd2_params.cmd.query_feature_caps.header = {
+ .type = DMUB_CMD__QUERY_FEATURE_CAPS,
+ .ret_status = 1,
+ .payload_bytes = sizeof(struct dmub_cmd_query_feature_caps_data),
+ },
+ .params.send_dmcub_cmd2_params.wait_type = DM_DMUB_WAIT_TYPE_WAIT_WITH_REPLY,
+ },
+ {
+ .func = DMUB_SEND_DMCUB_CMD2,
+ .params.send_dmcub_cmd2_params.cmd.idle_opt_set_dc_power_state = {
+ .header = {
+ .type = DMUB_CMD__IDLE_OPT,
+ .sub_type = DMUB_CMD__IDLE_OPT_SET_DC_POWER_STATE,
+ .payload_bytes = sizeof(struct dmub_idle_opt_set_dc_power_state_data),
+ },
+ .data.power_state = DMUB_IDLE_OPT_DC_POWER_STATE_D0,
+ },
+ .params.send_dmcub_cmd2_params.wait_type = DM_DMUB_WAIT_TYPE_WAIT,
+ },
+ {
+ .func = DCCG_GET_REF_FREQ,
+ },
+ {
+ .func = PMFW_SEND_MESSAGE_AND_WAIT,
+ .params.pmfw_send_and_wait_params = {
+ .message = {
+ .msg_id = PMFW_MSG_GET_SMU_VERSION,
+ }
+ }
+ },
+ {
+ .func = PMFW_SEND_MESSAGE_AND_WAIT,
+ .params.pmfw_send_and_wait_params = {
+ .message = {
+ .msg_id = PMFW_MSG_GET_DRIVER_IF_VERSION,
+ }
+ }
+ },
+ {
+ .func = PMFW_SEND_MESSAGE_AND_WAIT,
+ .params.pmfw_send_and_wait_params = {
+ .message = {
+ .msg_id = PMFW_MSG_GET_MSG_HEADER_VERSION,
+ }
+ }
+ },
+ {
+ .func = PMFW_SEND_MESSAGE_AND_WAIT,
+ .params.pmfw_send_and_wait_params = {
+ .continue_on_error = true,
+ .message = {
+ .msg_id = PMFW_MSG_GET_NUM_UMC_CHANNELS,
+ }
+ }
+ },
+ {
+ .func = PMFW_SEND_MESSAGE_AND_WAIT,
+ .params.pmfw_send_and_wait_params = {
+ .continue_on_error = true,
+ .message = {
+ .msg_id = PMFW_MSG_GET_DPM_FREQ_BY_INDEX,
+ .param_count = 1,
+ .params = { DCN401_PMFW_SOCCLK_LEVEL_COUNT },
+ }
+ }
+ },
+ {
+ .func = PMFW_SEND_MESSAGE_AND_WAIT,
+ .params.pmfw_send_and_wait_params = {
+ .continue_on_error = true,
+ .message = {
+ .msg_id = PMFW_MSG_GET_DPM_FREQ_BY_INDEX,
+ .param_count = 1,
+ .params = { DCN401_PMFW_UCLK_LEVEL_COUNT },
+ }
+ }
+ },
+ {
+ .func = PMFW_SEND_MESSAGE_AND_WAIT,
+ .params.pmfw_send_and_wait_params = {
+ .continue_on_error = true,
+ .message = {
+ .msg_id = PMFW_MSG_GET_DPM_FREQ_BY_INDEX,
+ .param_count = 1,
+ .params = { DCN401_PMFW_FCLK_LEVEL_COUNT },
+ }
+ }
+ },
+ {
+ .func = PMFW_SEND_MESSAGE_AND_WAIT,
+ .params.pmfw_send_and_wait_params = {
+ .continue_on_error = true,
+ .message = {
+ .msg_id = PMFW_MSG_GET_DPM_FREQ_BY_INDEX,
+ .param_count = 1,
+ .params = { DCN401_PMFW_DISPCLK_LEVEL_COUNT },
+ }
+ }
+ },
+ {
+ .func = PMFW_SEND_MESSAGE_AND_WAIT,
+ .params.pmfw_send_and_wait_params = {
+ .continue_on_error = true,
+ .message = {
+ .msg_id = PMFW_MSG_GET_DPM_FREQ_BY_INDEX,
+ .param_count = 1,
+ .params = { DCN401_PMFW_DPPCLK_LEVEL_COUNT },
+ }
+ }
+ },
+ {
+ .func = PMFW_SEND_MESSAGE_AND_WAIT,
+ .params.pmfw_send_and_wait_params = {
+ .continue_on_error = true,
+ .message = {
+ .msg_id = PMFW_MSG_GET_DPM_FREQ_BY_INDEX,
+ .param_count = 1,
+ .params = { DCN401_PMFW_DCFCLK_LEVEL_COUNT },
+ }
+ }
+ },
+ {
+ .func = PMFW_SEND_MESSAGE_AND_WAIT,
+ .params.pmfw_send_and_wait_params = {
+ .continue_on_error = true,
+ .message = {
+ .msg_id = PMFW_MSG_GET_DPM_FREQ_BY_INDEX,
+ .param_count = 1,
+ .params = { DCN401_PMFW_DTBCLK_LEVEL_COUNT },
+ }
+ }
+ },
+
+ {
+ .func = PMFW_SEND_MESSAGE_AND_WAIT,
+ .params.pmfw_send_and_wait_params = {
+ .continue_on_error = true,
+ .message = {
+ .msg_id = PMFW_MSG_GET_DC_MODE_MAX_DPM_FREQ,
+ .param_count = 1,
+ .params = { DCN401_PMFW_CLK_PARAM(DCN401_PMFW_CLK_SOCCLK) },
+ }
+ }
+ },
+ {
+ .func = PMFW_SEND_MESSAGE_AND_WAIT,
+ .params.pmfw_send_and_wait_params = {
+ .continue_on_error = true,
+ .message = {
+ .msg_id = PMFW_MSG_GET_DC_MODE_MAX_DPM_FREQ,
+ .param_count = 1,
+ .params = { DCN401_PMFW_CLK_PARAM(DCN401_PMFW_CLK_UCLK) },
+ }
+ }
+ },
+ {
+ .func = PMFW_SEND_MESSAGE_AND_WAIT,
+ .params.pmfw_send_and_wait_params = {
+ .continue_on_error = true,
+ .message = {
+ .msg_id = PMFW_MSG_GET_DC_MODE_MAX_DPM_FREQ,
+ .param_count = 1,
+ .params = { DCN401_PMFW_CLK_PARAM(DCN401_PMFW_CLK_FCLK) },
+ }
+ }
+ },
+ {
+ .func = PMFW_SEND_MESSAGE_AND_WAIT,
+ .params.pmfw_send_and_wait_params = {
+ .continue_on_error = true,
+ .message = {
+ .msg_id = PMFW_MSG_GET_DC_MODE_MAX_DPM_FREQ,
+ .param_count = 1,
+ .params = { DCN401_PMFW_CLK_PARAM(DCN401_PMFW_CLK_DISPCLK) },
+ }
+ }
+ },
+ {
+ .func = PMFW_SEND_MESSAGE_AND_WAIT,
+ .params.pmfw_send_and_wait_params = {
+ .continue_on_error = true,
+ .message = {
+ .msg_id = PMFW_MSG_GET_DC_MODE_MAX_DPM_FREQ,
+ .param_count = 1,
+ .params = { DCN401_PMFW_CLK_PARAM(DCN401_PMFW_CLK_DCFCLK) },
+ }
+ }
+ },
+ {
+ .func = PMFW_SEND_MESSAGE_AND_WAIT,
+ .params.pmfw_send_and_wait_params = {
+ .continue_on_error = true,
+ .message = {
+ .msg_id = PMFW_MSG_GET_DC_MODE_MAX_DPM_FREQ,
+ .param_count = 1,
+ .params = { DCN401_PMFW_CLK_PARAM(DCN401_PMFW_CLK_DTBCLK) },
+ }
+ }
+ },
+ {
+ .func = HWSS_ENABLE_ACCELERATED_MODE,
+ },
+};
static bool dcn401_initialization_check_capability(
const struct bls_builder_check_capability_params *params)
{
- return dcn401_check_initialization_support(params) ==
- BLS_BUILD_SUCCESS;
+ return params && params->dc &&
+ !params->dc->config.seamless_boot_edp_requested;
}
-static enum bls_builder_result dcn401_validate_initialization_step(
- const struct bls_builder_declarative_params *params,
- enum block_sequence_func func)
+static enum bls_builder_result dcn401_build_initialization_step(
+ struct bls_builder_declarative_params *params,
+ struct block_sequence *step)
{
- struct bls_builder_output_init *out_init = NULL;
- struct clk_mgr *clk_mgr = params->dc->clk_mgr;
- struct dccg *dccg = params->dc->res_pool->dccg;
-
- if (params->out_targets)
- out_init = params->out_targets->DCN_DECL_INITIALIZATION;
-
- switch (func) {
- case LEGACY_CLK_MGR_INIT_CLOCKS:
- if (!clk_mgr || !clk_mgr->funcs ||
- !clk_mgr->funcs->init_clocks)
- return BLS_BUILD_ERROR_RESOURCE_MAPPING;
- return BLS_BUILD_SUCCESS;
- case LEGACY_CLK_MGR_IS_DC_MODE_PRESENT:
- if (!clk_mgr || !clk_mgr->funcs ||
- !clk_mgr->funcs->is_dc_mode_present ||
- !out_init)
- return BLS_BUILD_ERROR_RESOURCE_MAPPING;
- return BLS_BUILD_SUCCESS;
- case DCCG_INITIALIZE_CLOCKS:
- if (!dccg->funcs || !dccg->funcs->dccg_init)
- return BLS_BUILD_ERROR_RESOURCE_MAPPING;
- return BLS_BUILD_SUCCESS;
- case DMUB_GPINT_SEND_AND_WAIT:
- case DMUB_HALT_FW: {
- struct dc_context *ctx = params->dc->ctx;
- struct dmub_srv *dmub;
-
- if (!ctx || !ctx->dmub_srv || !ctx->dmub_srv->dmub || !out_init)
- return BLS_BUILD_ERROR_RESOURCE_MAPPING;
- dmub = ctx->dmub_srv->dmub;
- if (!dmub->sw_init || !dmub->hw_funcs.set_gpint ||
- !dmub->hw_funcs.is_gpint_acked ||
- !dmub->hw_funcs.get_gpint_response)
- return BLS_BUILD_ERROR_RESOURCE_MAPPING;
- return BLS_BUILD_SUCCESS;
- }
- case PSP_RELOAD_DMUB_FW: {
- struct dmub_srv *dmub;
-
- if (!params->dc->ctx || !params->dc->ctx->dmub_srv ||
- !params->dc->ctx->dmub_srv->dmub)
- return BLS_BUILD_ERROR_RESOURCE_MAPPING;
- /*
- * An explicit caller pointer wins, including a test double
- * whose fb_info is still empty. Otherwise use the windows
- * dmub_srv retained from the DM's earlier hw init.
- */
- if (params->dmub_hw_params)
- return BLS_BUILD_SUCCESS;
- dmub = params->dc->ctx->dmub_srv->dmub;
- if (!dmub->fb_info ||
- dmub->fb_info->num_fb < DMUB_WINDOW_TOTAL)
- return BLS_BUILD_ERROR_RESOURCE_MAPPING;
- return BLS_BUILD_SUCCESS;
- }
- case DMUB_SEND_DMCUB_CMD:
- case DMUB_INITIALIZE_DCN:
- if (!params->dc->ctx || !params->dc->ctx->dmub_srv ||
- !params->dc->ctx->dmub_srv->dmub || !out_init)
- return BLS_BUILD_ERROR_RESOURCE_MAPPING;
- return BLS_BUILD_SUCCESS;
+ struct dc *dc = params->dc;
+ struct dcn401_bls_builder_initialization_stages *stages =
+ ¶ms->out_targets->DCN_DECL_INITIALIZATION->dcn401_stages;
+ struct block_sequence_state sequence = {
+ .steps = params->head_sequence,
+ .num_steps = ¶ms->head_num_steps,
+ };
+
+ switch (step->func) {
+ case DMUB_SEND_DMCUB_CMD2:
+ step->params.send_dmcub_cmd2_params.ctx = dc->ctx;
+ break;
+ case DCCG_GET_REF_FREQ:
+ step->params.dccg_get_ref_freq_params.dccg = dc->res_pool->dccg;
+ step->params.dccg_get_ref_freq_params.xtalin_khz =
+ dc->ctx->dc_bios->fw_info.pll_info.crystal_frequency;
+ step->params.dccg_get_ref_freq_params.out_xtalin_khz =
+ &stages->stage_1.xtalin_clock_inKhz;
+ step->params.dccg_get_ref_freq_params.out_dccg_ref_khz =
+ &stages->stage_1.dccg_ref_clock_inKhz;
+ break;
+ case HUBBUB_GET_DCHUB_REF_FREQ:
+ step->params.hubbub_get_dchub_ref_freq_params.hubbub = dc->res_pool->hubbub;
+ step->params.hubbub_get_dchub_ref_freq_params.dccg_ref_khz =
+ stages->stage_1.dccg_ref_clock_inKhz;
+ step->params.hubbub_get_dchub_ref_freq_params.out_dchub_ref_khz =
+ &stages->stage_2.dchub_ref_clock_inKhz;
+ break;
+ case HWSS_ENABLE_ACCELERATED_MODE:
+ step->params.dc_init_call_params.dc = dc;
+ break;
+ case PMFW_SEND_MESSAGE_AND_WAIT:
+ break;
default:
return BLS_BUILD_ERROR_UNSUPPORTED_STATE_UPDATE;
}
-}
-
-enum bls_builder_result dcn401_build_clk_mgr_init(
- struct clk_mgr *clk_mgr, struct block_sequence_state *sequence)
-{
- union block_sequence_params bls_params = {0};
- bls_params.legacy_clk_mgr_init_clocks_params.clk_mgr = clk_mgr;
- if (!bls_append(sequence, LEGACY_CLK_MGR_INIT_CLOCKS, &bls_params))
+ if (!bls_append(&sequence, step->func, &step->params))
return BLS_BUILD_ERROR_UNSUPPORTED_STATE_UPDATE;
return BLS_BUILD_SUCCESS;
}
-enum bls_builder_result dcn401_build_dc_mode_read(
- struct clk_mgr *clk_mgr, bool *out_dcmode_power_limits_present,
- struct block_sequence_state *sequence)
+static enum bls_builder_result dcn401_build_stage1(struct bls_builder_declarative_params *params)
{
- union block_sequence_params bls_params = {0};
-
- bls_params.legacy_clk_mgr_is_dc_mode_present_params.clk_mgr = clk_mgr;
- bls_params.legacy_clk_mgr_is_dc_mode_present_params
- .out_dcmode_power_limits_present =
- out_dcmode_power_limits_present;
- if (!bls_append(sequence, LEGACY_CLK_MGR_IS_DC_MODE_PRESENT,
- &bls_params))
- return BLS_BUILD_ERROR_UNSUPPORTED_STATE_UPDATE;
+ struct dcn401_bls_builder_initialization_stage_1 *stage_1 =
+ ¶ms->out_targets->DCN_DECL_INITIALIZATION->dcn401_stages.stage_1;
+ enum bls_builder_result result;
+ uint32_t step;
- return BLS_BUILD_SUCCESS;
-}
+ stage_1->xtalin_clock_inKhz = params->dc->res_pool->ref_clocks.xtalin_clock_inKhz;
+ stage_1->dccg_ref_clock_inKhz = params->dc->res_pool->ref_clocks.dccg_ref_clock_inKhz;
-enum bls_builder_result dcn401_build_dccg_init(
- struct dccg *dccg, struct block_sequence_state *sequence)
-{
- union block_sequence_params bls_params = {0};
+ for (step = 0; step < ARRAY_SIZE(dcn401_init_stage1_sequence); step++) {
+ struct block_sequence block = dcn401_init_stage1_sequence[step];
- bls_params.dccg_initialize_clocks_params.dccg = dccg;
- if (!bls_append(sequence, DCCG_INITIALIZE_CLOCKS, &bls_params))
- return BLS_BUILD_ERROR_UNSUPPORTED_STATE_UPDATE;
+ result = dcn401_build_initialization_step(params, &block);
+ if (result != BLS_BUILD_SUCCESS)
+ return result;
+ }
return BLS_BUILD_SUCCESS;
}
-static inline enum bls_builder_result dcn401_build_dmub_halt_fw(
- struct bls_builder_declarative_params *params,
- struct block_sequence_state *sequence)
+static enum bls_builder_result dcn401_build_pmfw_get_dpm_freq(
+ struct bls_builder_declarative_params *params, enum pmfw_clocks clock, uint32_t level)
{
- union block_sequence_params bls_params = {0};
- struct bls_builder_output_init *out_init =
- params->out_targets->DCN_DECL_INITIALIZATION;
-
- bls_params.dmub_gpint_params.command_code = DMUB_GPINT__STOP_FW;
- bls_params.dmub_gpint_params.param = 0;
- bls_params.dmub_gpint_params.response =
- &out_init->dmub_stop_fw_response;
- if (!bls_append(sequence, DMUB_HALT_FW, &bls_params))
- return BLS_BUILD_ERROR_UNSUPPORTED_STATE_UPDATE;
-
- return BLS_BUILD_SUCCESS;
-}
+ struct block_sequence block = {
+ .func = PMFW_SEND_MESSAGE_AND_WAIT,
+ .params.pmfw_send_and_wait_params = {
+ .continue_on_error = true,
+ .message = {
+ .msg_id = PMFW_MSG_GET_DPM_FREQ_BY_INDEX,
+ .param_count = 1,
+ .params = {
+ DCN401_PMFW_DPM_FREQ_PARAM(dcn401_pmfw_clocks[clock], level),
+ }
+ }
+ }
+ };
-static const struct dmub_srv_hw_params *dcn401_psp_hw_params(
- struct bls_builder_declarative_params *params)
-{
- struct dmub_srv *dmub;
-
- if (params->dmub_hw_params)
- return params->dmub_hw_params;
-
- dmub = params->dc->ctx->dmub_srv->dmub;
- params->owned_dmub_fb_info = *dmub->fb_info;
- memset(¶ms->owned_dmub_hw_params, 0,
- sizeof(params->owned_dmub_hw_params));
- params->owned_dmub_hw_params.fb_info = ¶ms->owned_dmub_fb_info;
- params->owned_dmub_hw_params.soc_fb_info = dmub->soc_fb_info;
- params->owned_dmub_hw_params.psp_version = dmub->psp_version;
- return ¶ms->owned_dmub_hw_params;
+ return dcn401_build_initialization_step(params, &block);
}
-static inline enum bls_builder_result dcn401_build_psp_reload(
- struct bls_builder_declarative_params *params,
- struct block_sequence_state *sequence)
+static enum bls_builder_result dcn401_build_stage2(struct bls_builder_declarative_params *params)
{
- union block_sequence_params bls_params = {0};
-
- bls_params.psp_reload_dmub_fw_params.dmub =
- params->dc->ctx->dmub_srv->dmub;
- bls_params.psp_reload_dmub_fw_params.hw_params =
- dcn401_psp_hw_params(params);
- if (!bls_append(sequence, PSP_RELOAD_DMUB_FW, &bls_params))
- return BLS_BUILD_ERROR_UNSUPPORTED_STATE_UPDATE;
-
- return BLS_BUILD_SUCCESS;
-}
+ struct dcn401_bls_builder_initialization_stages *stages =
+ ¶ms->out_targets->DCN_DECL_INITIALIZATION->dcn401_stages;
+ struct block_sequence block = { .func = HUBBUB_GET_DCHUB_REF_FREQ };
+ enum bls_builder_result result;
+ uint32_t clock, level;
-static inline enum bls_builder_result dcn401_build_dmub_fw_version(
- struct bls_builder_declarative_params *params,
- struct block_sequence_state *sequence)
-{
- union block_sequence_params bls_params = {0};
- struct bls_builder_output_init *out_init =
- params->out_targets->DCN_DECL_INITIALIZATION;
+ stages->stage_2.dchub_ref_clock_inKhz =
+ params->dc->res_pool->ref_clocks.dchub_ref_clock_inKhz;
+ result = dcn401_build_initialization_step(params, &block);
+ if (result != BLS_BUILD_SUCCESS)
+ return result;
- bls_params.dmub_gpint_params.command_code =
- DMUB_GPINT__GET_FW_VERSION;
- bls_params.dmub_gpint_params.param = 0;
- bls_params.dmub_gpint_params.response =
- &out_init->dmub_abi.fw_version;
- if (!bls_append(sequence, DMUB_GPINT_SEND_AND_WAIT, &bls_params))
- return BLS_BUILD_ERROR_UNSUPPORTED_STATE_UPDATE;
+ if (stages->stage_1.smu_version != 0) {
+ for (clock = 0; clock < PMFW_CLOCK_COUNT; clock++) {
+ for (level = 0; level < stages->stage_1.dpm_level_count[clock]; level++) {
+ result = dcn401_build_pmfw_get_dpm_freq(params, clock, level);
+ if (result != BLS_BUILD_SUCCESS)
+ return result;
+ }
+ }
+ }
return BLS_BUILD_SUCCESS;
}
-bool dcn401_add_dmub_cmd(struct block_sequence_state *sequence,
- struct dc_context *ctx, union dmub_rb_cmd *cmd,
- enum dm_dmub_wait_type wait_type, bool continue_on_error)
-{
- union block_sequence_params bls_params = {0};
-
- bls_params.send_dmcub_cmd_params.ctx = ctx;
- bls_params.send_dmcub_cmd_params.cmd = cmd;
- bls_params.send_dmcub_cmd_params.wait_type = wait_type;
- bls_params.send_dmcub_cmd_params.continue_on_error = continue_on_error;
- return bls_append(sequence, DMUB_SEND_DMCUB_CMD, &bls_params);
-}
-
-void dcn401_fill_query_feature_caps_cmd(union dmub_rb_cmd *cmd)
+static void dcn401_process_pmfw_response(
+ struct dcn401_bls_builder_initialization_stages *stages,
+ const struct pmfw_send_and_wait_params *pmfw, uint32_t response)
{
- memset(cmd, 0, sizeof(*cmd));
- cmd->query_feature_caps.header.type = DMUB_CMD__QUERY_FEATURE_CAPS;
- cmd->query_feature_caps.header.sub_type = 0;
- cmd->query_feature_caps.header.ret_status = 1;
- cmd->query_feature_caps.header.payload_bytes =
- sizeof(struct dmub_cmd_query_feature_caps_data);
+ uint32_t level = pmfw->message.params[0] & 0xFF;
+ uint32_t clock;
+
+ switch (pmfw->message.msg_id) {
+ case PMFW_MSG_GET_SMU_VERSION:
+ stages->stage_1.smu_version = response;
+ break;
+ case PMFW_MSG_GET_NUM_UMC_CHANNELS:
+ stages->stage_1.num_umc_channels = response;
+ break;
+ case PMFW_MSG_GET_DPM_FREQ_BY_INDEX:
+ case PMFW_MSG_GET_DC_MODE_MAX_DPM_FREQ:
+ for (clock = 0; clock < PMFW_CLOCK_COUNT; clock++) {
+ if ((pmfw->message.params[0] >> 16) != (uint32_t)dcn401_pmfw_clocks[clock])
+ continue;
+ if (pmfw->message.msg_id == PMFW_MSG_GET_DC_MODE_MAX_DPM_FREQ)
+ stages->stage_1.dc_mode_max[clock] = (int32_t)response;
+ else if (level == DCN401_PMFW_LEVEL_COUNT_INDEX)
+ stages->stage_1.dpm_level_count[clock] = min(
+ (response & (1U << 31)) ? 2U : response & 0xFF,
+ (uint32_t)PMFW_MAX_NUM_DPM_LVL);
+ else if (level < stages->stage_1.dpm_level_count[clock])
+ stages->stage_2.dpm_levels[clock].levels[level] = response & 0xFFFF;
+ break;
+ }
+ break;
+ default:
+ break;
+ }
}
-static inline enum bls_builder_result dcn401_build_dmub_feature_caps(
- struct bls_builder_declarative_params *params,
- struct block_sequence_state *sequence)
+static void dcn401_fill_initialization_output(struct bls_builder_declarative_params *params)
{
- struct bls_builder_output_init *out_init =
+ struct bls_builder_initialization *initialization =
params->out_targets->DCN_DECL_INITIALIZATION;
- union dmub_rb_cmd *cmd = &out_init->dmub_query_feature_caps_cmd;
-
- dcn401_fill_query_feature_caps_cmd(cmd);
- if (!dcn401_add_dmub_cmd(sequence, params->dc->ctx, cmd,
- DM_DMUB_WAIT_TYPE_WAIT_WITH_REPLY, false))
- return BLS_BUILD_ERROR_UNSUPPORTED_STATE_UPDATE;
-
- return BLS_BUILD_SUCCESS;
+ const struct dcn401_bls_builder_initialization_stages *stages =
+ &initialization->dcn401_stages;
+ struct bls_builder_initialization_output *output = &initialization->output;
+ uint32_t clock;
+
+ output->dmub_abi.fw_version = params->dc->ctx->dmub_srv->dmub->fw_version;
+ output->dmub_abi.feature_caps = stages->stage_1.feature_caps;
+ output->smu_version = stages->stage_1.smu_version;
+ output->num_umc_channels = stages->stage_1.num_umc_channels;
+ output->xtalin_clock_inKhz = stages->stage_1.xtalin_clock_inKhz;
+ output->dccg_ref_clock_inKhz = stages->stage_1.dccg_ref_clock_inKhz;
+ output->dchub_ref_clock_inKhz = stages->stage_2.dchub_ref_clock_inKhz;
+ for (clock = 0; clock < PMFW_CLOCK_COUNT; clock++) {
+ struct bls_builder_dpm *dpm = &output->dpm_clocks[clock];
+
+ dpm->num_levels = stages->stage_1.dpm_level_count[clock];
+ dpm->dc_mode_max = (uint32_t)stages->stage_1.dc_mode_max[clock];
+ memcpy(dpm->dpm_level, stages->stage_2.dpm_levels[clock].levels,
+ sizeof(dpm->dpm_level));
+ }
}
-static inline enum bls_builder_result dcn401_build_dmub_initialize_dcn(
- struct bls_builder_declarative_params *params,
- struct block_sequence_state *sequence)
+static void dcn401_postprocess_initialization(struct bls_builder_declarative_params *params)
{
- union block_sequence_params bls_params = {0};
- struct bls_builder_output_init *out_init =
+ struct bls_builder_initialization *initialization =
params->out_targets->DCN_DECL_INITIALIZATION;
- union dmub_rb_cmd *cmd = &out_init->dmub_initialize_dcn_cmd;
-
- /*
- * No Initialize DCN opcode exists in dmub_cmd.h. A caller-supplied
- * non-zero type is preserved for tests; zero stays an undefined
- * command and cannot complete a successful build.
- */
- if (!cmd->cmd_common.header.type)
- memset(cmd, 0, sizeof(*cmd));
- bls_params.send_dmcub_cmd_params.ctx = params->dc->ctx;
- bls_params.send_dmcub_cmd_params.cmd = cmd;
- bls_params.send_dmcub_cmd_params.wait_type =
- DM_DMUB_WAIT_TYPE_WAIT_WITH_REPLY;
- if (!bls_append(sequence, DMUB_INITIALIZE_DCN, &bls_params))
- return BLS_BUILD_ERROR_UNSUPPORTED_STATE_UPDATE;
-
- return BLS_BUILD_SUCCESS;
-}
-
-static enum bls_builder_result dcn401_build_initialization_step(
- struct bls_builder_declarative_params *params,
- struct block_sequence_state *sequence,
- enum block_sequence_func func)
-{
- switch (func) {
- case LEGACY_CLK_MGR_INIT_CLOCKS:
- return dcn401_build_clk_mgr_init(params->dc->clk_mgr, sequence);
- case LEGACY_CLK_MGR_IS_DC_MODE_PRESENT:
- return dcn401_build_dc_mode_read(params->dc->clk_mgr,
- ¶ms->out_targets->DCN_DECL_INITIALIZATION
- ->dcmode_power_limits_present, sequence);
- case DCCG_INITIALIZE_CLOCKS:
- return dcn401_build_dccg_init(params->dc->res_pool->dccg,
- sequence);
- case DMUB_HALT_FW:
- return dcn401_build_dmub_halt_fw(params, sequence);
- case PSP_RELOAD_DMUB_FW:
- return dcn401_build_psp_reload(params, sequence);
- case DMUB_GPINT_SEND_AND_WAIT:
- return dcn401_build_dmub_fw_version(params, sequence);
- case DMUB_SEND_DMCUB_CMD:
- return dcn401_build_dmub_feature_caps(params, sequence);
- case DMUB_INITIALIZE_DCN:
- return dcn401_build_dmub_initialize_dcn(params, sequence);
- default:
- return BLS_BUILD_ERROR_UNSUPPORTED_STATE_UPDATE;
+ struct dcn401_bls_builder_initialization_stages *stages = &initialization->dcn401_stages;
+ uint32_t step;
+
+ if (initialization->stage >= DCN401_INIT_BUILDER_DONE)
+ return;
+
+ for (step = 0; step < params->head_num_steps; step++) {
+ const struct block_sequence *block = ¶ms->head_sequence[step];
+ const struct pmfw_send_and_wait_params *pmfw;
+
+ switch (block->func) {
+ case DMUB_SEND_DMCUB_CMD2: {
+ const union dmub_rb_cmd *cmd = &block->params.send_dmcub_cmd2_params.cmd;
+
+ if (cmd->cmd_common.header.type == DMUB_CMD__QUERY_FEATURE_CAPS &&
+ cmd->cmd_common.header.ret_status == 0)
+ memcpy(&stages->stage_1.feature_caps,
+ &cmd->query_feature_caps.query_feature_caps_data,
+ sizeof(stages->stage_1.feature_caps));
+ break;
+ }
+ case PMFW_SEND_MESSAGE_AND_WAIT:
+ pmfw = &block->params.pmfw_send_and_wait_params;
+ if (!pmfw->response.response_count)
+ break;
+ dcn401_process_pmfw_response(stages, pmfw, pmfw->response.response[0]);
+ break;
+ default:
+ break;
+ }
}
+
+ initialization->stage++;
+ if (initialization->stage == DCN401_INIT_BUILDER_DONE)
+ dcn401_fill_initialization_output(params);
}
-static enum bls_builder_result dcn401_build_initialization(
- struct bls_builder_declarative_params *params)
+static enum bls_builder_result dcn401_build_initialization(struct bls_builder_declarative_params *params)
{
- struct bls_builder_check_capability_params check_params = {0};
- enum bls_builder_result result;
- struct block_sequence_state sequence;
- struct bls_builder_output_init *out_init = NULL;
- unsigned int i;
-
- if (!params)
- return dcn401_check_initialization_support(NULL);
-
- check_params.dc = params->dc;
- check_params.current_state = params->current_state;
- check_params.new_state = params->new_state;
- result =
- dcn401_check_initialization_support(&check_params);
- if (result != BLS_BUILD_SUCCESS)
- return result;
+ struct bls_builder_initialization *initialization =
+ params->out_targets->DCN_DECL_INITIALIZATION;
params->head_num_steps = 0;
params->tail_num_steps = 0;
- for (i = 0; i < ARRAY_SIZE(dcn401_dc2_init_sequence); i++) {
- result = dcn401_validate_initialization_step(params,
- dcn401_dc2_init_sequence[i]);
- if (result != BLS_BUILD_SUCCESS)
- return result;
- }
-
- sequence.steps = params->head_sequence;
- sequence.num_steps = ¶ms->head_num_steps;
- if (params->out_targets)
- out_init = params->out_targets->DCN_DECL_INITIALIZATION;
- if (out_init) {
- out_init->dcmode_power_limits_present = false;
- out_init->dmub_stop_fw_response = 0;
- out_init->dmub_abi.fw_version = 0;
- memset(&out_init->dmub_abi.feature_caps, 0,
- sizeof(out_init->dmub_abi.feature_caps));
- }
-
- /*
- * LEGACY/pmfw-msg: preserve the clock-manager entry points until
- * PMFW Messenger can express the same calls, order, and output.
- */
- for (i = 0; i < ARRAY_SIZE(dcn401_dc2_init_sequence); i++) {
- result = dcn401_build_initialization_step(params, &sequence,
- dcn401_dc2_init_sequence[i]);
- if (result != BLS_BUILD_SUCCESS)
- return result;
- }
- if (out_init &&
- out_init->dmub_initialize_dcn_cmd.cmd_common.header.type)
+ if (initialization->stage >= DCN401_INIT_BUILDER_DONE)
return BLS_BUILD_SUCCESS;
-
- return BLS_BUILD_ERROR_UNSUPPORTED_STATE_UPDATE;
+ if (initialization->stage == DCN401_INIT_BUILDER_STAGE1)
+ return dcn401_build_stage1(params);
+ return dcn401_build_stage2(params);
}
-/* Reads the VBIOS accelerated-mode bit into the caller's out-target. */
-static enum bls_builder_result dcn401_build_accelerated_mode_query(
- struct bls_builder_declarative_params *params)
+const struct bls_builder *dcn401_initialization_builder(void)
{
- union block_sequence_params bls_params = {0};
- struct block_sequence_state sequence;
- struct dc_bios *dcb;
-
- if (!params || !params->dc || !params->dc->ctx || !params->out_targets ||
- !params->out_targets->DCN_DECL_QUERY_ACCELERATED_MODE)
- return BLS_BUILD_ERROR_RESOURCE_MAPPING;
- dcb = params->dc->ctx->dc_bios;
- if (!dcb || !dcb->funcs || !dcb->funcs->is_accelerated_mode)
- return BLS_BUILD_ERROR_RESOURCE_MAPPING;
-
- sequence.steps = params->head_sequence;
- sequence.num_steps = ¶ms->head_num_steps;
- bls_params.bios_is_accelerated_mode_params.dcb = dcb;
- bls_params.bios_is_accelerated_mode_params.out_accelerated_mode =
- params->out_targets->DCN_DECL_QUERY_ACCELERATED_MODE;
- if (!bls_append(&sequence, BIOS_IS_ACCELERATED_MODE, &bls_params))
- return BLS_BUILD_ERROR_RESOURCE_MAPPING;
- return BLS_BUILD_SUCCESS;
-}
-
-const struct bls_builder *dcn401_bls_builder_create(
- enum bls_builder_name name)
-{
- static const struct bls_builder initialization_builder = {
+ static const struct bls_builder builder = {
.name = DCN_DECL_INITIALIZATION,
.kind = BLS_BUILDER_DECLARATIVE,
.check_capability = dcn401_initialization_check_capability,
.build.declarative = dcn401_build_initialization,
- };
- static const struct bls_builder legacy_initialization_builder = {
- .name = DCN_DECL_INITIALIZATION_LEGACY,
- .kind = BLS_BUILDER_DECLARATIVE,
- .check_capability = dcn401_dc1_initialization_check_capability,
- .build.declarative = dcn401_build_dc1_initialization,
- };
- static const struct bls_builder accelerated_mode_query_builder = {
- .name = DCN_DECL_QUERY_ACCELERATED_MODE,
- .kind = BLS_BUILDER_DECLARATIVE,
- .build.declarative = dcn401_build_accelerated_mode_query,
+ .postprocess = dcn401_postprocess_initialization,
};
- switch (name) {
- case DCN_DECL_INITIALIZATION:
- return &initialization_builder;
- case DCN_DECL_INITIALIZATION_LEGACY:
- return &legacy_initialization_builder;
- case DCN_DECL_NON_SEAMLESS_COMMIT:
- return dcn401_non_seamless_commit_builder();
- case DCN_DECL_SEAMLESS_UPDATE:
- return dcn401_seamless_update_builder();
- case DCN_DECL_QUERY_ACCELERATED_MODE:
- return &accelerated_mode_query_builder;
- default:
- return NULL;
- }
+ return &builder;
}
+
diff --git a/drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_init_builder.h b/drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_init_builder.h
index fe70971cb8a5..714990f1fd9a 100644
--- a/drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_init_builder.h
+++ b/drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_init_builder.h
@@ -7,10 +7,6 @@
#include "bls_builder/bls_builder.h"
-struct clk_mgr;
-struct dccg;
-struct dc_context;
-
static inline bool bls_append(struct block_sequence_state *sequence,
enum block_sequence_func func,
const union block_sequence_params *params)
@@ -28,15 +24,3 @@ static inline bool bls_append(struct block_sequence_state *sequence,
(*sequence->num_steps)++;
return true;
}
-
-enum bls_builder_result dcn401_build_clk_mgr_init(
- struct clk_mgr *clk_mgr, struct block_sequence_state *sequence);
-enum bls_builder_result dcn401_build_dc_mode_read(
- struct clk_mgr *clk_mgr, bool *out_dcmode_power_limits_present,
- struct block_sequence_state *sequence);
-enum bls_builder_result dcn401_build_dccg_init(
- struct dccg *dccg, struct block_sequence_state *sequence);
-bool dcn401_add_dmub_cmd(struct block_sequence_state *sequence,
- struct dc_context *ctx, union dmub_rb_cmd *cmd,
- enum dm_dmub_wait_type wait_type, bool continue_on_error);
-void dcn401_fill_query_feature_caps_cmd(union dmub_rb_cmd *cmd);
diff --git a/drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_init_builder_legacy.c b/drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_init_builder_legacy.c
index e13c16920a0c..b47d2deed2a9 100644
--- a/drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_init_builder_legacy.c
+++ b/drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_init_builder_legacy.c
@@ -21,6 +21,7 @@
#include "dce/dce_hwseq.h"
#include "hwss/hw_sequencer_private.h"
#include "dcn32/dcn32_resource.h"
+#include "bls_builder/bls_builder_internal.h"
#include "bls_builder/dcn401_init_builder.h"
#include "bls_builder/dcn401_init_builder_legacy.h"
@@ -60,6 +61,70 @@ static bool dcn401_dc1_has_dmub(struct dc *dc)
return dc->ctx->dmub_srv && dc->ctx->dmub_srv->dmub;
}
+static enum bls_builder_result dcn401_build_clk_mgr_init(
+ struct clk_mgr *clk_mgr, struct block_sequence_state *sequence)
+{
+ union block_sequence_params bls_params = {0};
+
+ bls_params.legacy_clk_mgr_init_clocks_params.clk_mgr = clk_mgr;
+ if (!bls_append(sequence, LEGACY_CLK_MGR_INIT_CLOCKS, &bls_params))
+ return BLS_BUILD_ERROR_UNSUPPORTED_STATE_UPDATE;
+
+ return BLS_BUILD_SUCCESS;
+}
+
+static enum bls_builder_result dcn401_build_dc_mode_read(
+ struct clk_mgr *clk_mgr, bool *out_dcmode_power_limits_present,
+ struct block_sequence_state *sequence)
+{
+ union block_sequence_params bls_params = {0};
+
+ bls_params.legacy_clk_mgr_is_dc_mode_present_params.clk_mgr = clk_mgr;
+ bls_params.legacy_clk_mgr_is_dc_mode_present_params
+ .out_dcmode_power_limits_present =
+ out_dcmode_power_limits_present;
+ if (!bls_append(sequence, LEGACY_CLK_MGR_IS_DC_MODE_PRESENT,
+ &bls_params))
+ return BLS_BUILD_ERROR_UNSUPPORTED_STATE_UPDATE;
+
+ return BLS_BUILD_SUCCESS;
+}
+
+static enum bls_builder_result dcn401_build_dccg_init(
+ struct dccg *dccg, struct block_sequence_state *sequence)
+{
+ union block_sequence_params bls_params = {0};
+
+ bls_params.dccg_initialize_clocks_params.dccg = dccg;
+ if (!bls_append(sequence, DCCG_INITIALIZE_CLOCKS, &bls_params))
+ return BLS_BUILD_ERROR_UNSUPPORTED_STATE_UPDATE;
+
+ return BLS_BUILD_SUCCESS;
+}
+
+static bool dcn401_add_dmub_cmd(struct block_sequence_state *sequence,
+ struct dc_context *ctx, union dmub_rb_cmd *cmd,
+ enum dm_dmub_wait_type wait_type, bool continue_on_error)
+{
+ union block_sequence_params bls_params = {0};
+
+ bls_params.send_dmcub_cmd_params.ctx = ctx;
+ bls_params.send_dmcub_cmd_params.cmd = cmd;
+ bls_params.send_dmcub_cmd_params.wait_type = wait_type;
+ bls_params.send_dmcub_cmd_params.continue_on_error = continue_on_error;
+ return bls_append(sequence, DMUB_SEND_DMCUB_CMD, &bls_params);
+}
+
+static void dcn401_fill_query_feature_caps_cmd(union dmub_rb_cmd *cmd)
+{
+ memset(cmd, 0, sizeof(*cmd));
+ cmd->query_feature_caps.header.type = DMUB_CMD__QUERY_FEATURE_CAPS;
+ cmd->query_feature_caps.header.sub_type = 0;
+ cmd->query_feature_caps.header.ret_status = 1;
+ cmd->query_feature_caps.header.payload_bytes =
+ sizeof(struct dmub_cmd_query_feature_caps_data);
+}
+
static enum bls_builder_result dcn401_validate_dc1_links(struct dc *dc)
{
struct dc_bios *dcb = dc->ctx->dc_bios;
@@ -1069,3 +1134,15 @@ bool dcn401_dc1_initialization_check_capability(
return params && params->dc && params->dc->ctx &&
params->dc->res_pool;
}
+
+const struct bls_builder *dcn401_legacy_initialization_builder(void)
+{
+ static const struct bls_builder builder = {
+ .name = DCN_DECL_INITIALIZATION_LEGACY,
+ .kind = BLS_BUILDER_DECLARATIVE,
+ .check_capability = dcn401_dc1_initialization_check_capability,
+ .build.declarative = dcn401_build_dc1_initialization,
+ };
+
+ return &builder;
+}
diff --git a/drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_query_builder.c b/drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_query_builder.c
new file mode 100644
index 000000000000..d2c67d1df637
--- /dev/null
+++ b/drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_query_builder.c
@@ -0,0 +1,41 @@
+#include "dm_services.h"
+#include "core_types.h"
+#include "dc_bios_types.h"
+#include "bls_builder/bls_builder_internal.h"
+#include "bls_builder/dcn401_init_builder.h"
+
+/* Reads the VBIOS accelerated-mode bit into the caller's out-target. */
+static enum bls_builder_result dcn401_build_accelerated_mode_query(
+ struct bls_builder_declarative_params *params)
+{
+ union block_sequence_params bls_params = {0};
+ struct block_sequence_state sequence;
+ struct dc_bios *dcb;
+
+ if (!params || !params->dc || !params->dc->ctx || !params->out_targets ||
+ !params->out_targets->DCN_DECL_QUERY_ACCELERATED_MODE)
+ return BLS_BUILD_ERROR_RESOURCE_MAPPING;
+ dcb = params->dc->ctx->dc_bios;
+ if (!dcb || !dcb->funcs || !dcb->funcs->is_accelerated_mode)
+ return BLS_BUILD_ERROR_RESOURCE_MAPPING;
+
+ sequence.steps = params->head_sequence;
+ sequence.num_steps = ¶ms->head_num_steps;
+ bls_params.bios_is_accelerated_mode_params.dcb = dcb;
+ bls_params.bios_is_accelerated_mode_params.out_accelerated_mode =
+ params->out_targets->DCN_DECL_QUERY_ACCELERATED_MODE;
+ if (!bls_append(&sequence, BIOS_IS_ACCELERATED_MODE, &bls_params))
+ return BLS_BUILD_ERROR_RESOURCE_MAPPING;
+ return BLS_BUILD_SUCCESS;
+}
+
+const struct bls_builder *dcn401_accelerated_mode_query_builder(void)
+{
+ static const struct bls_builder builder = {
+ .name = DCN_DECL_QUERY_ACCELERATED_MODE,
+ .kind = BLS_BUILDER_DECLARATIVE,
+ .build.declarative = dcn401_build_accelerated_mode_query,
+ };
+
+ return &builder;
+}
diff --git a/drivers/gpu/drm/amd/display/dc/bls_executor/bls_executor.c b/drivers/gpu/drm/amd/display/dc/bls_executor/bls_executor.c
index 297ddbed2eac..47278d7057d5 100644
--- a/drivers/gpu/drm/amd/display/dc/bls_executor/bls_executor.c
+++ b/drivers/gpu/drm/amd/display/dc/bls_executor/bls_executor.c
@@ -66,6 +66,16 @@ static noinline_for_stack bool dc2_bls_step_supported(const struct dc2 *dc2,
ctx = step->params.send_dmcub_cmd_params.ctx;
if (!ctx || !ctx->dmub_srv || !ctx->dmub_srv->dmub ||
!step->params.send_dmcub_cmd_params.cmd ||
+ !step->params.send_dmcub_cmd_params.cmd->cmd_common
+ .header.type ||
+ (ctx->dmub_srv->idle_allowed && !ctx->dc))
+ return false;
+ return true;
+ case DMUB_SEND_DMCUB_CMD2:
+ ctx = step->params.send_dmcub_cmd2_params.ctx;
+ if (!ctx || !ctx->dmub_srv || !ctx->dmub_srv->dmub ||
+ !step->params.send_dmcub_cmd2_params.cmd.cmd_common
+ .header.type ||
(ctx->dmub_srv->idle_allowed && !ctx->dc))
return false;
return true;
@@ -89,15 +99,6 @@ static noinline_for_stack bool dc2_bls_step_supported(const struct dc2 *dc2,
hw_params && hw_params->fb_info &&
hw_params->fb_info->num_fb >= DMUB_WINDOW_TOTAL;
}
- case DMUB_INITIALIZE_DCN:
- ctx = step->params.send_dmcub_cmd_params.ctx;
- if (!ctx || !ctx->dmub_srv || !ctx->dmub_srv->dmub ||
- !step->params.send_dmcub_cmd_params.cmd ||
- !step->params.send_dmcub_cmd_params.cmd->cmd_common
- .header.type ||
- (ctx->dmub_srv->idle_allowed && !ctx->dc))
- return false;
- return true;
case OPTC_SET_ODM_MEM_POWER: {
struct dce_hwseq *hws = step->params.hwseq_reg_control_params.hws;
@@ -638,6 +639,11 @@ static noinline_for_stack bool dc2_bls_step_supported(const struct dc2 *dc2,
case MPC_SET_OUTPUT_GAMMA:
mpc = step->params.mpc_set_output_gamma_params.mpc;
return mpc && mpc->funcs && mpc->funcs->set_output_gamma;
+ case PMFW_SEND_MESSAGE_AND_WAIT:
+ return dc2 && dc2->pmfw_messenger.funcs &&
+ dc2->pmfw_messenger.funcs->send_message_and_wait &&
+ step->params.pmfw_send_and_wait_params.message
+ .param_count <= PMFW_MESSENGER_MAX_MESSAGE_PARAMS;
default:
return false;
}
@@ -662,29 +668,56 @@ static noinline_for_stack void dc2_bls_exec_initialize_min_clocks(
}
static noinline_for_stack enum dc2_bls_exec_result dc2_bls_exec_dmub_send(
- const struct block_sequence *entry)
+ struct block_sequence *entry)
{
struct dmub_messenger messenger;
struct dmub_messenger_init_data init_data;
struct dmub_send_cmd_params params;
struct dc_context *ctx;
-
- ctx = entry->params.send_dmcub_cmd_params.ctx;
+ bool continue_on_error;
+
+ if (entry->func == DMUB_SEND_DMCUB_CMD2) {
+ struct send_dmcub_cmd2_params *send = &entry->params.send_dmcub_cmd2_params;
+
+ ctx = send->ctx;
+ params.cmd = &send->cmd;
+ params.wait_type = send->wait_type;
+ continue_on_error = send->continue_on_error;
+ } else {
+ struct send_dmcub_cmd_params *send = &entry->params.send_dmcub_cmd_params;
+
+ ctx = send->ctx;
+ params.cmd = send->cmd;
+ params.wait_type = send->wait_type;
+ continue_on_error = send->continue_on_error;
+ }
init_data.ctx = ctx;
init_data.dc_dmub_srv = ctx->dmub_srv;
- params.cmd = entry->params.send_dmcub_cmd_params.cmd;
- params.wait_type = entry->params.send_dmcub_cmd_params.wait_type;
dmub_messenger_construct(&messenger, &init_data);
if (messenger.funcs->inbox_cmd_send_and_wait(&messenger, ¶ms) !=
DMUB_MSG_OK)
- return entry->params.send_dmcub_cmd_params.continue_on_error ?
+ return continue_on_error ?
DC2_BLS_EXEC_CONTINUED_ON_ERROR :
DC2_BLS_EXEC_ERROR;
return DC2_BLS_EXEC_OK;
}
+static noinline_for_stack enum dc2_bls_exec_result dc2_bls_exec_pmfw_send_and_wait(
+ struct dc2 *dc2, struct block_sequence *entry)
+{
+ struct pmfw_send_and_wait_params *p = &entry->params.pmfw_send_and_wait_params;
+ struct pmfw_messenger *messenger = &dc2->pmfw_messenger;
+
+ if (messenger->funcs->send_message_and_wait(messenger, p->message,
+ &p->response) == PMFW_MSG_OK)
+ return DC2_BLS_EXEC_OK;
+
+ return p->continue_on_error ? DC2_BLS_EXEC_CONTINUED_ON_ERROR :
+ DC2_BLS_EXEC_ERROR;
+}
+
static noinline_for_stack enum dc2_bls_exec_result dc2_bls_exec_dmub_gpint(
struct dc2 *dc2, const struct block_sequence *entry)
{
@@ -776,11 +809,11 @@ static noinline_for_stack void dc2_bls_program_surface_config(
enum dc2_bls_exec_result dc2_bls_execute(
struct dc2 *dc2,
- const struct block_sequence *steps,
+ struct block_sequence *steps,
unsigned int num_steps)
{
enum dc2_bls_exec_result result = DC2_BLS_EXEC_OK;
- const struct block_sequence *entry;
+ struct block_sequence *entry;
enum dc2_bls_exec_result sent;
struct timing_generator *tg;
struct output_pixel_processor *opp;
@@ -826,6 +859,7 @@ enum dc2_bls_exec_result dc2_bls_execute(
entry->params.dccg_initialize_clocks_params.dccg);
break;
case DMUB_SEND_DMCUB_CMD:
+ case DMUB_SEND_DMCUB_CMD2:
sent = dc2_bls_exec_dmub_send(entry);
if (sent == DC2_BLS_EXEC_ERROR)
return DC2_BLS_EXEC_ERROR;
@@ -844,10 +878,6 @@ enum dc2_bls_exec_result dc2_bls_execute(
DMUB_STATUS_OK)
return DC2_BLS_EXEC_ERROR;
break;
- case DMUB_INITIALIZE_DCN:
- if (dc2_bls_exec_dmub_send(entry) != DC2_BLS_EXEC_OK)
- return DC2_BLS_EXEC_ERROR;
- break;
/*
* S-INT/bld-seq: dce_hwseq init functions. Remove when the
* OPTC, MMHUBBUB, DCCG and HPO BLCs expose them.
@@ -1769,6 +1799,13 @@ enum dc2_bls_exec_result dc2_bls_execute(
p->params);
break;
}
+ case PMFW_SEND_MESSAGE_AND_WAIT:
+ sent = dc2_bls_exec_pmfw_send_and_wait(dc2, entry);
+ if (sent == DC2_BLS_EXEC_ERROR)
+ return DC2_BLS_EXEC_ERROR;
+ if (sent == DC2_BLS_EXEC_CONTINUED_ON_ERROR)
+ result = DC2_BLS_EXEC_CONTINUED_ON_ERROR;
+ break;
default:
ASSERT(false);
return DC2_BLS_EXEC_ERROR;
diff --git a/drivers/gpu/drm/amd/display/dc/bls_executor/bls_executor.h b/drivers/gpu/drm/amd/display/dc/bls_executor/bls_executor.h
index d686f03c34c2..88a2ca8b3694 100644
--- a/drivers/gpu/drm/amd/display/dc/bls_executor/bls_executor.h
+++ b/drivers/gpu/drm/amd/display/dc/bls_executor/bls_executor.h
@@ -17,5 +17,5 @@ enum dc2_bls_exec_result {
enum dc2_bls_exec_result dc2_bls_execute(
struct dc2 *dc2,
- const struct block_sequence *steps,
+ struct block_sequence *steps,
unsigned int num_steps);
diff --git a/drivers/gpu/drm/amd/display/dc/core2/dc_core2.c b/drivers/gpu/drm/amd/display/dc/core2/dc_core2.c
index 0e92c2e7a4e6..d05d74595829 100644
--- a/drivers/gpu/drm/amd/display/dc/core2/dc_core2.c
+++ b/drivers/gpu/drm/amd/display/dc/core2/dc_core2.c
@@ -46,6 +46,8 @@ void core2_construct(struct dc *dc)
for (name = 0; name < BLS_BUILDER_NAME_COUNT; name++)
dc2->builders[name] = bls_builder_create(dc, name);
+
+ pmfw_messenger_construct(&dc2->pmfw_messenger, dc->ctx);
}
void core2_destruct(struct dc *dc)
diff --git a/drivers/gpu/drm/amd/display/dc/core2/dc_core2_init.c b/drivers/gpu/drm/amd/display/dc/core2/dc_core2_init.c
index 319aa3e219d2..6d5dd6f00b9f 100644
--- a/drivers/gpu/drm/amd/display/dc/core2/dc_core2_init.c
+++ b/drivers/gpu/drm/amd/display/dc/core2/dc_core2_init.c
@@ -5,6 +5,10 @@
#include "dm_services.h"
#include "dc.h"
+#include "core_types.h"
+#include "clk_mgr_internal.h"
+#include "dc_dmub_srv.h"
+#include "dc_bios_types.h"
#include "bls_builder/bls_builder.h"
#include "bls_executor/bls_executor.h"
#include "workaround_manager/workaround_manager.h"
@@ -34,56 +38,300 @@ static void core2_detect_edp_presence(struct dc *dc)
}
}
-static void core2_run_native_hardware_init(struct dc *dc)
+static void core2_resolve_dmub_abi(struct dc *dc,
+ const struct bls_builder_initialization_output *initialization)
{
+ struct dc2 *dc2 = TO_DC2(dc);
+
+ dc2->dmub_abi = initialization->dmub_abi;
+ dc2->dmub_abi_resolved = true;
+ dc->ctx->dmub_srv->dmub->feature_caps = initialization->dmub_abi.feature_caps;
+ dc->caps.dmub_caps.psr = initialization->dmub_abi.feature_caps.psr;
+ dc->caps.dmub_caps.mclk_sw = initialization->dmub_abi.feature_caps.fw_assisted_mclk_switch_ver > 0;
+ dc->caps.dmub_caps.fams_ver = initialization->dmub_abi.feature_caps.fw_assisted_mclk_switch_ver;
+ dc->debug.fams2_config.bits.enable &= dc->caps.dmub_caps.fams_ver == dc->debug.fams_version.ver;
+}
+
+static void core2_build_dcn401_wm_ranges(struct dc *dc, struct clk_bw_params *bw_params)
+{
+ enum {
+ DCN401_WATERMARKS_CLOCK_RANGE = 0,
+ DCN401_WATERMARKS_DUMMY_PSTATE = 1,
+ };
+
+ bw_params->wm_table.nv_entries[WM_A].valid = true;
+ bw_params->wm_table.nv_entries[WM_A].pmfw_breakdown.wm_type = DCN401_WATERMARKS_CLOCK_RANGE;
+ bw_params->wm_table.nv_entries[WM_A].pmfw_breakdown.min_dcfclk =
+ (uint16_t)bw_params->clk_table.entries[0].dcfclk_mhz;
+ bw_params->wm_table.nv_entries[WM_A].pmfw_breakdown.max_dcfclk = 0xFFFF;
+ bw_params->wm_table.nv_entries[WM_A].pmfw_breakdown.min_uclk =
+ (uint16_t)bw_params->clk_table.entries[0].memclk_mhz;
+ bw_params->wm_table.nv_entries[WM_A].pmfw_breakdown.max_uclk = 0xFFFF;
+ bw_params->wm_table.nv_entries[WM_B].valid = false;
+ bw_params->wm_table.nv_entries[WM_1A].valid =
+ dc->bb_overrides.dummy_clock_change_latency_ns != 0x7FFFFFFF;
+ if (bw_params->wm_table.nv_entries[WM_1A].valid) {
+ bw_params->wm_table.nv_entries[WM_1A].pmfw_breakdown =
+ bw_params->wm_table.nv_entries[WM_A].pmfw_breakdown;
+ bw_params->wm_table.nv_entries[WM_1A].pmfw_breakdown.wm_type = DCN401_WATERMARKS_DUMMY_PSTATE;
+ }
+ bw_params->wm_table.nv_entries[WM_1B].valid = false;
+}
+
+static void core2_build_wm_ranges(struct dc *dc, struct clk_bw_params *bw_params)
+{
+ switch (dc->ctx->dce_version) {
+ case DCN_VERSION_4_01:
+ core2_build_dcn401_wm_ranges(dc, bw_params);
+ break;
+ default:
+ break;
+ }
+}
+
+static void core2_resolve_dpm_limits(struct dc *dc, struct clk_bw_params *bw_params,
+ const struct bls_builder_initialization_output *initialization)
+{
+ struct clk_limit_num_entries *counts = &bw_params->clk_table.num_entries_per_clk;
+ unsigned int *num_levels[PMFW_CLOCK_COUNT] = {
+ [PMFW_CLOCK_DCFCLK] = &counts->num_dcfclk_levels,
+ [PMFW_CLOCK_SOCCLK] = &counts->num_socclk_levels,
+ [PMFW_CLOCK_DTBCLK] = &counts->num_dtbclk_levels,
+ [PMFW_CLOCK_DISPCLK] = &counts->num_dispclk_levels,
+ [PMFW_CLOCK_DPPCLK] = &counts->num_dppclk_levels,
+ [PMFW_CLOCK_UCLK] = &counts->num_memclk_levels,
+ [PMFW_CLOCK_FCLK] = &counts->num_fclk_levels,
+ };
+ unsigned int *dc_mode_max[PMFW_CLOCK_COUNT] = {
+ [PMFW_CLOCK_DCFCLK] = &bw_params->dc_mode_limit.dcfclk_mhz,
+ [PMFW_CLOCK_SOCCLK] = &bw_params->dc_mode_limit.socclk_mhz,
+ [PMFW_CLOCK_DTBCLK] = &bw_params->dc_mode_limit.dtbclk_mhz,
+ [PMFW_CLOCK_DISPCLK] = &bw_params->dc_mode_limit.dispclk_mhz,
+ [PMFW_CLOCK_DPPCLK] = &bw_params->dc_mode_limit.dppclk_mhz,
+ [PMFW_CLOCK_UCLK] = &bw_params->dc_mode_limit.memclk_mhz,
+ [PMFW_CLOCK_FCLK] = &bw_params->dc_mode_limit.fclk_mhz,
+ };
+ unsigned int clock;
+
+ dc->caps.dcmode_power_limits_present = false;
+ for (clock = 0; clock < PMFW_CLOCK_COUNT; clock++) {
+ const struct bls_builder_dpm *dpm = &initialization->dpm_clocks[clock];
+
+ *num_levels[clock] = dpm->num_levels;
+ *dc_mode_max[clock] = dpm->dc_mode_max;
+ if (dpm->num_levels && dpm->dc_mode_max == dpm->dpm_level[dpm->num_levels - 1])
+ *dc_mode_max[clock] = 0;
+ dc->caps.dcmode_power_limits_present |= *dc_mode_max[clock] != 0;
+ }
+}
+
+static void core2_resolve_dpm_frequencies(struct clk_bw_params *bw_params,
+ const struct bls_builder_initialization_output *initialization)
+{
+ unsigned int clock, level;
+
+ for (level = 0; level < ARRAY_SIZE(bw_params->clk_table.entries); level++) {
+ struct clk_limit_table_entry *entry = &bw_params->clk_table.entries[level];
+ unsigned int *frequency[PMFW_CLOCK_COUNT] = {
+ [PMFW_CLOCK_DCFCLK] = &entry->dcfclk_mhz,
+ [PMFW_CLOCK_SOCCLK] = &entry->socclk_mhz,
+ [PMFW_CLOCK_DTBCLK] = &entry->dtbclk_mhz,
+ [PMFW_CLOCK_DISPCLK] = &entry->dispclk_mhz,
+ [PMFW_CLOCK_DPPCLK] = &entry->dppclk_mhz,
+ [PMFW_CLOCK_UCLK] = &entry->memclk_mhz,
+ [PMFW_CLOCK_FCLK] = &entry->fclk_mhz,
+ };
+
+ for (clock = 0; clock < PMFW_CLOCK_COUNT; clock++)
+ if (level < initialization->dpm_clocks[clock].num_levels)
+ *frequency[clock] = initialization->dpm_clocks[clock].dpm_level[level];
+ }
+}
+
+static void core2_apply_clock_debug_overrides(struct dc *dc, struct clk_bw_params *bw_params)
+{
+ const struct clk_limit_num_entries *counts = &bw_params->clk_table.num_entries_per_clk;
+ unsigned int level;
+
+ if (dc->debug.min_disp_clk_khz) {
+ unsigned int min_dispclk_mhz = (unsigned int)khz_to_mhz_ceil(dc->debug.min_disp_clk_khz);
+
+ for (level = 0; level < counts->num_dispclk_levels; level++)
+ bw_params->clk_table.entries[level].dispclk_mhz =
+ max(bw_params->clk_table.entries[level].dispclk_mhz, min_dispclk_mhz);
+ }
+ if (dc->debug.min_dpp_clk_khz) {
+ unsigned int min_dppclk_mhz = (unsigned int)khz_to_mhz_ceil(dc->debug.min_dpp_clk_khz);
+
+ for (level = 0; level < counts->num_dppclk_levels; level++)
+ bw_params->clk_table.entries[level].dppclk_mhz =
+ max(bw_params->clk_table.entries[level].dppclk_mhz, min_dppclk_mhz);
+ }
+}
+
+static void core2_resolve_bandwidth_clocks(struct dc *dc, struct clk_mgr_internal *clk_mgr,
+ struct clk_bw_params *bw_params,
+ const struct bls_builder_initialization_output *initialization)
+{
+ const struct clk_limit_num_entries *counts = &bw_params->clk_table.num_entries_per_clk;
+
+ bw_params->dc_mode_softmax_memclk = bw_params->dc_mode_limit.memclk_mhz;
+ if (counts->num_memclk_levels)
+ bw_params->max_memclk_mhz = initialization->dpm_clocks[PMFW_CLOCK_UCLK].dpm_level[
+ counts->num_memclk_levels - 1];
+ bw_params->clk_table.num_entries = max(counts->num_memclk_levels, counts->num_fclk_levels);
+ if (!bw_params->clk_table.num_entries)
+ bw_params->clk_table.num_entries = 1;
+ clk_mgr->dpm_present = counts->num_dcfclk_levels && counts->num_dtbclk_levels &&
+ counts->num_dispclk_levels && (counts->num_memclk_levels || counts->num_fclk_levels);
+ bw_params->num_channels = initialization->num_umc_channels;
+ if (dc->ctx->dc_bios) {
+ if (!bw_params->num_channels)
+ bw_params->num_channels = dc->ctx->dc_bios->vram_info.num_chans;
+ bw_params->dram_channel_width_bytes = dc->ctx->dc_bios->vram_info.dram_channel_width_bytes;
+ }
+}
+
+static void core2_resolve_clocks(struct dc *dc,
+ const struct bls_builder_initialization_output *initialization)
+{
+ struct clk_mgr_internal *clk_mgr;
+ struct clk_bw_params *bw_params;
+
+ if (!dc->clk_mgr)
+ return;
+
+ clk_mgr = TO_CLK_MGR_INTERNAL(dc->clk_mgr);
+ bw_params = dc->clk_mgr->bw_params;
+ if (bw_params) {
+ memset(&dc->clk_mgr->clks, 0, sizeof(dc->clk_mgr->clks));
+ dc->clk_mgr->clks.p_state_change_support = true;
+ dc->clk_mgr->clks.prev_p_state_change_support = true;
+ dc->clk_mgr->clks.fclk_prev_p_state_change_support = true;
+ }
+ clk_mgr->smu_ver = initialization->smu_version;
+ clk_mgr->smu_present = initialization->smu_version != 0;
+ clk_mgr->dpm_present = false;
+ if (!clk_mgr->smu_present || !bw_params)
+ return;
+
+ core2_resolve_dpm_limits(dc, bw_params, initialization);
+ core2_resolve_dpm_frequencies(bw_params, initialization);
+ core2_apply_clock_debug_overrides(dc, bw_params);
+ core2_resolve_bandwidth_clocks(dc, clk_mgr, bw_params, initialization);
+ if (dc->res_pool->funcs->update_bw_bounding_box)
+ dc->res_pool->funcs->update_bw_bounding_box(dc, bw_params);
+ core2_build_wm_ranges(dc, bw_params);
+}
+
+/* dcn401_init_hw refreshes the bounding box after the DMUB caps query. */
+static void core2_update_bw_bounding_box(struct dc *dc,
+ bool dchub_ref_freq_changed)
+{
+ if (dc->ctx->dmub_srv &&
+ (!dc->debug.fams2_config.bits.enable || dchub_ref_freq_changed) &&
+ dc->res_pool->funcs->update_bw_bounding_box &&
+ dc->clk_mgr && dc->clk_mgr->bw_params)
+ dc->res_pool->funcs->update_bw_bounding_box(dc, dc->clk_mgr->bw_params);
+}
+
+/* Build, apply workarounds, execute, and let the builder read the replies. */
+static bool core2_run_init_stage(struct dc *dc,
+ const struct bls_builder *builder,
+ const struct workaround_manager *wam,
+ struct bls_builder_declarative_params *params)
+{
+ struct workaround_context wa_ctx = {0};
+ struct block_sequence_state sequence;
+ enum dc2_bls_exec_result exec_result;
+
+ if (builder->build.declarative(params) != BLS_BUILD_SUCCESS)
+ return false;
+
+ sequence.steps = params->head_sequence;
+ sequence.num_steps = ¶ms->head_num_steps;
+ wa_ctx.current_state = dc->current_state;
+ wa_ctx.builder_name = builder->name;
+ wa_ctx.dcn_version = dc->ctx->dce_version;
+ wa_ctx.bug_wa = &dc->work_arounds;
+ wa_ctx.debug = &dc->debug;
+ if (workaround_manager_apply(wam, &sequence, &wa_ctx) != WAM_OK ||
+ params->head_num_steps > DC2_BLS_MAX_STEPS)
+ return false;
+
+ exec_result = dc2_bls_execute(TO_DC2(dc), params->head_sequence,
+ params->head_num_steps);
+ if (exec_result != DC2_BLS_EXEC_OK &&
+ exec_result != DC2_BLS_EXEC_CONTINUED_ON_ERROR)
+ return false;
+
+ builder->postprocess(params);
+ return true;
+}
+
+static void core2_run_wrapped_hardware_init(struct dc *dc)
+{
+ const struct workaround_manager *wam = dc2_workaround_manager_get();
struct bls_builder_declarative_params *params;
- struct bls_builder_output_init *out_init;
struct bls_builder_output_targets out_targets = {0};
+ struct bls_builder_initialization *initialization;
+ const struct bls_builder_initialization_output *output;
const struct bls_builder *builder;
- enum bls_builder_result result;
+ bool dchub_ref_freq_changed;
+ unsigned int stage;
builder = TO_DC2(dc)->builders[DCN_DECL_INITIALIZATION];
if (!builder || builder->kind != BLS_BUILDER_DECLARATIVE ||
- !builder->build.declarative)
+ !builder->build.declarative || !builder->postprocess || !wam ||
+ !dc->current_state)
return;
+ TO_DC2(dc)->dmub_abi_resolved = false;
/*
- * The declarative params hold 128 block-sequence entries, and the
- * init output holds DMUB command buffers. Keep both off the stack
- * so the kernel frame stays under the 2048-byte limit.
+ * The declarative params hold 128 block-sequence entries. Keep them
+ * and the init output off the stack so the kernel frame stays under
+ * the 2048-byte limit.
*/
- params = kvzalloc(sizeof(*params), GFP_KERNEL);
- out_init = kvzalloc(sizeof(*out_init), GFP_KERNEL);
- if (!params || !out_init)
+ params = kvzalloc_obj(*params, GFP_KERNEL);
+ initialization = kvzalloc_obj(*initialization, GFP_KERNEL);
+ if (!params || !initialization)
goto out;
params->dc = dc;
- out_targets.DCN_DECL_INITIALIZATION = out_init;
+ out_targets.DCN_DECL_INITIALIZATION = initialization;
params->out_targets = &out_targets;
- /*
- * The builder copies DMUB windows retained on dmub_srv. Missing
- * windows fail the build closed. Execute only a successful build,
- * and do not fall back to legacy hwseq.
- */
- result = builder->build.declarative(params);
- if (result == BLS_BUILD_SUCCESS)
- dc2_bls_execute(TO_DC2(dc), params->head_sequence,
- params->head_num_steps);
+
+ /* Builders emit empty sequences for stages past their last one. */
+ for (stage = 0; stage < BLS_BUILDER_INIT_MAX_STAGE_COUNT; stage++) {
+ if (!core2_run_init_stage(dc, builder, wam, params))
+ goto out;
+ }
+
+ dc->current_state->bls_builder_initialization = *initialization;
+ output = &dc->current_state->bls_builder_initialization.output;
+
+ dchub_ref_freq_changed = dc->res_pool->ref_clocks.dchub_ref_clock_inKhz / 1000 !=
+ output->dchub_ref_clock_inKhz / 1000;
+ dc->res_pool->ref_clocks.xtalin_clock_inKhz = output->xtalin_clock_inKhz;
+ dc->res_pool->ref_clocks.dccg_ref_clock_inKhz = output->dccg_ref_clock_inKhz;
+ dc->res_pool->ref_clocks.dchub_ref_clock_inKhz = output->dchub_ref_clock_inKhz;
+ core2_resolve_dmub_abi(dc, output);
+ core2_resolve_clocks(dc, output);
+ core2_update_bw_bounding_box(dc, dchub_ref_freq_changed);
out:
kvfree(params);
- kvfree(out_init);
+ kvfree(initialization);
}
-/* CORE2 runs the DC2_DC1_Wrapped init until dcn401 init is native. */
void core2_hardware_init(struct dc *dc)
{
if (!dc)
return;
core2_detect_edp_presence(dc);
- if (TO_DC2(dc)->selection == DC2_SELECTION_CORE2)
- core2_run_legacy_hardware_init(dc, dc2_workaround_manager_get());
+ if (TO_DC2(dc)->init_method == DC2_INIT_METHOD_WRAPPED)
+ core2_run_wrapped_hardware_init(dc);
else
- core2_run_native_hardware_init(dc);
+ core2_run_legacy_hardware_init(dc, dc2_workaround_manager_get());
}
diff --git a/drivers/gpu/drm/amd/display/dc/dc.h b/drivers/gpu/drm/amd/display/dc/dc.h
index 4c235520b908..775259e5e478 100644
--- a/drivers/gpu/drm/amd/display/dc/dc.h
+++ b/drivers/gpu/drm/amd/display/dc/dc.h
@@ -1414,6 +1414,7 @@ struct dc_init_data {
uint32_t *clk_reg_offsets;
void *bb_from_dmub;
enum dc2_selection dc2_selection;
+ enum dc2_init_method dc2_init_method;
};
struct dc_callback_init {
diff --git a/drivers/gpu/drm/amd/display/dc/dc_api_dispatch/api_shim.c b/drivers/gpu/drm/amd/display/dc/dc_api_dispatch/api_shim.c
index 5d7117501428..ec3b14ba8509 100644
--- a/drivers/gpu/drm/amd/display/dc/dc_api_dispatch/api_shim.c
+++ b/drivers/gpu/drm/amd/display/dc/dc_api_dispatch/api_shim.c
@@ -14,6 +14,7 @@ void api_shim_construct(struct dc *dc, const struct dc_init_data *init_params)
{
/* DM override today; ASIC allow-list later. Owned only by this shim. */
TO_DC2(dc)->selection = init_params->dc2_selection;
+ TO_DC2(dc)->init_method = init_params->dc2_init_method;
}
void dc_hardware_init(struct dc *dc)
diff --git a/drivers/gpu/drm/amd/display/dc/dc_api_dispatch/api_shim.h b/drivers/gpu/drm/amd/display/dc/dc_api_dispatch/api_shim.h
index 93dd2d47c8dc..297d2920f733 100644
--- a/drivers/gpu/drm/amd/display/dc/dc_api_dispatch/api_shim.h
+++ b/drivers/gpu/drm/amd/display/dc/dc_api_dispatch/api_shim.h
@@ -8,16 +8,19 @@
#include "dc.h"
#include "inc/dc_core_interface.h"
#include "bls_builder/bls_builder.h"
+#include "pmfw_messenger/pmfw_messenger.h"
struct dc2 {
/* First member: TO_DC2 is a typed upcast, not container_of. */
struct dc dc;
enum dc2_selection selection;
+ enum dc2_init_method init_method;
/* Resolved by hardware init; later builds take it as dmub_abi. */
struct dmub_abi dmub_abi;
bool dmub_abi_resolved;
/* Set once by core2_construct; NULL where this DCN has no builder. */
const struct bls_builder *builders[BLS_BUILDER_NAME_COUNT];
+ struct pmfw_messenger pmfw_messenger;
};
#define TO_DC2(ptr) ((struct dc2 *)(ptr))
diff --git a/drivers/gpu/drm/amd/display/dc/hwss/hw_sequencer.h b/drivers/gpu/drm/amd/display/dc/hwss/hw_sequencer.h
index e447dd2c69ec..6e009ba37ff9 100644
--- a/drivers/gpu/drm/amd/display/dc/hwss/hw_sequencer.h
+++ b/drivers/gpu/drm/amd/display/dc/hwss/hw_sequencer.h
@@ -38,6 +38,7 @@
#include "link_service_types.h"
#include "dmub/inc/dmub_cmd.h"
#include "dc_dmub_srv.h"
+#include "pmfw_messenger/pmfw_messenger.h"
struct pipe_ctx;
struct dc_state;
@@ -147,6 +148,13 @@ struct send_dmcub_cmd_params {
bool continue_on_error;
};
+struct send_dmcub_cmd2_params {
+ struct dc_context *ctx;
+ union dmub_rb_cmd cmd;
+ enum dm_dmub_wait_type wait_type;
+ bool continue_on_error;
+};
+
struct dmub_gpint_params {
unsigned int command_code;
unsigned int param;
@@ -1350,6 +1358,12 @@ struct dccg_initialize_clocks_params {
struct dccg *dccg;
};
+struct pmfw_send_and_wait_params {
+ struct pmfw_message message;
+ struct pmfw_response response;
+ bool continue_on_error;
+};
+
struct hubbub_program_watermarks_params {
struct hubbub *hubbub;
/* Workaround: watermarks by value would add ~160 B to every step (~158 KiB per dc_state).
@@ -1398,6 +1412,7 @@ union block_sequence_params {
struct update_info_frame_params update_info_frame_params;
struct program_manual_trigger_params program_manual_trigger_params;
struct send_dmcub_cmd_params send_dmcub_cmd_params;
+ struct send_dmcub_cmd2_params send_dmcub_cmd2_params;
struct lsdma_send_pio_copy_params lsdma_send_pio_copy_params;
struct setup_dpp_params setup_dpp_params;
struct program_bias_and_scale_params program_bias_and_scale_params;
@@ -1634,6 +1649,7 @@ union block_sequence_params {
struct hubp_program_3dlut_fl_config_params
hubp_program_3dlut_fl_config_params;
struct hubp_set_3dlut_fl_params hubp_set_3dlut_fl_params;
+ struct pmfw_send_and_wait_params pmfw_send_and_wait_params;
};
enum block_sequence_func {
@@ -1811,7 +1827,6 @@ enum block_sequence_func {
DMUB_GPINT_SEND_AND_WAIT,
DMUB_HALT_FW,
PSP_RELOAD_DMUB_FW,
- DMUB_INITIALIZE_DCN,
OPTC_SET_ODM_MEM_POWER,
MMHUBBUB_SET_MEM_POWER,
DCCG_GET_REF_FREQ,
@@ -1879,6 +1894,8 @@ enum block_sequence_func {
DPP_PROGRAM_GAMCOR_LUT,
HUBP_PROGRAM_3DLUT_FL_CONFIG,
HUBP_SET_3DLUT_FL,
+ PMFW_SEND_MESSAGE_AND_WAIT,
+ DMUB_SEND_DMCUB_CMD2,
/* This must be the last value in this enum, add new ones above */
HWSS_BLOCK_SEQUENCE_FUNC_COUNT
};
diff --git a/drivers/gpu/drm/amd/display/dc/inc/core_types.h b/drivers/gpu/drm/amd/display/dc/inc/core_types.h
index 1d6bb41312b7..f1b6053fa5c6 100644
--- a/drivers/gpu/drm/amd/display/dc/inc/core_types.h
+++ b/drivers/gpu/drm/amd/display/dc/inc/core_types.h
@@ -42,6 +42,7 @@
#include "panel_cntl.h"
#include "dmub/inc/dmub_cmd.h"
#include "bls_builder/bls_builder_legacy_init.h"
+#include "bls_builder/bls_builder.h"
#include "pg_cntl.h"
#include "sspl/dc_spl.h"
@@ -730,6 +731,8 @@ struct dc_state {
* outputs of each stage run so far
*/
struct bls_builder_legacy_hw_init_info hw_init_info;
+
+ struct bls_builder_initialization bls_builder_initialization;
};
struct replay_context {
diff --git a/drivers/gpu/drm/amd/display/dc/inc/dc_core_interface.h b/drivers/gpu/drm/amd/display/dc/inc/dc_core_interface.h
index 4cd01e34a959..6e21ddb839a3 100644
--- a/drivers/gpu/drm/amd/display/dc/inc/dc_core_interface.h
+++ b/drivers/gpu/drm/amd/display/dc/inc/dc_core_interface.h
@@ -20,6 +20,12 @@ enum dc2_selection {
DC2_SELECTION_CORE2,
};
+/* Temporary: picks the CORE2 hardware init flow for bring-up testing. */
+enum dc2_init_method {
+ DC2_INIT_METHOD_LEGACY = 0,
+ DC2_INIT_METHOD_WRAPPED,
+};
+
enum dc2_hw_ownership {
DC2_HW_OWNERSHIP_RELEASED = 0,
DC2_HW_OWNERSHIP_OWNED,
diff --git a/drivers/gpu/drm/amd/display/dc/pmfw_messenger/dcn401_pmfw_messenger.c b/drivers/gpu/drm/amd/display/dc/pmfw_messenger/dcn401_pmfw_messenger.c
new file mode 100644
index 000000000000..79910c2dc16d
--- /dev/null
+++ b/drivers/gpu/drm/amd/display/dc/pmfw_messenger/dcn401_pmfw_messenger.c
@@ -0,0 +1,211 @@
+// SPDX-License-Identifier: MIT
+/*
+ * Copyright 2026 Advanced Micro Devices, Inc.
+ */
+
+#include "dm_services.h"
+
+#include "reg_helper.h"
+#include "pmfw_messenger/pmfw_messenger.h"
+
+#define mmDAL_MSG_REG 0x1628A
+#define mmDAL_ARG_REG 0x16273
+#define mmDAL_RESP_REG 0x16274
+
+#define REG(reg_name) \
+ mm ## reg_name
+
+#define CTX pmfw_messenger->ctx
+
+#define DCN401_PMFW_STATUS_IN_PROGRESS 0x00
+#define DCN401_PMFW_STATUS_OK 0x01
+
+#define DCN401_PMFW_POLL_DELAY_US 10
+#define DCN401_PMFW_POLL_MAX_RETRIES 200000
+
+#define DALSMC_VERSION 0x1
+#define DALSMC_Result_OK 0x1
+#define DALSMC_Result_Failed 0xFF
+#define DALSMC_Result_UnknownCmd 0xFE
+#define DALSMC_Result_CmdRejectedPrereq 0xFD
+#define DALSMC_Result_CmdRejectedBusy 0xFC
+#define DALSMC_MSG_TestMessage 0x1
+#define DALSMC_MSG_GetSmuVersion 0x2
+#define DALSMC_MSG_GetDriverIfVersion 0x3
+#define DALSMC_MSG_GetMsgHeaderVersion 0x4
+#define DALSMC_MSG_SetDalDramAddrHigh 0x5
+#define DALSMC_MSG_SetDalDramAddrLow 0x6
+#define DALSMC_MSG_TransferTableSmu2Dram 0x7
+#define DALSMC_MSG_TransferTableDram2Smu 0x8
+#define DALSMC_MSG_SetHardMinByFreq 0x9
+#define DALSMC_MSG_SetHardMaxByFreq 0xA
+#define DALSMC_MSG_GetDpmFreqByIndex 0xB
+#define DALSMC_MSG_GetDcModeMaxDpmFreq 0xC
+#define DALSMC_MSG_SetMinDeepSleepDcfclk 0xD
+#define DALSMC_MSG_NumOfDisplays 0xE
+#define DALSMC_MSG_SetExternalClientDfCstateAllow 0xF
+#define DALSMC_MSG_BacoAudioD3PME 0x10
+#define DALSMC_MSG_SetFclkSwitchAllow 0x11
+#define DALSMC_MSG_SetCabForUclkPstate 0x12
+#define DALSMC_MSG_SetWorstCaseUclkLatency 0x13
+#define DALSMC_MSG_DcnExitReset 0x14
+#define DALSMC_MSG_ReturnHardMinStatus 0x15
+#define DALSMC_MSG_SetAlwaysWaitDmcubResp 0x16
+#define DALSMC_MSG_IndicateDrrStatus 0x17
+#define DALSMC_MSG_ActiveUclkFclk 0x18
+#define DALSMC_MSG_IdleUclkFclk 0x19
+#define DALSMC_MSG_SetUclkPstateAllow 0x1A
+#define DALSMC_MSG_SubvpUclkFclk 0x1B
+#define DALSMC_MSG_GetNumUmcChannels 0x1C
+#define DALSMC_Message_Count 0x1D
+
+static uint32_t dcn401_pmfw_message_id(enum pmfw_message_id message_id)
+{
+ switch (message_id) {
+ case PMFW_MSG_TEST_MESSAGE: return DALSMC_MSG_TestMessage;
+ case PMFW_MSG_GET_SMU_VERSION: return DALSMC_MSG_GetSmuVersion;
+ case PMFW_MSG_GET_DRIVER_IF_VERSION: return DALSMC_MSG_GetDriverIfVersion;
+ case PMFW_MSG_GET_MSG_HEADER_VERSION: return DALSMC_MSG_GetMsgHeaderVersion;
+ case PMFW_MSG_SET_DAL_DRAM_ADDR_HIGH: return DALSMC_MSG_SetDalDramAddrHigh;
+ case PMFW_MSG_SET_DAL_DRAM_ADDR_LOW: return DALSMC_MSG_SetDalDramAddrLow;
+ case PMFW_MSG_TRANSFER_TABLE_SMU_TO_DRAM: return DALSMC_MSG_TransferTableSmu2Dram;
+ case PMFW_MSG_TRANSFER_TABLE_DRAM_TO_SMU: return DALSMC_MSG_TransferTableDram2Smu;
+ case PMFW_MSG_SET_HARD_MIN_BY_FREQ: return DALSMC_MSG_SetHardMinByFreq;
+ case PMFW_MSG_SET_HARD_MAX_BY_FREQ: return DALSMC_MSG_SetHardMaxByFreq;
+ case PMFW_MSG_GET_DPM_FREQ_BY_INDEX: return DALSMC_MSG_GetDpmFreqByIndex;
+ case PMFW_MSG_GET_DC_MODE_MAX_DPM_FREQ: return DALSMC_MSG_GetDcModeMaxDpmFreq;
+ case PMFW_MSG_SET_MIN_DEEP_SLEEP_DCFCLK: return DALSMC_MSG_SetMinDeepSleepDcfclk;
+ case PMFW_MSG_NUM_OF_DISPLAYS: return DALSMC_MSG_NumOfDisplays;
+ case PMFW_MSG_SET_EXTERNAL_CLIENT_DF_CSTATE_ALLOW: return DALSMC_MSG_SetExternalClientDfCstateAllow;
+ case PMFW_MSG_BACO_AUDIO_D3_PME: return DALSMC_MSG_BacoAudioD3PME;
+ case PMFW_MSG_SET_FCLK_SWITCH_ALLOW: return DALSMC_MSG_SetFclkSwitchAllow;
+ case PMFW_MSG_SET_CAB_FOR_UCLK_PSTATE: return DALSMC_MSG_SetCabForUclkPstate;
+ case PMFW_MSG_SET_WORST_CASE_UCLK_LATENCY: return DALSMC_MSG_SetWorstCaseUclkLatency;
+ case PMFW_MSG_DCN_EXIT_RESET: return DALSMC_MSG_DcnExitReset;
+ case PMFW_MSG_RETURN_HARD_MIN_STATUS: return DALSMC_MSG_ReturnHardMinStatus;
+ case PMFW_MSG_SET_ALWAYS_WAIT_DMCUB_RESP: return DALSMC_MSG_SetAlwaysWaitDmcubResp;
+ case PMFW_MSG_INDICATE_DRR_STATUS: return DALSMC_MSG_IndicateDrrStatus;
+ case PMFW_MSG_ACTIVE_UCLK_FCLK: return DALSMC_MSG_ActiveUclkFclk;
+ case PMFW_MSG_IDLE_UCLK_FCLK: return DALSMC_MSG_IdleUclkFclk;
+ case PMFW_MSG_SET_UCLK_PSTATE_ALLOW: return DALSMC_MSG_SetUclkPstateAllow;
+ case PMFW_MSG_SUBVP_UCLK_FCLK: return DALSMC_MSG_SubvpUclkFclk;
+ case PMFW_MSG_GET_NUM_UMC_CHANNELS: return DALSMC_MSG_GetNumUmcChannels;
+ default: return 0;
+ }
+}
+
+static uint32_t dcn401_pmfw_poll_status(struct pmfw_messenger *pmfw_messenger)
+{
+ unsigned int max_retries = DCN401_PMFW_POLL_MAX_RETRIES;
+ uint32_t status;
+
+ do {
+ status = REG_READ(DAL_RESP_REG);
+ if (status != DCN401_PMFW_STATUS_IN_PROGRESS)
+ break;
+
+ udelay(DCN401_PMFW_POLL_DELAY_US);
+ } while (max_retries--);
+
+ return status;
+}
+
+static enum pmfw_msg_result dcn401_pmfw_send_message(struct pmfw_messenger *pmfw_messenger,
+ struct pmfw_message message)
+{
+ uint32_t param;
+ uint32_t firmware_message_id;
+
+ if (pmfw_messenger->request_outstanding || message.param_count > 1)
+ return PMFW_MSG_ERROR;
+
+ firmware_message_id = dcn401_pmfw_message_id(message.msg_id);
+ if (!firmware_message_id)
+ return PMFW_MSG_ERROR;
+
+ param = message.param_count ? message.params[0] : 0;
+
+ /* DCN401 sends even if the previous request never completed. */
+ dcn401_pmfw_poll_status(pmfw_messenger);
+
+ TRACE_SMU_MSG_ENTER(firmware_message_id, param, pmfw_messenger->ctx);
+
+ REG_WRITE(DAL_RESP_REG, DCN401_PMFW_STATUS_IN_PROGRESS);
+ REG_WRITE(DAL_ARG_REG, param);
+ REG_WRITE(DAL_MSG_REG, firmware_message_id);
+
+ pmfw_messenger->request_outstanding = true;
+
+ return PMFW_MSG_OK;
+}
+
+static enum pmfw_msg_result dcn401_pmfw_wait_for_response(struct pmfw_messenger *pmfw_messenger,
+ struct pmfw_response *response)
+{
+ uint32_t status;
+
+ if (!response)
+ return PMFW_MSG_ERROR;
+
+ response->response_count = 0;
+
+ if (!pmfw_messenger->request_outstanding)
+ return PMFW_MSG_ERROR;
+
+ status = dcn401_pmfw_poll_status(pmfw_messenger);
+
+ if (status == DCN401_PMFW_STATUS_IN_PROGRESS) {
+ TRACE_SMU_MSG_EXIT(false, 0, pmfw_messenger->ctx);
+ /* A timed-out request is still owned by firmware; the Builder may wait again. */
+ return PMFW_MSG_TIMEOUT;
+ }
+
+ pmfw_messenger->request_outstanding = false;
+
+ if (status != DCN401_PMFW_STATUS_OK) {
+ TRACE_SMU_MSG_EXIT(false, 0, pmfw_messenger->ctx);
+ return PMFW_MSG_ERROR;
+ }
+
+ response->response[0] = REG_READ(DAL_ARG_REG);
+ response->response_count = 1;
+
+ TRACE_SMU_MSG_EXIT(true, response->response[0], pmfw_messenger->ctx);
+
+ return PMFW_MSG_OK;
+}
+
+static enum pmfw_msg_result dcn401_pmfw_send_message_and_wait(struct pmfw_messenger *pmfw_messenger,
+ struct pmfw_message message, struct pmfw_response *response)
+{
+ enum pmfw_msg_result result;
+
+ if (!response)
+ return PMFW_MSG_ERROR;
+
+ response->response_count = 0;
+
+ result = dcn401_pmfw_send_message(pmfw_messenger, message);
+ if (result != PMFW_MSG_OK)
+ return result;
+
+ result = dcn401_pmfw_wait_for_response(pmfw_messenger, response);
+ pmfw_messenger->request_outstanding = false;
+
+ return result;
+}
+
+static const struct pmfw_messenger_funcs dcn401_pmfw_messenger_funcs = {
+ .send_message = dcn401_pmfw_send_message,
+ .wait_for_response = dcn401_pmfw_wait_for_response,
+ .send_message_and_wait = dcn401_pmfw_send_message_and_wait,
+};
+
+void dcn401_pmfw_messenger_construct(struct pmfw_messenger *pmfw_messenger,
+ struct dc_context *ctx)
+{
+ pmfw_messenger->funcs = &dcn401_pmfw_messenger_funcs;
+ pmfw_messenger->ctx = ctx;
+ pmfw_messenger->inst = 0;
+ pmfw_messenger->request_outstanding = false;
+}
diff --git a/drivers/gpu/drm/amd/display/dc/pmfw_messenger/pmfw_messenger.c b/drivers/gpu/drm/amd/display/dc/pmfw_messenger/pmfw_messenger.c
new file mode 100644
index 000000000000..b35ffea381df
--- /dev/null
+++ b/drivers/gpu/drm/amd/display/dc/pmfw_messenger/pmfw_messenger.c
@@ -0,0 +1,62 @@
+// SPDX-License-Identifier: MIT
+/*
+ * Copyright 2026 Advanced Micro Devices, Inc.
+ */
+
+#include "dm_services.h"
+#include "dc_types.h"
+#include "pmfw_messenger/pmfw_messenger.h"
+
+static enum pmfw_msg_result pmfw_absent_send_message(
+ struct pmfw_messenger *pmfw_messenger, struct pmfw_message message)
+{
+ (void)pmfw_messenger;
+ (void)message;
+ return PMFW_MSG_NOT_PRESENT;
+}
+
+static enum pmfw_msg_result pmfw_absent_wait_for_response(
+ struct pmfw_messenger *pmfw_messenger, struct pmfw_response *response)
+{
+ (void)pmfw_messenger;
+ if (response)
+ response->response_count = 0;
+
+ return PMFW_MSG_NOT_PRESENT;
+}
+
+static enum pmfw_msg_result pmfw_absent_send_message_and_wait(
+ struct pmfw_messenger *pmfw_messenger, struct pmfw_message message,
+ struct pmfw_response *response)
+{
+ (void)message;
+ return pmfw_absent_wait_for_response(pmfw_messenger, response);
+}
+
+static const struct pmfw_messenger_funcs pmfw_absent_funcs = {
+ .send_message = pmfw_absent_send_message,
+ .wait_for_response = pmfw_absent_wait_for_response,
+ .send_message_and_wait = pmfw_absent_send_message_and_wait,
+};
+
+void pmfw_messenger_construct(struct pmfw_messenger *m, struct dc_context *ctx)
+{
+ if (!m)
+ return;
+
+ m->funcs = &pmfw_absent_funcs;
+ m->ctx = ctx;
+ m->inst = 0;
+ m->request_outstanding = false;
+
+ if (!ctx)
+ return;
+
+ switch (ctx->dce_version) {
+ case DCN_VERSION_4_01:
+ dcn401_pmfw_messenger_construct(m, ctx);
+ break;
+ default:
+ break;
+ }
+}
diff --git a/drivers/gpu/drm/amd/display/dc/pmfw_messenger/pmfw_messenger.h b/drivers/gpu/drm/amd/display/dc/pmfw_messenger/pmfw_messenger.h
new file mode 100644
index 000000000000..5c7233d48df9
--- /dev/null
+++ b/drivers/gpu/drm/amd/display/dc/pmfw_messenger/pmfw_messenger.h
@@ -0,0 +1,118 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright 2026 Advanced Micro Devices, Inc.
+ */
+
+#pragma once
+
+#include "dm_services_types.h"
+
+struct dc_context;
+struct pmfw_messenger;
+
+#define PMFW_MESSENGER_MAX_MESSAGE_PARAMS 4
+#define PMFW_MESSENGER_MAX_RESPONSE_WORDS 1
+#define PMFW_MAX_NUM_DPM_LVL 8
+
+enum pmfw_message_id {
+ PMFW_MSG_TEST_MESSAGE,
+ PMFW_MSG_GET_SMU_VERSION,
+ PMFW_MSG_GET_PMFW_VERSION,
+ PMFW_MSG_GET_DRIVER_IF_VERSION,
+ PMFW_MSG_GET_MSG_HEADER_VERSION,
+ PMFW_MSG_SET_DAL_DRAM_ADDR_HIGH,
+ PMFW_MSG_SET_DAL_DRAM_ADDR_LOW,
+ PMFW_MSG_SET_DRAM_ADDR_HIGH,
+ PMFW_MSG_SET_DRAM_ADDR_LOW,
+ PMFW_MSG_TRANSFER_TABLE_SMU_TO_DRAM,
+ PMFW_MSG_TRANSFER_TABLE_DRAM_TO_SMU,
+ PMFW_MSG_SET_HARD_MIN_BY_FREQ,
+ PMFW_MSG_SET_HARD_MAX_BY_FREQ,
+ PMFW_MSG_GET_DPM_FREQ_BY_INDEX,
+ PMFW_MSG_GET_DC_MODE_MAX_DPM_FREQ,
+ PMFW_MSG_SET_MIN_DEEP_SLEEP_DCFCLK,
+ PMFW_MSG_NUM_OF_DISPLAYS,
+ PMFW_MSG_SET_EXTERNAL_CLIENT_DF_CSTATE_ALLOW,
+ PMFW_MSG_BACO_AUDIO_D3_PME,
+ PMFW_MSG_SACO_AUDIO_D3_PME,
+ PMFW_MSG_SET_FCLK_SWITCH_ALLOW,
+ PMFW_MSG_SET_CAB_FOR_UCLK_PSTATE,
+ PMFW_MSG_SET_WORST_CASE_UCLK_LATENCY,
+ PMFW_MSG_DCN_EXIT_RESET,
+ PMFW_MSG_RETURN_HARD_MIN_STATUS,
+ PMFW_MSG_SET_ALWAYS_WAIT_DMCUB_RESP,
+ PMFW_MSG_INDICATE_DRR_STATUS,
+ PMFW_MSG_ACTIVE_UCLK_FCLK,
+ PMFW_MSG_IDLE_UCLK_FCLK,
+ PMFW_MSG_SET_UCLK_PSTATE_ALLOW,
+ PMFW_MSG_SUBVP_UCLK_FCLK,
+ PMFW_MSG_GET_NUM_UMC_CHANNELS,
+ PMFW_MSG_SET_DISPCLK_FREQ,
+ PMFW_MSG_SET_DPPCLK_FREQ,
+ PMFW_MSG_SET_HARD_MIN_DCFCLK_BY_FREQ,
+ PMFW_MSG_UPDATE_PME_RESTORE,
+ PMFW_MSG_GET_FCLK_FREQUENCY,
+ PMFW_MSG_SET_DISPLAY_IDLE_OPTIMIZATIONS,
+ PMFW_MSG_GET_DPREFCLK_FREQ,
+ PMFW_MSG_GET_DTBCLK_FREQ,
+ PMFW_MSG_ALLOW_ZSTATES_ENTRY,
+ PMFW_MSG_ALLOW_ZSTATES_ENTRY_SPARE0,
+ PMFW_MSG_SET_DTB_CLK,
+ PMFW_MSG_DISP_IPS2_EXIT,
+ PMFW_MSG_DISP_IPS2_EXIT_SPARE1,
+ PMFW_MSG_QUERY_IPS2_SUPPORT,
+ PMFW_MSG_DF_CSTATE_DISABLE,
+ PMFW_MSG_BANDWIDTH_REQUEST,
+ PMFW_MSG_UPDATE_UTM_QOS_PARAMS,
+ PMFW_MSG_STUTTER_EFFICIENCY,
+ PMFW_MSG_GET_DISPCLK_FREQ,
+ PMFW_MSG_GET_DPPCLK_FREQ,
+ PMFW_MSG_INDICATE_PSTATE_STATUS,
+};
+
+enum pmfw_clocks {
+ PMFW_CLOCK_DCFCLK,
+ PMFW_CLOCK_SOCCLK,
+ PMFW_CLOCK_DTBCLK,
+ PMFW_CLOCK_DISPCLK,
+ PMFW_CLOCK_DPPCLK,
+ PMFW_CLOCK_UCLK,
+ PMFW_CLOCK_FCLK,
+ PMFW_CLOCK_COUNT,
+};
+
+struct pmfw_message {
+ enum pmfw_message_id msg_id;
+ uint32_t param_count;
+ uint32_t params[PMFW_MESSENGER_MAX_MESSAGE_PARAMS];
+};
+
+struct pmfw_response {
+ uint32_t response_count;
+ uint32_t response[PMFW_MESSENGER_MAX_RESPONSE_WORDS];
+};
+
+enum pmfw_msg_result {
+ PMFW_MSG_OK,
+ PMFW_MSG_NOT_PRESENT,
+ PMFW_MSG_TIMEOUT,
+ PMFW_MSG_ERROR,
+};
+
+struct pmfw_messenger_funcs {
+ enum pmfw_msg_result (*send_message)(struct pmfw_messenger *pmfw_messenger, struct pmfw_message message);
+ enum pmfw_msg_result (*wait_for_response)(struct pmfw_messenger *pmfw_messenger, struct pmfw_response *response);
+ enum pmfw_msg_result (*send_message_and_wait)(struct pmfw_messenger *pmfw_messenger, struct pmfw_message message,
+ struct pmfw_response *response);
+};
+
+struct pmfw_messenger {
+ const struct pmfw_messenger_funcs *funcs;
+ struct dc_context *ctx;
+ unsigned int inst;
+ bool request_outstanding;
+};
+
+void pmfw_messenger_construct(struct pmfw_messenger *m, struct dc_context *ctx);
+
+void dcn401_pmfw_messenger_construct(struct pmfw_messenger *m, struct dc_context *ctx);
--
2.43.0
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [PATCH 20/33] drm/amd/display: Honor the Replay stream regeneration wait event
2026-11-16 21:50 [PATCH 00/33] DC Patches November 23, 2026 James Lin
` (18 preceding siblings ...)
2026-11-16 21:50 ` [PATCH 19/33] drm/amd/display: Add DC2 wrapped initialization for DCN401 James Lin
@ 2026-11-16 21:50 ` James Lin
2026-11-16 21:50 ` [PATCH 21/33] drm/amd/display: Disable Replay when link off frame count is below 2 James Lin
` (12 subsequent siblings)
32 siblings, 0 replies; 34+ messages in thread
From: James Lin @ 2026-11-16 21:50 UTC (permalink / raw)
To: amd-gfx
Cc: Harry Wentland, Leo Li, Aurabindo Pillai, Roman Li, Wayne Lin,
Tom Chung, Fangzhi Zuo, Dan Wheeler, Ray Wu, Ivan Lipski,
Alex Hung, James Lin, Chenyu Chen, Harry VanZyllDeJong,
Leon Huang, Mario Limonciello, Alex Deucher, stable, James Lin
From: Harry VanZyllDeJong <hvanzyll@amd.com>
[Why]
The shared FreeSync Replay inactive mask omits the stream regeneration
wait event. Replay can become eligible before the regeneration wait
period expires after stream enable.
[How]
Include the regeneration wait in the inactive mask. Exercise the
public event API to verify nominal coasting while waiting and
restoration of static-screen coasting after the event clears.
Cc: Leon Huang <leon.huang1@amd.com>
Cc: Mario Limonciello <mario.limonciello@amd.com>
Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: stable@vger.kernel.org
Signed-off-by: Harry VanZyllDeJong <hvanzyll@amd.com>
Signed-off-by: James Lin <pinglei.lin@amd.com>
---
drivers/gpu/drm/amd/display/modules/power/power_replay.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/gpu/drm/amd/display/modules/power/power_replay.c b/drivers/gpu/drm/amd/display/modules/power/power_replay.c
index fcfb6066066c..6b1955ff2109 100644
--- a/drivers/gpu/drm/amd/display/modules/power/power_replay.c
+++ b/drivers/gpu/drm/amd/display/modules/power/power_replay.c
@@ -232,6 +232,7 @@ static bool mod_power_update_replay_active_status(unsigned int active_replay_eve
replay_event_sleep_resume |
replay_event_disable_in_AC |
replay_event_disable_replay_while_detect_display |
+ replay_event_waiting_stream_regen |
replay_event_infopacket |
replay_event_crc_window_active))
return false;
--
2.43.0
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [PATCH 21/33] drm/amd/display: Disable Replay when link off frame count is below 2
2026-11-16 21:50 [PATCH 00/33] DC Patches November 23, 2026 James Lin
` (19 preceding siblings ...)
2026-11-16 21:50 ` [PATCH 20/33] drm/amd/display: Honor the Replay stream regeneration wait event James Lin
@ 2026-11-16 21:50 ` James Lin
2026-11-16 21:50 ` [PATCH 22/33] drm/amd/display: Skip DSC padding borrow estimate for zero padding James Lin
` (11 subsequent siblings)
32 siblings, 0 replies; 34+ messages in thread
From: James Lin @ 2026-11-16 21:50 UTC (permalink / raw)
To: amd-gfx
Cc: Harry Wentland, Leo Li, Aurabindo Pillai, Roman Li, Wayne Lin,
Tom Chung, Fangzhi Zuo, Dan Wheeler, Ray Wu, Ivan Lipski,
Alex Hung, James Lin, Chenyu Chen, Ray Wu, James Lin
From: Ray Wu <ray.wu@amd.com>
[Why]
Replay must be disabled when the link off frame count of the selected
timing, computed from the sink max deviation lines, is less than 2.
amdgpu_dm_link_setup_replay() computed it but never used it.
[How]
Clear replay_supported on a modeset when link_off_frame_count is below
PR_LINK_OFF_FRAME_COUNT_GOOD. Re-evaluate it on a later timing while
keeping the disallow_edp_enter_replay and freesync caps disables.
Cc: ChiaHsuan Chung <chiahsuan.chung@amd.com>
Signed-off-by: Ray Wu <ray.wu@amd.com>
Signed-off-by: James Lin <pinglei.lin@amd.com>
---
.../amd/display/amdgpu_dm/amdgpu_dm_replay.c | 23 +++-
.../amdgpu_dm/tests/amdgpu_dm_replay_test.c | 129 ++++++++++++++++++
2 files changed, 151 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_replay.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_replay.c
index ee2e4754b089..2106122d4031 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_replay.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_replay.c
@@ -142,6 +142,7 @@ EXPORT_IF_KUNIT(amdgpu_dm_set_replay_caps);
bool amdgpu_dm_link_setup_replay(struct dc_stream_state *stream,
struct mod_vrr_params *vrr_params)
{
+ struct amdgpu_dm_connector *aconnector;
struct dc_link *link;
unsigned int static_coasting_vtotal;
@@ -149,7 +150,8 @@ bool amdgpu_dm_link_setup_replay(struct dc_stream_state *stream,
return false;
link = stream->link;
- if (!link->replay_settings.config.replay_supported)
+ aconnector = (struct amdgpu_dm_connector *)stream->dm_stream_context;
+ if (!link->replay_settings.config.replay_cap_support || !aconnector)
return false;
if (link->replay_settings.replay_feature_enabled)
@@ -158,6 +160,25 @@ bool amdgpu_dm_link_setup_replay(struct dc_stream_state *stream,
calculate_replay_link_off_frame_count(link, stream->timing.v_total,
stream->timing.h_total);
+ /* FreeSync Replay must stay off for timings with link off frame count < 2 */
+ if (link->replay_settings.config.replay_version == DC_FREESYNC_REPLAY &&
+ link->replay_settings.link_off_frame_count < PR_LINK_OFF_FRAME_COUNT_GOOD) {
+ link->replay_settings.config.replay_supported = false;
+ return false;
+ }
+
+ /*
+ * replay_supported may have been cleared by the link off check of a
+ * previous timing, by disallow_edp_enter_replay or by a freesync caps
+ * update. Re-evaluate it so only the first case is restored here.
+ */
+ if (!link->replay_settings.config.replay_supported)
+ link->replay_settings.config.replay_supported =
+ !aconnector->disallow_edp_enter_replay &&
+ amdgpu_dm_link_supports_replay(link, aconnector);
+ if (!link->replay_settings.config.replay_supported)
+ return false;
+
static_coasting_vtotal = mod_freesync_calc_v_total_from_refresh(stream,
vrr_params->min_refresh_in_uhz);
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_replay_test.c b/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_replay_test.c
index 6f633b1bbaca..bdbf11bfc785 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_replay_test.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_replay_test.c
@@ -47,6 +47,7 @@ static struct replay_test_ctx *alloc_replay_ctx(struct kunit *test)
KUNIT_ASSERT_NOT_NULL(test, ctx->dm_state);
ctx->stream = dm_kunit_alloc_stream(test, ctx->link);
+ ctx->stream->dm_stream_context = ctx->aconnector;
/* Wire connector state so to_dm_connector_state() works */
ctx->aconnector->base.state = &ctx->dm_state->base;
@@ -377,6 +378,7 @@ static void dm_test_replay_link_setup_already_enabled(struct kunit *test)
struct replay_test_ctx *ctx = alloc_replay_ctx(test);
struct mod_vrr_params vrr_params = { 0 };
+ ctx->link->replay_settings.config.replay_cap_support = true;
ctx->link->replay_settings.config.replay_supported = true;
ctx->link->replay_settings.replay_feature_enabled = true;
@@ -396,6 +398,8 @@ static void dm_test_replay_link_setup_success(struct kunit *test)
struct replay_test_ctx *ctx = alloc_replay_ctx(test);
struct mod_vrr_params vrr_params = { 0 };
+ set_all_replay_caps(ctx);
+ ctx->link->replay_settings.config.replay_cap_support = true;
ctx->link->replay_settings.config.replay_supported = true;
ctx->link->replay_settings.config.replay_version = DC_FREESYNC_REPLAY;
@@ -425,6 +429,126 @@ static void dm_test_replay_link_setup_success(struct kunit *test)
(uint32_t)4);
}
+/*
+ * Helper: prepare a FreeSync Replay capable link with a 1125/2200 timing and
+ * the given max deviation line, so link off frame count is
+ * 2200 * max_deviation_line / (4 * 1125).
+ */
+static void setup_link_off_ctx(struct replay_test_ctx *ctx, uint16_t max_deviation_line)
+{
+ set_all_replay_caps(ctx);
+ ctx->link->replay_settings.config.replay_cap_support = true;
+ ctx->link->replay_settings.config.replay_supported = true;
+ ctx->link->replay_settings.config.replay_version = DC_FREESYNC_REPLAY;
+
+ ctx->stream->timing.v_total = 1125;
+ ctx->stream->timing.h_total = 2200;
+ ctx->stream->timing.pix_clk_100hz = 1485000;
+ ctx->link->dpcd_caps.pr_info.pixel_deviation_per_line = 4;
+ ctx->link->dpcd_caps.pr_info.max_deviation_line = max_deviation_line;
+}
+
+/**
+ * dm_test_replay_link_setup_link_off_below_good - Verify link off gate
+ * @test: KUnit test context
+ *
+ * When the link off frame count of the timing is below
+ * PR_LINK_OFF_FRAME_COUNT_GOOD, Replay must be disabled for this timing.
+ */
+static void dm_test_replay_link_setup_link_off_below_good(struct kunit *test)
+{
+ struct replay_test_ctx *ctx = alloc_replay_ctx(test);
+ struct mod_vrr_params vrr_params = { 0 };
+
+ /* 2200*3/(4*1125) = 1 */
+ setup_link_off_ctx(ctx, 3);
+
+ KUNIT_EXPECT_FALSE(test, amdgpu_dm_link_setup_replay(ctx->stream, &vrr_params));
+ KUNIT_EXPECT_EQ(test, ctx->link->replay_settings.link_off_frame_count, (uint32_t)1);
+ KUNIT_EXPECT_FALSE(test, ctx->link->replay_settings.config.replay_supported);
+}
+
+/**
+ * dm_test_replay_link_setup_link_off_at_good - Verify link off gate boundary
+ * @test: KUnit test context
+ *
+ * A link off frame count equal to PR_LINK_OFF_FRAME_COUNT_GOOD keeps Replay
+ * supported.
+ */
+static void dm_test_replay_link_setup_link_off_at_good(struct kunit *test)
+{
+ struct replay_test_ctx *ctx = alloc_replay_ctx(test);
+ struct mod_vrr_params vrr_params = { 0 };
+
+ /* 2200*5/(4*1125) = 2 */
+ setup_link_off_ctx(ctx, 5);
+
+ KUNIT_EXPECT_TRUE(test, amdgpu_dm_link_setup_replay(ctx->stream, &vrr_params));
+ KUNIT_EXPECT_EQ(test, ctx->link->replay_settings.link_off_frame_count, (uint32_t)2);
+ KUNIT_EXPECT_TRUE(test, ctx->link->replay_settings.config.replay_supported);
+}
+
+/**
+ * dm_test_replay_link_setup_link_off_restored - Verify Replay is restored
+ * @test: KUnit test context
+ *
+ * After a timing disabled Replay by the link off gate, a later timing with a
+ * sufficient link off frame count must make Replay supported again.
+ */
+static void dm_test_replay_link_setup_link_off_restored(struct kunit *test)
+{
+ struct replay_test_ctx *ctx = alloc_replay_ctx(test);
+ struct mod_vrr_params vrr_params = { 0 };
+
+ setup_link_off_ctx(ctx, 3);
+ KUNIT_EXPECT_FALSE(test, amdgpu_dm_link_setup_replay(ctx->stream, &vrr_params));
+ KUNIT_EXPECT_FALSE(test, ctx->link->replay_settings.config.replay_supported);
+
+ ctx->link->dpcd_caps.pr_info.max_deviation_line = 10;
+ KUNIT_EXPECT_TRUE(test, amdgpu_dm_link_setup_replay(ctx->stream, &vrr_params));
+ KUNIT_EXPECT_TRUE(test, ctx->link->replay_settings.config.replay_supported);
+}
+
+/**
+ * dm_test_replay_link_setup_disallowed_by_debugfs - Verify debugfs is honored
+ * @test: KUnit test context
+ *
+ * A sufficient link off frame count must not re-enable Replay while
+ * disallow_edp_enter_replay is set.
+ */
+static void dm_test_replay_link_setup_disallowed_by_debugfs(struct kunit *test)
+{
+ struct replay_test_ctx *ctx = alloc_replay_ctx(test);
+ struct mod_vrr_params vrr_params = { 0 };
+
+ setup_link_off_ctx(ctx, 10);
+ ctx->aconnector->disallow_edp_enter_replay = true;
+ ctx->link->replay_settings.config.replay_supported = false;
+
+ KUNIT_EXPECT_FALSE(test, amdgpu_dm_link_setup_replay(ctx->stream, &vrr_params));
+ KUNIT_EXPECT_FALSE(test, ctx->link->replay_settings.config.replay_supported);
+}
+
+/**
+ * dm_test_replay_link_setup_freesync_not_capable - Verify freesync is honored
+ * @test: KUnit test context
+ *
+ * A sufficient link off frame count must not re-enable Replay while the
+ * connector is not freesync capable.
+ */
+static void dm_test_replay_link_setup_freesync_not_capable(struct kunit *test)
+{
+ struct replay_test_ctx *ctx = alloc_replay_ctx(test);
+ struct mod_vrr_params vrr_params = { 0 };
+
+ setup_link_off_ctx(ctx, 10);
+ ctx->dm_state->freesync_capable = false;
+ ctx->link->replay_settings.config.replay_supported = false;
+
+ KUNIT_EXPECT_FALSE(test, amdgpu_dm_link_setup_replay(ctx->stream, &vrr_params));
+ KUNIT_EXPECT_FALSE(test, ctx->link->replay_settings.config.replay_supported);
+}
+
/* Tests for amdgpu_dm_replay_set_event() */
/**
@@ -604,6 +728,11 @@ static struct kunit_case dm_replay_test_cases[] = {
KUNIT_CASE(dm_test_replay_link_setup_not_supported),
KUNIT_CASE(dm_test_replay_link_setup_already_enabled),
KUNIT_CASE(dm_test_replay_link_setup_success),
+ KUNIT_CASE(dm_test_replay_link_setup_link_off_below_good),
+ KUNIT_CASE(dm_test_replay_link_setup_link_off_at_good),
+ KUNIT_CASE(dm_test_replay_link_setup_link_off_restored),
+ KUNIT_CASE(dm_test_replay_link_setup_disallowed_by_debugfs),
+ KUNIT_CASE(dm_test_replay_link_setup_freesync_not_capable),
/* amdgpu_dm_replay_set_event */
KUNIT_CASE(dm_test_replay_set_event_null_stream),
KUNIT_CASE(dm_test_replay_set_event_null_link),
--
2.43.0
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [PATCH 22/33] drm/amd/display: Skip DSC padding borrow estimate for zero padding
2026-11-16 21:50 [PATCH 00/33] DC Patches November 23, 2026 James Lin
` (20 preceding siblings ...)
2026-11-16 21:50 ` [PATCH 21/33] drm/amd/display: Disable Replay when link off frame count is below 2 James Lin
@ 2026-11-16 21:50 ` James Lin
2026-11-16 21:51 ` [PATCH 23/33] drm/amd/display: Drop unused DC interfaces James Lin
` (10 subsequent siblings)
32 siblings, 0 replies; 34+ messages in thread
From: James Lin @ 2026-11-16 21:50 UTC (permalink / raw)
To: amd-gfx
Cc: Harry Wentland, Leo Li, Aurabindo Pillai, Roman Li, Wayne Lin,
Tom Chung, Fangzhi Zuo, Dan Wheeler, Ray Wu, Ivan Lipski,
Alex Hung, James Lin, Chenyu Chen, Nicholas Kazlauskas, Aric Cyr,
Mario Limonciello, Alex Deucher, stable, James Lin
From: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com>
[Why]
For non-DSC streams the DSC padding is zero.
This causes the borrow-mode estimate to always borrow instead of
falling back to FRL_BORROW_MODE_NONE.
[How]
Return early in update_borrow_mode_from_dsc_padding() when both
hactive and htotal padding are zero.
Cc: Aric Cyr <aric.cyr@amd.com>
Cc: Mario Limonciello <mario.limonciello@amd.com>
Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: stable@vger.kernel.org
Signed-off-by: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com>
Signed-off-by: James Lin <pinglei.lin@amd.com>
---
drivers/gpu/drm/amd/display/dc/link/protocols/link_hdmi_frl.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/gpu/drm/amd/display/dc/link/protocols/link_hdmi_frl.c b/drivers/gpu/drm/amd/display/dc/link/protocols/link_hdmi_frl.c
index 2eaa830662b0..cb201c9ee3c6 100644
--- a/drivers/gpu/drm/amd/display/dc/link/protocols/link_hdmi_frl.c
+++ b/drivers/gpu/drm/amd/display/dc/link/protocols/link_hdmi_frl.c
@@ -1173,6 +1173,10 @@ static void update_borrow_mode_from_dsc_padding(struct dsc_padding_params *dsc_p
uint32_t h_blank = timing->h_total - h_active;
struct frl_borrow_params *borrow_params = &frl_link_settings->borrow_params;
+ if (dsc_padding_params->dsc_hactive_padding == 0 &&
+ dsc_padding_params->dsc_htotal_padding == 0)
+ return;
+
borrow_params->borrow_mode = frl_modify_borrow_mode_for_dsc_padding(timing->pix_clk_100hz,
h_active,
h_active + dsc_padding_params->dsc_hactive_padding,
--
2.43.0
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [PATCH 23/33] drm/amd/display: Drop unused DC interfaces
2026-11-16 21:50 [PATCH 00/33] DC Patches November 23, 2026 James Lin
` (21 preceding siblings ...)
2026-11-16 21:50 ` [PATCH 22/33] drm/amd/display: Skip DSC padding borrow estimate for zero padding James Lin
@ 2026-11-16 21:51 ` James Lin
2026-11-16 21:51 ` [PATCH 24/33] drm/amd/display: Let the DC2 commit replace or keep a stream James Lin
` (9 subsequent siblings)
32 siblings, 0 replies; 34+ messages in thread
From: James Lin @ 2026-11-16 21:51 UTC (permalink / raw)
To: amd-gfx
Cc: Harry Wentland, Leo Li, Aurabindo Pillai, Roman Li, Wayne Lin,
Tom Chung, Fangzhi Zuo, Dan Wheeler, Ray Wu, Ivan Lipski,
Alex Hung, James Lin, Chenyu Chen, Nicholas Kazlauskas, Aric Cyr,
James Lin
From: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com>
[why & how]
Cleanup for unused interfaces no longer in use by any DCN revision.
Cc: Aric Cyr <aric.cyr@amd.com>
Signed-off-by: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com>
Signed-off-by: James Lin <pinglei.lin@amd.com>
---
drivers/gpu/drm/amd/display/dc/dc.h | 8 --------
drivers/gpu/drm/amd/display/dc/dc_hw_types.h | 6 ------
drivers/gpu/drm/amd/display/dc/hwss/dcn30/dcn30_hwseq.h | 8 --------
drivers/gpu/drm/amd/display/dc/inc/hw/timing_generator.h | 4 ----
4 files changed, 26 deletions(-)
diff --git a/drivers/gpu/drm/amd/display/dc/dc.h b/drivers/gpu/drm/amd/display/dc/dc.h
index 775259e5e478..7d0a47e7bc1a 100644
--- a/drivers/gpu/drm/amd/display/dc/dc.h
+++ b/drivers/gpu/drm/amd/display/dc/dc.h
@@ -2489,14 +2489,6 @@ struct dc_plane_state *dc_get_surface_for_mpcc(struct dc *dc,
uint32_t dc_get_opp_for_plane(struct dc *dc, struct dc_plane_state *plane);
-bool dc_set_fva_vrr_adjust(struct dc *dc,
- struct dc_stream_state *stream,
- struct fva_adj *fva_adj,
- struct dc_crtc_timing_adjust *vrr_adj);
-
-int dc_get_hw_max_fva_factor(struct dc *dc,
- struct dc_stream_state *stream,
- unsigned int max_pixel_clock);
void dc_set_vstartup_start(struct dc *dc,
struct dc_stream_state *stream);
diff --git a/drivers/gpu/drm/amd/display/dc/dc_hw_types.h b/drivers/gpu/drm/amd/display/dc/dc_hw_types.h
index 20504dfb1b13..387d2ebb2b7c 100644
--- a/drivers/gpu/drm/amd/display/dc/dc_hw_types.h
+++ b/drivers/gpu/drm/amd/display/dc/dc_hw_types.h
@@ -1207,12 +1207,6 @@ struct mcif_buf_params {
uint8_t tmz_id;
};
-struct fva_adj {
- unsigned int pixel_clock_100hz;
- unsigned int max_pixel_clock_100hz;
- unsigned int fva_factor;
-};
-
enum symclk_state {
SYMCLK_OFF_TX_OFF,
SYMCLK_ON_TX_ON,
diff --git a/drivers/gpu/drm/amd/display/dc/hwss/dcn30/dcn30_hwseq.h b/drivers/gpu/drm/amd/display/dc/hwss/dcn30/dcn30_hwseq.h
index 65014d42195c..61470a51da23 100644
--- a/drivers/gpu/drm/amd/display/dc/hwss/dcn30/dcn30_hwseq.h
+++ b/drivers/gpu/drm/amd/display/dc/hwss/dcn30/dcn30_hwseq.h
@@ -72,14 +72,6 @@ enum dc_status dcn30_setup_hdmi_frl_link(
struct dc_link *link,
int hpo_inst,
enum clock_source_id frl_phy_clock_source_id);
-void dcn30_hw_set_fva_vrr_adj(struct dc *dc, struct pipe_ctx **pipe_ctx, int num_pipes,
- struct fva_adj *fva_adj,
- struct dc_crtc_timing_adjust *vrr_adj);
-
-int dcn30_hw_get_max_fva_factor(struct dc *dc,
- struct pipe_ctx *pipe_ctx,
- struct dc_crtc_timing *timing,
- unsigned int max_pixel_clock);
bool dcn30_does_plane_fit_in_mall(struct dc *dc,
unsigned int pitch,
diff --git a/drivers/gpu/drm/amd/display/dc/inc/hw/timing_generator.h b/drivers/gpu/drm/amd/display/dc/inc/hw/timing_generator.h
index 52d4d57358cd..c538e89bfac4 100644
--- a/drivers/gpu/drm/amd/display/dc/inc/hw/timing_generator.h
+++ b/drivers/gpu/drm/amd/display/dc/inc/hw/timing_generator.h
@@ -494,10 +494,6 @@ struct timing_generator_funcs {
void (*set_out_mux)(struct timing_generator *tg, enum otg_out_mux_dest dest);
void (*set_drr_trigger_window)(struct timing_generator *optc,
uint32_t window_start, uint32_t window_end);
- int (*set_fva_factor)(struct timing_generator *optc, struct fva_adj *fva_adj);
- int (*get_max_hw_supported_fva_factor)(struct timing_generator *optc,
- struct dc_crtc_timing *timing,
- unsigned int max_pixclk_100hz);
void (*set_vtotal_change_limit)(struct timing_generator *optc,
uint32_t limit);
void (*align_vblanks)(struct timing_generator *master_optc,
--
2.43.0
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [PATCH 24/33] drm/amd/display: Let the DC2 commit replace or keep a stream
2026-11-16 21:50 [PATCH 00/33] DC Patches November 23, 2026 James Lin
` (22 preceding siblings ...)
2026-11-16 21:51 ` [PATCH 23/33] drm/amd/display: Drop unused DC interfaces James Lin
@ 2026-11-16 21:51 ` James Lin
2026-11-16 21:51 ` [PATCH 25/33] drm/amd/display: Support two streams in the dcn401 DC2 builders James Lin
` (8 subsequent siblings)
32 siblings, 0 replies; 34+ messages in thread
From: James Lin @ 2026-11-16 21:51 UTC (permalink / raw)
To: amd-gfx
Cc: Harry Wentland, Leo Li, Aurabindo Pillai, Roman Li, Wayne Lin,
Tom Chung, Fangzhi Zuo, Dan Wheeler, Ray Wu, Ivan Lipski,
Alex Hung, James Lin, Chenyu Chen, Tony Cheng, James Lin
From: Tony Cheng <tony.cheng@amd.com>
[Why]
The dcn401 non-seamless commit builder rejects a commit when both
states have a stream, or when the link of the new stream is active.
A commit that replaces a stream on the same link fails.
[How]
Remove the check that rejects a stream in both states. The builder
disables the current stream before it enables the new stream, so it
programs all pipes of the new stream again. Accept an active link when
the current stream uses that link.
Signed-off-by: Tony Cheng <tony.cheng@amd.com>
Signed-off-by: James Lin <pinglei.lin@amd.com>
---
.../bls_builder/dcn401_non_seamless_builder.c | 24 +++++++++----------
1 file changed, 11 insertions(+), 13 deletions(-)
diff --git a/drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_non_seamless_builder.c b/drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_non_seamless_builder.c
index f9aa8f0b9b1e..d5adbef8a6f1 100644
--- a/drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_non_seamless_builder.c
+++ b/drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_non_seamless_builder.c
@@ -139,24 +139,23 @@ static enum bls_builder_result dcn401_check_commit_state_support(
return BLS_BUILD_SUCCESS;
}
-static bool check_stream_not_kept(const struct dc *dc,
- const struct dc_state *current_state,
- const struct dc_state *new_state)
-{
- (void)dc;
- /* A stream is either removed or added, never kept. */
- return !current_state->stream_count || !new_state->stream_count;
-}
-
+/*
+ * The current stream is disabled before the new one is enabled, so the
+ * link may be active when it carries the current stream.
+ */
static bool check_link_not_active(const struct dc *dc,
const struct dc_state *current_state,
const struct dc_state *new_state)
{
+ const struct dc_link *link;
+
(void)dc;
- (void)current_state;
if (!new_state->stream_count)
return true;
- return !new_state->streams[0]->link->link_status.link_active;
+ link = new_state->streams[0]->link;
+ return !link->link_status.link_active ||
+ (current_state->stream_count &&
+ current_state->streams[0]->link == link);
}
static enum bls_builder_result dcn401_check_non_seamless_commit_support(
@@ -180,8 +179,7 @@ static enum bls_builder_result dcn401_check_non_seamless_commit_support(
if (result != BLS_BUILD_SUCCESS)
return result;
- CHECK_CONDITION(stream_not_kept, "stream is kept across the commit");
- CHECK_CONDITION(link_not_active, "link is already active");
+ CHECK_CONDITION(link_not_active, "link is active on another stream");
return BLS_BUILD_SUCCESS;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [PATCH 25/33] drm/amd/display: Support two streams in the dcn401 DC2 builders
2026-11-16 21:50 [PATCH 00/33] DC Patches November 23, 2026 James Lin
` (23 preceding siblings ...)
2026-11-16 21:51 ` [PATCH 24/33] drm/amd/display: Let the DC2 commit replace or keep a stream James Lin
@ 2026-11-16 21:51 ` James Lin
2026-11-16 21:51 ` [PATCH 26/33] drm/amd/display: Add a plane beside a kept plane in DC2 update James Lin
` (7 subsequent siblings)
32 siblings, 0 replies; 34+ messages in thread
From: James Lin @ 2026-11-16 21:51 UTC (permalink / raw)
To: amd-gfx
Cc: Harry Wentland, Leo Li, Aurabindo Pillai, Roman Li, Wayne Lin,
Tom Chung, Fangzhi Zuo, Dan Wheeler, Ray Wu, Ivan Lipski,
Alex Hung, James Lin, Chenyu Chen, Tony Cheng, James Lin
From: Tony Cheng <tony.cheng@amd.com>
[Why]
The DC2 builders check only the first stream and reject a state with
two streams. Core2 cannot commit or update two streams.
[How]
Run the stream checks on each stream of a state. Find the OTG master
of each stream, and reject two streams on one link. The non-seamless
commit disables each current stream and enables each new stream. The
seamless update programs only the stream that the update names. Core2
builds the info frame and sets the software state for each stream.
Signed-off-by: Tony Cheng <tony.cheng@amd.com>
Signed-off-by: James Lin <pinglei.lin@amd.com>
---
.../amd/display/dc/bls_builder/bls_builder.h | 3 +
.../dc/bls_builder/dcn401_builder_internal.h | 47 +-
.../bls_builder/dcn401_non_seamless_builder.c | 158 ++---
.../dc/bls_builder/dcn401_seamless_builder.c | 601 ++++++++++--------
.../gpu/drm/amd/display/dc/core2/dc_core2.c | 70 +-
5 files changed, 496 insertions(+), 383 deletions(-)
diff --git a/drivers/gpu/drm/amd/display/dc/bls_builder/bls_builder.h b/drivers/gpu/drm/amd/display/dc/bls_builder/bls_builder.h
index 627c6186d135..879ff188264d 100644
--- a/drivers/gpu/drm/amd/display/dc/bls_builder/bls_builder.h
+++ b/drivers/gpu/drm/amd/display/dc/bls_builder/bls_builder.h
@@ -93,16 +93,19 @@ struct bls_builder_output_targets {
};
};
+/* stream is the one stream an update changes, or NULL for a commit. */
struct bls_builder_check_capability_params {
struct dc *dc;
const struct dc_state *current_state;
const struct dc_state *new_state;
+ const struct dc_stream_state *stream;
};
struct bls_builder_declarative_params {
struct dc *dc;
const struct dc_state *current_state;
const struct dc_state *new_state;
+ const struct dc_stream_state *stream;
struct bls_builder_output_targets *out_targets;
struct block_sequence head_sequence[DC2_BLS_MAX_STEPS];
unsigned int head_num_steps;
diff --git a/drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_builder_internal.h b/drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_builder_internal.h
index 41a31202162b..35ad8982db9a 100644
--- a/drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_builder_internal.h
+++ b/drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_builder_internal.h
@@ -44,6 +44,23 @@ void dcn401_commit_check_failed(const struct dc *dc, const char *msg);
} \
} while (0)
+/* Each check_<name> stream helper takes the state and a stream index. */
+#define CHECK_STREAM_CONDITION(name, msg) \
+ do { \
+ if (!check_##name(dc, state, i)) { \
+ dcn401_commit_check_failed(dc, msg); \
+ return BLS_BUILD_ERROR_UNSUPPORTED_STATE_UPDATE; \
+ } \
+ } while (0)
+
+#define CHECK_STREAM_RESOURCE(name, msg) \
+ do { \
+ if (!check_##name(dc, state, i)) { \
+ dcn401_commit_check_failed(dc, msg); \
+ return BLS_BUILD_ERROR_RESOURCE_MAPPING; \
+ } \
+ } while (0)
+
static inline const struct dc_state *dcn401_checked_state(
const struct dc_state *current_state,
const struct dc_state *new_state)
@@ -51,26 +68,37 @@ static inline const struct dc_state *dcn401_checked_state(
return current_state ? current_state : new_state;
}
-/* The OTG master of state's one stream, or NULL when it is not one pipe. */
-const struct pipe_ctx *dcn401_otg_of(const struct dc *dc,
- const struct dc_state *state);
-const struct pipe_ctx *dcn401_checked_otg_master(const struct dc *dc,
- const struct dc_state *current_state,
- const struct dc_state *new_state);
+/* The one OTG master of stream in state, or NULL when it has none or more. */
+const struct pipe_ctx *dcn401_otg_master(const struct dc_state *state,
+ const struct dc_stream_state *stream);
+/* The index of stream in state, or -1. */
+int dcn401_stream_index(const struct dc_state *state,
+ const struct dc_stream_state *stream);
+/*
+ * stream is in both states on the same pipes, each with the same plane
+ * and blocks.
+ */
+bool dcn401_stream_unchanged(const struct dc_state *current_state,
+ const struct dc_state *new_state,
+ const struct dc_stream_state *stream);
/* What both builders need of the dc, before either state. */
enum bls_builder_result dcn401_check_dc_support(const struct dc *dc);
-/* What both builders need of a state's stream, apart from its planes. */
+/* What both builders need of each stream of a state, apart from its planes. */
enum bls_builder_result dcn401_check_stream_support(const struct dc *dc,
const struct dc_state *current_state,
const struct dc_state *new_state);
-/* pipe is NULL only for the bandwidth and p-state steps. */
+/*
+ * pipe is NULL only for the bandwidth and p-state steps. The walkers
+ * expand only stream when it is set.
+ */
struct dcn401_commit_step_args {
struct dc *dc;
struct dc_state *current_state;
struct dc_state *new_state;
+ const struct dc_stream_state *stream;
struct pipe_ctx *pipe;
};
@@ -78,7 +106,8 @@ struct dcn401_commit_step_args {
* A sub-sequence names the state its steps read and how they expand: once,
* or once per OTG master, OPP head (ODM slice) or DPP pipe of each stream
* of that state, the OTG master first. A builder lists its sub-sequences
- * in emission order.
+ * in emission order. A sequence longer than DC2_BLS_MAX_STEPS keeps its
+ * count and only the first entries; Core rejects it.
*/
#define DCN401_CURRENT_STATE (1u << 0)
#define DCN401_NEW_STATE (1u << 1)
diff --git a/drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_non_seamless_builder.c b/drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_non_seamless_builder.c
index d5adbef8a6f1..bfbe2e0e7eb2 100644
--- a/drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_non_seamless_builder.c
+++ b/drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_non_seamless_builder.c
@@ -10,12 +10,12 @@
#include "state_facts/state_facts.h"
/*
- * DCN_DECL_NON_SEAMLESS_COMMIT for one virtual stream without planes.
- * The new state has no stream, or one stream with no plane; the current
- * state has no stream, or one stream with one or two planes, one per DPP
- * pipe. Planes are added later by DCN_DECL_SEAMLESS_UPDATE, not by this
- * commit. The stream is in ODM bypass, 2:1 or 3:1, with one OPP head
- * and at most one DPP pipe per slice.
+ * DCN_DECL_NON_SEAMLESS_COMMIT for virtual streams without planes. It
+ * disables every current stream, each with one or two planes, one per DPP
+ * pipe, then enables every new stream, each with no plane. Planes are
+ * added later by DCN_DECL_SEAMLESS_UPDATE, not by this commit. Each
+ * stream is in ODM bypass, 2:1 or 3:1, with one OPP head and at most one
+ * DPP pipe per slice.
*
* The sequence follows legacy_commit_state_hw on dcn401: the same leaf
* calls in the same order, including the calls DC1 repeats. Everything is
@@ -32,78 +32,44 @@ static bool check_stream_config_update(const struct dc *dc,
return !dc->ctx->cp_psp.funcs.update_stream_config;
}
-static bool check_plane_count(const struct dc *dc,
- const struct dc_state *current_state,
- const struct dc_state *new_state)
+/* A current stream has its planes, one per DPP pipe. */
+static bool check_current_planes(const struct dc *dc,
+ const struct dc_state *state, unsigned int i)
{
- const struct dc_state *state = dcn401_checked_state(current_state,
- new_state);
- unsigned int planes = state->stream_status[0].plane_count;
+ unsigned int planes = state->stream_status[i].plane_count;
struct dc_state_facts facts;
- /*
- * The current state carries the removed planes, one per DPP pipe.
- * The new state has none.
- */
(void)dc;
- if (!current_state)
- return !planes;
dc_state_facts_derive(state, &facts);
return planes && planes ==
- facts.global.blend_tree[0].dpp_pipe_count;
-}
-
-static bool check_pipe_plane(const struct dc *dc,
- const struct dc_state *current_state,
- const struct dc_state *new_state)
-{
- /*
- * The current state carries the removed planes. The new state has
- * none.
- */
- struct dc_state_facts facts;
- const struct dc_state *state = current_state ? current_state : new_state;
-
- (void)dc;
- dc_state_facts_derive(state, &facts);
- if (!facts.pipe.count)
- return false;
- if (current_state)
- return dc_state_facts_all_pipe(&facts, 0, DC_TRAIT_MATCH(0, 0),
- DC_TRAIT_MATCH(DC_PIPE_TRAIT_PLANE, 0));
- return !dc_state_facts_any_pipe(&facts, 0,
+ facts.global.blend_tree[i].dpp_pipe_count &&
+ dc_state_facts_all_pipe(&facts, (uint8_t)i,
+ DC_TRAIT_MATCH(0, 0),
DC_TRAIT_MATCH(DC_PIPE_TRAIT_PLANE, 0));
}
static bool check_plane_blocks(const struct dc *dc,
- const struct dc_state *current_state,
- const struct dc_state *new_state)
+ const struct dc_state *state, unsigned int i)
{
struct dc_state_facts facts;
- (void)new_state;
(void)dc;
- if (!current_state)
- return true;
- dc_state_facts_derive(current_state, &facts);
- return facts.pipe.count &&
- dc_state_facts_all_pipe(&facts, 0, DC_TRAIT_MATCH(0, 0),
+ dc_state_facts_derive(state, &facts);
+ return dc_state_facts_all_pipe(&facts, (uint8_t)i,
+ DC_TRAIT_MATCH(0, 0),
DC_TRAIT_MATCH(DC_PIPE_TRAIT_PLANE_RESOURCES, 0));
}
/* Each OPP's tree holds exactly the removed MPCCs of its slice, in order. */
static bool check_mpcc_tree(const struct dc *dc,
- const struct dc_state *current_state,
- const struct dc_state *new_state)
+ const struct dc_state *state, unsigned int i)
{
- const struct pipe_ctx *opp_head = dcn401_checked_otg_master(dc,
- current_state, new_state);
+ const struct pipe_ctx *opp_head = dcn401_otg_master(state,
+ state->streams[i]);
const struct pipe_ctx *pipe;
const struct mpcc *mpcc;
- if (!current_state)
- return true;
- if (!opp_head || !dc->res_pool || !dc->res_pool->mpc)
+ if (!dc->res_pool || !dc->res_pool->mpc)
return false;
for (; opp_head; opp_head = opp_head->next_odm_pipe) {
mpcc = opp_head->stream_res.opp->mpc_tree_params.opp_list;
@@ -120,42 +86,79 @@ static bool check_mpcc_tree(const struct dc *dc,
return true;
}
+/* A new stream has no plane. */
+static bool check_new_no_planes(const struct dc *dc,
+ const struct dc_state *state, unsigned int i)
+{
+ struct dc_state_facts facts;
+
+ (void)dc;
+ dc_state_facts_derive(state, &facts);
+ return !state->stream_status[i].plane_count &&
+ !dc_state_facts_any_pipe(&facts, (uint8_t)i,
+ DC_TRAIT_MATCH(DC_PIPE_TRAIT_PLANE, 0));
+}
+
+static enum bls_builder_result dcn401_check_current_stream(
+ const struct dc *dc, const struct dc_state *state,
+ unsigned int i)
+{
+ CHECK_STREAM_CONDITION(current_planes,
+ "plane count does not match the pipes");
+ CHECK_STREAM_RESOURCE(plane_blocks, "plane is missing hubp or dpp");
+ CHECK_STREAM_CONDITION(mpcc_tree, "opp tree does not match the pipes");
+ return BLS_BUILD_SUCCESS;
+}
+
+static enum bls_builder_result dcn401_check_new_stream(
+ const struct dc *dc, const struct dc_state *state,
+ unsigned int i)
+{
+ CHECK_STREAM_CONDITION(new_no_planes, "new stream has a plane");
+ return BLS_BUILD_SUCCESS;
+}
+
static enum bls_builder_result dcn401_check_commit_state_support(
const struct dc *dc, const struct dc_state *current_state,
const struct dc_state *new_state)
{
+ const struct dc_state *state = dcn401_checked_state(current_state,
+ new_state);
enum bls_builder_result result;
+ unsigned int i;
result = dcn401_check_stream_support(dc, current_state, new_state);
- if (result != BLS_BUILD_SUCCESS ||
- !dcn401_checked_state(current_state,
- new_state)->stream_count)
- return result;
-
- CHECK_CONDITION(plane_count, "plane count does not match the state");
- CHECK_CONDITION(pipe_plane, "pipe plane does not match the state");
- CHECK_RESOURCE(plane_blocks, "plane is missing hubp or dpp");
- CHECK_CONDITION(mpcc_tree, "opp tree does not match the pipes");
- return BLS_BUILD_SUCCESS;
+ for (i = 0; result == BLS_BUILD_SUCCESS && i < state->stream_count;
+ i++)
+ result = current_state ?
+ dcn401_check_current_stream(dc, state, i) :
+ dcn401_check_new_stream(dc, state, i);
+ return result;
}
/*
- * The current stream is disabled before the new one is enabled, so the
- * link may be active when it carries the current stream.
+ * The current streams are disabled before the new ones are enabled, so a
+ * new stream's link may be active when it carries a current stream.
*/
static bool check_link_not_active(const struct dc *dc,
const struct dc_state *current_state,
const struct dc_state *new_state)
{
const struct dc_link *link;
+ int i, j;
(void)dc;
- if (!new_state->stream_count)
- return true;
- link = new_state->streams[0]->link;
- return !link->link_status.link_active ||
- (current_state->stream_count &&
- current_state->streams[0]->link == link);
+ for (i = 0; i < new_state->stream_count; i++) {
+ link = new_state->streams[i]->link;
+ if (!link->link_status.link_active)
+ continue;
+ for (j = 0; j < current_state->stream_count; j++)
+ if (current_state->streams[j]->link == link)
+ break;
+ if (j == current_state->stream_count)
+ return false;
+ }
+ return true;
}
static enum bls_builder_result dcn401_check_non_seamless_commit_support(
@@ -200,7 +203,7 @@ prepare_bandwidth[] = {
};
/*
- * Net effect: disable the stream of the current state.
+ * Net effect: disable each stream of the current state.
* - disable_dangling_plane: disconnect the MPCC under the OTG lock, then
* dcn20_disable_plane.
* - link_set_dpms_off for the virtual signal: dcn401_disable_stream, then
@@ -265,7 +268,7 @@ static const struct dcn401_commit_step stream_off[] = {
};
/*
- * Net effect: enable the stream of the new state. Between the BIOS
+ * Net effect: enable each stream of the new state. Between the BIOS
* critical-state calls:
* - dcn401_enable_stream_timing plus the dce110_apply_single_controller
* calls around it, up to the DIG connect.
@@ -376,10 +379,7 @@ static const struct dcn401_commit_step postamble[] = {
.meta.clk_mgr_update_clocks_for_state.safe_to_lower = true },
};
-/*
- * Bounds on what build adds. The support check allows one stream per
- * state, and never one in both.
- */
+/* Bounds on what build adds for one stream in either state. */
static_assert(ARRAY_SIZE(prepare_bandwidth) +
ARRAY_SIZE(lock) +
DCN401_MAX_OPP_HEADS * ARRAY_SIZE(blank) +
diff --git a/drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_seamless_builder.c b/drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_seamless_builder.c
index a9884eefdd9f..09ea7ba26452 100644
--- a/drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_seamless_builder.c
+++ b/drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_seamless_builder.c
@@ -26,11 +26,12 @@
dc->ctx->logger
/*
- * DCN_DECL_SEAMLESS_UPDATE for the one virtual stream that
+ * DCN_DECL_SEAMLESS_UPDATE for one of the virtual streams that
* DCN_DECL_NON_SEAMLESS_COMMIT (dcn401_non_seamless_builder.c) enabled.
- * The update either adds one plane, or two MPC-blended planes, to that
- * stream, or keeps one plane and programs its surface, address, scaler
- * and viewport. The sequence follows the full update in
+ * The other streams keep their pipes and planes, and the update programs
+ * none of them. The update either adds one plane, or two MPC-blended
+ * planes, to the stream, or keeps one plane and programs its surface,
+ * address, scaler and viewport. The sequence follows the full update in
* commit_planes_for_stream on dcn401, all in head_sequence: the
* outstanding updates, prepare_bandwidth and the pending-update waits,
* then the locked front-end programming and
@@ -138,15 +139,13 @@ enum bls_builder_result dcn401_check_dc_support(const struct dc *dc)
return BLS_BUILD_SUCCESS;
}
-static bool check_one_stream(const struct dc *dc,
+static bool check_no_phantom(const struct dc *dc,
const struct dc_state *current_state,
const struct dc_state *new_state)
{
- const struct dc_state *state = dcn401_checked_state(current_state,
- new_state);
-
(void)dc;
- return state->stream_count <= 1 && !state->phantom_stream_count;
+ return !dcn401_checked_state(current_state,
+ new_state)->phantom_stream_count;
}
static bool check_fams2_state(const struct dc *dc,
@@ -161,47 +160,35 @@ static bool check_fams2_state(const struct dc *dc,
}
static bool check_stream_link(const struct dc *dc,
- const struct dc_state *current_state,
- const struct dc_state *new_state)
+ const struct dc_state *state, unsigned int i)
{
- const struct dc_state *state = dcn401_checked_state(current_state,
- new_state);
- const struct dc_stream_state *stream = state->streams[0];
-
(void)dc;
- return stream && stream->link;
+ return state->streams[i] && state->streams[i]->link;
}
/* link_set_dpms_on and _off program nothing for a virtual signal. */
static bool check_virtual_signal(const struct dc *dc,
- const struct dc_state *current_state,
- const struct dc_state *new_state)
+ const struct dc_state *state, unsigned int i)
{
- const struct dc_state *state = dcn401_checked_state(current_state,
- new_state);
-
(void)dc;
(void)state;
+ (void)i;
return false;
}
static bool check_link_encoder(const struct dc *dc,
- const struct dc_state *current_state,
- const struct dc_state *new_state)
+ const struct dc_state *state, unsigned int i)
{
- const struct dc_link *link = dcn401_checked_state(current_state,
- new_state)->streams[0]->link;
+ const struct dc_link *link = state->streams[i]->link;
(void)dc;
return link->ep_type == DISPLAY_ENDPOINT_PHY && link->link_enc;
}
static bool check_timing_flags(const struct dc *dc,
- const struct dc_state *current_state,
- const struct dc_state *new_state)
+ const struct dc_state *state, unsigned int i)
{
- const struct dc_crtc_timing *timing = &dcn401_checked_state(
- current_state, new_state)->streams[0]->timing;
+ const struct dc_crtc_timing *timing = &state->streams[i]->timing;
(void)dc;
return !timing->flags.DSC && !timing->flags.INTERLACE &&
@@ -210,11 +197,9 @@ static bool check_timing_flags(const struct dc *dc,
/* The DPG black and the pixel rate divider are fixed for RGB. */
static bool check_rgb_srgb(const struct dc *dc,
- const struct dc_state *current_state,
- const struct dc_state *new_state)
+ const struct dc_state *state, unsigned int i)
{
- const struct dc_stream_state *stream = dcn401_checked_state(
- current_state, new_state)->streams[0];
+ const struct dc_stream_state *stream = state->streams[i];
(void)dc;
return stream->timing.pixel_encoding == PIXEL_ENCODING_RGB &&
@@ -222,11 +207,9 @@ static bool check_rgb_srgb(const struct dc *dc,
}
static bool check_no_drr(const struct dc *dc,
- const struct dc_state *current_state,
- const struct dc_state *new_state)
+ const struct dc_state *state, unsigned int i)
{
- const struct dc_stream_state *stream = dcn401_checked_state(
- current_state, new_state)->streams[0];
+ const struct dc_stream_state *stream = state->streams[i];
(void)dc;
return !stream->ignore_msa_timing_param &&
@@ -235,11 +218,9 @@ static bool check_no_drr(const struct dc *dc,
}
static bool check_no_boot_dpms_writeback(const struct dc *dc,
- const struct dc_state *current_state,
- const struct dc_state *new_state)
+ const struct dc_state *state, unsigned int i)
{
- const struct dc_stream_state *stream = dcn401_checked_state(
- current_state, new_state)->streams[0];
+ const struct dc_stream_state *stream = state->streams[i];
(void)dc;
return !stream->apply_seamless_boot_optimization && !stream->dpms_off &&
@@ -247,11 +228,9 @@ static bool check_no_boot_dpms_writeback(const struct dc *dc,
}
static bool check_abm(const struct dc *dc,
- const struct dc_state *current_state,
- const struct dc_state *new_state)
+ const struct dc_state *state, unsigned int i)
{
- const struct dc_stream_state *stream = dcn401_checked_state(
- current_state, new_state)->streams[0];
+ const struct dc_stream_state *stream = state->streams[i];
(void)dc;
return !stream->abm_level ||
@@ -259,82 +238,86 @@ static bool check_abm(const struct dc *dc,
}
/*
- * The OTG master for this state's one stream, or NULL when the stream has
- * more than one. An MPC bottom pipe or an ODM slice of the stream is not
- * an OTG master; check_mpc_blend and check_odm_combine bound them.
+ * An MPC bottom pipe or an ODM slice of the stream is not an OTG master;
+ * check_mpc_blend and check_odm_combine bound them.
*/
-static const struct pipe_ctx *dcn401_state_otg_master(const struct dc *dc,
- const struct dc_state *state, bool *not_one_pipe)
+const struct pipe_ctx *dcn401_otg_master(const struct dc_state *state,
+ const struct dc_stream_state *stream)
{
const struct pipe_ctx *otg_master = NULL;
unsigned int i;
- (void)dc;
- *not_one_pipe = false;
for (i = 0; i < MAX_PIPES; i++) {
const struct pipe_ctx *pipe = &state->res_ctx.pipe_ctx[i];
- if (!pipe->stream)
- continue;
- if (pipe->stream == state->streams[0] &&
- (pipe->top_pipe || pipe->prev_odm_pipe))
+ if (!stream || pipe->stream != stream ||
+ pipe->top_pipe || pipe->prev_odm_pipe)
continue;
- if (pipe->stream != state->streams[0] || otg_master) {
- *not_one_pipe = true;
+ if (otg_master)
return NULL;
- }
otg_master = pipe;
}
return otg_master;
}
-const struct pipe_ctx *dcn401_checked_otg_master(const struct dc *dc,
- const struct dc_state *current_state,
- const struct dc_state *new_state)
+int dcn401_stream_index(const struct dc_state *state,
+ const struct dc_stream_state *stream)
{
- bool not_one_pipe = false;
+ int i;
- return dcn401_state_otg_master(dc, dcn401_checked_state(current_state,
- new_state), ¬_one_pipe);
+ for (i = 0; i < state->stream_count; i++)
+ if (state->streams[i] == stream)
+ return i;
+ return -1;
}
-const struct pipe_ctx *dcn401_otg_of(const struct dc *dc,
- const struct dc_state *state)
+bool dcn401_stream_unchanged(const struct dc_state *current_state,
+ const struct dc_state *new_state,
+ const struct dc_stream_state *stream)
{
- bool not_one_pipe = false;
-
- if (!state)
- return NULL;
- return dcn401_state_otg_master(dc, state, ¬_one_pipe);
-}
-
-static bool check_one_otg_pipe(const struct dc *dc,
- const struct dc_state *current_state,
- const struct dc_state *new_state)
-{
- bool not_one_pipe = false;
+ const struct pipe_ctx *cur, *new;
+ unsigned int i;
- dcn401_state_otg_master(dc, dcn401_checked_state(current_state,
- new_state), ¬_one_pipe);
- return !not_one_pipe;
+ if (dcn401_stream_index(current_state, stream) < 0 ||
+ dcn401_stream_index(new_state, stream) < 0)
+ return false;
+ for (i = 0; i < MAX_PIPES; i++) {
+ cur = ¤t_state->res_ctx.pipe_ctx[i];
+ new = &new_state->res_ctx.pipe_ctx[i];
+ if ((cur->stream == stream) != (new->stream == stream))
+ return false;
+ if (new->stream != stream)
+ continue;
+ if (cur->plane_state != new->plane_state ||
+ cur->plane_res.hubp != new->plane_res.hubp ||
+ cur->plane_res.dpp != new->plane_res.dpp ||
+ cur->stream_res.tg != new->stream_res.tg ||
+ cur->stream_res.opp != new->stream_res.opp ||
+ !cur->top_pipe != !new->top_pipe ||
+ !cur->bottom_pipe != !new->bottom_pipe ||
+ !cur->prev_odm_pipe != !new->prev_odm_pipe ||
+ !cur->next_odm_pipe != !new->next_odm_pipe)
+ return false;
+ }
+ return true;
}
static bool check_otg_master_present(const struct dc *dc,
- const struct dc_state *current_state,
- const struct dc_state *new_state)
+ const struct dc_state *state, unsigned int i)
{
- return dcn401_checked_otg_master(dc, current_state, new_state) != NULL;
+ (void)dc;
+ return dcn401_otg_master(state, state->streams[i]) != NULL;
}
/* At most DCN401_MAX_OPP_HEADS ODM slices, each with an OPP. */
static bool check_odm_combine(const struct dc *dc,
- const struct dc_state *current_state,
- const struct dc_state *new_state)
+ const struct dc_state *state, unsigned int i)
{
- const struct pipe_ctx *odm = dcn401_checked_otg_master(dc,
- current_state, new_state);
+ const struct pipe_ctx *odm = dcn401_otg_master(state,
+ state->streams[i]);
unsigned int count = 0;
+ (void)dc;
for (; odm; odm = odm->next_odm_pipe)
if (!odm->stream_res.opp || ++count > DCN401_MAX_OPP_HEADS)
return false;
@@ -342,76 +325,69 @@ static bool check_odm_combine(const struct dc *dc,
}
static bool check_mpc_blend(const struct dc *dc,
- const struct dc_state *current_state,
- const struct dc_state *new_state)
+ const struct dc_state *state, unsigned int i)
{
- const struct pipe_ctx *pipe = dcn401_checked_otg_master(dc,
- current_state, new_state);
-
struct dc_state_facts facts;
- if (!pipe || pipe->top_pipe)
- return false;
- dc_state_facts_derive(dcn401_checked_state(current_state, new_state),
- &facts);
+ (void)dc;
+ dc_state_facts_derive(state, &facts);
/*
* At most one bottom pipe, on the master's OTG and OPP. A bottom pipe
* and ODM do not go together.
*/
- return facts.global.blend_tree[0].dpp_pipe_count <= 2 &&
- facts.global.blend_tree[0].on_otg_master_blocks &&
- (facts.global.blend_tree[0].dpp_pipe_count == 1 ||
- !dc_state_facts_any_pipe(&facts, 0,
+ return facts.global.blend_tree[i].dpp_pipe_count <= 2 &&
+ facts.global.blend_tree[i].on_otg_master_blocks &&
+ (facts.global.blend_tree[i].dpp_pipe_count == 1 ||
+ !dc_state_facts_any_pipe(&facts, (uint8_t)i,
DC_TRAIT_MATCH(DC_PIPE_TRAIT_ODM, 0)));
}
static bool check_otg_master_blocks(const struct dc *dc,
- const struct dc_state *current_state,
- const struct dc_state *new_state)
+ const struct dc_state *state, unsigned int i)
{
- const struct pipe_ctx *pipe = dcn401_checked_otg_master(dc,
- current_state, new_state);
+ const struct pipe_ctx *pipe = dcn401_otg_master(state,
+ state->streams[i]);
+ (void)dc;
return pipe && pipe->stream_res.tg && pipe->stream_res.opp &&
pipe->stream_res.stream_enc && pipe->clock_source;
}
static bool check_pipe_audio(const struct dc *dc,
- const struct dc_state *current_state,
- const struct dc_state *new_state)
+ const struct dc_state *state, unsigned int i)
{
- const struct pipe_ctx *pipe = dcn401_checked_otg_master(dc,
- current_state, new_state);
+ const struct pipe_ctx *pipe = dcn401_otg_master(state,
+ state->streams[i]);
+ (void)dc;
return pipe && !pipe->stream_res.audio;
}
static bool check_pipe_dsc(const struct dc *dc,
- const struct dc_state *current_state,
- const struct dc_state *new_state)
+ const struct dc_state *state, unsigned int i)
{
- const struct pipe_ctx *pipe = dcn401_checked_otg_master(dc,
- current_state, new_state);
+ const struct pipe_ctx *pipe = dcn401_otg_master(state,
+ state->streams[i]);
+ (void)dc;
return pipe && !pipe->stream_res.dsc;
}
static bool check_pipe_gsl(const struct dc *dc,
- const struct dc_state *current_state,
- const struct dc_state *new_state)
+ const struct dc_state *state, unsigned int i)
{
- const struct pipe_ctx *pipe = dcn401_checked_otg_master(dc,
- current_state, new_state);
+ const struct pipe_ctx *pipe = dcn401_otg_master(state,
+ state->streams[i]);
+ (void)dc;
return pipe && !pipe->stream_res.gsl_group;
}
static bool check_link_enc_assignment(const struct dc *dc,
- const struct dc_state *current_state,
- const struct dc_state *new_state)
+ const struct dc_state *state, unsigned int i)
{
- const struct pipe_ctx *pipe = dcn401_checked_otg_master(dc,
- current_state, new_state);
+ const struct pipe_ctx *pipe = dcn401_otg_master(state,
+ state->streams[i]);
if (!dc->config.unify_link_enc_assignment)
return true;
@@ -419,69 +395,133 @@ static bool check_link_enc_assignment(const struct dc *dc,
pipe->stream->link->link_enc;
}
+/* Each stream on its own link. */
+static bool check_own_link(const struct dc *dc,
+ const struct dc_state *state, unsigned int i)
+{
+ unsigned int j;
+
+ (void)dc;
+ for (j = 0; j < i; j++)
+ if (state->streams[j]->link == state->streams[i]->link)
+ return false;
+ return true;
+}
+
+static enum bls_builder_result dcn401_check_one_stream(const struct dc *dc,
+ const struct dc_state *state, unsigned int i)
+{
+ CHECK_STREAM_RESOURCE(stream_link, "stream has no link");
+ CHECK_STREAM_CONDITION(own_link, "streams share a link");
+ CHECK_STREAM_CONDITION(virtual_signal, "signal is not virtual");
+ CHECK_STREAM_RESOURCE(link_encoder, "link encoder is not DIO");
+ CHECK_STREAM_CONDITION(timing_flags,
+ "timing is DSC, interlace, or stereo");
+ CHECK_STREAM_CONDITION(rgb_srgb, "stream is not RGB sRGB");
+ CHECK_STREAM_CONDITION(no_drr, "DRR is set");
+ CHECK_STREAM_CONDITION(no_boot_dpms_writeback,
+ "seamless boot, dpms, or writeback is set");
+ CHECK_STREAM_CONDITION(abm, "ABM level is set");
+ CHECK_STREAM_RESOURCE(otg_master_present,
+ "stream has no otg master, or more than one");
+ CHECK_STREAM_CONDITION(odm_combine, "odm is not bypass, 2:1 or 3:1");
+ CHECK_STREAM_CONDITION(mpc_blend,
+ "more than one bottom pipe, off the otg or opp, or with odm");
+ CHECK_STREAM_RESOURCE(otg_master_blocks,
+ "otg master is missing a stream resource or pixel clock");
+ CHECK_STREAM_CONDITION(pipe_audio, "audio is set");
+ CHECK_STREAM_CONDITION(pipe_dsc, "dsc is set");
+ CHECK_STREAM_CONDITION(pipe_gsl, "gsl is set");
+ CHECK_STREAM_CONDITION(link_enc_assignment,
+ "link encoder assignment differs");
+ return BLS_BUILD_SUCCESS;
+}
+
+/* Every pipe with a stream belongs to a stream of the state. */
+static bool check_pipe_streams(const struct dc *dc,
+ const struct dc_state *current_state,
+ const struct dc_state *new_state)
+{
+ const struct dc_state *state = dcn401_checked_state(current_state,
+ new_state);
+ unsigned int i;
+
+ (void)dc;
+ for (i = 0; i < MAX_PIPES; i++)
+ if (state->res_ctx.pipe_ctx[i].stream &&
+ dcn401_stream_index(state,
+ state->res_ctx.pipe_ctx[i].stream) < 0)
+ return false;
+ return true;
+}
+
enum bls_builder_result dcn401_check_stream_support(const struct dc *dc,
const struct dc_state *current_state,
const struct dc_state *new_state)
{
const struct dc_state *state = dcn401_checked_state(current_state,
new_state);
+ enum bls_builder_result result;
+ unsigned int i;
if (!state)
return BLS_BUILD_ERROR_UNSUPPORTED_STATE_UPDATE;
- CHECK_CONDITION(one_stream, "more than one stream");
+ CHECK_CONDITION(no_phantom, "a phantom stream is set");
CHECK_CONDITION(fams2_state, "fams2 is enabled");
- if (!state->stream_count)
- return BLS_BUILD_SUCCESS;
-
- CHECK_RESOURCE(stream_link, "stream has no link");
- CHECK_CONDITION(virtual_signal, "signal is not virtual");
- CHECK_RESOURCE(link_encoder, "link encoder is not DIO");
- CHECK_CONDITION(timing_flags, "timing is DSC, interlace, or stereo");
- CHECK_CONDITION(rgb_srgb, "stream is not RGB sRGB");
- CHECK_CONDITION(no_drr, "DRR is set");
- CHECK_CONDITION(no_boot_dpms_writeback,
- "seamless boot, dpms, or writeback is set");
- CHECK_CONDITION(abm, "ABM level is set");
- CHECK_CONDITION(one_otg_pipe, "stream is not on one pipe");
- CHECK_RESOURCE(otg_master_present, "stream has no otg master");
- CHECK_CONDITION(odm_combine, "odm is not bypass, 2:1 or 3:1");
- CHECK_CONDITION(mpc_blend,
- "more than one bottom pipe, off the otg or opp, or with odm");
- CHECK_RESOURCE(otg_master_blocks,
- "otg master is missing a stream resource or pixel clock");
- CHECK_CONDITION(pipe_audio, "audio is set");
- CHECK_CONDITION(pipe_dsc, "dsc is set");
- CHECK_CONDITION(pipe_gsl, "gsl is set");
- CHECK_CONDITION(link_enc_assignment, "link encoder assignment differs");
+ CHECK_CONDITION(pipe_streams, "a pipe has a stream the state lacks");
+ for (i = 0; i < state->stream_count; i++) {
+ result = dcn401_check_one_stream(dc, state, i);
+ if (result != BLS_BUILD_SUCCESS)
+ return result;
+ }
return BLS_BUILD_SUCCESS;
}
-/* The seamless update keeps the one stream across the update. */
-static bool check_stream_kept(const struct dc *dc,
+/*
+ * The update keeps every stream. A stream other than the updated one keeps
+ * its pipes, planes and blocks.
+ */
+static bool check_streams_kept(const struct dc *dc,
const struct dc_state *current_state,
- const struct dc_state *new_state)
+ const struct dc_state *new_state, unsigned int i)
{
+ int j;
+
(void)dc;
- return current_state->stream_count == 1 &&
- new_state->stream_count == 1 &&
- current_state->streams[0] == new_state->streams[0];
+ if (current_state->stream_count != new_state->stream_count)
+ return false;
+ for (j = 0; j < new_state->stream_count; j++)
+ if (dcn401_stream_index(current_state,
+ new_state->streams[j]) < 0 ||
+ (j != i && !dcn401_stream_unchanged(current_state,
+ new_state, new_state->streams[j])))
+ return false;
+ return true;
+}
+
+static unsigned int dcn401_current_plane_count(
+ const struct dc_state *current_state,
+ const struct dc_state *new_state, unsigned int i)
+{
+ return current_state->stream_status[dcn401_stream_index(current_state,
+ new_state->streams[i])].plane_count;
}
/* Both planes of an MPO state are added together, by one update. */
static bool dcn401_is_plane_add(const struct dc_state *current_state,
- const struct dc_state *new_state)
+ const struct dc_state *new_state, unsigned int i)
{
- unsigned int planes = new_state->stream_status[0].plane_count;
+ unsigned int planes = new_state->stream_status[i].plane_count;
- return !current_state->stream_status[0].plane_count &&
+ return !dcn401_current_plane_count(current_state, new_state, i) &&
(planes == 1 || planes == 2);
}
static bool dcn401_is_plane_kept(const struct dc_state *current_state,
- const struct dc_state *new_state)
+ const struct dc_state *new_state, unsigned int i)
{
- return current_state->stream_status[0].plane_count == 1 &&
- new_state->stream_status[0].plane_count == 1;
+ return dcn401_current_plane_count(current_state, new_state, i) == 1 &&
+ new_state->stream_status[i].plane_count == 1;
}
/*
@@ -491,28 +531,30 @@ static bool dcn401_is_plane_kept(const struct dc_state *current_state,
*/
static bool check_plane_add_or_kept(const struct dc *dc,
const struct dc_state *current_state,
- const struct dc_state *new_state)
+ const struct dc_state *new_state, unsigned int i)
{
struct dc_state_facts facts;
(void)dc;
- if (!dcn401_is_plane_add(current_state, new_state) &&
- !dcn401_is_plane_kept(current_state, new_state))
+ if (!dcn401_is_plane_add(current_state, new_state, i) &&
+ !dcn401_is_plane_kept(current_state, new_state, i))
return false;
dc_state_facts_derive(new_state, &facts);
- return facts.global.blend_tree[0].dpp_pipe_count ==
- new_state->stream_status[0].plane_count;
+ return facts.global.blend_tree[i].dpp_pipe_count ==
+ new_state->stream_status[i].plane_count;
}
static bool check_same_otg_master_blocks(const struct dc *dc,
const struct dc_state *current_state,
- const struct dc_state *new_state)
+ const struct dc_state *new_state, unsigned int i)
{
- const struct pipe_ctx *current_pipe = dcn401_otg_of(dc, current_state);
- const struct pipe_ctx *new_pipe = dcn401_otg_of(dc, new_state);
+ const struct pipe_ctx *current_pipe = dcn401_otg_master(current_state,
+ new_state->streams[i]);
+ const struct pipe_ctx *new_pipe = dcn401_otg_master(new_state,
+ new_state->streams[i]);
- if (!current_pipe || !new_pipe ||
- current_pipe->stream_res.tg != new_pipe->stream_res.tg)
+ (void)dc;
+ if (current_pipe->stream_res.tg != new_pipe->stream_res.tg)
return false;
/* The same OPP for each ODM slice. */
for (; current_pipe && new_pipe;
@@ -525,16 +567,16 @@ static bool check_same_otg_master_blocks(const struct dc *dc,
static bool check_new_plane_blocks(const struct dc *dc,
const struct dc_state *current_state,
- const struct dc_state *new_state)
+ const struct dc_state *new_state, unsigned int i)
{
struct dc_state_facts facts;
(void)current_state;
- if (!dcn401_otg_of(dc, new_state))
- return false;
+ (void)dc;
dc_state_facts_derive(new_state, &facts);
return facts.pipe.count &&
- dc_state_facts_all_pipe(&facts, 0, DC_TRAIT_MATCH(0, 0),
+ dc_state_facts_all_pipe(&facts, (uint8_t)i,
+ DC_TRAIT_MATCH(0, 0),
DC_TRAIT_MATCH(DC_PIPE_TRAIT_PLANE |
DC_PIPE_TRAIT_PLANE_RESOURCES, 0));
}
@@ -580,23 +622,23 @@ static bool check_no_sanity_checks(const struct dc *dc,
static bool check_no_pipe_wait(const struct dc *dc,
const struct dc_state *current_state,
- const struct dc_state *new_state)
+ const struct dc_state *new_state, unsigned int i)
{
struct dc_state_facts facts;
(void)current_state;
(void)dc;
dc_state_facts_derive(new_state, &facts);
- return facts.pipe.count && !dc_state_facts_any_pipe(&facts, 0,
+ return facts.pipe.count && !dc_state_facts_any_pipe(&facts, (uint8_t)i,
DC_TRAIT_MATCH(DC_PIPE_TRAIT_WAIT, 0));
}
/* dcn20_blank_pixel_data does nothing while a test pattern is on. */
static bool check_no_test_pattern(const struct dc *dc,
const struct dc_state *current_state,
- const struct dc_state *new_state)
+ const struct dc_state *new_state, unsigned int i)
{
- const struct dc_stream_state *stream = new_state->streams[0];
+ const struct dc_stream_state *stream = new_state->streams[i];
(void)dc;
(void)current_state;
@@ -618,14 +660,14 @@ static bool check_no_forced_dpg(const struct dc *dc,
/* dcn20_blank_pixel_data sets the ABM pipe on unblank when there is one. */
static bool check_no_abm_pipe(const struct dc *dc,
const struct dc_state *current_state,
- const struct dc_state *new_state)
+ const struct dc_state *new_state, unsigned int i)
{
struct dc_state_facts facts;
(void)current_state;
(void)dc;
dc_state_facts_derive(new_state, &facts);
- return facts.pipe.count && !dc_state_facts_any_pipe(&facts, 0,
+ return facts.pipe.count && !dc_state_facts_any_pipe(&facts, (uint8_t)i,
DC_TRAIT_MATCH(DC_PIPE_TRAIT_ABM, 0));
}
@@ -642,20 +684,19 @@ static bool check_no_vm_aperture(const struct dc *dc,
/* enable_plane sets the flip interrupt when the plane asks for one. */
static bool check_no_flip_int(const struct dc *dc,
const struct dc_state *current_state,
- const struct dc_state *new_state)
+ const struct dc_state *new_state, unsigned int i)
{
struct pipe_ctx *dpp_pipes[MAX_PIPES];
- int i, n = new_state && new_state->stream_count ?
- resource_get_dpp_pipes_for_stream(new_state->streams[0],
+ int j, n = resource_get_dpp_pipes_for_stream(new_state->streams[i],
(struct resource_context *)&new_state->res_ctx,
- dpp_pipes) : 0;
+ dpp_pipes);
(void)dc;
(void)current_state;
if (!n)
return false;
- for (i = 0; i < n; i++)
- if (dpp_pipes[i]->plane_state->flip_int_enabled)
+ for (j = 0; j < n; j++)
+ if (dpp_pipes[j]->plane_state->flip_int_enabled)
return false;
return true;
}
@@ -663,20 +704,19 @@ static bool check_no_flip_int(const struct dc *dc,
/* The update bypasses the plane gamut remap. */
static bool check_no_plane_gamut_remap(const struct dc *dc,
const struct dc_state *current_state,
- const struct dc_state *new_state)
+ const struct dc_state *new_state, unsigned int i)
{
struct pipe_ctx *dpp_pipes[MAX_PIPES];
- int i, n = new_state && new_state->stream_count ?
- resource_get_dpp_pipes_for_stream(new_state->streams[0],
+ int j, n = resource_get_dpp_pipes_for_stream(new_state->streams[i],
(struct resource_context *)&new_state->res_ctx,
- dpp_pipes) : 0;
+ dpp_pipes);
(void)dc;
(void)current_state;
if (!n)
return false;
- for (i = 0; i < n; i++)
- if (dpp_pipes[i]->plane_state->gamut_remap_matrix.enable_remap)
+ for (j = 0; j < n; j++)
+ if (dpp_pipes[j]->plane_state->gamut_remap_matrix.enable_remap)
return false;
return true;
}
@@ -684,45 +724,44 @@ static bool check_no_plane_gamut_remap(const struct dc *dc,
/* The update bypasses the stream gamut remap. */
static bool check_no_stream_gamut_remap(const struct dc *dc,
const struct dc_state *current_state,
- const struct dc_state *new_state)
+ const struct dc_state *new_state, unsigned int i)
{
(void)dc;
(void)current_state;
- return !new_state->streams[0]->gamut_remap_matrix.enable_remap;
+ return !new_state->streams[i]->gamut_remap_matrix.enable_remap;
}
/* The update sets the default output CSC. */
static bool check_no_output_csc(const struct dc *dc,
const struct dc_state *current_state,
- const struct dc_state *new_state)
+ const struct dc_state *new_state, unsigned int i)
{
(void)dc;
(void)current_state;
- return !new_state->streams[0]->csc_color_matrix.enable_adjustment;
+ return !new_state->streams[i]->csc_color_matrix.enable_adjustment;
}
/* The update programs the surface and its address without DCC. */
static bool check_no_dcc(const struct dc *dc,
const struct dc_state *current_state,
- const struct dc_state *new_state)
+ const struct dc_state *new_state, unsigned int i)
{
struct dc_state_facts facts;
(void)current_state;
- if (!dcn401_otg_of(dc, new_state))
- return false;
+ (void)dc;
dc_state_facts_derive(new_state, &facts);
return facts.pipe.count &&
- dc_state_facts_all_pipe(&facts, 0, DC_TRAIT_MATCH(0, 0),
+ dc_state_facts_all_pipe(&facts, (uint8_t)i, DC_TRAIT_MATCH(0, 0),
DC_TRAIT_MATCH(DC_PIPE_TRAIT_PLANE, 0)) &&
- !dc_state_facts_any_plane(&facts, 0,
+ !dc_state_facts_any_plane(&facts, (uint8_t)i,
DC_TRAIT_MATCH(DC_PLANE_TRAIT_DCC, 0));
}
/* The update programs a single graphics address, not stereo or video. */
static bool check_graphics_address(const struct dc *dc,
const struct dc_state *current_state,
- const struct dc_state *new_state)
+ const struct dc_state *new_state, unsigned int i)
{
struct dc_state_facts facts;
@@ -730,27 +769,26 @@ static bool check_graphics_address(const struct dc *dc,
(void)dc;
dc_state_facts_derive(new_state, &facts);
return facts.pipe.count &&
- dc_state_facts_all_pipe(&facts, 0, DC_TRAIT_MATCH(0, 0),
+ dc_state_facts_all_pipe(&facts, (uint8_t)i, DC_TRAIT_MATCH(0, 0),
DC_TRAIT_MATCH(DC_PIPE_TRAIT_PLANE, 0)) &&
- dc_state_facts_all_plane(&facts, 0, DC_TRAIT_MATCH(0, 0),
+ dc_state_facts_all_plane(&facts, (uint8_t)i, DC_TRAIT_MATCH(0, 0),
DC_TRAIT_MATCH(DC_PLANE_TRAIT_GRAPHICS_ADDRESS, 0));
}
/* DC1 programs triple buffering and the flip only for a queued flip. */
static bool check_no_immediate_flip(const struct dc *dc,
const struct dc_state *current_state,
- const struct dc_state *new_state)
+ const struct dc_state *new_state, unsigned int i)
{
struct dc_state_facts facts;
(void)current_state;
- if (!dcn401_otg_of(dc, new_state))
- return false;
+ (void)dc;
dc_state_facts_derive(new_state, &facts);
return facts.pipe.count &&
- dc_state_facts_all_pipe(&facts, 0, DC_TRAIT_MATCH(0, 0),
+ dc_state_facts_all_pipe(&facts, (uint8_t)i, DC_TRAIT_MATCH(0, 0),
DC_TRAIT_MATCH(DC_PIPE_TRAIT_PLANE, 0)) &&
- !dc_state_facts_any_plane(&facts, 0,
+ !dc_state_facts_any_plane(&facts, (uint8_t)i,
DC_TRAIT_MATCH(DC_PLANE_TRAIT_FLIP_IMMEDIATE, 0));
}
@@ -760,7 +798,7 @@ static bool check_no_immediate_flip(const struct dc *dc,
*/
static bool check_no_degamma_curve(const struct dc *dc,
const struct dc_state *current_state,
- const struct dc_state *new_state)
+ const struct dc_state *new_state, unsigned int i)
{
struct dc_state_facts facts;
@@ -768,16 +806,16 @@ static bool check_no_degamma_curve(const struct dc *dc,
(void)dc;
dc_state_facts_derive(new_state, &facts);
return facts.pipe.count &&
- dc_state_facts_all_pipe(&facts, 0, DC_TRAIT_MATCH(0, 0),
+ dc_state_facts_all_pipe(&facts, (uint8_t)i, DC_TRAIT_MATCH(0, 0),
DC_TRAIT_MATCH(DC_PIPE_TRAIT_PLANE, 0)) &&
- !dc_state_facts_any_plane(&facts, 0,
+ !dc_state_facts_any_plane(&facts, (uint8_t)i,
DC_TRAIT_MATCH(DC_PLANE_TRAIT_DEGAMMA_CURVE, 0));
}
/* dcn401_set_mcm_luts then programs every MCM LUT off. */
static bool check_no_mcm_luts(const struct dc *dc,
const struct dc_state *current_state,
- const struct dc_state *new_state)
+ const struct dc_state *new_state, unsigned int i)
{
struct dc_state_facts facts;
@@ -786,17 +824,17 @@ static bool check_no_mcm_luts(const struct dc *dc,
(void)dc;
dc_state_facts_derive(new_state, &facts);
return facts.pipe.count &&
- dc_state_facts_all_pipe(&facts, 0, DC_TRAIT_MATCH(0, 0),
+ dc_state_facts_all_pipe(&facts, (uint8_t)i, DC_TRAIT_MATCH(0, 0),
DC_TRAIT_MATCH(DC_PIPE_TRAIT_PLANE, 0)) &&
- !dc_state_facts_any_plane(&facts, 0,
+ !dc_state_facts_any_plane(&facts, (uint8_t)i,
DC_TRAIT_MATCH(DC_PLANE_TRAIT_MCM_LUTS, 0));
}
static bool check_no_shaper_curve(const struct dc *dc,
const struct dc_state *current_state,
- const struct dc_state *new_state)
+ const struct dc_state *new_state, unsigned int i)
{
- const struct dc_transfer_func *shaper = new_state->streams[0]->func_shaper;
+ const struct dc_transfer_func *shaper = new_state->streams[i]->func_shaper;
(void)dc;
(void)current_state;
@@ -805,9 +843,9 @@ static bool check_no_shaper_curve(const struct dc *dc,
static bool check_no_stream_3dlut(const struct dc *dc,
const struct dc_state *current_state,
- const struct dc_state *new_state)
+ const struct dc_state *new_state, unsigned int i)
{
- const struct dc_3dlut *lut3d = new_state->streams[0]->lut3d_func;
+ const struct dc_3dlut *lut3d = new_state->streams[i]->lut3d_func;
(void)dc;
(void)current_state;
@@ -816,44 +854,76 @@ static bool check_no_stream_3dlut(const struct dc *dc,
static bool check_no_regamma_curve(const struct dc *dc,
const struct dc_state *current_state,
- const struct dc_state *new_state)
+ const struct dc_state *new_state, unsigned int i)
{
(void)dc;
(void)current_state;
- return new_state->streams[0]->out_transfer_func.type !=
+ return new_state->streams[i]->out_transfer_func.type !=
TF_TYPE_DISTRIBUTED_POINTS;
}
static bool check_no_cursor(const struct dc *dc,
const struct dc_state *current_state,
- const struct dc_state *new_state)
+ const struct dc_state *new_state, unsigned int i)
{
(void)dc;
(void)current_state;
- return !new_state->streams[0]->cursor_attributes.address.quad_part;
+ return !new_state->streams[i]->cursor_attributes.address.quad_part;
}
static bool check_no_dsc_change(const struct dc *dc,
const struct dc_state *current_state,
- const struct dc_state *new_state)
+ const struct dc_state *new_state, unsigned int i)
{
(void)dc;
(void)current_state;
- return !new_state->streams[0]->update_flags.bits.dsc_changed;
+ return !new_state->streams[i]->update_flags.bits.dsc_changed;
}
/*
* The checks follow the update in the order it programs the pipe. Each one
* rejects a state for which DC1 would make a call the update does not emit.
*/
+#define CHECK_UPDATE(name, msg) \
+ do { \
+ if (!check_##name(dc, current_state, new_state, i)) { \
+ dcn401_commit_check_failed(dc, msg); \
+ return BLS_BUILD_ERROR_UNSUPPORTED_STATE_UPDATE; \
+ } \
+ } while (0)
+
+#define CHECK_UPDATE_RESOURCE(name, msg) \
+ do { \
+ if (!check_##name(dc, current_state, new_state, i)) { \
+ dcn401_commit_check_failed(dc, msg); \
+ return BLS_BUILD_ERROR_RESOURCE_MAPPING; \
+ } \
+ } while (0)
+
+/* The updated stream: the one named, else the state's only stream. */
+static const struct dc_stream_state *dcn401_updated_stream(
+ const struct dc_state *new_state,
+ const struct dc_stream_state *stream)
+{
+ if (!stream && new_state->stream_count == 1)
+ return new_state->streams[0];
+ return stream;
+}
+
static enum bls_builder_result dcn401_check_seamless_update_support(
const struct dc *dc, const struct dc_state *current_state,
- const struct dc_state *new_state)
+ const struct dc_state *new_state,
+ const struct dc_stream_state *stream)
{
enum bls_builder_result result;
+ int i;
if (!dc || !current_state || !new_state)
return BLS_BUILD_ERROR_UNSUPPORTED_STATE_UPDATE;
+ i = dcn401_stream_index(new_state,
+ dcn401_updated_stream(new_state, stream));
+ if (i < 0)
+ return BLS_BUILD_ERROR_UNSUPPORTED_STATE_UPDATE;
result = dcn401_check_dc_support(dc);
if (result != BLS_BUILD_SUCCESS)
@@ -866,45 +936,46 @@ static enum bls_builder_result dcn401_check_seamless_update_support(
if (result != BLS_BUILD_SUCCESS)
return result;
- /* The transition: one stream, kept; add a plane or keep one plane. */
- CHECK_CONDITION(stream_kept, "stream is not kept across the update");
- CHECK_CONDITION(plane_add_or_kept,
+ /* The transition: streams kept; add a plane or keep one plane. */
+ CHECK_UPDATE(streams_kept,
+ "a stream is not kept, or another stream changes");
+ CHECK_UPDATE(plane_add_or_kept,
"update is not a plane add or a kept-plane surface update");
- CHECK_CONDITION(same_otg_master_blocks, "otg, opp or odm changes");
- CHECK_RESOURCE(new_plane_blocks, "plane is missing hubp or dpp");
+ CHECK_UPDATE(same_otg_master_blocks, "otg, opp or odm changes");
+ CHECK_UPDATE_RESOURCE(new_plane_blocks, "plane is missing hubp or dpp");
CHECK_RESOURCE(pool_funcs, "resource pool or hubbub has no funcs");
CHECK_CONDITION(det_by_segments, "hubbub programs det size");
/* Under the lock, before the pipe is programmed. */
CHECK_CONDITION(triple_buffer, "triple buffer is disabled");
CHECK_CONDITION(no_sanity_checks, "sanity checks are enabled");
- CHECK_CONDITION(no_pipe_wait, "pipe wait is required");
+ CHECK_UPDATE(no_pipe_wait, "pipe wait is required");
/* Unblank / enable_plane: only the plane-add path emits these. */
- CHECK_CONDITION(no_test_pattern, "test pattern is set");
+ CHECK_UPDATE(no_test_pattern, "test pattern is set");
CHECK_CONDITION(no_forced_dpg, "dpg is forced");
- CHECK_CONDITION(no_abm_pipe, "abm is set");
+ CHECK_UPDATE(no_abm_pipe, "abm is set");
CHECK_CONDITION(no_vm_aperture, "vm system aperture is valid");
- CHECK_CONDITION(no_flip_int, "flip interrupt is enabled");
+ CHECK_UPDATE(no_flip_int, "flip interrupt is enabled");
/* update_dchubp_dpp. */
- CHECK_CONDITION(no_plane_gamut_remap, "plane gamut remap is set");
- CHECK_CONDITION(no_stream_gamut_remap, "stream gamut remap is set");
- CHECK_CONDITION(no_output_csc, "output csc is set");
- CHECK_CONDITION(no_dcc, "dcc is enabled");
- CHECK_CONDITION(graphics_address, "address is not graphics");
- CHECK_CONDITION(no_immediate_flip, "flip is immediate");
+ CHECK_UPDATE(no_plane_gamut_remap, "plane gamut remap is set");
+ CHECK_UPDATE(no_stream_gamut_remap, "stream gamut remap is set");
+ CHECK_UPDATE(no_output_csc, "output csc is set");
+ CHECK_UPDATE(no_dcc, "dcc is enabled");
+ CHECK_UPDATE(graphics_address, "address is not graphics");
+ CHECK_UPDATE(no_immediate_flip, "flip is immediate");
/* Input, MCM and output transfer functions. */
- CHECK_CONDITION(no_degamma_curve, "plane degamma is distributed points");
- CHECK_CONDITION(no_mcm_luts, "an mcm lut is enabled");
- CHECK_CONDITION(no_shaper_curve, "shaper is distributed points");
- CHECK_CONDITION(no_stream_3dlut, "stream 3dlut is set");
- CHECK_CONDITION(no_regamma_curve, "regamma is distributed points");
+ CHECK_UPDATE(no_degamma_curve, "plane degamma is distributed points");
+ CHECK_UPDATE(no_mcm_luts, "an mcm lut is enabled");
+ CHECK_UPDATE(no_shaper_curve, "shaper is distributed points");
+ CHECK_UPDATE(no_stream_3dlut, "stream 3dlut is set");
+ CHECK_UPDATE(no_regamma_curve, "regamma is distributed points");
/* Not programmed by this update. */
- CHECK_CONDITION(no_cursor, "cursor is set");
- CHECK_CONDITION(no_dsc_change, "dsc changes");
+ CHECK_UPDATE(no_cursor, "cursor is set");
+ CHECK_UPDATE(no_dsc_change, "dsc changes");
return BLS_BUILD_SUCCESS;
}
@@ -1394,9 +1465,8 @@ static void dcn401_add_step(struct block_sequence_state *sequence,
const struct dcn401_commit_step_args *args,
const struct dcn401_commit_step *step)
{
- struct block_sequence *entry =
- &sequence->steps[(*sequence->num_steps)++];
- union block_sequence_params *p = &entry->params;
+ struct block_sequence *entry;
+ union block_sequence_params *p;
struct dc *dc = args->dc;
struct dcn_bw_output *bw = &args->new_state->bw_ctx.bw.dcn;
struct pipe_ctx *pipe;
@@ -1404,6 +1474,12 @@ static void dcn401_add_step(struct block_sequence_state *sequence,
struct dc_plane_state *plane;
const struct dcn401_commit_step_meta *m = &step->meta;
+ if (*sequence->num_steps >= DC2_BLS_MAX_STEPS) {
+ (*sequence->num_steps)++;
+ return;
+ }
+ entry = &sequence->steps[(*sequence->num_steps)++];
+ p = &entry->params;
memset(entry, 0, sizeof(*entry));
entry->func = step->func;
/*
@@ -2011,8 +2087,10 @@ static bool dcn401_skip_step(const struct dcn401_commit_step_args *args,
!args->pipe->stream_res.opp->mpc_tree_params.opp_list))
return true;
if (step->meta.skip_if.hubp_dpp_already_enabled &&
- args->current_state->stream_count &&
- args->current_state->stream_status[0].plane_count)
+ dcn401_stream_index(args->current_state,
+ args->pipe->stream) >= 0 &&
+ args->current_state->stream_status[dcn401_stream_index(
+ args->current_state, args->pipe->stream)].plane_count)
return true;
if (step->meta.skip_if.scaling_unchanged &&
!args->pipe->plane_state->update_bits.scaling_change &&
@@ -2047,6 +2125,8 @@ static void dcn401_add_per_otg_master(struct block_sequence_state *sequence,
unsigned int i;
for (i = 0; i < state->stream_count; i++) {
+ if (args.stream && state->streams[i] != args.stream)
+ continue;
args.pipe = resource_get_otg_master_for_stream(
&state->res_ctx, state->streams[i]);
dcn401_add_steps(sequence, &args, steps, count);
@@ -2064,6 +2144,8 @@ static void dcn401_add_per_opp_head(struct block_sequence_state *sequence,
int j, n;
for (i = 0; i < state->stream_count; i++) {
+ if (args.stream && state->streams[i] != args.stream)
+ continue;
n = resource_get_opp_heads_for_stream(state->streams[i],
&state->res_ctx, opp_heads);
for (j = 0; j < n; j++) {
@@ -2084,6 +2166,8 @@ static void dcn401_add_per_dpp_pipe(struct block_sequence_state *sequence,
int j, n;
for (i = 0; i < state->stream_count; i++) {
+ if (args.stream && state->streams[i] != args.stream)
+ continue;
n = resource_get_dpp_pipes_for_stream(state->streams[i],
&state->res_ctx, dpp_pipes);
for (j = 0; j < n; j++) {
@@ -2129,6 +2213,7 @@ void dcn401_init_and_unpack_params(
state_args->dc = params->dc;
state_args->current_state = (struct dc_state *)params->current_state;
state_args->new_state = (struct dc_state *)params->new_state;
+ state_args->stream = NULL;
state_args->pipe = NULL;
params->head_num_steps = 0;
@@ -2138,10 +2223,10 @@ void dcn401_init_and_unpack_params(
}
/*
- * One stream. skip_if drops first-enable steps when the HUBP/DPP is
- * already on, so a kept-plane surface update is the same table. The
- * enable_plane list runs per DPP pipe, top pipe first, so the top MPCC is
- * inserted before the bottom one.
+ * The updated stream only. skip_if drops first-enable steps when the
+ * HUBP/DPP is already on, so a kept-plane surface update is the same
+ * table. The enable_plane list runs per DPP pipe, top pipe first, so the
+ * top MPCC is inserted before the bottom one.
*/
static const struct dcn401_sub_sequence bls_update_head[] = {
{ .flags = DCN401_CURRENT_STATE | DCN401_PER_STREAM_PER_OTG_MASTER,
@@ -2204,11 +2289,13 @@ static enum bls_builder_result dcn401_build_seamless_update(
if (!params)
return BLS_BUILD_ERROR_UNSUPPORTED_STATE_UPDATE;
result = dcn401_check_seamless_update_support(params->dc,
- params->current_state, params->new_state);
+ params->current_state, params->new_state, params->stream);
if (result != BLS_BUILD_SUCCESS)
return result;
dcn401_init_and_unpack_params(params, &state_args, &head);
+ state_args.stream = dcn401_updated_stream(params->new_state,
+ params->stream);
DCN401_ADD_SUB_SEQUENCES(&head, &state_args, bls_update_head);
return BLS_BUILD_SUCCESS;
@@ -2218,7 +2305,7 @@ static bool dcn401_seamless_update_check_capability(
const struct bls_builder_check_capability_params *params)
{
return params && dcn401_check_seamless_update_support(params->dc,
- params->current_state, params->new_state) ==
+ params->current_state, params->new_state, params->stream) ==
BLS_BUILD_SUCCESS;
}
diff --git a/drivers/gpu/drm/amd/display/dc/core2/dc_core2.c b/drivers/gpu/drm/amd/display/dc/core2/dc_core2.c
index d05d74595829..90bcf02ded00 100644
--- a/drivers/gpu/drm/amd/display/dc/core2/dc_core2.c
+++ b/drivers/gpu/drm/amd/display/dc/core2/dc_core2.c
@@ -55,21 +55,6 @@ void core2_destruct(struct dc *dc)
(void)dc;
}
-static struct pipe_ctx *core2_otg_master(struct dc_state *state)
-{
- unsigned int i;
-
- if (!state->stream_count)
- return NULL;
- for (i = 0; i < MAX_PIPES; i++) {
- if (state->res_ctx.pipe_ctx[i].stream == state->streams[0] &&
- !state->res_ctx.pipe_ctx[i].top_pipe &&
- !state->res_ctx.pipe_ctx[i].prev_odm_pipe)
- return &state->res_ctx.pipe_ctx[i];
- }
- return NULL;
-}
-
static bool core2_run_commit_sequence(struct dc *dc,
const struct bls_builder *builder,
const struct workaround_manager *wam,
@@ -177,7 +162,8 @@ static void core2_commit_disable_done(struct dc *dc, struct pipe_ctx *pipe)
/* Builds and runs one declarative builder from dc->current_state to new_state. */
static enum dc_status core2_build_and_run(struct dc *dc,
- enum bls_builder_name name, struct dc_state *new_state)
+ enum bls_builder_name name, struct dc_state *new_state,
+ const struct dc_stream_state *stream)
{
const struct bls_builder *builder = TO_DC2(dc)->builders[name];
const struct workaround_manager *wam = dc2_workaround_manager_get();
@@ -191,6 +177,7 @@ static enum dc_status core2_build_and_run(struct dc *dc,
params->dc = dc;
params->current_state = dc->current_state;
params->new_state = new_state;
+ params->stream = stream;
/*
* A tail runs on the vsync after the head, so Core would have to wait
@@ -213,13 +200,14 @@ static enum dc_status core2_build_and_run(struct dc *dc,
}
static bool core2_builder_supports(struct dc *dc, enum bls_builder_name name,
- struct dc_state *new_state)
+ struct dc_state *new_state, const struct dc_stream_state *stream)
{
const struct bls_builder *builder = TO_DC2(dc)->builders[name];
struct bls_builder_check_capability_params check = {
.dc = dc,
.current_state = dc->current_state,
.new_state = new_state,
+ .stream = stream,
};
return builder && builder->check_capability &&
@@ -233,33 +221,36 @@ static bool core2_builder_supports(struct dc *dc, enum bls_builder_name name,
/* Never falls back to legacy_commit_state_hw: DC2 must not call DC1. */
enum dc_status core2_commit_state_hw(struct dc *dc, struct dc_state *context)
{
- struct pipe_ctx *old_pipe;
- struct pipe_ctx *new_pipe;
+ struct dc_state *current_state = dc->current_state;
enum dc_status status;
+ int i;
- if (!core2_builder_supports(dc, DCN_DECL_NON_SEAMLESS_COMMIT, context))
+ if (!core2_builder_supports(dc, DCN_DECL_NON_SEAMLESS_COMMIT, context,
+ NULL))
return DC_NOT_SUPPORTED;
- old_pipe = core2_otg_master(dc->current_state);
- new_pipe = core2_otg_master(context);
-
/*
* link_set_dpms_on builds the info frame into the
* pipe before it programs the packets. Remove when the builder
* computes it.
*/
- if (new_pipe)
- resource_build_info_frame(new_pipe);
+ for (i = 0; i < context->stream_count; i++)
+ resource_build_info_frame(resource_get_otg_master_for_stream(
+ &context->res_ctx, context->streams[i]));
- status = core2_build_and_run(dc, DCN_DECL_NON_SEAMLESS_COMMIT, context);
+ status = core2_build_and_run(dc, DCN_DECL_NON_SEAMLESS_COMMIT, context,
+ NULL);
if (status != DC_OK)
return status;
core2_commit_prepare_done(dc, context);
- if (old_pipe)
- core2_commit_disable_done(dc, old_pipe);
- if (new_pipe)
- core2_commit_enable_done(new_pipe);
+ for (i = 0; i < current_state->stream_count; i++)
+ core2_commit_disable_done(dc, resource_get_otg_master_for_stream(
+ ¤t_state->res_ctx,
+ current_state->streams[i]));
+ for (i = 0; i < context->stream_count; i++)
+ core2_commit_enable_done(resource_get_otg_master_for_stream(
+ &context->res_ctx, context->streams[i]));
return DC_OK;
}
@@ -309,7 +300,7 @@ static bool core2_update_state_supported(
if (!core2_stream_update_supported(scratch->stream_update))
return false;
return core2_builder_supports(scratch->dc, DCN_DECL_SEAMLESS_UPDATE,
- scratch->new_context);
+ scratch->new_context, scratch->stream);
}
/*
@@ -317,14 +308,15 @@ static bool core2_update_state_supported(
* the plane. The swap to the new context stays in
* dc_update_state_cleanup.
*/
-static void core2_update_done(struct dc *dc, struct dc_state *context)
+static void core2_update_done(struct dc *dc, struct dc_state *context,
+ struct dc_stream_state *stream)
{
struct pipe_ctx *dpp_pipes[MAX_PIPES];
struct pipe_ctx *pipe;
struct dc_plane_state *plane;
struct hubp *hubp;
- int i, n = context->stream_count ? resource_get_dpp_pipes_for_stream(
- context->streams[0], &context->res_ctx, dpp_pipes) : 0;
+ int i, n = resource_get_dpp_pipes_for_stream(stream, &context->res_ctx,
+ dpp_pipes);
for (i = 0; i < n; i++) {
pipe = dpp_pipes[i];
@@ -349,7 +341,8 @@ static void core2_update_state_execute(
{
struct dc *dc = scratch->dc;
struct dc_state *context = scratch->new_context;
- struct pipe_ctx *pipe = core2_otg_master(context);
+ struct pipe_ctx *pipe = resource_get_otg_master_for_stream(
+ &context->res_ctx, scratch->stream);
struct pipe_ctx *dpp_pipes[MAX_PIPES];
int i, n;
@@ -361,15 +354,16 @@ static void core2_update_state_execute(
return;
if (dc->res_pool->funcs->prepare_mcache_programming)
dc->res_pool->funcs->prepare_mcache_programming(dc, context);
- n = resource_get_dpp_pipes_for_stream(pipe->stream, &context->res_ctx,
+ n = resource_get_dpp_pipes_for_stream(scratch->stream, &context->res_ctx,
dpp_pipes);
for (i = 0; i < n; i++)
dpp_pipes[i]->plane_res.scl_data.lb_params.alpha_en =
dpp_pipes[i]->plane_state->per_pixel_alpha;
- if (core2_build_and_run(dc, DCN_DECL_SEAMLESS_UPDATE, context) != DC_OK) {
+ if (core2_build_and_run(dc, DCN_DECL_SEAMLESS_UPDATE, context,
+ scratch->stream) != DC_OK) {
ASSERT(false);
return;
}
- core2_update_done(dc, context);
+ core2_update_done(dc, context, scratch->stream);
}
--
2.43.0
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [PATCH 26/33] drm/amd/display: Add a plane beside a kept plane in DC2 update
2026-11-16 21:50 [PATCH 00/33] DC Patches November 23, 2026 James Lin
` (24 preceding siblings ...)
2026-11-16 21:51 ` [PATCH 25/33] drm/amd/display: Support two streams in the dcn401 DC2 builders James Lin
@ 2026-11-16 21:51 ` James Lin
2026-11-16 21:51 ` [PATCH 27/33] drm/amd/display: Keep an unchanged stream in the DC2 commit James Lin
` (6 subsequent siblings)
32 siblings, 0 replies; 34+ messages in thread
From: James Lin @ 2026-11-16 21:51 UTC (permalink / raw)
To: amd-gfx
Cc: Harry Wentland, Leo Li, Aurabindo Pillai, Roman Li, Wayne Lin,
Tom Chung, Fangzhi Zuo, Dan Wheeler, Ray Wu, Ivan Lipski,
Alex Hung, James Lin, Chenyu Chen, Tony Cheng, James Lin
From: Tony Cheng <tony.cheng@amd.com>
[Why]
The DC2 seamless update builder accepts a plane add only on a stream
with no plane. An update that adds a second plane to a stream fails.
[How]
Accept one or two kept planes and at most one added plane. Each kept
plane stays on its pipe, HUBP and DPP. Skip the first-enable steps of a
kept pipe, and program the DET segments when its DET size changes.
Signed-off-by: Tony Cheng <tony.cheng@amd.com>
Signed-off-by: James Lin <pinglei.lin@amd.com>
---
.../bls_builder/bls_builder_private_types.h | 7 +-
.../dc/bls_builder/dcn401_seamless_builder.c | 72 ++++++++++++++-----
2 files changed, 59 insertions(+), 20 deletions(-)
diff --git a/drivers/gpu/drm/amd/display/dc/bls_builder/bls_builder_private_types.h b/drivers/gpu/drm/amd/display/dc/bls_builder/bls_builder_private_types.h
index cc301a02c494..ed9d2f7fc0a2 100644
--- a/drivers/gpu/drm/amd/display/dc/bls_builder/bls_builder_private_types.h
+++ b/drivers/gpu/drm/amd/display/dc/bls_builder/bls_builder_private_types.h
@@ -116,10 +116,13 @@ struct dcn401_commit_step_meta {
/* The OPP MPC tree has no plane yet. */
bool opp_tree_empty;
/*
- * The HUBP/DPP block is already on. The step is part of
- * enabling that block the first time, not of reconfiguring it.
+ * The pipe already showed the plane on this HUBP. The step is
+ * part of enabling that block the first time, not of
+ * reconfiguring it.
*/
bool hubp_dpp_already_enabled;
+ /* As hubp_dpp_already_enabled, and the DET size is the same. */
+ bool det_unchanged;
/*
* Neither the plane scaling, the plane position nor the
* stream scaling changed. A full update sets every plane bit,
diff --git a/drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_seamless_builder.c b/drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_seamless_builder.c
index 09ea7ba26452..178598f18517 100644
--- a/drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_seamless_builder.c
+++ b/drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_seamless_builder.c
@@ -30,14 +30,15 @@
* DCN_DECL_NON_SEAMLESS_COMMIT (dcn401_non_seamless_builder.c) enabled.
* The other streams keep their pipes and planes, and the update programs
* none of them. The update either adds one plane, or two MPC-blended
- * planes, to the stream, or keeps one plane and programs its surface,
- * address, scaler and viewport. The sequence follows the full update in
+ * planes, to the stream, or keeps its planes and programs their surface,
+ * address, scaler and viewport, and may add a second plane below a kept
+ * one. The sequence follows the full update in
* commit_planes_for_stream on dcn401, all in head_sequence: the
* outstanding updates, prepare_bandwidth and the pending-update waits,
* then the locked front-end programming and
- * post_unlock_program_front_end. A kept-plane update skips enable_plane
- * and the stream unblank. The bandwidth lower stays with
- * dc_post_update_surfaces_to_stream.
+ * post_unlock_program_front_end. A kept plane skips the first-enable steps
+ * of enable_plane, and a stream that had a plane skips the unblank. The
+ * bandwidth lower stays with dc_post_update_surfaces_to_stream.
*
* This file also holds what both builders share: the dc and stream
* support checks, and the step walkers that turn a table into BLS entries.
@@ -517,17 +518,40 @@ static bool dcn401_is_plane_add(const struct dc_state *current_state,
(planes == 1 || planes == 2);
}
+/*
+ * Each current plane stays on its pipe, HUBP and DPP, and at most one
+ * plane is added under them.
+ */
static bool dcn401_is_plane_kept(const struct dc_state *current_state,
const struct dc_state *new_state, unsigned int i)
{
- return dcn401_current_plane_count(current_state, new_state, i) == 1 &&
- new_state->stream_status[i].plane_count == 1;
+ unsigned int planes = dcn401_current_plane_count(current_state,
+ new_state, i);
+ const struct pipe_ctx *cur, *new;
+ unsigned int j;
+
+ if (!planes || new_state->stream_status[i].plane_count < planes ||
+ new_state->stream_status[i].plane_count > 2)
+ return false;
+ for (j = 0; j < MAX_PIPES; j++) {
+ cur = ¤t_state->res_ctx.pipe_ctx[j];
+ new = &new_state->res_ctx.pipe_ctx[j];
+ if (cur->stream != new_state->streams[i] || !cur->plane_state)
+ continue;
+ if (new->stream != cur->stream ||
+ new->plane_state != cur->plane_state ||
+ new->plane_res.hubp != cur->plane_res.hubp ||
+ new->plane_res.dpp != cur->plane_res.dpp ||
+ !new->top_pipe != !cur->top_pipe)
+ return false;
+ }
+ return true;
}
/*
* The seamless update either adds the first one or two planes, or keeps
- * one plane and programs its surface, address, scaler and viewport. Each
- * plane has its own DPP pipe.
+ * the planes and programs their surface, address, scaler and viewport,
+ * and may add a second plane below one. Each plane has its own DPP pipe.
*/
static bool check_plane_add_or_kept(const struct dc *dc,
const struct dc_state *current_state,
@@ -940,7 +964,7 @@ static enum bls_builder_result dcn401_check_seamless_update_support(
CHECK_UPDATE(streams_kept,
"a stream is not kept, or another stream changes");
CHECK_UPDATE(plane_add_or_kept,
- "update is not a plane add or a kept-plane surface update");
+ "update is not a plane add, or keeps a plane off its pipe");
CHECK_UPDATE(same_otg_master_blocks, "otg, opp or odm changes");
CHECK_UPDATE_RESOURCE(new_plane_blocks, "plane is missing hubp or dpp");
CHECK_RESOURCE(pool_funcs, "resource pool or hubbub has no funcs");
@@ -1104,7 +1128,7 @@ static const struct dcn401_commit_step enable_plane[] = {
.meta.skip_if.hubp_dpp_already_enabled = true },
{ .func = HUBP_PROGRAM_DET_SEGMENTS,
.meta.hubp_program_det_segments.allocate = true,
- .meta.skip_if.hubp_dpp_already_enabled = true },
+ .meta.skip_if.det_unchanged = true },
/*
* update_dchubp_dpp. First enable runs the whole table. A reconfigure
* skips the steps that only bring the HUBP/DPP up, and programs the
@@ -2069,6 +2093,16 @@ static void dcn401_add_step(struct block_sequence_state *sequence,
}
}
+static bool dcn401_pipe_already_enabled(
+ const struct dcn401_commit_step_args *args)
+{
+ const struct pipe_ctx *cur =
+ &args->current_state->res_ctx.pipe_ctx[args->pipe->pipe_idx];
+
+ return cur->plane_state && cur->stream == args->pipe->stream &&
+ cur->plane_res.hubp == args->pipe->plane_res.hubp;
+}
+
static bool dcn401_skip_step(const struct dcn401_commit_step_args *args,
const struct dcn401_commit_step *step)
{
@@ -2087,10 +2121,12 @@ static bool dcn401_skip_step(const struct dcn401_commit_step_args *args,
!args->pipe->stream_res.opp->mpc_tree_params.opp_list))
return true;
if (step->meta.skip_if.hubp_dpp_already_enabled &&
- dcn401_stream_index(args->current_state,
- args->pipe->stream) >= 0 &&
- args->current_state->stream_status[dcn401_stream_index(
- args->current_state, args->pipe->stream)].plane_count)
+ dcn401_pipe_already_enabled(args))
+ return true;
+ if (step->meta.skip_if.det_unchanged &&
+ dcn401_pipe_already_enabled(args) &&
+ args->current_state->res_ctx.pipe_ctx[args->pipe->pipe_idx]
+ .hubp_regs.det_size == args->pipe->hubp_regs.det_size)
return true;
if (step->meta.skip_if.scaling_unchanged &&
!args->pipe->plane_state->update_bits.scaling_change &&
@@ -2223,9 +2259,9 @@ void dcn401_init_and_unpack_params(
}
/*
- * The updated stream only. skip_if drops first-enable steps when the
- * HUBP/DPP is already on, so a kept-plane surface update is the same
- * table. The enable_plane list runs per DPP pipe, top pipe first, so the
+ * The updated stream only. skip_if drops first-enable steps on a pipe
+ * that already showed its plane, so a kept-plane surface update is the
+ * same table. The enable_plane list runs per DPP pipe, top pipe first, so the
* top MPCC is inserted before the bottom one.
*/
static const struct dcn401_sub_sequence bls_update_head[] = {
--
2.43.0
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [PATCH 27/33] drm/amd/display: Keep an unchanged stream in the DC2 commit
2026-11-16 21:50 [PATCH 00/33] DC Patches November 23, 2026 James Lin
` (25 preceding siblings ...)
2026-11-16 21:51 ` [PATCH 26/33] drm/amd/display: Add a plane beside a kept plane in DC2 update James Lin
@ 2026-11-16 21:51 ` James Lin
2026-11-16 21:51 ` [PATCH 28/33] drm/amd/display: Change the ODM and MPC layout in DC2 update James Lin
` (5 subsequent siblings)
32 siblings, 0 replies; 34+ messages in thread
From: James Lin @ 2026-11-16 21:51 UTC (permalink / raw)
To: amd-gfx
Cc: Harry Wentland, Leo Li, Aurabindo Pillai, Roman Li, Wayne Lin,
Tom Chung, Fangzhi Zuo, Dan Wheeler, Ray Wu, Ivan Lipski,
Alex Hung, James Lin, Chenyu Chen, Tony Cheng, James Lin
From: Tony Cheng <tony.cheng@amd.com>
[Why]
The DC2 non-seamless commit builder disables every current stream and
enables every new stream. A commit that removes one of two streams
blanks the other stream, or fails when that stream shows a plane.
[How]
Do not program a stream that is in both states on the same pipes with
the same planes and blocks. The checks, the step walkers and the Core2
software state skip that stream.
Signed-off-by: Tony Cheng <tony.cheng@amd.com>
Signed-off-by: James Lin <pinglei.lin@amd.com>
---
.../amd/display/dc/bls_builder/bls_builder.h | 8 +++++
.../dc/bls_builder/dcn401_builder_internal.h | 10 ++----
.../bls_builder/dcn401_non_seamless_builder.c | 31 ++++++++++++-------
.../dc/bls_builder/dcn401_seamless_builder.c | 15 +++++++--
.../gpu/drm/amd/display/dc/core2/dc_core2.c | 16 +++++++---
5 files changed, 52 insertions(+), 28 deletions(-)
diff --git a/drivers/gpu/drm/amd/display/dc/bls_builder/bls_builder.h b/drivers/gpu/drm/amd/display/dc/bls_builder/bls_builder.h
index 879ff188264d..f899c27ea836 100644
--- a/drivers/gpu/drm/amd/display/dc/bls_builder/bls_builder.h
+++ b/drivers/gpu/drm/amd/display/dc/bls_builder/bls_builder.h
@@ -133,3 +133,11 @@ struct bls_builder {
const struct bls_builder *bls_builder_create(struct dc *dc,
enum bls_builder_name name);
+
+/*
+ * stream is in both states on the same pipes, each with the same plane
+ * and blocks. DCN_DECL_NON_SEAMLESS_COMMIT leaves such a stream alone.
+ */
+bool dcn401_stream_unchanged(const struct dc_state *current_state,
+ const struct dc_state *new_state,
+ const struct dc_stream_state *stream);
diff --git a/drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_builder_internal.h b/drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_builder_internal.h
index 35ad8982db9a..2d832017f613 100644
--- a/drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_builder_internal.h
+++ b/drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_builder_internal.h
@@ -74,13 +74,6 @@ const struct pipe_ctx *dcn401_otg_master(const struct dc_state *state,
/* The index of stream in state, or -1. */
int dcn401_stream_index(const struct dc_state *state,
const struct dc_stream_state *stream);
-/*
- * stream is in both states on the same pipes, each with the same plane
- * and blocks.
- */
-bool dcn401_stream_unchanged(const struct dc_state *current_state,
- const struct dc_state *new_state,
- const struct dc_stream_state *stream);
/* What both builders need of the dc, before either state. */
@@ -92,7 +85,8 @@ enum bls_builder_result dcn401_check_stream_support(const struct dc *dc,
/*
* pipe is NULL only for the bandwidth and p-state steps. The walkers
- * expand only stream when it is set.
+ * expand only stream when it is set, else each stream that is not
+ * unchanged.
*/
struct dcn401_commit_step_args {
struct dc *dc;
diff --git a/drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_non_seamless_builder.c b/drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_non_seamless_builder.c
index bfbe2e0e7eb2..dcd1c8a50429 100644
--- a/drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_non_seamless_builder.c
+++ b/drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_non_seamless_builder.c
@@ -10,10 +10,11 @@
#include "state_facts/state_facts.h"
/*
- * DCN_DECL_NON_SEAMLESS_COMMIT for virtual streams without planes. It
- * disables every current stream, each with one or two planes, one per DPP
- * pipe, then enables every new stream, each with no plane. Planes are
- * added later by DCN_DECL_SEAMLESS_UPDATE, not by this commit. Each
+ * DCN_DECL_NON_SEAMLESS_COMMIT for virtual streams. It disables every
+ * current stream, each with one or two planes, one per DPP pipe, then
+ * enables every new stream, each with no plane. A stream that is
+ * unchanged keeps its pipes and planes, and the commit programs none of
+ * them. Planes are added later by DCN_DECL_SEAMLESS_UPDATE. Each
* stream is in ODM bypass, 2:1 or 3:1, with one OPP head and at most one
* DPP pipe per slice.
*
@@ -120,19 +121,23 @@ static enum bls_builder_result dcn401_check_new_stream(
static enum bls_builder_result dcn401_check_commit_state_support(
const struct dc *dc, const struct dc_state *current_state,
- const struct dc_state *new_state)
+ const struct dc_state *new_state, bool is_current)
{
- const struct dc_state *state = dcn401_checked_state(current_state,
- new_state);
+ const struct dc_state *state = is_current ? current_state : new_state;
enum bls_builder_result result;
unsigned int i;
- result = dcn401_check_stream_support(dc, current_state, new_state);
+ result = dcn401_check_stream_support(dc, is_current ? state : NULL,
+ is_current ? NULL : state);
for (i = 0; result == BLS_BUILD_SUCCESS && i < state->stream_count;
- i++)
- result = current_state ?
+ i++) {
+ if (dcn401_stream_unchanged(current_state, new_state,
+ state->streams[i]))
+ continue;
+ result = is_current ?
dcn401_check_current_stream(dc, state, i) :
dcn401_check_new_stream(dc, state, i);
+ }
return result;
}
@@ -175,10 +180,12 @@ static enum bls_builder_result dcn401_check_non_seamless_commit_support(
return result;
CHECK_CONDITION(stream_config_update, "stream config update is set");
- result = dcn401_check_commit_state_support(dc, current_state, NULL);
+ result = dcn401_check_commit_state_support(dc, current_state,
+ new_state, true);
if (result != BLS_BUILD_SUCCESS)
return result;
- result = dcn401_check_commit_state_support(dc, NULL, new_state);
+ result = dcn401_check_commit_state_support(dc, current_state,
+ new_state, false);
if (result != BLS_BUILD_SUCCESS)
return result;
diff --git a/drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_seamless_builder.c b/drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_seamless_builder.c
index 178598f18517..3f0285763d52 100644
--- a/drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_seamless_builder.c
+++ b/drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_seamless_builder.c
@@ -2152,6 +2152,15 @@ static void dcn401_add_steps(struct block_sequence_state *sequence,
}
}
+static bool dcn401_walks_stream(const struct dcn401_commit_step_args *args,
+ const struct dc_stream_state *stream)
+{
+ if (args->stream)
+ return stream == args->stream;
+ return !dcn401_stream_unchanged(args->current_state, args->new_state,
+ stream);
+}
+
static void dcn401_add_per_otg_master(struct block_sequence_state *sequence,
const struct dcn401_commit_step_args *state_args,
struct dc_state *state,
@@ -2161,7 +2170,7 @@ static void dcn401_add_per_otg_master(struct block_sequence_state *sequence,
unsigned int i;
for (i = 0; i < state->stream_count; i++) {
- if (args.stream && state->streams[i] != args.stream)
+ if (!dcn401_walks_stream(&args, state->streams[i]))
continue;
args.pipe = resource_get_otg_master_for_stream(
&state->res_ctx, state->streams[i]);
@@ -2180,7 +2189,7 @@ static void dcn401_add_per_opp_head(struct block_sequence_state *sequence,
int j, n;
for (i = 0; i < state->stream_count; i++) {
- if (args.stream && state->streams[i] != args.stream)
+ if (!dcn401_walks_stream(&args, state->streams[i]))
continue;
n = resource_get_opp_heads_for_stream(state->streams[i],
&state->res_ctx, opp_heads);
@@ -2202,7 +2211,7 @@ static void dcn401_add_per_dpp_pipe(struct block_sequence_state *sequence,
int j, n;
for (i = 0; i < state->stream_count; i++) {
- if (args.stream && state->streams[i] != args.stream)
+ if (!dcn401_walks_stream(&args, state->streams[i]))
continue;
n = resource_get_dpp_pipes_for_stream(state->streams[i],
&state->res_ctx, dpp_pipes);
diff --git a/drivers/gpu/drm/amd/display/dc/core2/dc_core2.c b/drivers/gpu/drm/amd/display/dc/core2/dc_core2.c
index 90bcf02ded00..ce2b14bb7a5a 100644
--- a/drivers/gpu/drm/amd/display/dc/core2/dc_core2.c
+++ b/drivers/gpu/drm/amd/display/dc/core2/dc_core2.c
@@ -245,12 +245,18 @@ enum dc_status core2_commit_state_hw(struct dc *dc, struct dc_state *context)
core2_commit_prepare_done(dc, context);
for (i = 0; i < current_state->stream_count; i++)
- core2_commit_disable_done(dc, resource_get_otg_master_for_stream(
- ¤t_state->res_ctx,
- current_state->streams[i]));
+ if (!dcn401_stream_unchanged(current_state, context,
+ current_state->streams[i]))
+ core2_commit_disable_done(dc,
+ resource_get_otg_master_for_stream(
+ ¤t_state->res_ctx,
+ current_state->streams[i]));
for (i = 0; i < context->stream_count; i++)
- core2_commit_enable_done(resource_get_otg_master_for_stream(
- &context->res_ctx, context->streams[i]));
+ if (!dcn401_stream_unchanged(current_state, context,
+ context->streams[i]))
+ core2_commit_enable_done(
+ resource_get_otg_master_for_stream(
+ &context->res_ctx, context->streams[i]));
return DC_OK;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [PATCH 28/33] drm/amd/display: Change the ODM and MPC layout in DC2 update
2026-11-16 21:50 [PATCH 00/33] DC Patches November 23, 2026 James Lin
` (26 preceding siblings ...)
2026-11-16 21:51 ` [PATCH 27/33] drm/amd/display: Keep an unchanged stream in the DC2 commit James Lin
@ 2026-11-16 21:51 ` James Lin
2026-11-16 21:51 ` [PATCH 29/33] drm/amd/display: Give the DC2 builders State pipe facts James Lin
` (4 subsequent siblings)
32 siblings, 0 replies; 34+ messages in thread
From: James Lin @ 2026-11-16 21:51 UTC (permalink / raw)
To: amd-gfx
Cc: Harry Wentland, Leo Li, Aurabindo Pillai, Roman Li, Wayne Lin,
Tom Chung, Fangzhi Zuo, Dan Wheeler, Ray Wu, Ivan Lipski,
Alex Hung, James Lin, Chenyu Chen, Tony Cheng, James Lin
From: Tony Cheng <tony.cheng@amd.com>
[Why]
The DC2 seamless update builder keeps the OPP of each ODM slice and
does not remove a pipe. An update between ODM 2:1 and ODM bypass with
two blended planes fails. The commit blanks a kept stream that
changes its layout.
[How]
Accept an update where each pipe keeps its plane and blocks, joins on
a free pipe, or leaves the stream on the same OTG. Under the lock,
disconnect the MPCC and DET of each removed pipe, and program the ODM
mode and each new OPP head. After the unlock, power down the removed
pipes and wait for the ODM double buffer. The commit keeps a stream
that keeps its OTG and programs its front end after the enable.
Signed-off-by: Tony Cheng <tony.cheng@amd.com>
Signed-off-by: James Lin <pinglei.lin@amd.com>
---
.../amd/display/dc/bls_builder/bls_builder.h | 8 +-
.../bls_builder/bls_builder_private_types.h | 9 +
.../dc/bls_builder/dcn401_builder_internal.h | 36 +++
.../bls_builder/dcn401_non_seamless_builder.c | 60 ++--
.../dc/bls_builder/dcn401_seamless_builder.c | 276 +++++++++++-------
.../gpu/drm/amd/display/dc/core2/dc_core2.c | 79 +++--
6 files changed, 305 insertions(+), 163 deletions(-)
diff --git a/drivers/gpu/drm/amd/display/dc/bls_builder/bls_builder.h b/drivers/gpu/drm/amd/display/dc/bls_builder/bls_builder.h
index f899c27ea836..c9a4e59056ae 100644
--- a/drivers/gpu/drm/amd/display/dc/bls_builder/bls_builder.h
+++ b/drivers/gpu/drm/amd/display/dc/bls_builder/bls_builder.h
@@ -135,9 +135,11 @@ const struct bls_builder *bls_builder_create(struct dc *dc,
enum bls_builder_name name);
/*
- * stream is in both states on the same pipes, each with the same plane
- * and blocks. DCN_DECL_NON_SEAMLESS_COMMIT leaves such a stream alone.
+ * stream is in both states and keeps its OTG, and the seamless update can
+ * program its front end. DCN_DECL_NON_SEAMLESS_COMMIT neither disables nor
+ * enables such a stream; it runs that front end when the stream changes.
*/
-bool dcn401_stream_unchanged(const struct dc_state *current_state,
+bool dcn401_stream_kept(const struct dc *dc,
+ const struct dc_state *current_state,
const struct dc_state *new_state,
const struct dc_stream_state *stream);
diff --git a/drivers/gpu/drm/amd/display/dc/bls_builder/bls_builder_private_types.h b/drivers/gpu/drm/amd/display/dc/bls_builder/bls_builder_private_types.h
index ed9d2f7fc0a2..de73efe274c1 100644
--- a/drivers/gpu/drm/amd/display/dc/bls_builder/bls_builder_private_types.h
+++ b/drivers/gpu/drm/amd/display/dc/bls_builder/bls_builder_private_types.h
@@ -123,6 +123,15 @@ struct dcn401_commit_step_meta {
bool hubp_dpp_already_enabled;
/* As hubp_dpp_already_enabled, and the DET size is the same. */
bool det_unchanged;
+ /*
+ * The current pipe had no plane, or keeps its plane, HUBP, DPP
+ * and OPP in the new state.
+ */
+ bool no_plane_removed;
+ /* As hubp_dpp_already_enabled, and each ODM slice keeps its OPP. */
+ bool odm_kept;
+ /* Each ODM slice of the stream keeps its OPP. */
+ bool same_opp_heads;
/*
* Neither the plane scaling, the plane position nor the
* stream scaling changed. A full update sets every plane bit,
diff --git a/drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_builder_internal.h b/drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_builder_internal.h
index 2d832017f613..e9f190176485 100644
--- a/drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_builder_internal.h
+++ b/drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_builder_internal.h
@@ -76,6 +76,27 @@ int dcn401_stream_index(const struct dc_state *state,
const struct dc_stream_state *stream);
+/*
+ * stream is in both states on the same pipes, each with the same plane
+ * and blocks.
+ */
+bool dcn401_stream_unchanged(const struct dc_state *current_state,
+ const struct dc_state *new_state,
+ const struct dc_stream_state *stream);
+/*
+ * The pipe shows a plane on the same HUBP, DPP and OPP. The plane may be a
+ * new dc_plane_state; the update reprograms its contents.
+ */
+bool dcn401_pipe_kept(const struct pipe_ctx *current_pipe,
+ const struct pipe_ctx *new_pipe);
+/*
+ * What the seamless update needs of stream i of new_state, apart from the
+ * other streams.
+ */
+enum bls_builder_result dcn401_check_stream_update(const struct dc *dc,
+ const struct dc_state *current_state,
+ const struct dc_state *new_state, unsigned int i);
+
/* What both builders need of the dc, before either state. */
enum bls_builder_result dcn401_check_dc_support(const struct dc *dc);
/* What both builders need of each stream of a state, apart from its planes. */
@@ -122,6 +143,21 @@ void dcn401_add_sub_sequences(struct block_sequence_state *sequence,
#define DCN401_ADD_SUB_SEQUENCES(sequence, args, subs) \
dcn401_add_sub_sequences(sequence, args, subs, ARRAY_SIZE(subs))
+#define DCN401_DISCONNECT_STEPS 2
+#define DCN401_POWER_DOWN_STEPS 12
+/*
+ * Per current DPP pipe that leaves the stream: the MPCC and DET disconnect
+ * under the lock, and disable_plane after it.
+ */
+extern const struct dcn401_commit_step
+ dcn401_disconnect[DCN401_DISCONNECT_STEPS];
+extern const struct dcn401_commit_step
+ dcn401_power_down[DCN401_POWER_DOWN_STEPS];
+
+/* The seamless update's front end for args->stream, between the waits. */
+void dcn401_add_stream_update(struct block_sequence_state *sequence,
+ const struct dcn401_commit_step_args *args);
+
/*
* Points the step arguments at the states and the sequence at
* head_sequence, both empty. The entries point into the states; the build
diff --git a/drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_non_seamless_builder.c b/drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_non_seamless_builder.c
index dcd1c8a50429..f24480e949d6 100644
--- a/drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_non_seamless_builder.c
+++ b/drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_non_seamless_builder.c
@@ -12,11 +12,11 @@
/*
* DCN_DECL_NON_SEAMLESS_COMMIT for virtual streams. It disables every
* current stream, each with one or two planes, one per DPP pipe, then
- * enables every new stream, each with no plane. A stream that is
- * unchanged keeps its pipes and planes, and the commit programs none of
- * them. Planes are added later by DCN_DECL_SEAMLESS_UPDATE. Each
- * stream is in ODM bypass, 2:1 or 3:1, with one OPP head and at most one
- * DPP pipe per slice.
+ * enables every new stream, each with no plane. A kept stream keeps its
+ * OTG, and the commit runs the seamless update's front end for it when its
+ * pipes or planes change. Planes are added later by
+ * DCN_DECL_SEAMLESS_UPDATE. Each stream is in ODM bypass, 2:1 or 3:1, with
+ * one OPP head and at most one DPP pipe per slice.
*
* The sequence follows legacy_commit_state_hw on dcn401: the same leaf
* calls in the same order, including the calls DC1 repeats. Everything is
@@ -131,7 +131,7 @@ static enum bls_builder_result dcn401_check_commit_state_support(
is_current ? NULL : state);
for (i = 0; result == BLS_BUILD_SUCCESS && i < state->stream_count;
i++) {
- if (dcn401_stream_unchanged(current_state, new_state,
+ if (dcn401_stream_kept(dc, current_state, new_state,
state->streams[i]))
continue;
result = is_current ?
@@ -229,32 +229,10 @@ static const struct dcn401_commit_step blank[] = {
{ .func = OPP_SET_DISP_PATTERN_GENERATOR },
};
-static const struct dcn401_commit_step disconnect[] = {
- { .func = HUBP_PROGRAM_DET_SEGMENTS },
- { .func = MPC_REMOVE_MPCC },
-};
-
static const struct dcn401_commit_step unlock[] = {
{ .func = TG_LOCK, .meta.tg_lock.lock = false },
};
-static const struct dcn401_commit_step power_down[] = {
- { .func = MPC_ASSERT_IDLE_MPCC },
- { .func = HUBP_SET_BLANK },
- { .func = HUBP_UPDATE_MALL_SEL },
- { .func = HUBP_SET_FLIP_CONTROL_GSL },
- { .func = HUBP_CLK_CNTL },
- { .func = DPP_DPPCLK_CONTROL },
- { .func = DC_IP_REQUEST_STATUS, .meta.skip_if.no_ip_request = true },
- { .func = DC_IP_REQUEST_CNTL, .meta.dc_ip_request_cntl.enable = true,
- .meta.skip_if.no_ip_request = true },
- { .func = HUBP_PG_CONTROL },
- { .func = HUBP_RESET },
- { .func = DPP_RESET },
- { .func = DC_IP_REQUEST_CNTL, .meta.dc_ip_request_cntl.enable = false,
- .meta.skip_if.no_ip_request = true },
-};
-
static const struct dcn401_commit_step stream_off[] = {
{ .func = HUBBUB_FORCE_PSTATE_CHANGE_CONTROL },
@@ -390,9 +368,9 @@ static const struct dcn401_commit_step postamble[] = {
static_assert(ARRAY_SIZE(prepare_bandwidth) +
ARRAY_SIZE(lock) +
DCN401_MAX_OPP_HEADS * ARRAY_SIZE(blank) +
- DCN401_MAX_DPP_PIPES * ARRAY_SIZE(disconnect) +
+ DCN401_MAX_DPP_PIPES * ARRAY_SIZE(dcn401_disconnect) +
ARRAY_SIZE(unlock) +
- DCN401_MAX_DPP_PIPES * ARRAY_SIZE(power_down) +
+ DCN401_MAX_DPP_PIPES * ARRAY_SIZE(dcn401_power_down) +
ARRAY_SIZE(stream_off) +
ARRAY_SIZE(postamble) <=
DC2_BLS_MAX_STEPS,
@@ -422,14 +400,14 @@ static const struct dcn401_sub_sequence bls_head[] = {
.steps = blank,
.count = ARRAY_SIZE(blank) },
{ .flags = DCN401_CURRENT_STATE | DCN401_PER_STREAM_PER_DPP_PIPE,
- .steps = disconnect,
- .count = ARRAY_SIZE(disconnect) },
+ .steps = dcn401_disconnect,
+ .count = ARRAY_SIZE(dcn401_disconnect) },
{ .flags = DCN401_CURRENT_STATE | DCN401_PER_STREAM_PER_OTG_MASTER,
.steps = unlock,
.count = ARRAY_SIZE(unlock) },
{ .flags = DCN401_CURRENT_STATE | DCN401_PER_STREAM_PER_DPP_PIPE,
- .steps = power_down,
- .count = ARRAY_SIZE(power_down) },
+ .steps = dcn401_power_down,
+ .count = ARRAY_SIZE(dcn401_power_down) },
{ .flags = DCN401_CURRENT_STATE | DCN401_PER_STREAM_PER_OTG_MASTER,
.steps = stream_off,
.count = ARRAY_SIZE(stream_off) },
@@ -460,6 +438,9 @@ static const struct dcn401_sub_sequence bls_head[] = {
{ .flags = DCN401_NEW_STATE | DCN401_PER_STREAM_PER_OTG_MASTER,
.steps = front_end,
.count = ARRAY_SIZE(front_end) },
+};
+
+static const struct dcn401_sub_sequence bls_postamble[] = {
{ .flags = DCN401_NEW_STATE,
.steps = postamble,
.count = ARRAY_SIZE(postamble) },
@@ -471,6 +452,7 @@ static enum bls_builder_result dcn401_build_non_seamless_commit(
struct dcn401_commit_step_args state_args;
struct block_sequence_state head;
enum bls_builder_result result;
+ unsigned int i;
if (!params)
return BLS_BUILD_ERROR_UNSUPPORTED_STATE_UPDATE;
@@ -481,6 +463,16 @@ static enum bls_builder_result dcn401_build_non_seamless_commit(
dcn401_init_and_unpack_params(params, &state_args, &head);
DCN401_ADD_SUB_SEQUENCES(&head, &state_args, bls_head);
+ for (i = 0; i < state_args.new_state->stream_count; i++) {
+ state_args.stream = state_args.new_state->streams[i];
+ if (dcn401_stream_kept(params->dc, params->current_state,
+ params->new_state, state_args.stream) &&
+ !dcn401_stream_unchanged(params->current_state,
+ params->new_state, state_args.stream))
+ dcn401_add_stream_update(&head, &state_args);
+ }
+ state_args.stream = NULL;
+ DCN401_ADD_SUB_SEQUENCES(&head, &state_args, bls_postamble);
return BLS_BUILD_SUCCESS;
}
diff --git a/drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_seamless_builder.c b/drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_seamless_builder.c
index 3f0285763d52..5218ecfbc385 100644
--- a/drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_seamless_builder.c
+++ b/drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_seamless_builder.c
@@ -29,16 +29,17 @@
* DCN_DECL_SEAMLESS_UPDATE for one of the virtual streams that
* DCN_DECL_NON_SEAMLESS_COMMIT (dcn401_non_seamless_builder.c) enabled.
* The other streams keep their pipes and planes, and the update programs
- * none of them. The update either adds one plane, or two MPC-blended
- * planes, to the stream, or keeps its planes and programs their surface,
- * address, scaler and viewport, and may add a second plane below a kept
- * one. The sequence follows the full update in
+ * none of them. The stream ends with one or two planes. Each of its pipes
+ * keeps a plane on its HUBP, DPP and OPP, is added on a free pipe, or leaves
+ * the stream, so the update can add and remove planes and change the ODM
+ * and MPC layout on the same OTG. The sequence follows the full update in
* commit_planes_for_stream on dcn401, all in head_sequence: the
* outstanding updates, prepare_bandwidth and the pending-update waits,
* then the locked front-end programming and
- * post_unlock_program_front_end. A kept plane skips the first-enable steps
- * of enable_plane, and a stream that had a plane skips the unblank. The
- * bandwidth lower stays with dc_post_update_surfaces_to_stream.
+ * post_unlock_program_front_end. Under the lock, a removed pipe leaves its
+ * MPCC; after it, the pipe powers down. A kept pipe skips the first-enable
+ * steps of enable_plane. The bandwidth lower stays with
+ * dc_post_update_surfaces_to_stream.
*
* This file also holds what both builders share: the dc and stream
* support checks, and the step walkers that turn a table into BLS entries.
@@ -500,93 +501,73 @@ static bool check_streams_kept(const struct dc *dc,
return true;
}
-static unsigned int dcn401_current_plane_count(
- const struct dc_state *current_state,
- const struct dc_state *new_state, unsigned int i)
+bool dcn401_pipe_kept(const struct pipe_ctx *current_pipe,
+ const struct pipe_ctx *new_pipe)
{
- return current_state->stream_status[dcn401_stream_index(current_state,
- new_state->streams[i])].plane_count;
-}
-
-/* Both planes of an MPO state are added together, by one update. */
-static bool dcn401_is_plane_add(const struct dc_state *current_state,
- const struct dc_state *new_state, unsigned int i)
-{
- unsigned int planes = new_state->stream_status[i].plane_count;
-
- return !dcn401_current_plane_count(current_state, new_state, i) &&
- (planes == 1 || planes == 2);
+ return current_pipe->plane_state &&
+ current_pipe->stream == new_pipe->stream &&
+ new_pipe->plane_state &&
+ current_pipe->plane_res.hubp == new_pipe->plane_res.hubp &&
+ current_pipe->plane_res.dpp == new_pipe->plane_res.dpp &&
+ current_pipe->stream_res.opp == new_pipe->stream_res.opp;
}
/*
- * Each current plane stays on its pipe, HUBP and DPP, and at most one
- * plane is added under them.
+ * The stream shows one or two planes. Each of its pipes was free, or kept
+ * its OPP and either had no plane or keeps a plane on its HUBP and DPP. A
+ * current pipe that does neither is removed.
*/
-static bool dcn401_is_plane_kept(const struct dc_state *current_state,
+static bool check_pipes_kept_or_free(const struct dc *dc,
+ const struct dc_state *current_state,
const struct dc_state *new_state, unsigned int i)
{
- unsigned int planes = dcn401_current_plane_count(current_state,
- new_state, i);
+ unsigned int planes = new_state->stream_status[i].plane_count;
const struct pipe_ctx *cur, *new;
+ struct dc_state_facts facts;
unsigned int j;
- if (!planes || new_state->stream_status[i].plane_count < planes ||
- new_state->stream_status[i].plane_count > 2)
+ (void)dc;
+ if (planes < 1 || planes > 2)
return false;
for (j = 0; j < MAX_PIPES; j++) {
cur = ¤t_state->res_ctx.pipe_ctx[j];
new = &new_state->res_ctx.pipe_ctx[j];
- if (cur->stream != new_state->streams[i] || !cur->plane_state)
+ if (new->stream != new_state->streams[i] || !cur->stream)
continue;
- if (new->stream != cur->stream ||
- new->plane_state != cur->plane_state ||
- new->plane_res.hubp != cur->plane_res.hubp ||
- new->plane_res.dpp != cur->plane_res.dpp ||
- !new->top_pipe != !cur->top_pipe)
+ if (cur->stream != new->stream ||
+ cur->stream_res.opp != new->stream_res.opp ||
+ (cur->plane_state && !dcn401_pipe_kept(cur, new)))
return false;
}
- return true;
+ dc_state_facts_derive(new_state, &facts);
+ return facts.global.blend_tree[i].dpp_pipe_count == planes;
}
-/*
- * The seamless update either adds the first one or two planes, or keeps
- * the planes and programs their surface, address, scaler and viewport,
- * and may add a second plane below one. Each plane has its own DPP pipe.
- */
-static bool check_plane_add_or_kept(const struct dc *dc,
+static bool check_same_otg(const struct dc *dc,
const struct dc_state *current_state,
const struct dc_state *new_state, unsigned int i)
{
- struct dc_state_facts facts;
+ const struct pipe_ctx *cur = dcn401_otg_master(current_state,
+ new_state->streams[i]);
+ const struct pipe_ctx *new = dcn401_otg_master(new_state,
+ new_state->streams[i]);
(void)dc;
- if (!dcn401_is_plane_add(current_state, new_state, i) &&
- !dcn401_is_plane_kept(current_state, new_state, i))
- return false;
- dc_state_facts_derive(new_state, &facts);
- return facts.global.blend_tree[i].dpp_pipe_count ==
- new_state->stream_status[i].plane_count;
+ return cur && new && cur->stream_res.tg == new->stream_res.tg;
}
-static bool check_same_otg_master_blocks(const struct dc *dc,
- const struct dc_state *current_state,
- const struct dc_state *new_state, unsigned int i)
+/* stream has the same OPP for each ODM slice in both states. */
+static bool dcn401_same_opp_heads(const struct dc_state *current_state,
+ const struct dc_state *new_state,
+ const struct dc_stream_state *stream)
{
- const struct pipe_ctx *current_pipe = dcn401_otg_master(current_state,
- new_state->streams[i]);
- const struct pipe_ctx *new_pipe = dcn401_otg_master(new_state,
- new_state->streams[i]);
+ const struct pipe_ctx *cur = dcn401_otg_master(current_state, stream);
+ const struct pipe_ctx *new = dcn401_otg_master(new_state, stream);
- (void)dc;
- if (current_pipe->stream_res.tg != new_pipe->stream_res.tg)
- return false;
- /* The same OPP for each ODM slice. */
- for (; current_pipe && new_pipe;
- current_pipe = current_pipe->next_odm_pipe,
- new_pipe = new_pipe->next_odm_pipe)
- if (current_pipe->stream_res.opp != new_pipe->stream_res.opp)
+ for (; cur && new; cur = cur->next_odm_pipe, new = new->next_odm_pipe)
+ if (cur->stream_res.opp != new->stream_res.opp)
return false;
- return !current_pipe && !new_pipe;
+ return !cur && !new;
}
static bool check_new_plane_blocks(const struct dc *dc,
@@ -960,12 +941,32 @@ static enum bls_builder_result dcn401_check_seamless_update_support(
if (result != BLS_BUILD_SUCCESS)
return result;
- /* The transition: streams kept; add a plane or keep one plane. */
CHECK_UPDATE(streams_kept,
"a stream is not kept, or another stream changes");
- CHECK_UPDATE(plane_add_or_kept,
- "update is not a plane add, or keeps a plane off its pipe");
- CHECK_UPDATE(same_otg_master_blocks, "otg, opp or odm changes");
+ return dcn401_check_stream_update(dc, current_state, new_state, i);
+}
+
+bool dcn401_stream_kept(const struct dc *dc,
+ const struct dc_state *current_state,
+ const struct dc_state *new_state,
+ const struct dc_stream_state *stream)
+{
+ int i = dcn401_stream_index(new_state, stream);
+
+ if (i < 0 || dcn401_stream_index(current_state, stream) < 0)
+ return false;
+ return dcn401_stream_unchanged(current_state, new_state, stream) ||
+ dcn401_check_stream_update(dc, current_state, new_state,
+ (unsigned int)i) == BLS_BUILD_SUCCESS;
+}
+
+enum bls_builder_result dcn401_check_stream_update(const struct dc *dc,
+ const struct dc_state *current_state,
+ const struct dc_state *new_state, unsigned int i)
+{
+ CHECK_UPDATE(pipes_kept_or_free,
+ "a pipe moves, or the stream has no or too many planes");
+ CHECK_UPDATE(same_otg, "otg changes");
CHECK_UPDATE_RESOURCE(new_plane_blocks, "plane is missing hubp or dpp");
CHECK_RESOURCE(pool_funcs, "resource pool or hubbub has no funcs");
CHECK_CONDITION(det_by_segments, "hubbub programs det size");
@@ -1022,7 +1023,8 @@ prepare_bandwidth[] = {
/*
* Net effect: hwss_process_outstanding_hw_updates on the current state,
* which commit_planes_for_stream runs while optimized_required is set.
- * The OTG master has no plane yet, so no MPCC disconnect is pending.
+ * The update disconnects its removed pipes itself, so no MPCC disconnect
+ * is pending.
*/
static const struct dcn401_commit_step preamble[] = {
{ .func = TG_WAIT_FOR_ALL_PENDING_UPDATES,
@@ -1095,14 +1097,44 @@ static const struct dcn401_commit_step global_sync[] = {
{ .func = TG_SETUP_VERTICAL_INTERRUPT2,
.meta.skip_if.hubp_dpp_already_enabled = true },
{ .func = OPTC_SET_ODM_COMBINE,
- .meta.skip_if.hubp_dpp_already_enabled = true },
+ .meta.skip_if.odm_kept = true },
};
static const struct dcn401_commit_step opp_odm[] = {
{ .func = OPP_PIPE_CLOCK_CONTROL,
- .meta.skip_if.hubp_dpp_already_enabled = true },
+ .meta.skip_if.odm_kept = true },
{ .func = OPP_PROGRAM_LEFT_EDGE_EXTRA_PIXEL,
- .meta.skip_if.hubp_dpp_already_enabled = true },
+ .meta.skip_if.odm_kept = true },
+};
+
+/*
+ * Under the lock, each current pipe that the update removes leaves its
+ * MPCC and returns its DET segments, as DC1 disconnects a disabled pipe.
+ */
+const struct dcn401_commit_step dcn401_disconnect[DCN401_DISCONNECT_STEPS] = {
+ { .func = HUBP_PROGRAM_DET_SEGMENTS, .meta.skip_if.no_plane_removed = true },
+ { .func = MPC_REMOVE_MPCC, .meta.skip_if.no_plane_removed = true },
+};
+
+/* After the unlock, disable_plane on each removed pipe. */
+const struct dcn401_commit_step dcn401_power_down[DCN401_POWER_DOWN_STEPS] = {
+ { .func = MPC_ASSERT_IDLE_MPCC, .meta.skip_if.no_plane_removed = true },
+ { .func = HUBP_SET_BLANK, .meta.skip_if.no_plane_removed = true },
+ { .func = HUBP_UPDATE_MALL_SEL, .meta.skip_if.no_plane_removed = true },
+ { .func = HUBP_SET_FLIP_CONTROL_GSL, .meta.skip_if.no_plane_removed = true },
+ { .func = HUBP_CLK_CNTL, .meta.skip_if.no_plane_removed = true },
+ { .func = DPP_DPPCLK_CONTROL, .meta.skip_if.no_plane_removed = true },
+ { .func = DC_IP_REQUEST_STATUS, .meta.skip_if.no_ip_request = true,
+ .meta.skip_if.no_plane_removed = true },
+ { .func = DC_IP_REQUEST_CNTL, .meta.dc_ip_request_cntl.enable = true,
+ .meta.skip_if.no_ip_request = true,
+ .meta.skip_if.no_plane_removed = true },
+ { .func = HUBP_PG_CONTROL, .meta.skip_if.no_plane_removed = true },
+ { .func = HUBP_RESET, .meta.skip_if.no_plane_removed = true },
+ { .func = DPP_RESET, .meta.skip_if.no_plane_removed = true },
+ { .func = DC_IP_REQUEST_CNTL, .meta.dc_ip_request_cntl.enable = false,
+ .meta.skip_if.no_ip_request = true,
+ .meta.skip_if.no_plane_removed = true },
};
/* enable_plane, then the watermark propagate and the DET segments. */
@@ -1228,12 +1260,26 @@ static const struct dcn401_commit_step dpp_mall[] = {
.meta.hubp_update_mall_sel.from_new_state = true },
};
+/* A changed ODM layout takes effect before the update returns. */
+static const struct dcn401_commit_step odm_wait[] = {
+ { .func = TG_WAIT_ODM_DOUBLEBUFFER_PENDING_CLEAR,
+ .meta.skip_if.same_opp_heads = true },
+};
+
static const struct dcn401_commit_step trigger[] = {
{ .func = OPTC_PROGRAM_MANUAL_TRIGGER,
.meta.skip_if.no_manual_trigger = true },
};
-/* The support check allows one stream, kept across the update. */
+/*
+ * The update programs one stream. A pipe that leaves the stream emits
+ * fewer steps than a pipe the update programs, so the bound counts every
+ * pipe as programmed. dcn401_add_step catches a longer sequence.
+ */
+static_assert(ARRAY_SIZE(dcn401_disconnect) + ARRAY_SIZE(dcn401_power_down) <=
+ ARRAY_SIZE(dpp_lock) + ARRAY_SIZE(enable_plane) +
+ ARRAY_SIZE(dpp_flip) + ARRAY_SIZE(dpp_mall),
+ "a removed pipe emits more than a programmed pipe");
static_assert(
ARRAY_SIZE(preamble) +
ARRAY_SIZE(global_preamble) +
@@ -1247,6 +1293,7 @@ static_assert(
ARRAY_SIZE(opp_odm)) +
ARRAY_SIZE(unlock) +
ARRAY_SIZE(pstate) +
+ ARRAY_SIZE(odm_wait) +
ARRAY_SIZE(trigger) +
DCN401_MAX_DPP_PIPES * (
ARRAY_SIZE(dpp_lock) +
@@ -2093,25 +2140,26 @@ static void dcn401_add_step(struct block_sequence_state *sequence,
}
}
-static bool dcn401_pipe_already_enabled(
- const struct dcn401_commit_step_args *args)
-{
- const struct pipe_ctx *cur =
- &args->current_state->res_ctx.pipe_ctx[args->pipe->pipe_idx];
-
- return cur->plane_state && cur->stream == args->pipe->stream &&
- cur->plane_res.hubp == args->pipe->plane_res.hubp;
-}
-
static bool dcn401_skip_step(const struct dcn401_commit_step_args *args,
const struct dcn401_commit_step *step)
{
+ const struct pipe_ctx *cur, *new;
+
if (step->meta.skip_if.new_state_has_stream &&
args->new_state->stream_count)
return true;
if (step->meta.skip_if.optimized_not_required &&
!args->dc->optimized_required)
return true;
+ if (step->meta.skip_if.no_ip_request &&
+ (!args->dc->hwseq->funcs.pg_needs_ip_request ||
+ !args->dc->hwseq->funcs.pg_needs_ip_request(args->dc)))
+ return true;
+ /* The remaining conditions are for per-pipe steps. */
+ if (!args->pipe)
+ return false;
+ cur = &args->current_state->res_ctx.pipe_ctx[args->pipe->pipe_idx];
+ new = &args->new_state->res_ctx.pipe_ctx[args->pipe->pipe_idx];
if (step->meta.skip_if.no_manual_trigger &&
(!args->pipe->plane_state->update_bits.addr_update ||
args->pipe->plane_state->skip_manual_trigger))
@@ -2121,21 +2169,29 @@ static bool dcn401_skip_step(const struct dcn401_commit_step_args *args,
!args->pipe->stream_res.opp->mpc_tree_params.opp_list))
return true;
if (step->meta.skip_if.hubp_dpp_already_enabled &&
- dcn401_pipe_already_enabled(args))
+ dcn401_pipe_kept(cur, new))
+ return true;
+ if (step->meta.skip_if.no_plane_removed &&
+ (!cur->plane_state || dcn401_pipe_kept(cur, new)))
+ return true;
+ if (step->meta.skip_if.det_unchanged && dcn401_pipe_kept(cur, new) &&
+ cur->hubp_regs.det_size == new->hubp_regs.det_size)
return true;
- if (step->meta.skip_if.det_unchanged &&
- dcn401_pipe_already_enabled(args) &&
- args->current_state->res_ctx.pipe_ctx[args->pipe->pipe_idx]
- .hubp_regs.det_size == args->pipe->hubp_regs.det_size)
+ if (step->meta.skip_if.odm_kept && dcn401_pipe_kept(cur, new) &&
+ dcn401_same_opp_heads(args->current_state,
+ args->new_state, args->pipe->stream))
+ return true;
+ if (step->meta.skip_if.same_opp_heads &&
+ dcn401_same_opp_heads(args->current_state,
+ args->new_state, args->pipe->stream))
return true;
if (step->meta.skip_if.scaling_unchanged &&
!args->pipe->plane_state->update_bits.scaling_change &&
!args->pipe->plane_state->update_bits.position_change &&
- !args->pipe->stream->update_flags.bits.scaling)
- return true;
- if (step->meta.skip_if.no_ip_request &&
- (!args->dc->hwseq->funcs.pg_needs_ip_request ||
- !args->dc->hwseq->funcs.pg_needs_ip_request(args->dc)))
+ !args->pipe->stream->update_flags.bits.scaling &&
+ (!dcn401_pipe_kept(cur, new) ||
+ !memcmp(&cur->plane_res.scl_data, &new->plane_res.scl_data,
+ sizeof(cur->plane_res.scl_data))))
return true;
return false;
}
@@ -2157,8 +2213,8 @@ static bool dcn401_walks_stream(const struct dcn401_commit_step_args *args,
{
if (args->stream)
return stream == args->stream;
- return !dcn401_stream_unchanged(args->current_state, args->new_state,
- stream);
+ return !dcn401_stream_kept(args->dc, args->current_state,
+ args->new_state, stream);
}
static void dcn401_add_per_otg_master(struct block_sequence_state *sequence,
@@ -2268,10 +2324,10 @@ void dcn401_init_and_unpack_params(
}
/*
- * The updated stream only. skip_if drops first-enable steps on a pipe
- * that already showed its plane, so a kept-plane surface update is the
- * same table. The enable_plane list runs per DPP pipe, top pipe first, so the
- * top MPCC is inserted before the bottom one.
+ * The waits and the bandwidth raise, then the updated stream only.
+ * skip_if drops the steps a kept pipe or ODM layout does not need, so
+ * every transition is the same table. The enable_plane list runs per DPP
+ * pipe, top pipe first, so the top MPCC is inserted before the bottom one.
*/
static const struct dcn401_sub_sequence bls_update_head[] = {
{ .flags = DCN401_CURRENT_STATE | DCN401_PER_STREAM_PER_OTG_MASTER,
@@ -2283,6 +2339,10 @@ static const struct dcn401_sub_sequence bls_update_head[] = {
{ .flags = DCN401_NEW_STATE,
.steps = prepare_bandwidth,
.count = ARRAY_SIZE(prepare_bandwidth) },
+};
+
+/* The front end of one stream, which a commit also runs for a kept stream. */
+static const struct dcn401_sub_sequence bls_stream_update[] = {
{ .flags = DCN401_CURRENT_STATE | DCN401_PER_STREAM_PER_OTG_MASTER,
.steps = pending,
.count = ARRAY_SIZE(pending) },
@@ -2292,6 +2352,9 @@ static const struct dcn401_sub_sequence bls_update_head[] = {
{ .flags = DCN401_NEW_STATE | DCN401_PER_STREAM_PER_DPP_PIPE,
.steps = dpp_lock,
.count = ARRAY_SIZE(dpp_lock) },
+ { .flags = DCN401_CURRENT_STATE | DCN401_PER_STREAM_PER_DPP_PIPE,
+ .steps = dcn401_disconnect,
+ .count = ARRAY_SIZE(dcn401_disconnect) },
{ .flags = DCN401_NEW_STATE | DCN401_PER_STREAM_PER_OTG_MASTER,
.steps = first_hubp,
.count = ARRAY_SIZE(first_hubp) },
@@ -2310,6 +2373,9 @@ static const struct dcn401_sub_sequence bls_update_head[] = {
{ .flags = DCN401_NEW_STATE | DCN401_PER_STREAM_PER_OTG_MASTER,
.steps = unlock,
.count = ARRAY_SIZE(unlock) },
+ { .flags = DCN401_CURRENT_STATE | DCN401_PER_STREAM_PER_DPP_PIPE,
+ .steps = dcn401_power_down,
+ .count = ARRAY_SIZE(dcn401_power_down) },
{ .flags = DCN401_NEW_STATE | DCN401_PER_STREAM_PER_DPP_PIPE,
.steps = dpp_flip,
.count = ARRAY_SIZE(dpp_flip) },
@@ -2319,11 +2385,20 @@ static const struct dcn401_sub_sequence bls_update_head[] = {
{ .flags = DCN401_NEW_STATE | DCN401_PER_STREAM_PER_DPP_PIPE,
.steps = dpp_mall,
.count = ARRAY_SIZE(dpp_mall) },
+ { .flags = DCN401_NEW_STATE | DCN401_PER_STREAM_PER_OTG_MASTER,
+ .steps = odm_wait,
+ .count = ARRAY_SIZE(odm_wait) },
{ .flags = DCN401_NEW_STATE | DCN401_PER_STREAM_PER_OTG_MASTER,
.steps = trigger,
.count = ARRAY_SIZE(trigger) },
};
+void dcn401_add_stream_update(struct block_sequence_state *sequence,
+ const struct dcn401_commit_step_args *args)
+{
+ DCN401_ADD_SUB_SEQUENCES(sequence, args, bls_stream_update);
+}
+
static enum bls_builder_result dcn401_build_seamless_update(
struct bls_builder_declarative_params *params)
{
@@ -2342,6 +2417,7 @@ static enum bls_builder_result dcn401_build_seamless_update(
state_args.stream = dcn401_updated_stream(params->new_state,
params->stream);
DCN401_ADD_SUB_SEQUENCES(&head, &state_args, bls_update_head);
+ dcn401_add_stream_update(&head, &state_args);
return BLS_BUILD_SUCCESS;
}
diff --git a/drivers/gpu/drm/amd/display/dc/core2/dc_core2.c b/drivers/gpu/drm/amd/display/dc/core2/dc_core2.c
index ce2b14bb7a5a..22da4ebae256 100644
--- a/drivers/gpu/drm/amd/display/dc/core2/dc_core2.c
+++ b/drivers/gpu/drm/amd/display/dc/core2/dc_core2.c
@@ -218,6 +218,28 @@ static bool core2_builder_supports(struct dc *dc, enum bls_builder_name name,
core2_query_accelerated_mode(dc);
}
+/*
+ * The values DC1 computes into the context before it programs the planes.
+ * The builder reads them from the context.
+ */
+static void core2_update_prepare(struct dc *dc, struct dc_state *context,
+ const struct dc_stream_state *stream)
+{
+ struct pipe_ctx *dpp_pipes[MAX_PIPES];
+ int i, n;
+
+ if (dc->res_pool->funcs->prepare_mcache_programming)
+ dc->res_pool->funcs->prepare_mcache_programming(dc, context);
+ n = resource_get_dpp_pipes_for_stream(stream, &context->res_ctx,
+ dpp_pipes);
+ for (i = 0; i < n; i++)
+ dpp_pipes[i]->plane_res.scl_data.lb_params.alpha_en =
+ dpp_pipes[i]->plane_state->per_pixel_alpha;
+}
+
+static void core2_update_done(struct dc *dc, struct dc_state *context,
+ struct dc_stream_state *stream);
+
/* Never falls back to legacy_commit_state_hw: DC2 must not call DC1. */
enum dc_status core2_commit_state_hw(struct dc *dc, struct dc_state *context)
{
@@ -234,9 +256,16 @@ enum dc_status core2_commit_state_hw(struct dc *dc, struct dc_state *context)
* pipe before it programs the packets. Remove when the builder
* computes it.
*/
- for (i = 0; i < context->stream_count; i++)
- resource_build_info_frame(resource_get_otg_master_for_stream(
- &context->res_ctx, context->streams[i]));
+ for (i = 0; i < context->stream_count; i++) {
+ struct pipe_ctx *otg_master = resource_get_otg_master_for_stream(
+ &context->res_ctx, context->streams[i]);
+
+ if (otg_master)
+ resource_build_info_frame(otg_master);
+ if (dcn401_stream_kept(dc, current_state, context,
+ context->streams[i]))
+ core2_update_prepare(dc, context, context->streams[i]);
+ }
status = core2_build_and_run(dc, DCN_DECL_NON_SEAMLESS_COMMIT, context,
NULL);
@@ -244,16 +273,20 @@ enum dc_status core2_commit_state_hw(struct dc *dc, struct dc_state *context)
return status;
core2_commit_prepare_done(dc, context);
- for (i = 0; i < current_state->stream_count; i++)
- if (!dcn401_stream_unchanged(current_state, context,
- current_state->streams[i]))
- core2_commit_disable_done(dc,
- resource_get_otg_master_for_stream(
- ¤t_state->res_ctx,
- current_state->streams[i]));
+ for (i = 0; i < current_state->stream_count; i++) {
+ struct pipe_ctx *otg_master = resource_get_otg_master_for_stream(
+ ¤t_state->res_ctx,
+ current_state->streams[i]);
+
+ if (otg_master && !dcn401_stream_kept(dc, current_state,
+ context, current_state->streams[i]))
+ core2_commit_disable_done(dc, otg_master);
+ }
for (i = 0; i < context->stream_count; i++)
- if (!dcn401_stream_unchanged(current_state, context,
+ if (dcn401_stream_kept(dc, current_state, context,
context->streams[i]))
+ core2_update_done(dc, context, context->streams[i]);
+ else
core2_commit_enable_done(
resource_get_otg_master_for_stream(
&context->res_ctx, context->streams[i]));
@@ -321,9 +354,15 @@ static void core2_update_done(struct dc *dc, struct dc_state *context,
struct pipe_ctx *pipe;
struct dc_plane_state *plane;
struct hubp *hubp;
- int i, n = resource_get_dpp_pipes_for_stream(stream, &context->res_ctx,
- dpp_pipes);
+ int i, n = resource_get_dpp_pipes_for_stream(stream,
+ &dc->current_state->res_ctx, dpp_pipes);
+ /* The update powers down the pipes that leave the stream. */
+ for (i = 0; i < n; i++)
+ if (dpp_pipes[i]->plane_res.hubp)
+ dpp_pipes[i]->plane_res.hubp->power_gated = true;
+ n = resource_get_dpp_pipes_for_stream(stream, &context->res_ctx,
+ dpp_pipes);
for (i = 0; i < n; i++) {
pipe = dpp_pipes[i];
if (!pipe->plane_state || !pipe->plane_res.hubp ||
@@ -349,22 +388,10 @@ static void core2_update_state_execute(
struct dc_state *context = scratch->new_context;
struct pipe_ctx *pipe = resource_get_otg_master_for_stream(
&context->res_ctx, scratch->stream);
- struct pipe_ctx *dpp_pipes[MAX_PIPES];
- int i, n;
- /*
- * The values DC1 computes into the context before it programs the
- * planes. The builder reads them from the context.
- */
if (!pipe || !pipe->plane_state)
return;
- if (dc->res_pool->funcs->prepare_mcache_programming)
- dc->res_pool->funcs->prepare_mcache_programming(dc, context);
- n = resource_get_dpp_pipes_for_stream(scratch->stream, &context->res_ctx,
- dpp_pipes);
- for (i = 0; i < n; i++)
- dpp_pipes[i]->plane_res.scl_data.lb_params.alpha_en =
- dpp_pipes[i]->plane_state->per_pixel_alpha;
+ core2_update_prepare(dc, context, scratch->stream);
if (core2_build_and_run(dc, DCN_DECL_SEAMLESS_UPDATE, context,
scratch->stream) != DC_OK) {
--
2.43.0
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [PATCH 29/33] drm/amd/display: Give the DC2 builders State pipe facts
2026-11-16 21:50 [PATCH 00/33] DC Patches November 23, 2026 James Lin
` (27 preceding siblings ...)
2026-11-16 21:51 ` [PATCH 28/33] drm/amd/display: Change the ODM and MPC layout in DC2 update James Lin
@ 2026-11-16 21:51 ` James Lin
2026-11-16 21:51 ` [PATCH 30/33] drm/amd/display: Add RGBA8888 surface pixel format support James Lin
` (3 subsequent siblings)
32 siblings, 0 replies; 34+ messages in thread
From: James Lin @ 2026-11-16 21:51 UTC (permalink / raw)
To: amd-gfx
Cc: Harry Wentland, Leo Li, Aurabindo Pillai, Roman Li, Wayne Lin,
Tom Chung, Fangzhi Zuo, Dan Wheeler, Ray Wu, Ivan Lipski,
Alex Hung, James Lin, Chenyu Chen, Tony Cheng, James Lin
From: Tony Cheng <tony.cheng@amd.com>
[Why]
The dcn401 DC2 builders compare streams and pipe blocks by pointer,
which is not a reliable identity between two states.
[How]
Add dc_state_compute_update_flags(). It records the facts of each pipe
in the current and the new state. The builder finds a kept stream by
stream_id and its pipe blocks by inst, and derives the deltas. The
stream update steps skip when the kept stream did not change. Name
the unfiltered trait match DC_TRAIT_MATCH_ANY.
Signed-off-by: Tony Cheng <tony.cheng@amd.com>
Signed-off-by: James Lin <pinglei.lin@amd.com>
---
.../amd/display/dc/bls_builder/bls_builder.h | 5 +
.../bls_builder/bls_builder_private_types.h | 40 +-
.../dc/bls_builder/dcn401_builder_internal.h | 14 +-
.../bls_builder/dcn401_non_seamless_builder.c | 26 +-
.../dc/bls_builder/dcn401_seamless_builder.c | 497 ++++++++++++------
.../gpu/drm/amd/display/dc/core/dc_state.c | 28 +
.../gpu/drm/amd/display/dc/core2/dc_core2.c | 23 +-
.../gpu/drm/amd/display/dc/dc_state_priv.h | 23 +
.../amd/display/dc/state_facts/state_facts.h | 3 +
9 files changed, 474 insertions(+), 185 deletions(-)
diff --git a/drivers/gpu/drm/amd/display/dc/bls_builder/bls_builder.h b/drivers/gpu/drm/amd/display/dc/bls_builder/bls_builder.h
index c9a4e59056ae..99d57e7c0789 100644
--- a/drivers/gpu/drm/amd/display/dc/bls_builder/bls_builder.h
+++ b/drivers/gpu/drm/amd/display/dc/bls_builder/bls_builder.h
@@ -6,6 +6,7 @@
#pragma once
#include "dc.h"
+#include "dc_state_priv.h"
#include "dmub_cmd.h"
#include "dmub/dmub_srv.h"
#include "hwss/hw_sequencer.h"
@@ -99,6 +100,8 @@ struct bls_builder_check_capability_params {
const struct dc_state *current_state;
const struct dc_state *new_state;
const struct dc_stream_state *stream;
+ /* The current -> new delta from dc_state_compute_update_flags. */
+ const struct dc_state_update_flags *update_flags;
};
struct bls_builder_declarative_params {
@@ -106,6 +109,8 @@ struct bls_builder_declarative_params {
const struct dc_state *current_state;
const struct dc_state *new_state;
const struct dc_stream_state *stream;
+ /* Pipe facts of both states, from dc_state_compute_update_flags. */
+ const struct dc_state_update_flags *update_flags;
struct bls_builder_output_targets *out_targets;
struct block_sequence head_sequence[DC2_BLS_MAX_STEPS];
unsigned int head_num_steps;
diff --git a/drivers/gpu/drm/amd/display/dc/bls_builder/bls_builder_private_types.h b/drivers/gpu/drm/amd/display/dc/bls_builder/bls_builder_private_types.h
index de73efe274c1..11e452b36e05 100644
--- a/drivers/gpu/drm/amd/display/dc/bls_builder/bls_builder_private_types.h
+++ b/drivers/gpu/drm/amd/display/dc/bls_builder/bls_builder_private_types.h
@@ -7,12 +7,31 @@
#include "hw_sequencer.h"
#include "dccg.h"
+#include "dc_state_priv.h"
/*
* Step tables for the declarative builders. A change here changes what
* a builder can express; a change to a builder's .c alone does not.
*/
+/*
+ * Conditions on pipe i that compare its facts in the current and the
+ * new state.
+ */
+struct dcn401_pipe_deltas {
+ /*
+ * Both pipes are enabled and show a plane of the same stream on the
+ * same HUBP, DPP and OPP.
+ */
+ bool hubp_dpp_already_enabled;
+ /* The DET size is the same. */
+ bool det_unchanged;
+ /* The current pipe has no plane. */
+ bool current_has_no_plane;
+ /* The stream of the new pipe has the same OPP heads in both states. */
+ bool odm_kept;
+};
+
/*
* One dcn401 commit step is one BLS entry. The union holds the
* arguments that differ between the times DC1 makes that call; the
@@ -109,29 +128,20 @@ struct dcn401_commit_step_meta {
struct {
/* The new state has a stream. */
bool new_state_has_stream;
+ /* The stream of the step is unchanged between the states. */
+ bool stream_unchanged;
/* dc->optimized_required is clear. */
bool optimized_not_required;
/* The plane has no address update, or skips the manual trigger. */
bool no_manual_trigger;
/* The OPP MPC tree has no plane yet. */
bool opp_tree_empty;
+ struct dcn401_pipe_deltas pipe_deltas;
/*
- * The pipe already showed the plane on this HUBP. The step is
- * part of enabling that block the first time, not of
- * reconfiguring it.
- */
- bool hubp_dpp_already_enabled;
- /* As hubp_dpp_already_enabled, and the DET size is the same. */
- bool det_unchanged;
- /*
- * The current pipe had no plane, or keeps its plane, HUBP, DPP
- * and OPP in the new state.
+ * Skip only when each delta named in pipe_deltas is true. Clear,
+ * skip when any of them is true.
*/
- bool no_plane_removed;
- /* As hubp_dpp_already_enabled, and each ODM slice keeps its OPP. */
- bool odm_kept;
- /* Each ODM slice of the stream keeps its OPP. */
- bool same_opp_heads;
+ bool pipe_deltas_all;
/*
* Neither the plane scaling, the plane position nor the
* stream scaling changed. A full update sets every plane bit,
diff --git a/drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_builder_internal.h b/drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_builder_internal.h
index e9f190176485..4af30178b42b 100644
--- a/drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_builder_internal.h
+++ b/drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_builder_internal.h
@@ -44,6 +44,15 @@ void dcn401_commit_check_failed(const struct dc *dc, const char *msg);
} \
} while (0)
+/* As CHECK_UPDATE, for a helper that reads the update flags. */
+#define CHECK_UPDATE_FLAGS(name, msg) \
+ do { \
+ if (!check_##name(update_flags, current_state, new_state, i)) { \
+ dcn401_commit_check_failed(dc, msg); \
+ return BLS_BUILD_ERROR_UNSUPPORTED_STATE_UPDATE; \
+ } \
+ } while (0)
+
/* Each check_<name> stream helper takes the state and a stream index. */
#define CHECK_STREAM_CONDITION(name, msg) \
do { \
@@ -87,8 +96,6 @@ bool dcn401_stream_unchanged(const struct dc_state *current_state,
* The pipe shows a plane on the same HUBP, DPP and OPP. The plane may be a
* new dc_plane_state; the update reprograms its contents.
*/
-bool dcn401_pipe_kept(const struct pipe_ctx *current_pipe,
- const struct pipe_ctx *new_pipe);
/*
* What the seamless update needs of stream i of new_state, apart from the
* other streams.
@@ -115,6 +122,9 @@ struct dcn401_commit_step_args {
struct dc_state *new_state;
const struct dc_stream_state *stream;
struct pipe_ctx *pipe;
+ const struct dc_state_update_flags *update_flags;
+ /* stream is in both states on the same pipes, planes and blocks. */
+ bool stream_unchanged;
};
/*
diff --git a/drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_non_seamless_builder.c b/drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_non_seamless_builder.c
index f24480e949d6..2ce37c3aa982 100644
--- a/drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_non_seamless_builder.c
+++ b/drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_non_seamless_builder.c
@@ -45,7 +45,7 @@ static bool check_current_planes(const struct dc *dc,
return planes && planes ==
facts.global.blend_tree[i].dpp_pipe_count &&
dc_state_facts_all_pipe(&facts, (uint8_t)i,
- DC_TRAIT_MATCH(0, 0),
+ DC_TRAIT_MATCH_ANY,
DC_TRAIT_MATCH(DC_PIPE_TRAIT_PLANE, 0));
}
@@ -57,7 +57,7 @@ static bool check_plane_blocks(const struct dc *dc,
(void)dc;
dc_state_facts_derive(state, &facts);
return dc_state_facts_all_pipe(&facts, (uint8_t)i,
- DC_TRAIT_MATCH(0, 0),
+ DC_TRAIT_MATCH_ANY,
DC_TRAIT_MATCH(DC_PIPE_TRAIT_PLANE_RESOURCES, 0));
}
@@ -168,11 +168,12 @@ static bool check_link_not_active(const struct dc *dc,
static enum bls_builder_result dcn401_check_non_seamless_commit_support(
const struct dc *dc, const struct dc_state *current_state,
- const struct dc_state *new_state)
+ const struct dc_state *new_state,
+ const struct dc_state_update_flags *update_flags)
{
enum bls_builder_result result;
- if (!dc || !current_state || !new_state)
+ if (!dc || !current_state || !new_state || !update_flags)
return BLS_BUILD_ERROR_UNSUPPORTED_STATE_UPDATE;
result = dcn401_check_dc_support(dc);
@@ -457,7 +458,8 @@ static enum bls_builder_result dcn401_build_non_seamless_commit(
if (!params)
return BLS_BUILD_ERROR_UNSUPPORTED_STATE_UPDATE;
result = dcn401_check_non_seamless_commit_support(params->dc,
- params->current_state, params->new_state);
+ params->current_state, params->new_state,
+ params->update_flags);
if (result != BLS_BUILD_SUCCESS)
return result;
@@ -465,13 +467,16 @@ static enum bls_builder_result dcn401_build_non_seamless_commit(
DCN401_ADD_SUB_SEQUENCES(&head, &state_args, bls_head);
for (i = 0; i < state_args.new_state->stream_count; i++) {
state_args.stream = state_args.new_state->streams[i];
- if (dcn401_stream_kept(params->dc, params->current_state,
- params->new_state, state_args.stream) &&
- !dcn401_stream_unchanged(params->current_state,
+ if (!dcn401_stream_kept(params->dc, params->current_state,
params->new_state, state_args.stream))
- dcn401_add_stream_update(&head, &state_args);
+ continue;
+ state_args.stream_unchanged = dcn401_stream_unchanged(
+ params->current_state, params->new_state,
+ state_args.stream);
+ dcn401_add_stream_update(&head, &state_args);
}
state_args.stream = NULL;
+ state_args.stream_unchanged = false;
DCN401_ADD_SUB_SEQUENCES(&head, &state_args, bls_postamble);
return BLS_BUILD_SUCCESS;
@@ -481,7 +486,8 @@ static bool dcn401_non_seamless_commit_check_capability(
const struct bls_builder_check_capability_params *params)
{
return params && dcn401_check_non_seamless_commit_support(params->dc,
- params->current_state, params->new_state) ==
+ params->current_state, params->new_state,
+ params->update_flags) ==
BLS_BUILD_SUCCESS;
}
diff --git a/drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_seamless_builder.c b/drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_seamless_builder.c
index 5218ecfbc385..a2c8d7964208 100644
--- a/drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_seamless_builder.c
+++ b/drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_seamless_builder.c
@@ -252,7 +252,8 @@ const struct pipe_ctx *dcn401_otg_master(const struct dc_state *state,
for (i = 0; i < MAX_PIPES; i++) {
const struct pipe_ctx *pipe = &state->res_ctx.pipe_ctx[i];
- if (!stream || pipe->stream != stream ||
+ if (!stream || !pipe->stream ||
+ pipe->stream->stream_id != stream->stream_id ||
pipe->top_pipe || pipe->prev_odm_pipe)
continue;
if (otg_master)
@@ -267,12 +268,38 @@ int dcn401_stream_index(const struct dc_state *state,
{
int i;
+ if (!stream)
+ return -1;
for (i = 0; i < state->stream_count; i++)
- if (state->streams[i] == stream)
+ if (state->streams[i]->stream_id == stream->stream_id)
return i;
return -1;
}
+#define DCN401_SAME_INST(a, b) \
+ ((!(a) && !(b)) || ((a) && (b) && (a)->inst == (b)->inst))
+
+static bool dcn401_pipe_on_stream(const struct pipe_ctx *pipe,
+ const struct dc_stream_state *stream)
+{
+ return pipe->stream && pipe->stream->stream_id == stream->stream_id;
+}
+
+/* The plane is compared as an object: planes have no DC-assigned id yet. */
+static bool dcn401_pipe_layout_unchanged(const struct pipe_ctx *cur,
+ const struct pipe_ctx *new)
+{
+ return cur->plane_state == new->plane_state &&
+ DCN401_SAME_INST(cur->plane_res.hubp, new->plane_res.hubp) &&
+ DCN401_SAME_INST(cur->plane_res.dpp, new->plane_res.dpp) &&
+ DCN401_SAME_INST(cur->stream_res.tg, new->stream_res.tg) &&
+ DCN401_SAME_INST(cur->stream_res.opp, new->stream_res.opp) &&
+ !cur->top_pipe == !new->top_pipe &&
+ !cur->bottom_pipe == !new->bottom_pipe &&
+ !cur->prev_odm_pipe == !new->prev_odm_pipe &&
+ !cur->next_odm_pipe == !new->next_odm_pipe;
+}
+
bool dcn401_stream_unchanged(const struct dc_state *current_state,
const struct dc_state *new_state,
const struct dc_stream_state *stream)
@@ -286,19 +313,11 @@ bool dcn401_stream_unchanged(const struct dc_state *current_state,
for (i = 0; i < MAX_PIPES; i++) {
cur = ¤t_state->res_ctx.pipe_ctx[i];
new = &new_state->res_ctx.pipe_ctx[i];
- if ((cur->stream == stream) != (new->stream == stream))
+ if (dcn401_pipe_on_stream(cur, stream) !=
+ dcn401_pipe_on_stream(new, stream))
return false;
- if (new->stream != stream)
- continue;
- if (cur->plane_state != new->plane_state ||
- cur->plane_res.hubp != new->plane_res.hubp ||
- cur->plane_res.dpp != new->plane_res.dpp ||
- cur->stream_res.tg != new->stream_res.tg ||
- cur->stream_res.opp != new->stream_res.opp ||
- !cur->top_pipe != !new->top_pipe ||
- !cur->bottom_pipe != !new->bottom_pipe ||
- !cur->prev_odm_pipe != !new->prev_odm_pipe ||
- !cur->next_odm_pipe != !new->next_odm_pipe)
+ if (dcn401_pipe_on_stream(new, stream) &&
+ !dcn401_pipe_layout_unchanged(cur, new))
return false;
}
return true;
@@ -483,33 +502,51 @@ enum bls_builder_result dcn401_check_stream_support(const struct dc *dc,
* The update keeps every stream. A stream other than the updated one keeps
* its pipes, planes and blocks.
*/
-static bool check_streams_kept(const struct dc *dc,
+static bool check_streams_kept(
+ const struct dc_state_update_flags *update_flags,
const struct dc_state *current_state,
const struct dc_state *new_state, unsigned int i)
{
int j;
- (void)dc;
+ (void)update_flags;
if (current_state->stream_count != new_state->stream_count)
return false;
for (j = 0; j < new_state->stream_count; j++)
if (dcn401_stream_index(current_state,
new_state->streams[j]) < 0 ||
- (j != i && !dcn401_stream_unchanged(current_state,
+ (j != (int)i && !dcn401_stream_unchanged(current_state,
new_state, new_state->streams[j])))
return false;
return true;
}
-bool dcn401_pipe_kept(const struct pipe_ctx *current_pipe,
- const struct pipe_ctx *new_pipe)
+static bool pipe_has_plane(const struct pipe_ctx *pipe)
+{
+ return pipe->plane_state != NULL;
+}
+
+static bool pipe_assigned_to_stream(const struct pipe_ctx *pipe,
+ const struct dc_stream_state *stream)
+{
+ return pipe->stream && stream &&
+ pipe->stream->stream_id == stream->stream_id;
+}
+
+static bool pipe_plane_resources_identical(const struct pipe_ctx *cur,
+ const struct pipe_ctx *new)
+{
+ return cur->plane_res.hubp && new->plane_res.hubp &&
+ cur->plane_res.dpp && new->plane_res.dpp &&
+ cur->plane_res.hubp->inst == new->plane_res.hubp->inst &&
+ cur->plane_res.dpp->inst == new->plane_res.dpp->inst;
+}
+
+static bool pipe_opp_identical(const struct pipe_ctx *cur,
+ const struct pipe_ctx *new)
{
- return current_pipe->plane_state &&
- current_pipe->stream == new_pipe->stream &&
- new_pipe->plane_state &&
- current_pipe->plane_res.hubp == new_pipe->plane_res.hubp &&
- current_pipe->plane_res.dpp == new_pipe->plane_res.dpp &&
- current_pipe->stream_res.opp == new_pipe->stream_res.opp;
+ return cur->stream_res.opp && new->stream_res.opp &&
+ cur->stream_res.opp->inst == new->stream_res.opp->inst;
}
/*
@@ -534,9 +571,10 @@ static bool check_pipes_kept_or_free(const struct dc *dc,
new = &new_state->res_ctx.pipe_ctx[j];
if (new->stream != new_state->streams[i] || !cur->stream)
continue;
- if (cur->stream != new->stream ||
- cur->stream_res.opp != new->stream_res.opp ||
- (cur->plane_state && !dcn401_pipe_kept(cur, new)))
+ if (!pipe_assigned_to_stream(new, cur->stream) ||
+ !pipe_opp_identical(cur, new) ||
+ (pipe_has_plane(cur) && (!pipe_has_plane(new) ||
+ !pipe_plane_resources_identical(cur, new))))
return false;
}
dc_state_facts_derive(new_state, &facts);
@@ -553,21 +591,8 @@ static bool check_same_otg(const struct dc *dc,
new_state->streams[i]);
(void)dc;
- return cur && new && cur->stream_res.tg == new->stream_res.tg;
-}
-
-/* stream has the same OPP for each ODM slice in both states. */
-static bool dcn401_same_opp_heads(const struct dc_state *current_state,
- const struct dc_state *new_state,
- const struct dc_stream_state *stream)
-{
- const struct pipe_ctx *cur = dcn401_otg_master(current_state, stream);
- const struct pipe_ctx *new = dcn401_otg_master(new_state, stream);
-
- for (; cur && new; cur = cur->next_odm_pipe, new = new->next_odm_pipe)
- if (cur->stream_res.opp != new->stream_res.opp)
- return false;
- return !cur && !new;
+ return cur && new && cur->stream_res.tg && new->stream_res.tg &&
+ cur->stream_res.tg->inst == new->stream_res.tg->inst;
}
static bool check_new_plane_blocks(const struct dc *dc,
@@ -581,7 +606,7 @@ static bool check_new_plane_blocks(const struct dc *dc,
dc_state_facts_derive(new_state, &facts);
return facts.pipe.count &&
dc_state_facts_all_pipe(&facts, (uint8_t)i,
- DC_TRAIT_MATCH(0, 0),
+ DC_TRAIT_MATCH_ANY,
DC_TRAIT_MATCH(DC_PIPE_TRAIT_PLANE |
DC_PIPE_TRAIT_PLANE_RESOURCES, 0));
}
@@ -757,7 +782,7 @@ static bool check_no_dcc(const struct dc *dc,
(void)dc;
dc_state_facts_derive(new_state, &facts);
return facts.pipe.count &&
- dc_state_facts_all_pipe(&facts, (uint8_t)i, DC_TRAIT_MATCH(0, 0),
+ dc_state_facts_all_pipe(&facts, (uint8_t)i, DC_TRAIT_MATCH_ANY,
DC_TRAIT_MATCH(DC_PIPE_TRAIT_PLANE, 0)) &&
!dc_state_facts_any_plane(&facts, (uint8_t)i,
DC_TRAIT_MATCH(DC_PLANE_TRAIT_DCC, 0));
@@ -774,9 +799,9 @@ static bool check_graphics_address(const struct dc *dc,
(void)dc;
dc_state_facts_derive(new_state, &facts);
return facts.pipe.count &&
- dc_state_facts_all_pipe(&facts, (uint8_t)i, DC_TRAIT_MATCH(0, 0),
+ dc_state_facts_all_pipe(&facts, (uint8_t)i, DC_TRAIT_MATCH_ANY,
DC_TRAIT_MATCH(DC_PIPE_TRAIT_PLANE, 0)) &&
- dc_state_facts_all_plane(&facts, (uint8_t)i, DC_TRAIT_MATCH(0, 0),
+ dc_state_facts_all_plane(&facts, (uint8_t)i, DC_TRAIT_MATCH_ANY,
DC_TRAIT_MATCH(DC_PLANE_TRAIT_GRAPHICS_ADDRESS, 0));
}
@@ -791,7 +816,7 @@ static bool check_no_immediate_flip(const struct dc *dc,
(void)dc;
dc_state_facts_derive(new_state, &facts);
return facts.pipe.count &&
- dc_state_facts_all_pipe(&facts, (uint8_t)i, DC_TRAIT_MATCH(0, 0),
+ dc_state_facts_all_pipe(&facts, (uint8_t)i, DC_TRAIT_MATCH_ANY,
DC_TRAIT_MATCH(DC_PIPE_TRAIT_PLANE, 0)) &&
!dc_state_facts_any_plane(&facts, (uint8_t)i,
DC_TRAIT_MATCH(DC_PLANE_TRAIT_FLIP_IMMEDIATE, 0));
@@ -811,7 +836,7 @@ static bool check_no_degamma_curve(const struct dc *dc,
(void)dc;
dc_state_facts_derive(new_state, &facts);
return facts.pipe.count &&
- dc_state_facts_all_pipe(&facts, (uint8_t)i, DC_TRAIT_MATCH(0, 0),
+ dc_state_facts_all_pipe(&facts, (uint8_t)i, DC_TRAIT_MATCH_ANY,
DC_TRAIT_MATCH(DC_PIPE_TRAIT_PLANE, 0)) &&
!dc_state_facts_any_plane(&facts, (uint8_t)i,
DC_TRAIT_MATCH(DC_PLANE_TRAIT_DEGAMMA_CURVE, 0));
@@ -829,7 +854,7 @@ static bool check_no_mcm_luts(const struct dc *dc,
(void)dc;
dc_state_facts_derive(new_state, &facts);
return facts.pipe.count &&
- dc_state_facts_all_pipe(&facts, (uint8_t)i, DC_TRAIT_MATCH(0, 0),
+ dc_state_facts_all_pipe(&facts, (uint8_t)i, DC_TRAIT_MATCH_ANY,
DC_TRAIT_MATCH(DC_PIPE_TRAIT_PLANE, 0)) &&
!dc_state_facts_any_plane(&facts, (uint8_t)i,
DC_TRAIT_MATCH(DC_PLANE_TRAIT_MCM_LUTS, 0));
@@ -918,12 +943,13 @@ static const struct dc_stream_state *dcn401_updated_stream(
static enum bls_builder_result dcn401_check_seamless_update_support(
const struct dc *dc, const struct dc_state *current_state,
const struct dc_state *new_state,
+ const struct dc_state_update_flags *update_flags,
const struct dc_stream_state *stream)
{
enum bls_builder_result result;
int i;
- if (!dc || !current_state || !new_state)
+ if (!dc || !current_state || !new_state || !update_flags)
return BLS_BUILD_ERROR_UNSUPPORTED_STATE_UPDATE;
i = dcn401_stream_index(new_state,
dcn401_updated_stream(new_state, stream));
@@ -941,7 +967,7 @@ static enum bls_builder_result dcn401_check_seamless_update_support(
if (result != BLS_BUILD_SUCCESS)
return result;
- CHECK_UPDATE(streams_kept,
+ CHECK_UPDATE_FLAGS(streams_kept,
"a stream is not kept, or another stream changes");
return dcn401_check_stream_update(dc, current_state, new_state, i);
}
@@ -1048,9 +1074,12 @@ static const struct dcn401_commit_step global_preamble[] = {
* which a full update runs before it takes the pipe lock.
*/
static const struct dcn401_commit_step pending[] = {
- { .func = TG_WAIT_FOR_ALL_PENDING_UPDATES },
- { .func = TG_WAIT_ODM_DOUBLEBUFFER_PENDING_CLEAR },
- { .func = OPP_WAIT_FOR_BLANK_COMPLETE },
+ { .func = TG_WAIT_FOR_ALL_PENDING_UPDATES,
+ .meta.skip_if.stream_unchanged = true },
+ { .func = TG_WAIT_ODM_DOUBLEBUFFER_PENDING_CLEAR,
+ .meta.skip_if.stream_unchanged = true },
+ { .func = OPP_WAIT_FOR_BLANK_COMPLETE,
+ .meta.skip_if.stream_unchanged = true },
};
/*
@@ -1063,18 +1092,23 @@ static const struct dcn401_commit_step pending[] = {
* the first HUBP.
*/
static const struct dcn401_commit_step lock[] = {
- { .func = TG_LOCK, .meta.tg_lock.lock = true },
+ { .func = TG_LOCK,
+ .meta.skip_if.stream_unchanged = true, .meta.tg_lock.lock = true },
};
static const struct dcn401_commit_step dpp_lock[] = {
- { .func = HUBP_PROGRAM_TRIPLEBUFFER },
- { .func = HUBP_PROGRAM_TRIPLEBUFFER },
+ { .func = HUBP_PROGRAM_TRIPLEBUFFER,
+ .meta.skip_if.stream_unchanged = true },
+ { .func = HUBP_PROGRAM_TRIPLEBUFFER,
+ .meta.skip_if.stream_unchanged = true },
};
static const struct dcn401_commit_step first_hubp[] = {
{ .func = HUBBUB_FORCE_PSTATE_CHANGE_CONTROL,
+ .meta.skip_if.stream_unchanged = true,
.meta.hubbub_force_pstate_change_control.enable = true },
- { .func = DC_UDELAY },
+ { .func = DC_UDELAY,
+ .meta.skip_if.stream_unchanged = true },
};
/*
@@ -1083,28 +1117,42 @@ static const struct dcn401_commit_step first_hubp[] = {
*/
static const struct dcn401_commit_step opp_unblank[] = {
{ .func = OPP_SET_DISP_PATTERN_GENERATOR,
+ .meta.skip_if.stream_unchanged = true,
.meta.opp_set_disp_pattern_generator.unblank = true,
- .meta.skip_if.hubp_dpp_already_enabled = true },
+ .meta.skip_if.pipe_deltas.hubp_dpp_already_enabled = true },
};
static const struct dcn401_commit_step global_sync[] = {
{ .func = TG_PROGRAM_GLOBAL_SYNC,
- .meta.skip_if.hubp_dpp_already_enabled = true },
+ .meta.skip_if.stream_unchanged = true,
+ .meta.skip_if.pipe_deltas.hubp_dpp_already_enabled = true },
{ .func = TG_WAIT_FOR_STATE,
- .meta.skip_if.hubp_dpp_already_enabled = true },
+ .meta.skip_if.stream_unchanged = true,
+ .meta.skip_if.pipe_deltas.hubp_dpp_already_enabled = true },
{ .func = TG_SET_VTG_PARAMS,
- .meta.skip_if.hubp_dpp_already_enabled = true },
+ .meta.skip_if.stream_unchanged = true,
+ .meta.skip_if.pipe_deltas.hubp_dpp_already_enabled = true },
{ .func = TG_SETUP_VERTICAL_INTERRUPT2,
- .meta.skip_if.hubp_dpp_already_enabled = true },
+ .meta.skip_if.stream_unchanged = true,
+ .meta.skip_if.pipe_deltas.hubp_dpp_already_enabled = true },
{ .func = OPTC_SET_ODM_COMBINE,
- .meta.skip_if.odm_kept = true },
+ .meta.skip_if.stream_unchanged = true,
+ .meta.skip_if.pipe_deltas.hubp_dpp_already_enabled = true,
+ .meta.skip_if.pipe_deltas.odm_kept = true,
+ .meta.skip_if.pipe_deltas_all = true },
};
static const struct dcn401_commit_step opp_odm[] = {
{ .func = OPP_PIPE_CLOCK_CONTROL,
- .meta.skip_if.odm_kept = true },
+ .meta.skip_if.stream_unchanged = true,
+ .meta.skip_if.pipe_deltas.hubp_dpp_already_enabled = true,
+ .meta.skip_if.pipe_deltas.odm_kept = true,
+ .meta.skip_if.pipe_deltas_all = true },
{ .func = OPP_PROGRAM_LEFT_EDGE_EXTRA_PIXEL,
- .meta.skip_if.odm_kept = true },
+ .meta.skip_if.stream_unchanged = true,
+ .meta.skip_if.pipe_deltas.hubp_dpp_already_enabled = true,
+ .meta.skip_if.pipe_deltas.odm_kept = true,
+ .meta.skip_if.pipe_deltas_all = true },
};
/*
@@ -1112,130 +1160,204 @@ static const struct dcn401_commit_step opp_odm[] = {
* MPCC and returns its DET segments, as DC1 disconnects a disabled pipe.
*/
const struct dcn401_commit_step dcn401_disconnect[DCN401_DISCONNECT_STEPS] = {
- { .func = HUBP_PROGRAM_DET_SEGMENTS, .meta.skip_if.no_plane_removed = true },
- { .func = MPC_REMOVE_MPCC, .meta.skip_if.no_plane_removed = true },
+ { .func = HUBP_PROGRAM_DET_SEGMENTS,
+ .meta.skip_if.stream_unchanged = true, .meta.skip_if.pipe_deltas.current_has_no_plane = true,
+ .meta.skip_if.pipe_deltas.hubp_dpp_already_enabled = true },
+ { .func = MPC_REMOVE_MPCC,
+ .meta.skip_if.stream_unchanged = true, .meta.skip_if.pipe_deltas.current_has_no_plane = true,
+ .meta.skip_if.pipe_deltas.hubp_dpp_already_enabled = true },
};
/* After the unlock, disable_plane on each removed pipe. */
const struct dcn401_commit_step dcn401_power_down[DCN401_POWER_DOWN_STEPS] = {
- { .func = MPC_ASSERT_IDLE_MPCC, .meta.skip_if.no_plane_removed = true },
- { .func = HUBP_SET_BLANK, .meta.skip_if.no_plane_removed = true },
- { .func = HUBP_UPDATE_MALL_SEL, .meta.skip_if.no_plane_removed = true },
- { .func = HUBP_SET_FLIP_CONTROL_GSL, .meta.skip_if.no_plane_removed = true },
- { .func = HUBP_CLK_CNTL, .meta.skip_if.no_plane_removed = true },
- { .func = DPP_DPPCLK_CONTROL, .meta.skip_if.no_plane_removed = true },
- { .func = DC_IP_REQUEST_STATUS, .meta.skip_if.no_ip_request = true,
- .meta.skip_if.no_plane_removed = true },
- { .func = DC_IP_REQUEST_CNTL, .meta.dc_ip_request_cntl.enable = true,
+ { .func = MPC_ASSERT_IDLE_MPCC,
+ .meta.skip_if.stream_unchanged = true, .meta.skip_if.pipe_deltas.current_has_no_plane = true,
+ .meta.skip_if.pipe_deltas.hubp_dpp_already_enabled = true },
+ { .func = HUBP_SET_BLANK,
+ .meta.skip_if.stream_unchanged = true, .meta.skip_if.pipe_deltas.current_has_no_plane = true,
+ .meta.skip_if.pipe_deltas.hubp_dpp_already_enabled = true },
+ { .func = HUBP_UPDATE_MALL_SEL,
+ .meta.skip_if.stream_unchanged = true, .meta.skip_if.pipe_deltas.current_has_no_plane = true,
+ .meta.skip_if.pipe_deltas.hubp_dpp_already_enabled = true },
+ { .func = HUBP_SET_FLIP_CONTROL_GSL,
+ .meta.skip_if.stream_unchanged = true, .meta.skip_if.pipe_deltas.current_has_no_plane = true,
+ .meta.skip_if.pipe_deltas.hubp_dpp_already_enabled = true },
+ { .func = HUBP_CLK_CNTL,
+ .meta.skip_if.stream_unchanged = true, .meta.skip_if.pipe_deltas.current_has_no_plane = true,
+ .meta.skip_if.pipe_deltas.hubp_dpp_already_enabled = true },
+ { .func = DPP_DPPCLK_CONTROL,
+ .meta.skip_if.stream_unchanged = true, .meta.skip_if.pipe_deltas.current_has_no_plane = true,
+ .meta.skip_if.pipe_deltas.hubp_dpp_already_enabled = true },
+ { .func = DC_IP_REQUEST_STATUS,
+ .meta.skip_if.stream_unchanged = true, .meta.skip_if.no_ip_request = true,
+ .meta.skip_if.pipe_deltas.current_has_no_plane = true,
+ .meta.skip_if.pipe_deltas.hubp_dpp_already_enabled = true },
+ { .func = DC_IP_REQUEST_CNTL,
+ .meta.skip_if.stream_unchanged = true, .meta.dc_ip_request_cntl.enable = true,
.meta.skip_if.no_ip_request = true,
- .meta.skip_if.no_plane_removed = true },
- { .func = HUBP_PG_CONTROL, .meta.skip_if.no_plane_removed = true },
- { .func = HUBP_RESET, .meta.skip_if.no_plane_removed = true },
- { .func = DPP_RESET, .meta.skip_if.no_plane_removed = true },
- { .func = DC_IP_REQUEST_CNTL, .meta.dc_ip_request_cntl.enable = false,
+ .meta.skip_if.pipe_deltas.current_has_no_plane = true,
+ .meta.skip_if.pipe_deltas.hubp_dpp_already_enabled = true },
+ { .func = HUBP_PG_CONTROL,
+ .meta.skip_if.stream_unchanged = true, .meta.skip_if.pipe_deltas.current_has_no_plane = true,
+ .meta.skip_if.pipe_deltas.hubp_dpp_already_enabled = true },
+ { .func = HUBP_RESET,
+ .meta.skip_if.stream_unchanged = true, .meta.skip_if.pipe_deltas.current_has_no_plane = true,
+ .meta.skip_if.pipe_deltas.hubp_dpp_already_enabled = true },
+ { .func = DPP_RESET,
+ .meta.skip_if.stream_unchanged = true, .meta.skip_if.pipe_deltas.current_has_no_plane = true,
+ .meta.skip_if.pipe_deltas.hubp_dpp_already_enabled = true },
+ { .func = DC_IP_REQUEST_CNTL,
+ .meta.skip_if.stream_unchanged = true, .meta.dc_ip_request_cntl.enable = false,
.meta.skip_if.no_ip_request = true,
- .meta.skip_if.no_plane_removed = true },
+ .meta.skip_if.pipe_deltas.current_has_no_plane = true,
+ .meta.skip_if.pipe_deltas.hubp_dpp_already_enabled = true },
};
/* enable_plane, then the watermark propagate and the DET segments. */
static const struct dcn401_commit_step enable_plane[] = {
{ .func = DC_IP_REQUEST_STATUS,
- .meta.skip_if.hubp_dpp_already_enabled = true,
+ .meta.skip_if.stream_unchanged = true,
+ .meta.skip_if.pipe_deltas.hubp_dpp_already_enabled = true,
.meta.skip_if.no_ip_request = true },
- { .func = DC_IP_REQUEST_CNTL, .meta.dc_ip_request_cntl.enable = true,
- .meta.skip_if.hubp_dpp_already_enabled = true,
+ { .func = DC_IP_REQUEST_CNTL,
+ .meta.skip_if.stream_unchanged = true, .meta.dc_ip_request_cntl.enable = true,
+ .meta.skip_if.pipe_deltas.hubp_dpp_already_enabled = true,
.meta.skip_if.no_ip_request = true },
- { .func = HUBP_PG_CONTROL, .meta.hubp_pg_control.power_on = true,
- .meta.skip_if.hubp_dpp_already_enabled = true },
- { .func = DC_IP_REQUEST_CNTL, .meta.dc_ip_request_cntl.enable = false,
- .meta.skip_if.hubp_dpp_already_enabled = true,
+ { .func = HUBP_PG_CONTROL,
+ .meta.skip_if.stream_unchanged = true, .meta.hubp_pg_control.power_on = true,
+ .meta.skip_if.pipe_deltas.hubp_dpp_already_enabled = true },
+ { .func = DC_IP_REQUEST_CNTL,
+ .meta.skip_if.stream_unchanged = true, .meta.dc_ip_request_cntl.enable = false,
+ .meta.skip_if.pipe_deltas.hubp_dpp_already_enabled = true,
.meta.skip_if.no_ip_request = true },
- { .func = HUBP_CLK_CNTL, .meta.hubp_clk_cntl.enable = true,
- .meta.skip_if.hubp_dpp_already_enabled = true },
+ { .func = HUBP_CLK_CNTL,
+ .meta.skip_if.stream_unchanged = true, .meta.hubp_clk_cntl.enable = true,
+ .meta.skip_if.pipe_deltas.hubp_dpp_already_enabled = true },
{ .func = HUBP_INIT,
- .meta.skip_if.hubp_dpp_already_enabled = true },
+ .meta.skip_if.stream_unchanged = true,
+ .meta.skip_if.pipe_deltas.hubp_dpp_already_enabled = true },
{ .func = OPP_PIPE_CLOCK_CONTROL,
- .meta.skip_if.hubp_dpp_already_enabled = true },
+ .meta.skip_if.stream_unchanged = true,
+ .meta.skip_if.pipe_deltas.hubp_dpp_already_enabled = true },
{ .func = HUBBUB_FORCE_WM_PROPAGATE_TO_PIPES,
- .meta.skip_if.hubp_dpp_already_enabled = true },
+ .meta.skip_if.stream_unchanged = true,
+ .meta.skip_if.pipe_deltas.hubp_dpp_already_enabled = true },
{ .func = HUBP_PROGRAM_DET_SEGMENTS,
+ .meta.skip_if.stream_unchanged = true,
.meta.hubp_program_det_segments.allocate = true,
- .meta.skip_if.det_unchanged = true },
+ .meta.skip_if.pipe_deltas.hubp_dpp_already_enabled = true,
+ .meta.skip_if.pipe_deltas.det_unchanged = true,
+ .meta.skip_if.pipe_deltas_all = true },
/*
* update_dchubp_dpp. First enable runs the whole table. A reconfigure
* skips the steps that only bring the HUBP/DPP up, and programs the
* scaler and viewport only when scaling or position changed. The MPCC is
* removed when the OPP tree already holds one.
*/
- { .func = DPP_DPPCLK_CONTROL, .meta.dpp_dppclk_control.enable = true,
- .meta.skip_if.hubp_dpp_already_enabled = true },
+ { .func = DPP_DPPCLK_CONTROL,
+ .meta.skip_if.stream_unchanged = true, .meta.dpp_dppclk_control.enable = true,
+ .meta.skip_if.pipe_deltas.hubp_dpp_already_enabled = true },
{ .func = DCCG_UPDATE_DPP_DTO,
- .meta.skip_if.hubp_dpp_already_enabled = true },
+ .meta.skip_if.stream_unchanged = true,
+ .meta.skip_if.pipe_deltas.hubp_dpp_already_enabled = true },
{ .func = HUBP_VTG_SEL,
- .meta.skip_if.hubp_dpp_already_enabled = true },
+ .meta.skip_if.stream_unchanged = true,
+ .meta.skip_if.pipe_deltas.hubp_dpp_already_enabled = true },
{ .func = HUBP_SETUP2,
- .meta.skip_if.hubp_dpp_already_enabled = true },
+ .meta.skip_if.stream_unchanged = true,
+ .meta.skip_if.pipe_deltas.hubp_dpp_already_enabled = true },
{ .func = HUBP_SET_UNBOUNDED_REQUESTING,
- .meta.skip_if.hubp_dpp_already_enabled = true },
+ .meta.skip_if.stream_unchanged = true,
+ .meta.skip_if.pipe_deltas.hubp_dpp_already_enabled = true },
{ .func = HUBP_SETUP_INTERDEPENDENT2,
- .meta.skip_if.hubp_dpp_already_enabled = true },
- { .func = DPP_SETUP_DPP },
- { .func = DPP_SET_CURSOR_MATRIX },
- { .func = DPP_PROGRAM_BIAS_AND_SCALE },
+ .meta.skip_if.stream_unchanged = true,
+ .meta.skip_if.pipe_deltas.hubp_dpp_already_enabled = true },
+ { .func = DPP_SETUP_DPP,
+ .meta.skip_if.stream_unchanged = true },
+ { .func = DPP_SET_CURSOR_MATRIX,
+ .meta.skip_if.stream_unchanged = true },
+ { .func = DPP_PROGRAM_BIAS_AND_SCALE,
+ .meta.skip_if.stream_unchanged = true },
{ .func = MPC_REMOVE_MPCC,
+ .meta.skip_if.stream_unchanged = true,
.meta.skip_if.opp_tree_empty = true },
/* insert_plane programs the blending; no update_blending follows. */
- { .func = MPC_INSERT_PLANE },
- { .func = MPC_UPDATE_VISUAL_CONFIRM },
+ { .func = MPC_INSERT_PLANE,
+ .meta.skip_if.stream_unchanged = true },
+ { .func = MPC_UPDATE_VISUAL_CONFIRM,
+ .meta.skip_if.stream_unchanged = true },
{ .func = DPP_SET_SCALER,
+ .meta.skip_if.stream_unchanged = true,
.meta.skip_if.scaling_unchanged = true },
{ .func = HUBP_MEM_PROGRAM_VIEWPORT,
+ .meta.skip_if.stream_unchanged = true,
.meta.skip_if.scaling_unchanged = true },
- { .func = HUBP_PROGRAM_MCACHE_ID },
+ { .func = HUBP_PROGRAM_MCACHE_ID,
+ .meta.skip_if.stream_unchanged = true },
{ .func = MPC_SET_GAMUT_REMAP_BYPASS,
+ .meta.skip_if.stream_unchanged = true,
.meta.mpc_set_gamut_remap_bypass.block_id =
MPCC_MCM_FIRST_GAMUT_REMAP },
{ .func = MPC_SET_GAMUT_REMAP_BYPASS,
+ .meta.skip_if.stream_unchanged = true,
.meta.mpc_set_gamut_remap_bypass.block_id =
MPCC_MCM_SECOND_GAMUT_REMAP },
{ .func = MPC_SET_GAMUT_REMAP_BYPASS,
+ .meta.skip_if.stream_unchanged = true,
.meta.mpc_set_gamut_remap_bypass.block_id = MPCC_OGAM_GAMUT_REMAP },
- { .func = MPC_POWER_ON_MPC_MEM_PWR },
- { .func = MPC_SET_OCSC_DEFAULT },
- { .func = HUBP_PROGRAM_SURFACE_CONFIG },
- { .func = HUBP_UPDATE_PLANE_ADDR },
- { .func = HUBP_SET_BLANK, .meta.hubp_set_blank.unblank = true,
- .meta.skip_if.hubp_dpp_already_enabled = true },
+ { .func = MPC_POWER_ON_MPC_MEM_PWR,
+ .meta.skip_if.stream_unchanged = true },
+ { .func = MPC_SET_OCSC_DEFAULT,
+ .meta.skip_if.stream_unchanged = true },
+ { .func = HUBP_PROGRAM_SURFACE_CONFIG,
+ .meta.skip_if.stream_unchanged = true },
+ { .func = HUBP_UPDATE_PLANE_ADDR,
+ .meta.skip_if.stream_unchanged = true },
+ { .func = HUBP_SET_BLANK,
+ .meta.skip_if.stream_unchanged = true, .meta.hubp_set_blank.unblank = true,
+ .meta.skip_if.pipe_deltas.hubp_dpp_already_enabled = true },
/* set_hdr_multiplier, the input and MCM transfer functions, the
* output transfer function and the OPP format. First enable only.
*/
{ .func = DPP_SET_HDR_MULTIPLIER,
- .meta.skip_if.hubp_dpp_already_enabled = true },
+ .meta.skip_if.stream_unchanged = true,
+ .meta.skip_if.pipe_deltas.hubp_dpp_already_enabled = true },
{ .func = DPP_SET_PRE_DEGAM,
- .meta.skip_if.hubp_dpp_already_enabled = true },
+ .meta.skip_if.stream_unchanged = true,
+ .meta.skip_if.pipe_deltas.hubp_dpp_already_enabled = true },
{ .func = DPP_PROGRAM_GAMCOR_LUT,
- .meta.skip_if.hubp_dpp_already_enabled = true },
+ .meta.skip_if.stream_unchanged = true,
+ .meta.skip_if.pipe_deltas.hubp_dpp_already_enabled = true },
{ .func = MPC_SET_MOVABLE_CM_LOCATION,
- .meta.skip_if.hubp_dpp_already_enabled = true },
+ .meta.skip_if.stream_unchanged = true,
+ .meta.skip_if.pipe_deltas.hubp_dpp_already_enabled = true },
{ .func = MPC_PROGRAM_LUT_MODE,
+ .meta.skip_if.stream_unchanged = true,
.meta.mpc_program_lut_mode.id = MCM_LUT_1DLUT,
- .meta.skip_if.hubp_dpp_already_enabled = true },
+ .meta.skip_if.pipe_deltas.hubp_dpp_already_enabled = true },
{ .func = MPC_PROGRAM_LUT_MODE,
+ .meta.skip_if.stream_unchanged = true,
.meta.mpc_program_lut_mode.id = MCM_LUT_SHAPER,
- .meta.skip_if.hubp_dpp_already_enabled = true },
+ .meta.skip_if.pipe_deltas.hubp_dpp_already_enabled = true },
{ .func = MPC_PROGRAM_LUT_MODE,
+ .meta.skip_if.stream_unchanged = true,
.meta.mpc_program_lut_mode.id = MCM_LUT_3DLUT,
- .meta.skip_if.hubp_dpp_already_enabled = true },
+ .meta.skip_if.pipe_deltas.hubp_dpp_already_enabled = true },
{ .func = HUBP_PROGRAM_3DLUT_FL_CONFIG,
- .meta.skip_if.hubp_dpp_already_enabled = true },
+ .meta.skip_if.stream_unchanged = true,
+ .meta.skip_if.pipe_deltas.hubp_dpp_already_enabled = true },
{ .func = HUBP_SET_3DLUT_FL,
- .meta.skip_if.hubp_dpp_already_enabled = true },
+ .meta.skip_if.stream_unchanged = true,
+ .meta.skip_if.pipe_deltas.hubp_dpp_already_enabled = true },
{ .func = MPC_SET_OUTPUT_GAMMA,
- .meta.skip_if.hubp_dpp_already_enabled = true },
+ .meta.skip_if.stream_unchanged = true,
+ .meta.skip_if.pipe_deltas.hubp_dpp_already_enabled = true },
{ .func = OPP_SET_DYN_EXPANSION,
- .meta.skip_if.hubp_dpp_already_enabled = true },
+ .meta.skip_if.stream_unchanged = true,
+ .meta.skip_if.pipe_deltas.hubp_dpp_already_enabled = true },
{ .func = OPP_PROGRAM_FMT,
- .meta.skip_if.hubp_dpp_already_enabled = true },
+ .meta.skip_if.stream_unchanged = true,
+ .meta.skip_if.pipe_deltas.hubp_dpp_already_enabled = true },
};
/*
@@ -1244,30 +1366,36 @@ static const struct dcn401_commit_step enable_plane[] = {
* the manual trigger.
*/
static const struct dcn401_commit_step unlock[] = {
- { .func = TG_LOCK, .meta.tg_lock.lock = false },
+ { .func = TG_LOCK,
+ .meta.skip_if.stream_unchanged = true, .meta.tg_lock.lock = false },
};
static const struct dcn401_commit_step dpp_flip[] = {
- { .func = HUBP_WAIT_FLIP_PENDING },
+ { .func = HUBP_WAIT_FLIP_PENDING,
+ .meta.skip_if.stream_unchanged = true },
};
static const struct dcn401_commit_step pstate[] = {
- { .func = HUBBUB_FORCE_PSTATE_CHANGE_CONTROL },
+ { .func = HUBBUB_FORCE_PSTATE_CHANGE_CONTROL,
+ .meta.skip_if.stream_unchanged = true },
};
static const struct dcn401_commit_step dpp_mall[] = {
{ .func = HUBP_UPDATE_MALL_SEL,
+ .meta.skip_if.stream_unchanged = true,
.meta.hubp_update_mall_sel.from_new_state = true },
};
/* A changed ODM layout takes effect before the update returns. */
static const struct dcn401_commit_step odm_wait[] = {
{ .func = TG_WAIT_ODM_DOUBLEBUFFER_PENDING_CLEAR,
- .meta.skip_if.same_opp_heads = true },
+ .meta.skip_if.stream_unchanged = true,
+ .meta.skip_if.pipe_deltas.odm_kept = true },
};
static const struct dcn401_commit_step trigger[] = {
{ .func = OPTC_PROGRAM_MANUAL_TRIGGER,
+ .meta.skip_if.stream_unchanged = true,
.meta.skip_if.no_manual_trigger = true },
};
@@ -2140,14 +2268,88 @@ static void dcn401_add_step(struct block_sequence_state *sequence,
}
}
+static bool dcn401_same_opp_heads(const struct dc_state *current_state,
+ const struct dc_state *new_state,
+ const struct dc_stream_state *stream)
+{
+ const struct pipe_ctx *cur = dcn401_otg_master(current_state, stream);
+ const struct pipe_ctx *new = dcn401_otg_master(new_state, stream);
+ struct pipe_ctx *cur_heads[MAX_PIPES], *new_heads[MAX_PIPES];
+ int i, n;
+
+ if (!cur || !new)
+ return false;
+ n = resource_get_opp_heads_for_otg_master(cur,
+ (struct resource_context *)¤t_state->res_ctx,
+ cur_heads);
+ if (n != resource_get_opp_heads_for_otg_master(new,
+ (struct resource_context *)&new_state->res_ctx,
+ new_heads))
+ return false;
+ for (i = 0; i < n; i++)
+ if (!cur_heads[i]->stream_res.opp ||
+ !new_heads[i]->stream_res.opp ||
+ cur_heads[i]->stream_res.opp->inst !=
+ new_heads[i]->stream_res.opp->inst)
+ return false;
+ return true;
+}
+
+static void dcn401_eval_pipe_deltas(const struct dcn401_commit_step_args *args,
+ unsigned int idx, struct dcn401_pipe_deltas *deltas)
+{
+ const struct dc_state_pipe_flags *cur_f =
+ &args->update_flags->cur_pipes[idx];
+ const struct dc_state_pipe_flags *new_f =
+ &args->update_flags->new_pipes[idx];
+ const struct pipe_ctx *cur = &args->current_state->res_ctx.pipe_ctx[idx];
+ const struct pipe_ctx *new = &args->new_state->res_ctx.pipe_ctx[idx];
+
+ deltas->hubp_dpp_already_enabled = cur_f->enabled && new_f->enabled &&
+ cur->stream->stream_id == new->stream->stream_id &&
+ cur->plane_res.hubp->inst == new->plane_res.hubp->inst &&
+ cur->plane_res.dpp->inst == new->plane_res.dpp->inst &&
+ cur->stream_res.opp->inst == new->stream_res.opp->inst;
+ deltas->det_unchanged = cur_f->det_size == new_f->det_size;
+ deltas->current_has_no_plane = !cur_f->has_plane;
+ deltas->odm_kept = new->stream && dcn401_same_opp_heads(
+ args->current_state, args->new_state, new->stream);
+}
+
+static bool dcn401_pipe_deltas_match(const struct dcn401_pipe_deltas *skip,
+ const struct dcn401_pipe_deltas *deltas, bool all)
+{
+ const bool named[] = { skip->hubp_dpp_already_enabled,
+ skip->det_unchanged, skip->current_has_no_plane,
+ skip->odm_kept };
+ const bool set[] = { deltas->hubp_dpp_already_enabled,
+ deltas->det_unchanged, deltas->current_has_no_plane,
+ deltas->odm_kept };
+ bool any = false;
+ unsigned int i;
+
+ for (i = 0; i < ARRAY_SIZE(named); i++) {
+ if (!named[i])
+ continue;
+ if (all && !set[i])
+ return false;
+ any |= set[i];
+ }
+ return any;
+}
+
static bool dcn401_skip_step(const struct dcn401_commit_step_args *args,
const struct dcn401_commit_step *step)
{
+ const struct dcn401_pipe_deltas *skip = &step->meta.skip_if.pipe_deltas;
+ struct dcn401_pipe_deltas deltas;
const struct pipe_ctx *cur, *new;
if (step->meta.skip_if.new_state_has_stream &&
args->new_state->stream_count)
return true;
+ if (step->meta.skip_if.stream_unchanged && args->stream_unchanged)
+ return true;
if (step->meta.skip_if.optimized_not_required &&
!args->dc->optimized_required)
return true;
@@ -2160,6 +2362,7 @@ static bool dcn401_skip_step(const struct dcn401_commit_step_args *args,
return false;
cur = &args->current_state->res_ctx.pipe_ctx[args->pipe->pipe_idx];
new = &args->new_state->res_ctx.pipe_ctx[args->pipe->pipe_idx];
+ dcn401_eval_pipe_deltas(args, args->pipe->pipe_idx, &deltas);
if (step->meta.skip_if.no_manual_trigger &&
(!args->pipe->plane_state->update_bits.addr_update ||
args->pipe->plane_state->skip_manual_trigger))
@@ -2168,28 +2371,14 @@ static bool dcn401_skip_step(const struct dcn401_commit_step_args *args,
(!args->pipe->stream_res.opp ||
!args->pipe->stream_res.opp->mpc_tree_params.opp_list))
return true;
- if (step->meta.skip_if.hubp_dpp_already_enabled &&
- dcn401_pipe_kept(cur, new))
- return true;
- if (step->meta.skip_if.no_plane_removed &&
- (!cur->plane_state || dcn401_pipe_kept(cur, new)))
- return true;
- if (step->meta.skip_if.det_unchanged && dcn401_pipe_kept(cur, new) &&
- cur->hubp_regs.det_size == new->hubp_regs.det_size)
- return true;
- if (step->meta.skip_if.odm_kept && dcn401_pipe_kept(cur, new) &&
- dcn401_same_opp_heads(args->current_state,
- args->new_state, args->pipe->stream))
- return true;
- if (step->meta.skip_if.same_opp_heads &&
- dcn401_same_opp_heads(args->current_state,
- args->new_state, args->pipe->stream))
+ if (dcn401_pipe_deltas_match(skip, &deltas,
+ step->meta.skip_if.pipe_deltas_all))
return true;
if (step->meta.skip_if.scaling_unchanged &&
!args->pipe->plane_state->update_bits.scaling_change &&
!args->pipe->plane_state->update_bits.position_change &&
!args->pipe->stream->update_flags.bits.scaling &&
- (!dcn401_pipe_kept(cur, new) ||
+ (!deltas.hubp_dpp_already_enabled ||
!memcmp(&cur->plane_res.scl_data, &new->plane_res.scl_data,
sizeof(cur->plane_res.scl_data))))
return true;
@@ -2212,7 +2401,7 @@ static bool dcn401_walks_stream(const struct dcn401_commit_step_args *args,
const struct dc_stream_state *stream)
{
if (args->stream)
- return stream == args->stream;
+ return stream->stream_id == args->stream->stream_id;
return !dcn401_stream_kept(args->dc, args->current_state,
args->new_state, stream);
}
@@ -2316,6 +2505,8 @@ void dcn401_init_and_unpack_params(
state_args->new_state = (struct dc_state *)params->new_state;
state_args->stream = NULL;
state_args->pipe = NULL;
+ state_args->update_flags = params->update_flags;
+ state_args->stream_unchanged = false;
params->head_num_steps = 0;
params->tail_num_steps = 0;
@@ -2409,7 +2600,8 @@ static enum bls_builder_result dcn401_build_seamless_update(
if (!params)
return BLS_BUILD_ERROR_UNSUPPORTED_STATE_UPDATE;
result = dcn401_check_seamless_update_support(params->dc,
- params->current_state, params->new_state, params->stream);
+ params->current_state, params->new_state,
+ params->update_flags, params->stream);
if (result != BLS_BUILD_SUCCESS)
return result;
@@ -2426,7 +2618,8 @@ static bool dcn401_seamless_update_check_capability(
const struct bls_builder_check_capability_params *params)
{
return params && dcn401_check_seamless_update_support(params->dc,
- params->current_state, params->new_state, params->stream) ==
+ params->current_state, params->new_state,
+ params->update_flags, params->stream) ==
BLS_BUILD_SUCCESS;
}
diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_state.c b/drivers/gpu/drm/amd/display/dc/core/dc_state.c
index edb50c23ce24..961c3c1ea51f 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_state.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_state.c
@@ -1165,3 +1165,31 @@ bool dc_state_is_alt_in_use(const struct dc *dc, const struct dc_state *state)
}
return false;
}
+
+static void pipe_flags(const struct pipe_ctx *pipe,
+ struct dc_state_pipe_flags *flags)
+{
+ flags->has_plane = pipe->plane_state != NULL;
+ flags->enabled = flags->has_plane && pipe->stream &&
+ pipe->plane_res.hubp && pipe->plane_res.dpp &&
+ pipe->stream_res.opp;
+ flags->det_size = pipe->hubp_regs.det_size;
+}
+
+enum dc_status dc_state_compute_update_flags(const struct dc_state *cur_state,
+ const struct dc_state *target_state,
+ struct dc_state_update_flags *out_flags)
+{
+ unsigned int i;
+
+ if (!cur_state || !target_state || !out_flags)
+ return DC_ERROR_UNEXPECTED;
+ memset(out_flags, 0, sizeof(*out_flags));
+ for (i = 0; i < MAX_PIPES; i++) {
+ pipe_flags(&cur_state->res_ctx.pipe_ctx[i],
+ &out_flags->cur_pipes[i]);
+ pipe_flags(&target_state->res_ctx.pipe_ctx[i],
+ &out_flags->new_pipes[i]);
+ }
+ return DC_OK;
+}
diff --git a/drivers/gpu/drm/amd/display/dc/core2/dc_core2.c b/drivers/gpu/drm/amd/display/dc/core2/dc_core2.c
index 22da4ebae256..c4e1fef8266e 100644
--- a/drivers/gpu/drm/amd/display/dc/core2/dc_core2.c
+++ b/drivers/gpu/drm/amd/display/dc/core2/dc_core2.c
@@ -169,6 +169,7 @@ static enum dc_status core2_build_and_run(struct dc *dc,
const struct workaround_manager *wam = dc2_workaround_manager_get();
struct bls_builder_declarative_params *params;
enum dc_status status = DC_ERROR_UNEXPECTED;
+ struct dc_state_update_flags update_flags;
/* 256 block-sequence entries; keep them off the kernel stack. */
params = kvzalloc(sizeof(*params), GFP_KERNEL);
@@ -178,6 +179,10 @@ static enum dc_status core2_build_and_run(struct dc *dc,
params->current_state = dc->current_state;
params->new_state = new_state;
params->stream = stream;
+ if (dc_state_compute_update_flags(dc->current_state, new_state,
+ &update_flags) != DC_OK)
+ goto out;
+ params->update_flags = &update_flags;
/*
* A tail runs on the vsync after the head, so Core would have to wait
@@ -203,14 +208,18 @@ static bool core2_builder_supports(struct dc *dc, enum bls_builder_name name,
struct dc_state *new_state, const struct dc_stream_state *stream)
{
const struct bls_builder *builder = TO_DC2(dc)->builders[name];
+ struct dc_state_update_flags update_flags;
struct bls_builder_check_capability_params check = {
.dc = dc,
.current_state = dc->current_state,
.new_state = new_state,
.stream = stream,
+ .update_flags = &update_flags,
};
- return builder && builder->check_capability &&
+ return dc_state_compute_update_flags(dc->current_state, new_state,
+ &update_flags) == DC_OK &&
+ builder && builder->check_capability &&
builder->kind == BLS_BUILDER_DECLARATIVE &&
builder->build.declarative &&
dc2_workaround_manager_get() &&
@@ -282,14 +291,16 @@ enum dc_status core2_commit_state_hw(struct dc *dc, struct dc_state *context)
context, current_state->streams[i]))
core2_commit_disable_done(dc, otg_master);
}
- for (i = 0; i < context->stream_count; i++)
+ for (i = 0; i < context->stream_count; i++) {
+ struct pipe_ctx *otg_master = resource_get_otg_master_for_stream(
+ &context->res_ctx, context->streams[i]);
+
if (dcn401_stream_kept(dc, current_state, context,
context->streams[i]))
core2_update_done(dc, context, context->streams[i]);
- else
- core2_commit_enable_done(
- resource_get_otg_master_for_stream(
- &context->res_ctx, context->streams[i]));
+ else if (otg_master)
+ core2_commit_enable_done(otg_master);
+ }
return DC_OK;
}
diff --git a/drivers/gpu/drm/amd/display/dc/dc_state_priv.h b/drivers/gpu/drm/amd/display/dc/dc_state_priv.h
index 191bb431991f..0415e45d438e 100644
--- a/drivers/gpu/drm/amd/display/dc/dc_state_priv.h
+++ b/drivers/gpu/drm/amd/display/dc/dc_state_priv.h
@@ -26,6 +26,7 @@
#ifndef _DC_STATE_PRIV_H_
#define _DC_STATE_PRIV_H_
+#include "dc.h"
#include "dc_state.h"
#include "dc_stream.h"
@@ -126,4 +127,26 @@ bool dc_state_can_clear_stream_cursor_subvp_limit(const struct dc_stream_state *
bool dc_state_is_subvp_in_use(struct dc_state *state);
bool dc_state_is_alt_in_use(const struct dc *dc, const struct dc_state *state);
+
+/* Facts about one pipe of one state. */
+struct dc_state_pipe_flags {
+ /* The pipe drives a stream through a HUBP, a DPP and an OPP. */
+ bool enabled;
+ /* The pipe shows a plane. */
+ bool has_plane;
+ /* The DET size from hubp_regs. */
+ uint32_t det_size;
+};
+
+/* The facts of pipe i in the current and in the target state. */
+struct dc_state_update_flags {
+ struct dc_state_pipe_flags cur_pipes[MAX_PIPES];
+ struct dc_state_pipe_flags new_pipes[MAX_PIPES];
+};
+
+/* Pure: reads both states and writes only out_flags. */
+enum dc_status dc_state_compute_update_flags(const struct dc_state *cur_state,
+ const struct dc_state *target_state,
+ struct dc_state_update_flags *out_flags);
+
#endif /* _DC_STATE_PRIV_H_ */
diff --git a/drivers/gpu/drm/amd/display/dc/state_facts/state_facts.h b/drivers/gpu/drm/amd/display/dc/state_facts/state_facts.h
index b8a8b8256262..c774ebdae968 100644
--- a/drivers/gpu/drm/amd/display/dc/state_facts/state_facts.h
+++ b/drivers/gpu/drm/amd/display/dc/state_facts/state_facts.h
@@ -19,6 +19,9 @@ struct dc_trait_match {
#define DC_TRAIT_MATCH(set, clear) \
((struct dc_trait_match){ .mask = (set) | (clear), .value = (set) })
+/* Every element matches: no trait constrains it. */
+#define DC_TRAIT_MATCH_ANY DC_TRAIT_MATCH(0, 0)
+
/* Plane and pipe accessors: no stream filter. */
#define DC_FACTS_ALL_STREAMS 0xFFu
--
2.43.0
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [PATCH 30/33] drm/amd/display: Add RGBA8888 surface pixel format support
2026-11-16 21:50 [PATCH 00/33] DC Patches November 23, 2026 James Lin
` (28 preceding siblings ...)
2026-11-16 21:51 ` [PATCH 29/33] drm/amd/display: Give the DC2 builders State pipe facts James Lin
@ 2026-11-16 21:51 ` James Lin
2026-11-16 21:51 ` [PATCH 31/33] drm/amd/display: Fix DCE crossbar for RGBA8888 surface format James Lin
` (2 subsequent siblings)
32 siblings, 0 replies; 34+ messages in thread
From: James Lin @ 2026-11-16 21:51 UTC (permalink / raw)
To: amd-gfx
Cc: Harry Wentland, Leo Li, Aurabindo Pillai, Roman Li, Wayne Lin,
Tom Chung, Fangzhi Zuo, Dan Wheeler, Ray Wu, Ivan Lipski,
Alex Hung, James Lin, Chenyu Chen, Nicholas Kazlauskas, James Lin
From: Harry Wentland <harry.wentland@amd.com>
[why]
amdgpu_dm advertises DRM_FORMAT_RGBA8888 for its planes, but DC has no
matching surface pixel format, so fill_dc_plane_info_and_addr()
rejects the format with -EINVAL. KWin modesets then fail with
"Unsupported screen format RA24 little-endian".
[how]
- Add SURFACE_PIXEL_FORMAT_GRPH_RGBA8888 to the surface_pixel_format
enum.
- Map DRM_FORMAT_RGBA8888 to the new format in amdgpu_dm.
- Program the dedicated RGBA8888 encoding (value 9) in HUBP and DPP
for all DCN generations. Unlike ABGR8888, there is no red/blue
crossbar swap.
- Treat RGBA8888 as a 32bpp graphics format in bandwidth,
bytes-per-pixel, DCC, and format-class helpers, the same as
ARGB8888.
Link: https://gitlab.freedesktop.org/drm/amd/-/issues/5339
Cc: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com>
Signed-off-by: Harry Wentland <harry.wentland@amd.com>
Signed-off-by: James Lin <pinglei.lin@amd.com>
---
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 3 +++
drivers/gpu/drm/amd/display/dc/basics/dce_calcs.c | 2 ++
drivers/gpu/drm/amd/display/dc/core/dc_resource.c | 4 ++++
drivers/gpu/drm/amd/display/dc/dc_hw_types.h | 2 ++
drivers/gpu/drm/amd/display/dc/dce/dce_mem_input.c | 1 +
drivers/gpu/drm/amd/display/dc/dce110/dce110_mem_input_v.c | 1 +
drivers/gpu/drm/amd/display/dc/dml/calcs/dcn_calcs.c | 1 +
drivers/gpu/drm/amd/display/dc/dpp/dcn10/dcn10_dpp.c | 3 +++
drivers/gpu/drm/amd/display/dc/dpp/dcn20/dcn20_dpp.c | 3 +++
drivers/gpu/drm/amd/display/dc/dpp/dcn201/dcn201_dpp.c | 3 +++
drivers/gpu/drm/amd/display/dc/dpp/dcn30/dcn30_dpp.c | 3 +++
drivers/gpu/drm/amd/display/dc/dpp/dcn401/dcn401_dpp.c | 3 +++
drivers/gpu/drm/amd/display/dc/dpp/dcn42/dcn42_dpp.c | 3 +++
drivers/gpu/drm/amd/display/dc/dpp/dcn50/dcn50_dpp.c | 3 +++
drivers/gpu/drm/amd/display/dc/dpp/dcn60/dcn60_dpp.c | 3 +++
drivers/gpu/drm/amd/display/dc/hubbub/dcn10/dcn10_hubbub.c | 1 +
drivers/gpu/drm/amd/display/dc/hubbub/dcn20/dcn20_hubbub.c | 1 +
drivers/gpu/drm/amd/display/dc/hubbub/dcn401/dcn401_hubbub.c | 1 +
drivers/gpu/drm/amd/display/dc/hubp/dcn10/dcn10_hubp.c | 4 ++++
drivers/gpu/drm/amd/display/dc/hubp/dcn20/dcn20_hubp.c | 4 ++++
drivers/gpu/drm/amd/display/dc/hubp/dcn35/dcn35_hubp.c | 4 ++++
drivers/gpu/drm/amd/display/dc/hubp/dcn42/dcn42_hubp.c | 4 ++++
drivers/gpu/drm/amd/display/dc/hubp/dcn50/dcn50_hubp.c | 4 ++++
drivers/gpu/drm/amd/display/dc/hwss/dce/dce_hwseq.c | 1 +
drivers/gpu/drm/amd/display/dc/hwss/dce110/dce110_hwseq.c | 1 +
25 files changed, 63 insertions(+)
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index 29d7c87a94ef..b6b67f730415 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -3105,6 +3105,9 @@ fill_dc_plane_info_and_addr(struct amdgpu_device *adev,
case DRM_FORMAT_ARGB8888:
plane_info->format = SURFACE_PIXEL_FORMAT_GRPH_ARGB8888;
break;
+ case DRM_FORMAT_RGBA8888:
+ plane_info->format = SURFACE_PIXEL_FORMAT_GRPH_RGBA8888;
+ break;
case DRM_FORMAT_XRGB2101010:
case DRM_FORMAT_ARGB2101010:
plane_info->format = SURFACE_PIXEL_FORMAT_GRPH_ARGB2101010;
diff --git a/drivers/gpu/drm/amd/display/dc/basics/dce_calcs.c b/drivers/gpu/drm/amd/display/dc/basics/dce_calcs.c
index 1b8e843020d6..1ff1a6c23c65 100644
--- a/drivers/gpu/drm/amd/display/dc/basics/dce_calcs.c
+++ b/drivers/gpu/drm/amd/display/dc/basics/dce_calcs.c
@@ -2853,6 +2853,7 @@ static void populate_initial_data(
break;
case SURFACE_PIXEL_FORMAT_GRPH_ARGB8888:
case SURFACE_PIXEL_FORMAT_GRPH_ABGR8888:
+ case SURFACE_PIXEL_FORMAT_GRPH_RGBA8888:
case SURFACE_PIXEL_FORMAT_GRPH_ARGB2101010:
case SURFACE_PIXEL_FORMAT_GRPH_ABGR2101010:
case SURFACE_PIXEL_FORMAT_GRPH_ABGR2101010_XR_BIAS:
@@ -2957,6 +2958,7 @@ static void populate_initial_data(
break;
case SURFACE_PIXEL_FORMAT_GRPH_ARGB8888:
case SURFACE_PIXEL_FORMAT_GRPH_ABGR8888:
+ case SURFACE_PIXEL_FORMAT_GRPH_RGBA8888:
case SURFACE_PIXEL_FORMAT_GRPH_ARGB2101010:
case SURFACE_PIXEL_FORMAT_GRPH_ABGR2101010:
case SURFACE_PIXEL_FORMAT_GRPH_ABGR2101010_XR_BIAS:
diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_resource.c b/drivers/gpu/drm/amd/display/dc/core/dc_resource.c
index b09490c84438..ec11a79811e7 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_resource.c
@@ -808,6 +808,9 @@ static enum dc_pixel_format convert_pixel_format_to_dalsurface(
case SURFACE_PIXEL_FORMAT_GRPH_ABGR8888:
dal_pixel_format = PIXEL_FORMAT_ARGB8888;
break;
+ case SURFACE_PIXEL_FORMAT_GRPH_RGBA8888:
+ dal_pixel_format = PIXEL_FORMAT_ARGB8888;
+ break;
case SURFACE_PIXEL_FORMAT_GRPH_ARGB2101010:
dal_pixel_format = PIXEL_FORMAT_ARGB2101010;
break;
@@ -5905,6 +5908,7 @@ unsigned int resource_pixel_format_to_bpp(enum surface_pixel_format format)
return 16;
case SURFACE_PIXEL_FORMAT_GRPH_ARGB8888:
case SURFACE_PIXEL_FORMAT_GRPH_ABGR8888:
+ case SURFACE_PIXEL_FORMAT_GRPH_RGBA8888:
case SURFACE_PIXEL_FORMAT_GRPH_ARGB2101010:
case SURFACE_PIXEL_FORMAT_GRPH_ABGR2101010:
case SURFACE_PIXEL_FORMAT_GRPH_ABGR2101010_XR_BIAS:
diff --git a/drivers/gpu/drm/amd/display/dc/dc_hw_types.h b/drivers/gpu/drm/amd/display/dc/dc_hw_types.h
index 387d2ebb2b7c..a361f5d9af50 100644
--- a/drivers/gpu/drm/amd/display/dc/dc_hw_types.h
+++ b/drivers/gpu/drm/amd/display/dc/dc_hw_types.h
@@ -176,6 +176,8 @@ enum surface_pixel_format {
SURFACE_PIXEL_FORMAT_GRPH_ARGB8888,
/*32 bpp swaped*/
SURFACE_PIXEL_FORMAT_GRPH_ABGR8888,
+ /*32 bpp, alpha in LSB*/
+ SURFACE_PIXEL_FORMAT_GRPH_RGBA8888,
SURFACE_PIXEL_FORMAT_GRPH_ARGB2101010,
/*swaped*/
diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_mem_input.c b/drivers/gpu/drm/amd/display/dc/dce/dce_mem_input.c
index 168c2d0a5eaa..08cde29a4a7a 100644
--- a/drivers/gpu/drm/amd/display/dc/dce/dce_mem_input.c
+++ b/drivers/gpu/drm/amd/display/dc/dce/dce_mem_input.c
@@ -593,6 +593,7 @@ static void program_grph_pixel_format(
break;
case SURFACE_PIXEL_FORMAT_GRPH_ARGB8888:
case SURFACE_PIXEL_FORMAT_GRPH_ABGR8888:
+ case SURFACE_PIXEL_FORMAT_GRPH_RGBA8888:
grph_depth = 2;
grph_format = 0;
break;
diff --git a/drivers/gpu/drm/amd/display/dc/dce110/dce110_mem_input_v.c b/drivers/gpu/drm/amd/display/dc/dce110/dce110_mem_input_v.c
index 095869912c09..9d781d12d669 100644
--- a/drivers/gpu/drm/amd/display/dc/dce110/dce110_mem_input_v.c
+++ b/drivers/gpu/drm/amd/display/dc/dce110/dce110_mem_input_v.c
@@ -381,6 +381,7 @@ static void program_pixel_format(
break;
case SURFACE_PIXEL_FORMAT_GRPH_ARGB8888:
case SURFACE_PIXEL_FORMAT_GRPH_ABGR8888:
+ case SURFACE_PIXEL_FORMAT_GRPH_RGBA8888:
grph_depth = 2;
grph_format = 0;
break;
diff --git a/drivers/gpu/drm/amd/display/dc/dml/calcs/dcn_calcs.c b/drivers/gpu/drm/amd/display/dc/dml/calcs/dcn_calcs.c
index 2ad4a2635683..ec25a76dc3f1 100644
--- a/drivers/gpu/drm/amd/display/dc/dml/calcs/dcn_calcs.c
+++ b/drivers/gpu/drm/amd/display/dc/dml/calcs/dcn_calcs.c
@@ -231,6 +231,7 @@ static enum dcn_bw_defs tl_pixel_format_to_bw_defs(enum surface_pixel_format for
return dcn_bw_rgb_sub_16;
case SURFACE_PIXEL_FORMAT_GRPH_ARGB8888:
case SURFACE_PIXEL_FORMAT_GRPH_ABGR8888:
+ case SURFACE_PIXEL_FORMAT_GRPH_RGBA8888:
case SURFACE_PIXEL_FORMAT_GRPH_ARGB2101010:
case SURFACE_PIXEL_FORMAT_GRPH_ABGR2101010:
case SURFACE_PIXEL_FORMAT_GRPH_ABGR2101010_XR_BIAS:
diff --git a/drivers/gpu/drm/amd/display/dc/dpp/dcn10/dcn10_dpp.c b/drivers/gpu/drm/amd/display/dc/dpp/dcn10/dcn10_dpp.c
index de420cdf1514..1156027198a4 100644
--- a/drivers/gpu/drm/amd/display/dc/dpp/dcn10/dcn10_dpp.c
+++ b/drivers/gpu/drm/amd/display/dc/dpp/dcn10/dcn10_dpp.c
@@ -344,6 +344,9 @@ void dpp1_cnv_setup (
case SURFACE_PIXEL_FORMAT_GRPH_ABGR8888:
pixel_format = 8;
break;
+ case SURFACE_PIXEL_FORMAT_GRPH_RGBA8888:
+ pixel_format = 9;
+ break;
case SURFACE_PIXEL_FORMAT_GRPH_ARGB2101010:
case SURFACE_PIXEL_FORMAT_GRPH_ABGR2101010:
pixel_format = 10;
diff --git a/drivers/gpu/drm/amd/display/dc/dpp/dcn20/dcn20_dpp.c b/drivers/gpu/drm/amd/display/dc/dpp/dcn20/dcn20_dpp.c
index 0f3b1717563b..5bf86b3cc388 100644
--- a/drivers/gpu/drm/amd/display/dc/dpp/dcn20/dcn20_dpp.c
+++ b/drivers/gpu/drm/amd/display/dc/dpp/dcn20/dcn20_dpp.c
@@ -143,6 +143,9 @@ static void dpp2_cnv_setup (
case SURFACE_PIXEL_FORMAT_GRPH_ABGR8888:
pixel_format = 8;
break;
+ case SURFACE_PIXEL_FORMAT_GRPH_RGBA8888:
+ pixel_format = 9;
+ break;
case SURFACE_PIXEL_FORMAT_GRPH_ARGB2101010:
case SURFACE_PIXEL_FORMAT_GRPH_ABGR2101010:
pixel_format = 10;
diff --git a/drivers/gpu/drm/amd/display/dc/dpp/dcn201/dcn201_dpp.c b/drivers/gpu/drm/amd/display/dc/dpp/dcn201/dcn201_dpp.c
index a2079db62f63..37a877f5b3e7 100644
--- a/drivers/gpu/drm/amd/display/dc/dpp/dcn201/dcn201_dpp.c
+++ b/drivers/gpu/drm/amd/display/dc/dpp/dcn201/dcn201_dpp.c
@@ -87,6 +87,9 @@ static void dpp201_cnv_setup(
case SURFACE_PIXEL_FORMAT_GRPH_ABGR8888:
pixel_format = 8;
break;
+ case SURFACE_PIXEL_FORMAT_GRPH_RGBA8888:
+ pixel_format = 9;
+ break;
case SURFACE_PIXEL_FORMAT_GRPH_ARGB2101010:
case SURFACE_PIXEL_FORMAT_GRPH_ABGR2101010:
pixel_format = 10;
diff --git a/drivers/gpu/drm/amd/display/dc/dpp/dcn30/dcn30_dpp.c b/drivers/gpu/drm/amd/display/dc/dpp/dcn30/dcn30_dpp.c
index 3db10019fa84..58260e0a2172 100644
--- a/drivers/gpu/drm/amd/display/dc/dpp/dcn30/dcn30_dpp.c
+++ b/drivers/gpu/drm/amd/display/dc/dpp/dcn30/dcn30_dpp.c
@@ -337,6 +337,9 @@ void dpp3_cnv_setup (
case SURFACE_PIXEL_FORMAT_GRPH_ABGR8888:
pixel_format = 8;
break;
+ case SURFACE_PIXEL_FORMAT_GRPH_RGBA8888:
+ pixel_format = 9;
+ break;
case SURFACE_PIXEL_FORMAT_GRPH_ARGB2101010:
case SURFACE_PIXEL_FORMAT_GRPH_ABGR2101010:
pixel_format = 10;
diff --git a/drivers/gpu/drm/amd/display/dc/dpp/dcn401/dcn401_dpp.c b/drivers/gpu/drm/amd/display/dc/dpp/dcn401/dcn401_dpp.c
index 7a3a7678c71a..379fe0f5531a 100644
--- a/drivers/gpu/drm/amd/display/dc/dpp/dcn401/dcn401_dpp.c
+++ b/drivers/gpu/drm/amd/display/dc/dpp/dcn401/dcn401_dpp.c
@@ -99,6 +99,9 @@ void dpp401_dpp_setup(
case SURFACE_PIXEL_FORMAT_GRPH_ABGR8888:
pixel_format = 8;
break;
+ case SURFACE_PIXEL_FORMAT_GRPH_RGBA8888:
+ pixel_format = 9;
+ break;
case SURFACE_PIXEL_FORMAT_GRPH_ARGB2101010:
case SURFACE_PIXEL_FORMAT_GRPH_ABGR2101010:
pixel_format = 10;
diff --git a/drivers/gpu/drm/amd/display/dc/dpp/dcn42/dcn42_dpp.c b/drivers/gpu/drm/amd/display/dc/dpp/dcn42/dcn42_dpp.c
index 2ce0694e3725..b0c1545fe3ff 100644
--- a/drivers/gpu/drm/amd/display/dc/dpp/dcn42/dcn42_dpp.c
+++ b/drivers/gpu/drm/amd/display/dc/dpp/dcn42/dcn42_dpp.c
@@ -159,6 +159,9 @@ static void dpp42_dpp_setup(
case SURFACE_PIXEL_FORMAT_GRPH_ABGR8888:
pixel_format = 8;
break;
+ case SURFACE_PIXEL_FORMAT_GRPH_RGBA8888:
+ pixel_format = 9;
+ break;
case SURFACE_PIXEL_FORMAT_GRPH_ARGB2101010:
case SURFACE_PIXEL_FORMAT_GRPH_ABGR2101010:
pixel_format = 10;
diff --git a/drivers/gpu/drm/amd/display/dc/dpp/dcn50/dcn50_dpp.c b/drivers/gpu/drm/amd/display/dc/dpp/dcn50/dcn50_dpp.c
index 5382fc656169..8857b7b33ab9 100644
--- a/drivers/gpu/drm/amd/display/dc/dpp/dcn50/dcn50_dpp.c
+++ b/drivers/gpu/drm/amd/display/dc/dpp/dcn50/dcn50_dpp.c
@@ -131,6 +131,9 @@ void dpp50_dpp_setup(
case SURFACE_PIXEL_FORMAT_GRPH_ABGR8888:
pixel_format = 8;
break;
+ case SURFACE_PIXEL_FORMAT_GRPH_RGBA8888:
+ pixel_format = 9;
+ break;
case SURFACE_PIXEL_FORMAT_GRPH_ARGB2101010:
case SURFACE_PIXEL_FORMAT_GRPH_ABGR2101010:
pixel_format = 10;
diff --git a/drivers/gpu/drm/amd/display/dc/dpp/dcn60/dcn60_dpp.c b/drivers/gpu/drm/amd/display/dc/dpp/dcn60/dcn60_dpp.c
index dfdbc539ac42..210e6658ac61 100644
--- a/drivers/gpu/drm/amd/display/dc/dpp/dcn60/dcn60_dpp.c
+++ b/drivers/gpu/drm/amd/display/dc/dpp/dcn60/dcn60_dpp.c
@@ -63,6 +63,9 @@ void dpp60_dpp_setup(
case SURFACE_PIXEL_FORMAT_GRPH_ABGR8888:
pixel_format = 8;
break;
+ case SURFACE_PIXEL_FORMAT_GRPH_RGBA8888:
+ pixel_format = 9;
+ break;
case SURFACE_PIXEL_FORMAT_GRPH_ARGB2101010:
case SURFACE_PIXEL_FORMAT_GRPH_ABGR2101010:
pixel_format = 10;
diff --git a/drivers/gpu/drm/amd/display/dc/hubbub/dcn10/dcn10_hubbub.c b/drivers/gpu/drm/amd/display/dc/hubbub/dcn10/dcn10_hubbub.c
index faad1c6f4509..238824369e00 100644
--- a/drivers/gpu/drm/amd/display/dc/hubbub/dcn10/dcn10_hubbub.c
+++ b/drivers/gpu/drm/amd/display/dc/hubbub/dcn10/dcn10_hubbub.c
@@ -761,6 +761,7 @@ static bool hubbub1_dcc_support_pixel_format(
return true;
case SURFACE_PIXEL_FORMAT_GRPH_ARGB8888:
case SURFACE_PIXEL_FORMAT_GRPH_ABGR8888:
+ case SURFACE_PIXEL_FORMAT_GRPH_RGBA8888:
case SURFACE_PIXEL_FORMAT_GRPH_ARGB2101010:
case SURFACE_PIXEL_FORMAT_GRPH_ABGR2101010:
*bytes_per_element = 4;
diff --git a/drivers/gpu/drm/amd/display/dc/hubbub/dcn20/dcn20_hubbub.c b/drivers/gpu/drm/amd/display/dc/hubbub/dcn20/dcn20_hubbub.c
index 464fc5924a56..6cfcce7bb48f 100644
--- a/drivers/gpu/drm/amd/display/dc/hubbub/dcn20/dcn20_hubbub.c
+++ b/drivers/gpu/drm/amd/display/dc/hubbub/dcn20/dcn20_hubbub.c
@@ -147,6 +147,7 @@ bool hubbub2_dcc_support_pixel_format(
return true;
case SURFACE_PIXEL_FORMAT_GRPH_ARGB8888:
case SURFACE_PIXEL_FORMAT_GRPH_ABGR8888:
+ case SURFACE_PIXEL_FORMAT_GRPH_RGBA8888:
case SURFACE_PIXEL_FORMAT_GRPH_ARGB2101010:
case SURFACE_PIXEL_FORMAT_GRPH_ABGR2101010:
case SURFACE_PIXEL_FORMAT_GRPH_RGB111110_FIX:
diff --git a/drivers/gpu/drm/amd/display/dc/hubbub/dcn401/dcn401_hubbub.c b/drivers/gpu/drm/amd/display/dc/hubbub/dcn401/dcn401_hubbub.c
index c18457c779de..cc3fda2c470c 100644
--- a/drivers/gpu/drm/amd/display/dc/hubbub/dcn401/dcn401_hubbub.c
+++ b/drivers/gpu/drm/amd/display/dc/hubbub/dcn401/dcn401_hubbub.c
@@ -672,6 +672,7 @@ bool hubbub401_dcc_support_pixel_format(
return true;
case SURFACE_PIXEL_FORMAT_GRPH_ARGB8888:
case SURFACE_PIXEL_FORMAT_GRPH_ABGR8888:
+ case SURFACE_PIXEL_FORMAT_GRPH_RGBA8888:
case SURFACE_PIXEL_FORMAT_GRPH_ARGB2101010:
case SURFACE_PIXEL_FORMAT_GRPH_ABGR2101010:
case SURFACE_PIXEL_FORMAT_GRPH_ABGR2101010_XR_BIAS:
diff --git a/drivers/gpu/drm/amd/display/dc/hubp/dcn10/dcn10_hubp.c b/drivers/gpu/drm/amd/display/dc/hubp/dcn10/dcn10_hubp.c
index 2a4be0c7a724..4723a390297c 100644
--- a/drivers/gpu/drm/amd/display/dc/hubp/dcn10/dcn10_hubp.c
+++ b/drivers/gpu/drm/amd/display/dc/hubp/dcn10/dcn10_hubp.c
@@ -272,6 +272,10 @@ void hubp1_program_pixel_format(
REG_UPDATE(DCSURF_SURFACE_CONFIG,
SURFACE_PIXEL_FORMAT, 8);
break;
+ case SURFACE_PIXEL_FORMAT_GRPH_RGBA8888:
+ REG_UPDATE(DCSURF_SURFACE_CONFIG,
+ SURFACE_PIXEL_FORMAT, 9);
+ break;
case SURFACE_PIXEL_FORMAT_GRPH_ARGB2101010:
case SURFACE_PIXEL_FORMAT_GRPH_ABGR2101010:
case SURFACE_PIXEL_FORMAT_GRPH_ABGR2101010_XR_BIAS:
diff --git a/drivers/gpu/drm/amd/display/dc/hubp/dcn20/dcn20_hubp.c b/drivers/gpu/drm/amd/display/dc/hubp/dcn20/dcn20_hubp.c
index 79a429814061..e82bb43be001 100644
--- a/drivers/gpu/drm/amd/display/dc/hubp/dcn20/dcn20_hubp.c
+++ b/drivers/gpu/drm/amd/display/dc/hubp/dcn20/dcn20_hubp.c
@@ -473,6 +473,10 @@ void hubp2_program_pixel_format(
REG_UPDATE(DCSURF_SURFACE_CONFIG,
SURFACE_PIXEL_FORMAT, 8);
break;
+ case SURFACE_PIXEL_FORMAT_GRPH_RGBA8888:
+ REG_UPDATE(DCSURF_SURFACE_CONFIG,
+ SURFACE_PIXEL_FORMAT, 9);
+ break;
case SURFACE_PIXEL_FORMAT_GRPH_ARGB2101010:
case SURFACE_PIXEL_FORMAT_GRPH_ABGR2101010:
case SURFACE_PIXEL_FORMAT_GRPH_ABGR2101010_XR_BIAS:
diff --git a/drivers/gpu/drm/amd/display/dc/hubp/dcn35/dcn35_hubp.c b/drivers/gpu/drm/amd/display/dc/hubp/dcn35/dcn35_hubp.c
index c879f4901c7d..69b5d41c959e 100644
--- a/drivers/gpu/drm/amd/display/dc/hubp/dcn35/dcn35_hubp.c
+++ b/drivers/gpu/drm/amd/display/dc/hubp/dcn35/dcn35_hubp.c
@@ -94,6 +94,10 @@ void hubp35_program_pixel_format(
REG_UPDATE(DCSURF_SURFACE_CONFIG,
SURFACE_PIXEL_FORMAT, 8);
break;
+ case SURFACE_PIXEL_FORMAT_GRPH_RGBA8888:
+ REG_UPDATE(DCSURF_SURFACE_CONFIG,
+ SURFACE_PIXEL_FORMAT, 9);
+ break;
case SURFACE_PIXEL_FORMAT_GRPH_ARGB2101010:
case SURFACE_PIXEL_FORMAT_GRPH_ABGR2101010:
case SURFACE_PIXEL_FORMAT_GRPH_ABGR2101010_XR_BIAS:
diff --git a/drivers/gpu/drm/amd/display/dc/hubp/dcn42/dcn42_hubp.c b/drivers/gpu/drm/amd/display/dc/hubp/dcn42/dcn42_hubp.c
index 0c8a23cef1e0..b70fc7c1c80d 100644
--- a/drivers/gpu/drm/amd/display/dc/hubp/dcn42/dcn42_hubp.c
+++ b/drivers/gpu/drm/amd/display/dc/hubp/dcn42/dcn42_hubp.c
@@ -78,6 +78,10 @@ static void hubp42_program_pixel_format(
REG_UPDATE(DCSURF_SURFACE_CONFIG,
SURFACE_PIXEL_FORMAT, 8);
break;
+ case SURFACE_PIXEL_FORMAT_GRPH_RGBA8888:
+ REG_UPDATE(DCSURF_SURFACE_CONFIG,
+ SURFACE_PIXEL_FORMAT, 9);
+ break;
case SURFACE_PIXEL_FORMAT_GRPH_ARGB2101010:
case SURFACE_PIXEL_FORMAT_GRPH_ABGR2101010:
case SURFACE_PIXEL_FORMAT_GRPH_ABGR2101010_XR_BIAS:
diff --git a/drivers/gpu/drm/amd/display/dc/hubp/dcn50/dcn50_hubp.c b/drivers/gpu/drm/amd/display/dc/hubp/dcn50/dcn50_hubp.c
index ceea0b766f5b..2aef6f239dc7 100644
--- a/drivers/gpu/drm/amd/display/dc/hubp/dcn50/dcn50_hubp.c
+++ b/drivers/gpu/drm/amd/display/dc/hubp/dcn50/dcn50_hubp.c
@@ -264,6 +264,10 @@ static void hubp50_program_pixel_format(
REG_UPDATE(DCSURF_SURFACE_CONFIG,
SURFACE_PIXEL_FORMAT, 8);
break;
+ case SURFACE_PIXEL_FORMAT_GRPH_RGBA8888:
+ REG_UPDATE(DCSURF_SURFACE_CONFIG,
+ SURFACE_PIXEL_FORMAT, 9);
+ break;
case SURFACE_PIXEL_FORMAT_GRPH_ARGB2101010:
case SURFACE_PIXEL_FORMAT_GRPH_ABGR2101010:
case SURFACE_PIXEL_FORMAT_GRPH_ABGR2101010_XR_BIAS:
diff --git a/drivers/gpu/drm/amd/display/dc/hwss/dce/dce_hwseq.c b/drivers/gpu/drm/amd/display/dc/hwss/dce/dce_hwseq.c
index 0f44577572fb..9b8d4d1a2cbe 100644
--- a/drivers/gpu/drm/amd/display/dc/hwss/dce/dce_hwseq.c
+++ b/drivers/gpu/drm/amd/display/dc/hwss/dce/dce_hwseq.c
@@ -228,6 +228,7 @@ bool dce_use_lut(enum surface_pixel_format format)
switch (format) {
case SURFACE_PIXEL_FORMAT_GRPH_ARGB8888:
case SURFACE_PIXEL_FORMAT_GRPH_ABGR8888:
+ case SURFACE_PIXEL_FORMAT_GRPH_RGBA8888:
return true;
default:
return false;
diff --git a/drivers/gpu/drm/amd/display/dc/hwss/dce110/dce110_hwseq.c b/drivers/gpu/drm/amd/display/dc/hwss/dce110/dce110_hwseq.c
index a08ceaeda91c..363961f700d9 100644
--- a/drivers/gpu/drm/amd/display/dc/hwss/dce110/dce110_hwseq.c
+++ b/drivers/gpu/drm/amd/display/dc/hwss/dce110/dce110_hwseq.c
@@ -271,6 +271,7 @@ static void dce110_prescale_params(struct ipp_prescale_params *prescale_params,
break;
case SURFACE_PIXEL_FORMAT_GRPH_ARGB8888:
case SURFACE_PIXEL_FORMAT_GRPH_ABGR8888:
+ case SURFACE_PIXEL_FORMAT_GRPH_RGBA8888:
prescale_params->scale = 0x2020;
break;
case SURFACE_PIXEL_FORMAT_GRPH_ARGB2101010:
--
2.43.0
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [PATCH 31/33] drm/amd/display: Fix DCE crossbar for RGBA8888 surface format
2026-11-16 21:50 [PATCH 00/33] DC Patches November 23, 2026 James Lin
` (29 preceding siblings ...)
2026-11-16 21:51 ` [PATCH 30/33] drm/amd/display: Add RGBA8888 surface pixel format support James Lin
@ 2026-11-16 21:51 ` James Lin
2026-11-16 21:51 ` [PATCH 32/33] drm/amd/display: [FW Promotion] Release 0.1.85.0 James Lin
2026-11-16 21:51 ` [PATCH 33/33] drm/amd/display: Promote DC to 3.2.408 James Lin
32 siblings, 0 replies; 34+ messages in thread
From: James Lin @ 2026-11-16 21:51 UTC (permalink / raw)
To: amd-gfx
Cc: Harry Wentland, Leo Li, Aurabindo Pillai, Roman Li, Wayne Lin,
Tom Chung, Fangzhi Zuo, Dan Wheeler, Ray Wu, Ivan Lipski,
Alex Hung, James Lin, Chenyu Chen, Nicholas Kazlauskas, James Lin
From: Harry Wentland <harry.wentland@amd.com>
[why]
DCE unpacks all 32bpp graphics formats as ARGB and has no native
alpha-in-LSB encoding. Channel reordering is done only through the
GRPH_SWAP_CNTL crossbar, which programmed just the red and blue
selects. RGBA8888 was therefore scanned out with alpha in the MSB.
[how]
- Program all four GRPH_SWAP_CNTL crossbar selects (red, green, blue,
alpha) in program_grph_pixel_format().
- Keep the existing R/B swap for ABGR formats.
- Add RGBA8888 with the mapping R<-A, G<-R, B<-G, A<-B.
- Add the GRPH_GREEN_CROSSBAR and GRPH_ALPHA_CROSSBAR fields to the
DCP register mask and field lists.
Closes: https://gitlab.freedesktop.org/drm/amd/-/issues/5339
Cc: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com>
Signed-off-by: Harry Wentland <harry.wentland@amd.com>
Signed-off-by: James Lin <pinglei.lin@amd.com>
---
.../drm/amd/display/dc/dce/dce_mem_input.c | 41 +++++++++++++------
.../drm/amd/display/dc/dce/dce_mem_input.h | 6 +++
2 files changed, 34 insertions(+), 13 deletions(-)
diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_mem_input.c b/drivers/gpu/drm/amd/display/dc/dce/dce_mem_input.c
index 08cde29a4a7a..4f1b8b2750d9 100644
--- a/drivers/gpu/drm/amd/display/dc/dce/dce_mem_input.c
+++ b/drivers/gpu/drm/amd/display/dc/dce/dce_mem_input.c
@@ -558,25 +558,40 @@ static void program_grph_pixel_format(
struct dce_mem_input *dce_mi,
enum surface_pixel_format format)
{
- uint32_t red_xbar = 0, blue_xbar = 0; /* no swap */
+ /* Crossbar per output channel: 0 R, 1 G, 2 B, 3 A source (see
+ * DCP_GRPH_*_CROSSBAR in the enum headers). DCE unpacks all 32bpp
+ * as ARGB, so alpha-in-LSB layouts are reordered via the crossbar.
+ */
+ uint32_t red_xbar = 0, green_xbar = 0, blue_xbar = 0, alpha_xbar = 0;
uint32_t grph_depth = 0, grph_format = 0;
uint32_t sign = 0, floating = 0;
- if (format == SURFACE_PIXEL_FORMAT_GRPH_ABGR8888 ||
- /*todo: doesn't look like we handle BGRA here,
- * should problem swap endian*/
- format == SURFACE_PIXEL_FORMAT_GRPH_ABGR2101010 ||
- format == SURFACE_PIXEL_FORMAT_GRPH_ABGR2101010_XR_BIAS ||
- format == SURFACE_PIXEL_FORMAT_GRPH_ABGR16161616 ||
- format == SURFACE_PIXEL_FORMAT_GRPH_ABGR16161616F) {
- /* ABGR formats */
- red_xbar = 2;
- blue_xbar = 2;
+ switch (format) {
+ case SURFACE_PIXEL_FORMAT_GRPH_ABGR8888:
+ case SURFACE_PIXEL_FORMAT_GRPH_ABGR2101010:
+ case SURFACE_PIXEL_FORMAT_GRPH_ABGR2101010_XR_BIAS:
+ case SURFACE_PIXEL_FORMAT_GRPH_ABGR16161616:
+ case SURFACE_PIXEL_FORMAT_GRPH_ABGR16161616F:
+ /* ABGR: swap R and B */
+ red_xbar = 2; /* R from B */
+ blue_xbar = 2; /* B from R */
+ break;
+ case SURFACE_PIXEL_FORMAT_GRPH_RGBA8888:
+ /* rotate ARGB -> RGBA */
+ red_xbar = 3; /* R from A */
+ green_xbar = 3; /* G from R */
+ blue_xbar = 3; /* B from G */
+ alpha_xbar = 3; /* A from B */
+ break;
+ default:
+ break;
}
- REG_SET_2(GRPH_SWAP_CNTL, 0,
+ REG_SET_4(GRPH_SWAP_CNTL, 0,
GRPH_RED_CROSSBAR, red_xbar,
- GRPH_BLUE_CROSSBAR, blue_xbar);
+ GRPH_GREEN_CROSSBAR, green_xbar,
+ GRPH_BLUE_CROSSBAR, blue_xbar,
+ GRPH_ALPHA_CROSSBAR, alpha_xbar);
switch (format) {
case SURFACE_PIXEL_FORMAT_GRPH_PALETA_256_COLORS:
diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_mem_input.h b/drivers/gpu/drm/amd/display/dc/dce/dce_mem_input.h
index e34e445a4013..a593842ee879 100644
--- a/drivers/gpu/drm/amd/display/dc/dce/dce_mem_input.h
+++ b/drivers/gpu/drm/amd/display/dc/dce/dce_mem_input.h
@@ -189,7 +189,9 @@ struct dce_mem_input_registers {
SFB(blk, GRPH_PITCH, GRPH_PITCH, mask_sh),\
SFB(blk, HW_ROTATION, GRPH_ROTATION_ANGLE, mask_sh),\
SFB(blk, GRPH_SWAP_CNTL, GRPH_RED_CROSSBAR, mask_sh),\
+ SFB(blk, GRPH_SWAP_CNTL, GRPH_GREEN_CROSSBAR, mask_sh),\
SFB(blk, GRPH_SWAP_CNTL, GRPH_BLUE_CROSSBAR, mask_sh),\
+ SFB(blk, GRPH_SWAP_CNTL, GRPH_ALPHA_CROSSBAR, mask_sh),\
SFB(blk, PRESCALE_GRPH_CONTROL, GRPH_PRESCALE_SELECT, mask_sh),\
SFB(blk, PRESCALE_GRPH_CONTROL, GRPH_PRESCALE_R_SIGN, mask_sh),\
SFB(blk, PRESCALE_GRPH_CONTROL, GRPH_PRESCALE_G_SIGN, mask_sh),\
@@ -213,7 +215,9 @@ struct dce_mem_input_registers {
SFB(blk, GRPH_Y_END, GRPH_Y_END, mask_sh),\
SFB(blk, GRPH_PITCH, GRPH_PITCH, mask_sh),\
SFB(blk, GRPH_SWAP_CNTL, GRPH_RED_CROSSBAR, mask_sh),\
+ SFB(blk, GRPH_SWAP_CNTL, GRPH_GREEN_CROSSBAR, mask_sh),\
SFB(blk, GRPH_SWAP_CNTL, GRPH_BLUE_CROSSBAR, mask_sh),\
+ SFB(blk, GRPH_SWAP_CNTL, GRPH_ALPHA_CROSSBAR, mask_sh),\
SFB(blk, PRESCALE_GRPH_CONTROL, GRPH_PRESCALE_SELECT, mask_sh),\
SFB(blk, PRESCALE_GRPH_CONTROL, GRPH_PRESCALE_R_SIGN, mask_sh),\
SFB(blk, PRESCALE_GRPH_CONTROL, GRPH_PRESCALE_G_SIGN, mask_sh),\
@@ -344,7 +348,9 @@ struct dce_mem_input_registers {
type GRPH_PITCH; \
type GRPH_ROTATION_ANGLE; \
type GRPH_RED_CROSSBAR; \
+ type GRPH_GREEN_CROSSBAR; \
type GRPH_BLUE_CROSSBAR; \
+ type GRPH_ALPHA_CROSSBAR; \
type GRPH_PRESCALE_SELECT; \
type GRPH_PRESCALE_R_SIGN; \
type GRPH_PRESCALE_G_SIGN; \
--
2.43.0
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [PATCH 32/33] drm/amd/display: [FW Promotion] Release 0.1.85.0
2026-11-16 21:50 [PATCH 00/33] DC Patches November 23, 2026 James Lin
` (30 preceding siblings ...)
2026-11-16 21:51 ` [PATCH 31/33] drm/amd/display: Fix DCE crossbar for RGBA8888 surface format James Lin
@ 2026-11-16 21:51 ` James Lin
2026-11-16 21:51 ` [PATCH 33/33] drm/amd/display: Promote DC to 3.2.408 James Lin
32 siblings, 0 replies; 34+ messages in thread
From: James Lin @ 2026-11-16 21:51 UTC (permalink / raw)
To: amd-gfx
Cc: Harry Wentland, Leo Li, Aurabindo Pillai, Roman Li, Wayne Lin,
Tom Chung, Fangzhi Zuo, Dan Wheeler, Ray Wu, Ivan Lipski,
Alex Hung, James Lin, Chenyu Chen, Taimur Hassan, James Lin
From: Taimur Hassan <Syed.Hassan@amd.com>
Updated display microcontroller (DMUB) interface
- Add the PSR command DMUB_CMD__PSR_SET_EXTERNAL_DISPLAY_CONNECTED
to tell the firmware whether an external (non-eDP) display is
connected. While it is set, the firmware skips HUBP/DPG memory
control for PSR.
- Add the Replay general command subtype
REPLAY_GENERAL_CMD_SET_EXTERNAL_DISPLAY_CONNECTED.
Signed-off-by: Taimur Hassan <Syed.Hassan@amd.com>
Signed-off-by: James Lin <pinglei.lin@amd.com>
---
.../gpu/drm/amd/display/dmub/inc/dmub_cmd.h | 48 +++++++++++++++++++
1 file changed, 48 insertions(+)
diff --git a/drivers/gpu/drm/amd/display/dmub/inc/dmub_cmd.h b/drivers/gpu/drm/amd/display/dmub/inc/dmub_cmd.h
index e9eee64fd834..3b0c9707437e 100644
--- a/drivers/gpu/drm/amd/display/dmub/inc/dmub_cmd.h
+++ b/drivers/gpu/drm/amd/display/dmub/inc/dmub_cmd.h
@@ -3817,6 +3817,11 @@ enum dmub_cmd_psr_type {
* Set PSR power option
*/
DMUB_CMD__SET_PSR_POWER_OPT = 7,
+ /**
+ * Set whether an external (non-eDP) display is connected.
+ * While set, FW skips HUBP/DPG memory control for PSR.
+ */
+ DMUB_CMD__PSR_SET_EXTERNAL_DISPLAY_CONNECTED = 8,
};
/**
@@ -4568,6 +4573,44 @@ struct dmub_rb_cmd_psr_set_power_opt {
struct dmub_cmd_psr_set_power_opt_data psr_set_power_opt_data;
};
+/**
+ * Data passed from driver to FW in a DMUB_CMD__PSR_SET_EXTERNAL_DISPLAY_CONNECTED command.
+ */
+struct dmub_cmd_psr_set_external_display_connected_data {
+ /**
+ * PSR control version.
+ */
+ uint8_t cmd_version;
+ /**
+ * Panel Instance.
+ * Panel instance to identify which psr_state to use
+ * Currently the support is only for 0 or 1
+ */
+ uint8_t panel_inst;
+ /**
+ * 1 if an external (non-eDP) display is connected, 0 otherwise.
+ */
+ uint8_t external_display_connected;
+ /**
+ * Explicit padding to 4 byte boundary.
+ */
+ uint8_t pad;
+};
+
+/**
+ * Definition of a DMUB_CMD__PSR_SET_EXTERNAL_DISPLAY_CONNECTED command.
+ */
+struct dmub_rb_cmd_psr_set_external_display_connected {
+ /**
+ * Command header.
+ */
+ struct dmub_cmd_header header;
+ /**
+ * Definition of a DMUB_CMD__PSR_SET_EXTERNAL_DISPLAY_CONNECTED command.
+ */
+ struct dmub_cmd_psr_set_external_display_connected_data psr_set_external_display_connected_data;
+};
+
enum dmub_alpm_mode {
ALPM_AUXWAKE = 0,
ALPM_AUXLESS = 1,
@@ -4766,6 +4809,7 @@ enum dmub_cmd_replay_general_subtype {
REPLAY_GENERAL_CMD_SET_CONTINUOUSLY_RESYNC,
REPLAY_GENERAL_CMD_SET_COASTING_VTOTAL_WITHOUT_FRAME_UPDATE,
REPLAY_GENERAL_CMD_LIVE_CAPTURE_WITH_CVT,
+ REPLAY_GENERAL_CMD_SET_EXTERNAL_DISPLAY_CONNECTED,
};
struct dmub_alpm_auxless_data {
@@ -8009,6 +8053,10 @@ union dmub_rb_cmd {
* Definition of a DMUB_CMD__SET_PSR_POWER_OPT command.
*/
struct dmub_rb_cmd_psr_set_power_opt psr_set_power_opt;
+ /**
+ * Definition of a DMUB_CMD__PSR_SET_EXTERNAL_DISPLAY_CONNECTED command.
+ */
+ struct dmub_rb_cmd_psr_set_external_display_connected psr_set_external_display_connected;
/**
* Definition of a DMUB_CMD__PLAT_54186_WA command.
*/
--
2.43.0
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [PATCH 33/33] drm/amd/display: Promote DC to 3.2.408
2026-11-16 21:50 [PATCH 00/33] DC Patches November 23, 2026 James Lin
` (31 preceding siblings ...)
2026-11-16 21:51 ` [PATCH 32/33] drm/amd/display: [FW Promotion] Release 0.1.85.0 James Lin
@ 2026-11-16 21:51 ` James Lin
32 siblings, 0 replies; 34+ messages in thread
From: James Lin @ 2026-11-16 21:51 UTC (permalink / raw)
To: amd-gfx
Cc: Harry Wentland, Leo Li, Aurabindo Pillai, Roman Li, Wayne Lin,
Tom Chung, Fangzhi Zuo, Dan Wheeler, Ray Wu, Ivan Lipski,
Alex Hung, James Lin, Chenyu Chen, Taimur Hassan, James Lin
From: Taimur Hassan <Syed.Hassan@amd.com>
This version brings along the following updates:
- Rename DPMS to DPMS_v1
- Power up eDP when detect link
- Add DPMS-v2 files
- Refactor DP retrain link HW sequence
- Add extra 0.25 line reserved for TSetup/TCalc inefficiency
- Use panel luminance range for AUX backlight in power module
- Read PWM back linearly with the linear backlight curve
- Add API to set brightness percent
- Pass linear brightness percent to power module
- Add DPMS-v2 types
- Always apply 0ppm pixel clock adjustment
- Add otg versions of get_vblank_counter/scanoutpos
- Queue vblank control work to sleepable context
- Fix KUnit tests for vblank control rework
- Add urgent request and assertion probes
- Fix G7 P-state aperture addresses
- Set stream min/max refresh from VRR config
- Add DC2 wrapped initialization for DCN401
- Honor the Replay stream regeneration wait event
- Disable Replay when link off frame count is below 2
- Skip DSC padding borrow estimate for zero padding
- Drop unused DC interfaces
- Let the DC2 commit replace or keep a stream
- Support two streams in the dcn401 DC2 builders
- Add a plane beside a kept plane in DC2 update
- Keep an unchanged stream in the DC2 commit
- Change the ODM and MPC layout in DC2 update
- Give the DC2 builders State pipe facts
- Add RGBA8888 surface pixel format support
- Fix DCE crossbar for RGBA8888 surface format
Signed-off-by: Taimur Hassan <Syed.Hassan@amd.com>
Signed-off-by: James Lin <pinglei.lin@amd.com>
---
drivers/gpu/drm/amd/display/dc/dc.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/amd/display/dc/dc.h b/drivers/gpu/drm/amd/display/dc/dc.h
index 7d0a47e7bc1a..908021f1ee36 100644
--- a/drivers/gpu/drm/amd/display/dc/dc.h
+++ b/drivers/gpu/drm/amd/display/dc/dc.h
@@ -69,7 +69,7 @@ struct dcn_dsc_reg_state;
struct dcn_optc_reg_state;
struct dcn_dccg_reg_state;
-#define DC_VER "3.2.407"
+#define DC_VER "3.2.408"
/**
* MAX_SURFACES - representative of the upper bound of surfaces that can be piped to a single CRTC
--
2.43.0
^ permalink raw reply related [flat|nested] 34+ messages in thread
end of thread, other threads:[~2026-11-17 17:18 UTC | newest]
Thread overview: 34+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-16 21:50 [PATCH 00/33] DC Patches November 23, 2026 James Lin
2026-11-16 21:50 ` [PATCH 01/33] drm/amd/display: Clear OTG_AUTO_FORCE_VSYNC_MODE on OTG disable James Lin
2026-11-16 21:50 ` [PATCH 02/33] drm/amd/display: Rename DPMS to DPMS_v1 James Lin
2026-11-16 21:50 ` [PATCH 03/33] drm/amd/display: Power up eDP when detect link James Lin
2026-11-16 21:50 ` [PATCH 04/33] drm/amd/display: Add DPMS-v2 files James Lin
2026-11-16 21:50 ` [PATCH 05/33] drm/amd/display: Refactor DP retrain link HW sequence James Lin
2026-11-16 21:50 ` [PATCH 06/33] drm/amd/display: add extra 0.25 line reserved for TSetup/TCalc inefficiency James Lin
2026-11-16 21:50 ` [PATCH 07/33] drm/amd/display: Use panel luminance range for AUX backlight in power module James Lin
2026-11-16 21:50 ` [PATCH 08/33] drm/amd/display: Read PWM back linearly with the linear backlight curve James Lin
2026-11-16 21:50 ` [PATCH 09/33] drm/amd/display: Add API to set brightness percent James Lin
2026-11-16 21:50 ` [PATCH 10/33] drm/amd/display: Pass linear brightness percent to power module James Lin
2026-11-16 21:50 ` [PATCH 11/33] drm/amd/display: Add DPMS-v2 types James Lin
2026-11-16 21:50 ` [PATCH 12/33] drm/amd/display: Always apply 0ppm pixel clock adjustment James Lin
2026-11-16 21:50 ` [PATCH 13/33] drm/amd/display: Add otg versions of get_vblank_counter/scanoutpos James Lin
2026-11-16 21:50 ` [PATCH 14/33] drm/amd/display: Queue vblank control work to sleepable context James Lin
2026-11-16 21:50 ` [PATCH 15/33] drm/amd/display: Fix KUnit tests for vblank control rework James Lin
2026-11-16 21:50 ` [PATCH 16/33] drm/amd/display: Add urgent request and assertion probes James Lin
2026-11-16 21:50 ` [PATCH 17/33] drm/amd/display: Fix G7 P-state aperture addresses James Lin
2026-11-16 21:50 ` [PATCH 18/33] drm/amd/display: Set stream min/max refresh from VRR config James Lin
2026-11-16 21:50 ` [PATCH 19/33] drm/amd/display: Add DC2 wrapped initialization for DCN401 James Lin
2026-11-16 21:50 ` [PATCH 20/33] drm/amd/display: Honor the Replay stream regeneration wait event James Lin
2026-11-16 21:50 ` [PATCH 21/33] drm/amd/display: Disable Replay when link off frame count is below 2 James Lin
2026-11-16 21:50 ` [PATCH 22/33] drm/amd/display: Skip DSC padding borrow estimate for zero padding James Lin
2026-11-16 21:51 ` [PATCH 23/33] drm/amd/display: Drop unused DC interfaces James Lin
2026-11-16 21:51 ` [PATCH 24/33] drm/amd/display: Let the DC2 commit replace or keep a stream James Lin
2026-11-16 21:51 ` [PATCH 25/33] drm/amd/display: Support two streams in the dcn401 DC2 builders James Lin
2026-11-16 21:51 ` [PATCH 26/33] drm/amd/display: Add a plane beside a kept plane in DC2 update James Lin
2026-11-16 21:51 ` [PATCH 27/33] drm/amd/display: Keep an unchanged stream in the DC2 commit James Lin
2026-11-16 21:51 ` [PATCH 28/33] drm/amd/display: Change the ODM and MPC layout in DC2 update James Lin
2026-11-16 21:51 ` [PATCH 29/33] drm/amd/display: Give the DC2 builders State pipe facts James Lin
2026-11-16 21:51 ` [PATCH 30/33] drm/amd/display: Add RGBA8888 surface pixel format support James Lin
2026-11-16 21:51 ` [PATCH 31/33] drm/amd/display: Fix DCE crossbar for RGBA8888 surface format James Lin
2026-11-16 21:51 ` [PATCH 32/33] drm/amd/display: [FW Promotion] Release 0.1.85.0 James Lin
2026-11-16 21:51 ` [PATCH 33/33] drm/amd/display: Promote DC to 3.2.408 James Lin
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.