From: Tony Cheng <[email protected]> dc_commit_state_no_check is one function, so Core2 has no place to run the hardware span of a commit. Calling that span from Core2 would put a DC1 helper on the Core2 path, which a native commit is not allowed to do. A Core2 display therefore cannot be lit, and a native builder has nowhere to attach.
Split the hardware span out as legacy_commit_state_hw and dispatch it through commit_state_hw on dc2_funcs. The shim calls the Core2 function only when DC2_SELECTION_CORE2 is set. Every other selection keeps the prologue, the legacy span and the epilogue, including the early return when the hardware span fails. core2_commit_state_hw returns DC_NOT_SUPPORTED and does not fall back to DC1. The builders a later native commit needs are created once in core2_construct and stored on struct dc2. Hardware init reads that table instead of calling the factory again. A DCN with no builder factory keeps NULL slots. Cc: Jun Lei <[email protected]> Signed-off-by: Tony Cheng <[email protected]> Signed-off-by: Wayne Lin <[email protected]> --- drivers/gpu/drm/amd/display/dc/core/dc.c | 46 ++++++++++++------- .../gpu/drm/amd/display/dc/core2/dc_core2.c | 17 ++++++- .../gpu/drm/amd/display/dc/core2/dc_core2.h | 1 + .../drm/amd/display/dc/core2/dc_core2_init.c | 2 +- .../display/dc/core2/dc_core2_legacy_init.c | 2 +- .../amd/display/dc/dc_api_dispatch/api_shim.c | 7 +++ .../amd/display/dc/dc_api_dispatch/api_shim.h | 5 +- .../amd/display/dc/inc/dc_core_interface.h | 5 ++ 8 files changed, 65 insertions(+), 20 deletions(-) diff --git a/drivers/gpu/drm/amd/display/dc/core/dc.c b/drivers/gpu/drm/amd/display/dc/core/dc.c index 8344d821d2e8..6b90c88b6cc3 100644 --- a/drivers/gpu/drm/amd/display/dc/core/dc.c +++ b/drivers/gpu/drm/amd/display/dc/core/dc.c @@ -2348,31 +2348,17 @@ static void determine_pipe_unlock_order(struct dc *dc, struct dc_state *context) } } -/** - * dc_commit_state_no_check - Apply context to the hardware - * - * @dc: DC object with the current status to be updated - * @context: New state that will become the current status at the end of this function - * - * Applies given context to the hardware and copy it into current context. - * It's up to the user to release the src context afterwards. - * - * Return: an enum dc_status result code for the operation - */ -static enum dc_status dc_commit_state_no_check(struct dc *dc, struct dc_state *context) +/* Hardware span of a commit. The API shim picks Core2 or this body. */ +enum dc_status legacy_commit_state_hw(struct dc *dc, struct dc_state *context) { struct dc_bios *dcb = dc->ctx->dc_bios; enum dc_status result = DC_ERROR_UNEXPECTED; struct pipe_ctx *pipe; unsigned int i, k, l; struct dc_stream_state *dc_streams[MAX_STREAMS] = {0}; - struct dc_state *old_state; bool subvp_prev_use = false; bool dmub_locked = false; - dc_z10_restore(dc); - dc_allow_idle_optimizations(dc, false); - for (i = 0; i < dc->res_pool->pipe_count; i++) { struct pipe_ctx *old_pipe = &dc->current_state->res_ctx.pipe_ctx[i]; @@ -2564,6 +2550,33 @@ static enum dc_status dc_commit_state_no_check(struct dc *dc, struct dc_state *c if (dc->hwss.update_dsc_pg) dc->hwss.update_dsc_pg(dc, context, true); + return result; +} + +/** + * dc_commit_state_no_check - Apply context to the hardware + * + * @dc: DC object with the current status to be updated + * @context: New state that will become the current status at the end of this function + * + * Applies given context to the hardware and copy it into current context. + * It's up to the user to release the src context afterwards. + * + * Return: an enum dc_status result code for the operation + */ +static enum dc_status dc_commit_state_no_check(struct dc *dc, struct dc_state *context) +{ + enum dc_status result; + unsigned int i; + struct dc_state *old_state; + + dc_z10_restore(dc); + dc_allow_idle_optimizations(dc, false); + + result = api_shim_commit_state_hw(dc, context); + if (result != DC_OK) + return result; + if (dc->ctx->dce_version >= DCE_VERSION_MAX) TRACE_DCN_CLOCK_STATE(&context->bw_ctx.bw.dcn.clk); else @@ -6771,6 +6784,7 @@ void legacy_hardware_release(struct dc *dc) static const struct dc2_funcs dc2_legacy_funcs_table = { .hardware_init = legacy_hardware_init, .hardware_release = legacy_hardware_release, + .commit_state_hw = legacy_commit_state_hw, }; const struct dc2_funcs *dc2_legacy_funcs(void) 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 f496e4d66575..8ef078e01dd4 100644 --- a/drivers/gpu/drm/amd/display/dc/core2/dc_core2.c +++ b/drivers/gpu/drm/amd/display/dc/core2/dc_core2.c @@ -7,6 +7,7 @@ #include "dc.h" #include "core2/dc_core2.h" #include "core2/dc_core2_init.h" +#include "dc_api_dispatch/api_shim.h" static void core2_hardware_release(struct dc *dc) { @@ -16,6 +17,7 @@ static void core2_hardware_release(struct dc *dc) static const struct dc2_funcs core2_funcs_table = { .hardware_init = core2_hardware_init, .hardware_release = core2_hardware_release, + .commit_state_hw = core2_commit_state_hw, }; const struct dc2_funcs *core2_funcs(void) @@ -25,10 +27,23 @@ const struct dc2_funcs *core2_funcs(void) void core2_construct(struct dc *dc) { - (void)dc; + struct dc2 *dc2 = TO_DC2(dc); + unsigned int name; + + for (name = 0; name < BLS_BUILDER_NAME_COUNT; name++) + dc2->builders[name] = bls_builder_create(dc, name); } void core2_destruct(struct dc *dc) { (void)dc; } + +/* 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) +{ + (void)dc; + (void)context; + + return DC_NOT_SUPPORTED; +} diff --git a/drivers/gpu/drm/amd/display/dc/core2/dc_core2.h b/drivers/gpu/drm/amd/display/dc/core2/dc_core2.h index a761e85a9973..7537863dcda4 100644 --- a/drivers/gpu/drm/amd/display/dc/core2/dc_core2.h +++ b/drivers/gpu/drm/amd/display/dc/core2/dc_core2.h @@ -15,5 +15,6 @@ struct dc_core2 { /* Core2-local; selection lives in the API shim, not here. */ const struct dc2_funcs *core2_funcs(void); +enum dc_status core2_commit_state_hw(struct dc *dc, struct dc_state *context); void core2_construct(struct dc *dc); 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 69a376351df1..319aa3e219d2 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 @@ -42,7 +42,7 @@ static void core2_run_native_hardware_init(struct dc *dc) const struct bls_builder *builder; enum bls_builder_result result; - builder = bls_builder_create(dc, DCN_DECL_INITIALIZATION); + builder = TO_DC2(dc)->builders[DCN_DECL_INITIALIZATION]; if (!builder || builder->kind != BLS_BUILDER_DECLARATIVE || !builder->build.declarative) return; diff --git a/drivers/gpu/drm/amd/display/dc/core2/dc_core2_legacy_init.c b/drivers/gpu/drm/amd/display/dc/core2/dc_core2_legacy_init.c index 285dfc9e6e69..760cb25e9cbe 100644 --- a/drivers/gpu/drm/amd/display/dc/core2/dc_core2_legacy_init.c +++ b/drivers/gpu/drm/amd/display/dc/core2/dc_core2_legacy_init.c @@ -199,7 +199,7 @@ bool core2_run_legacy_hardware_init(struct dc *dc, info = &dc->current_state->hw_init_info; memset(info, 0, sizeof(*info)); info->next_stage = LEGACY_INIT_STAGE_CLOCKS; - builder = bls_builder_create(dc, DCN_DECL_INITIALIZATION_LEGACY); + builder = TO_DC2(dc)->builders[DCN_DECL_INITIALIZATION_LEGACY]; if (!builder || builder->kind != BLS_BUILDER_DECLARATIVE || !builder->build.declarative) return false; 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 3dcfde8308c5..eca9b2de92fa 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 @@ -30,3 +30,10 @@ void dc_hardware_release(struct dc *dc) else legacy_hardware_release(dc); } + +enum dc_status api_shim_commit_state_hw(struct dc *dc, struct dc_state *context) +{ + if (TO_DC2(dc)->selection == DC2_SELECTION_CORE2) + return core2_funcs()->commit_state_hw(dc, context); + return legacy_commit_state_hw(dc, context); +} 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 b972ae06663d..6d9ad4192296 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 @@ -7,7 +7,7 @@ #include "dc.h" #include "inc/dc_core_interface.h" -#include "bls_builder/dmub_abi.h" +#include "bls_builder/bls_builder.h" struct dc2 { /* First member: TO_DC2 is a typed upcast, not container_of. */ @@ -16,8 +16,11 @@ struct dc2 { /* 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]; }; #define TO_DC2(ptr) ((struct dc2 *)(ptr)) void api_shim_construct(struct dc *dc, const struct dc_init_data *init_params); +enum dc_status api_shim_commit_state_hw(struct dc *dc, struct dc_state *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 35a6218c1285..383d14af91f1 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 @@ -5,7 +5,10 @@ #pragma once +#include "core_status.h" + struct dc; +struct dc_state; /* * Construction-time Core implementation selection. Zero is LEGACY so existing @@ -24,8 +27,10 @@ enum dc2_hw_ownership { struct dc2_funcs { void (*hardware_init)(struct dc *dc); void (*hardware_release)(struct dc *dc); + enum dc_status (*commit_state_hw)(struct dc *dc, struct dc_state *context); }; void legacy_hardware_init(struct dc *dc); void legacy_hardware_release(struct dc *dc); +enum dc_status legacy_commit_state_hw(struct dc *dc, struct dc_state *context); const struct dc2_funcs *dc2_legacy_funcs(void); -- 2.43.0
