drm/amd/display: Move FPU Guards From DML To DC - Part 1

[Why]
FPU guards (DC_FP_START/DC_FP_END) are required to wrap around code that
can manipulates floats. To do this properly, the FPU guards must be used
in a file that is not compiled as a FPU unit. If the guards are used in
a file that is a FPU unit, other sections in the file that aren't guarded
may be end up being compiled to use FPU operations.

[How]
Added DC_FP_START and DC_FP_END to DC functions that call DML functions
using FPU.

Reviewed-by: Dillon Varone <dillon.varone@amd.com>
Signed-off-by: Rafal Ostrowski <rafal.ostrowski@amd.com>
Signed-off-by: Alex Hung <alex.hung@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
Rafal Ostrowski 2026-02-24 15:36:09 +01:00 committed by Alex Deucher
parent 02c3060ee3
commit 3539437f35
14 changed files with 171 additions and 54 deletions

View File

@ -53,11 +53,30 @@ inline void dc_assert_fp_enabled(void)
{ {
int depth; int depth;
depth = __this_cpu_read(fpu_recursion_depth); depth = this_cpu_read(fpu_recursion_depth);
ASSERT(depth >= 1); ASSERT(depth >= 1);
} }
/**
* dc_assert_fp_enabled - Check if FPU protection is enabled
*
* This function tells if the code is already under FPU protection or not. A
* function that works as an API for a set of FPU operations can use this
* function for checking if the caller invoked it after DC_FP_START(). For
* example, take a look at dcn20_fpu.c file.
*
* Similar to dc_assert_fp_enabled, but does not assert, returns status instead.
*/
inline bool dc_is_fp_enabled(void)
{
int depth;
depth = this_cpu_read(fpu_recursion_depth);
return (depth >= 1);
}
/** /**
* dc_fpu_begin - Enables FPU protection * dc_fpu_begin - Enables FPU protection
* @function_name: A string containing the function name for debug purposes * @function_name: A string containing the function name for debug purposes
@ -77,7 +96,7 @@ void dc_fpu_begin(const char *function_name, const int line)
WARN_ON_ONCE(!in_task()); WARN_ON_ONCE(!in_task());
preempt_disable(); preempt_disable();
depth = __this_cpu_inc_return(fpu_recursion_depth); depth = this_cpu_inc_return(fpu_recursion_depth);
if (depth == 1) { if (depth == 1) {
BUG_ON(!kernel_fpu_available()); BUG_ON(!kernel_fpu_available());
kernel_fpu_begin(); kernel_fpu_begin();
@ -100,7 +119,7 @@ void dc_fpu_end(const char *function_name, const int line)
{ {
int depth; int depth;
depth = __this_cpu_dec_return(fpu_recursion_depth); depth = this_cpu_dec_return(fpu_recursion_depth);
if (depth == 0) { if (depth == 0) {
kernel_fpu_end(); kernel_fpu_end();
} else { } else {

View File

@ -28,15 +28,30 @@
#define __DC_FPU_H__ #define __DC_FPU_H__
void dc_assert_fp_enabled(void); void dc_assert_fp_enabled(void);
bool dc_is_fp_enabled(void);
void dc_fpu_begin(const char *function_name, const int line); void dc_fpu_begin(const char *function_name, const int line);
void dc_fpu_end(const char *function_name, const int line); void dc_fpu_end(const char *function_name, const int line);
#ifndef _LINUX_FPU_COMPILATION_UNIT #ifndef _LINUX_FPU_COMPILATION_UNIT
#define DC_FP_START() dc_fpu_begin(__func__, __LINE__) #define DC_FP_START() dc_fpu_begin(__func__, __LINE__)
#define DC_FP_END() dc_fpu_end(__func__, __LINE__) #define DC_FP_END() dc_fpu_end(__func__, __LINE__)
#ifdef CONFIG_DRM_AMD_DC_FP
#define DC_RUN_WITH_PREEMPTION_ENABLED(code) \
do { \
bool dc_fp_enabled = dc_is_fp_enabled(); \
if (dc_fp_enabled) \
DC_FP_END(); \
code; \
if (dc_fp_enabled) \
DC_FP_START(); \
} while (0)
#else
#define DC_RUN_WITH_PREEMPTION_ENABLED(code) code
#endif // !CONFIG_DRM_AMD_DC_FP
#else #else
#define DC_FP_START() BUILD_BUG() #define DC_FP_START() BUILD_BUG()
#define DC_FP_END() BUILD_BUG() #define DC_FP_END() BUILD_BUG()
#endif #define DC_RUN_WITH_PREEMPTION_ENABLED(code) code
#endif // !_LINUX_FPU_COMPILATION_UNIT
#endif /* __DC_FPU_H__ */ #endif /* __DC_FPU_H__ */

View File

@ -421,10 +421,8 @@ static void dcn3_get_memclk_states_from_smu(struct clk_mgr *clk_mgr_base)
clk_mgr_base->bw_params->dc_mode_softmax_memclk = dcn30_smu_get_dc_mode_max_dpm_freq(clk_mgr, PPCLK_UCLK); clk_mgr_base->bw_params->dc_mode_softmax_memclk = dcn30_smu_get_dc_mode_max_dpm_freq(clk_mgr, PPCLK_UCLK);
/* Refresh bounding box */ /* Refresh bounding box */
DC_FP_START();
clk_mgr_base->ctx->dc->res_pool->funcs->update_bw_bounding_box( clk_mgr_base->ctx->dc->res_pool->funcs->update_bw_bounding_box(
clk_mgr->base.ctx->dc, clk_mgr_base->bw_params); clk_mgr->base.ctx->dc, clk_mgr_base->bw_params);
DC_FP_END();
} }
static bool dcn3_is_smu_present(struct clk_mgr *clk_mgr_base) static bool dcn3_is_smu_present(struct clk_mgr *clk_mgr_base)

View File

@ -1059,11 +1059,9 @@ static void dcn32_get_memclk_states_from_smu(struct clk_mgr *clk_mgr_base)
if (!clk_mgr->dpm_present) if (!clk_mgr->dpm_present)
dcn32_patch_dpm_table(clk_mgr_base->bw_params); dcn32_patch_dpm_table(clk_mgr_base->bw_params);
DC_FP_START();
/* Refresh bounding box */ /* Refresh bounding box */
clk_mgr_base->ctx->dc->res_pool->funcs->update_bw_bounding_box( clk_mgr_base->ctx->dc->res_pool->funcs->update_bw_bounding_box(
clk_mgr->base.ctx->dc, clk_mgr_base->bw_params); clk_mgr->base.ctx->dc, clk_mgr_base->bw_params);
DC_FP_END();
} }
static bool dcn32_are_clock_states_equal(struct dc_clocks *a, static bool dcn32_are_clock_states_equal(struct dc_clocks *a,

View File

@ -1096,11 +1096,8 @@ static bool dc_construct(struct dc *dc,
#ifdef CONFIG_DRM_AMD_DC_FP #ifdef CONFIG_DRM_AMD_DC_FP
dc->clk_mgr->force_smu_not_present = init_params->force_smu_not_present; dc->clk_mgr->force_smu_not_present = init_params->force_smu_not_present;
if (dc->res_pool->funcs->update_bw_bounding_box) { if (dc->res_pool->funcs->update_bw_bounding_box)
DC_FP_START();
dc->res_pool->funcs->update_bw_bounding_box(dc, dc->clk_mgr->bw_params); dc->res_pool->funcs->update_bw_bounding_box(dc, dc->clk_mgr->bw_params);
DC_FP_END();
}
dc->soc_and_ip_translator = dc_create_soc_and_ip_translator(dc_ctx->dce_version); dc->soc_and_ip_translator = dc_create_soc_and_ip_translator(dc_ctx->dce_version);
if (!dc->soc_and_ip_translator) if (!dc->soc_and_ip_translator)
goto fail; goto fail;

View File

@ -205,19 +205,33 @@ struct dc_state *dc_state_create(struct dc *dc, struct dc_state_create_params *p
state->power_source = params ? params->power_source : DC_POWER_SOURCE_AC; state->power_source = params ? params->power_source : DC_POWER_SOURCE_AC;
#ifdef CONFIG_DRM_AMD_DC_FP #ifdef CONFIG_DRM_AMD_DC_FP
bool status;
if (dc->debug.using_dml2) { if (dc->debug.using_dml2) {
if (!dml2_create(dc, &dc->dml2_options, &state->bw_ctx.dml2)) { DC_FP_START();
status = dml2_create(dc, &dc->dml2_options, &state->bw_ctx.dml2);
DC_FP_END();
if (!status) {
dc_state_release(state); dc_state_release(state);
return NULL; return NULL;
} }
if (dc->caps.dcmode_power_limits_present && !dml2_create(dc, &dc->dml2_dc_power_options, &state->bw_ctx.dml2_dc_power_source)) { if (dc->caps.dcmode_power_limits_present) {
dc_state_release(state); bool status;
return NULL;
DC_FP_START();
status = dml2_create(dc, &dc->dml2_dc_power_options, &state->bw_ctx.dml2_dc_power_source);
DC_FP_END();
if (!status) {
dc_state_release(state);
return NULL;
}
} }
} }
#endif #endif // CONFIG_DRM_AMD_DC_FP
kref_init(&state->refcount); kref_init(&state->refcount);
return state; return state;
@ -235,14 +249,20 @@ void dc_state_copy(struct dc_state *dst_state, struct dc_state *src_state)
#ifdef CONFIG_DRM_AMD_DC_FP #ifdef CONFIG_DRM_AMD_DC_FP
dst_state->bw_ctx.dml2 = dst_dml2; dst_state->bw_ctx.dml2 = dst_dml2;
if (src_state->bw_ctx.dml2) if (src_state->bw_ctx.dml2) {
DC_FP_START();
dml2_copy(dst_state->bw_ctx.dml2, src_state->bw_ctx.dml2); dml2_copy(dst_state->bw_ctx.dml2, src_state->bw_ctx.dml2);
DC_FP_END();
}
dst_state->bw_ctx.dml2_dc_power_source = dst_dml2_dc_power_source; dst_state->bw_ctx.dml2_dc_power_source = dst_dml2_dc_power_source;
if (src_state->bw_ctx.dml2_dc_power_source)
dml2_copy(dst_state->bw_ctx.dml2_dc_power_source, src_state->bw_ctx.dml2_dc_power_source);
#endif
if (src_state->bw_ctx.dml2_dc_power_source) {
DC_FP_START();
dml2_copy(dst_state->bw_ctx.dml2_dc_power_source, src_state->bw_ctx.dml2_dc_power_source);
DC_FP_END();
}
#endif // CONFIG_DRM_AMD_DC_FP
/* context refcount should not be overridden */ /* context refcount should not be overridden */
dst_state->refcount = refcount; dst_state->refcount = refcount;
} }
@ -258,22 +278,35 @@ struct dc_state *dc_state_create_copy(struct dc_state *src_state)
dc_state_copy_internal(new_state, src_state); dc_state_copy_internal(new_state, src_state);
#ifdef CONFIG_DRM_AMD_DC_FP #ifdef CONFIG_DRM_AMD_DC_FP
bool status;
new_state->bw_ctx.dml2 = NULL; new_state->bw_ctx.dml2 = NULL;
new_state->bw_ctx.dml2_dc_power_source = NULL; new_state->bw_ctx.dml2_dc_power_source = NULL;
if (src_state->bw_ctx.dml2 && if (src_state->bw_ctx.dml2) {
!dml2_create_copy(&new_state->bw_ctx.dml2, src_state->bw_ctx.dml2)) { DC_FP_START();
dc_state_release(new_state); status = dml2_create_copy(&new_state->bw_ctx.dml2, src_state->bw_ctx.dml2);
return NULL; DC_FP_END();
if (!status) {
dc_state_release(new_state);
return NULL;
}
} }
if (src_state->bw_ctx.dml2_dc_power_source &&
!dml2_create_copy(&new_state->bw_ctx.dml2_dc_power_source, src_state->bw_ctx.dml2_dc_power_source)) {
dc_state_release(new_state);
return NULL;
}
#endif
if (src_state->bw_ctx.dml2_dc_power_source) {
DC_FP_START();
status = dml2_create_copy(&new_state->bw_ctx.dml2_dc_power_source,
src_state->bw_ctx.dml2_dc_power_source);
DC_FP_END();
if (!status) {
dc_state_release(new_state);
return NULL;
}
}
#endif // CONFIG_DRM_AMD_DC_FP
kref_init(&new_state->refcount); kref_init(&new_state->refcount);
return new_state; return new_state;
@ -351,11 +384,13 @@ static void dc_state_free(struct kref *kref)
dc_state_destruct(state); dc_state_destruct(state);
#ifdef CONFIG_DRM_AMD_DC_FP #ifdef CONFIG_DRM_AMD_DC_FP
DC_FP_START();
dml2_destroy(state->bw_ctx.dml2); dml2_destroy(state->bw_ctx.dml2);
state->bw_ctx.dml2 = 0; state->bw_ctx.dml2 = 0;
dml2_destroy(state->bw_ctx.dml2_dc_power_source); dml2_destroy(state->bw_ctx.dml2_dc_power_source);
state->bw_ctx.dml2_dc_power_source = 0; state->bw_ctx.dml2_dc_power_source = 0;
DC_FP_END();
#endif #endif
kvfree(state); kvfree(state);

View File

@ -42,6 +42,13 @@
#define MAX(x, y) ((x > y) ? x : y) #define MAX(x, y) ((x > y) ? x : y)
#endif #endif
#include "dc_fpu.h"
#if !defined(DC_RUN_WITH_PREEMPTION_ENABLED)
#define DC_RUN_WITH_PREEMPTION_ENABLED(code) code
#endif // !DC_RUN_WITH_PREEMPTION_ENABLED
/******************************************************************************* /*******************************************************************************
* Private functions * Private functions
******************************************************************************/ ******************************************************************************/
@ -170,12 +177,14 @@ struct dc_stream_state *dc_create_stream_for_sink(
if (sink == NULL) if (sink == NULL)
goto fail; goto fail;
stream = kzalloc_obj(struct dc_stream_state, GFP_ATOMIC); DC_RUN_WITH_PREEMPTION_ENABLED(stream = kzalloc_obj(struct dc_stream_state, GFP_ATOMIC));
if (stream == NULL) if (stream == NULL)
goto fail; goto fail;
stream->update_scratch = kzalloc((int32_t) dc_update_scratch_space_size(), GFP_ATOMIC); DC_RUN_WITH_PREEMPTION_ENABLED(stream->update_scratch =
kzalloc((int32_t) dc_update_scratch_space_size(),
GFP_ATOMIC));
if (stream->update_scratch == NULL) if (stream->update_scratch == NULL)
goto fail; goto fail;

View File

@ -368,8 +368,8 @@ void dcn401_init_hw(struct dc *dc)
dc->res_pool->funcs->update_bw_bounding_box && dc->res_pool->funcs->update_bw_bounding_box &&
dc->clk_mgr && dc->clk_mgr->bw_params) { dc->clk_mgr && dc->clk_mgr->bw_params) {
/* update bounding box if FAMS2 disabled, or if dchub clk has changed */ /* update bounding box if FAMS2 disabled, or if dchub clk has changed */
dc->res_pool->funcs->update_bw_bounding_box(dc, if (dc->clk_mgr)
dc->clk_mgr->bw_params); dc->res_pool->funcs->update_bw_bounding_box(dc, dc->clk_mgr->bw_params);
} }
} }
} }

View File

@ -1738,9 +1738,11 @@ static enum dc_status dcn35_validate_bandwidth(struct dc *dc,
{ {
bool out = false; bool out = false;
DC_FP_START();
out = dml2_validate(dc, context, out = dml2_validate(dc, context,
context->power_source == DC_POWER_SOURCE_DC ? context->bw_ctx.dml2_dc_power_source : context->bw_ctx.dml2, context->power_source == DC_POWER_SOURCE_DC ? context->bw_ctx.dml2_dc_power_source : context->bw_ctx.dml2,
validate_mode); validate_mode);
DC_FP_END();
if (validate_mode != DC_VALIDATE_MODE_AND_PROGRAMMING) if (validate_mode != DC_VALIDATE_MODE_AND_PROGRAMMING)
return out ? DC_OK : DC_FAIL_BANDWIDTH_VALIDATE; return out ? DC_OK : DC_FAIL_BANDWIDTH_VALIDATE;
@ -1774,6 +1776,12 @@ static int populate_dml_pipes_from_context_fpu(struct dc *dc,
return ret; return ret;
} }
void dcn35_update_bw_bounding_box(struct dc *dc, struct clk_bw_params *bw_params)
{
DC_FP_START();
dcn35_update_bw_bounding_box_fpu(dc, bw_params);
DC_FP_END();
}
static struct resource_funcs dcn35_res_pool_funcs = { static struct resource_funcs dcn35_res_pool_funcs = {
.destroy = dcn35_destroy_resource_pool, .destroy = dcn35_destroy_resource_pool,
.link_enc_create = dcn35_link_encoder_create, .link_enc_create = dcn35_link_encoder_create,
@ -1795,7 +1803,7 @@ static struct resource_funcs dcn35_res_pool_funcs = {
.find_first_free_match_stream_enc_for_link = dcn10_find_first_free_match_stream_enc_for_link, .find_first_free_match_stream_enc_for_link = dcn10_find_first_free_match_stream_enc_for_link,
.acquire_post_bldn_3dlut = dcn30_acquire_post_bldn_3dlut, .acquire_post_bldn_3dlut = dcn30_acquire_post_bldn_3dlut,
.release_post_bldn_3dlut = dcn30_release_post_bldn_3dlut, .release_post_bldn_3dlut = dcn30_release_post_bldn_3dlut,
.update_bw_bounding_box = dcn35_update_bw_bounding_box_fpu, .update_bw_bounding_box = dcn35_update_bw_bounding_box,
.patch_unknown_plane_state = dcn35_patch_unknown_plane_state, .patch_unknown_plane_state = dcn35_patch_unknown_plane_state,
.get_panel_config_defaults = dcn35_get_panel_config_defaults, .get_panel_config_defaults = dcn35_get_panel_config_defaults,
.get_preferred_eng_id_dpia = dcn35_get_preferred_eng_id_dpia, .get_preferred_eng_id_dpia = dcn35_get_preferred_eng_id_dpia,

View File

@ -312,4 +312,5 @@ struct resource_pool *dcn35_create_resource_pool(
#define DPP_REG_LIST_DCN35_RI(id)\ #define DPP_REG_LIST_DCN35_RI(id)\
DPP_REG_LIST_DCN30_COMMON_RI(id) DPP_REG_LIST_DCN30_COMMON_RI(id)
void dcn35_update_bw_bounding_box(struct dc *dc, struct clk_bw_params *bw_params);
#endif /* _DCN35_RESOURCE_H_ */ #endif /* _DCN35_RESOURCE_H_ */

View File

@ -1718,9 +1718,11 @@ static enum dc_status dcn351_validate_bandwidth(struct dc *dc,
{ {
bool out = false; bool out = false;
DC_FP_START();
out = dml2_validate(dc, context, out = dml2_validate(dc, context,
context->power_source == DC_POWER_SOURCE_DC ? context->bw_ctx.dml2_dc_power_source : context->bw_ctx.dml2, context->power_source == DC_POWER_SOURCE_DC ? context->bw_ctx.dml2_dc_power_source : context->bw_ctx.dml2,
validate_mode); validate_mode);
DC_FP_END();
if (validate_mode != DC_VALIDATE_MODE_AND_PROGRAMMING) if (validate_mode != DC_VALIDATE_MODE_AND_PROGRAMMING)
return out ? DC_OK : DC_FAIL_BANDWIDTH_VALIDATE; return out ? DC_OK : DC_FAIL_BANDWIDTH_VALIDATE;
@ -1747,6 +1749,12 @@ static int populate_dml_pipes_from_context_fpu(struct dc *dc,
} }
static void dcn351_update_bw_bounding_box(struct dc *dc, struct clk_bw_params *bw_params)
{
DC_FP_START();
dcn351_update_bw_bounding_box_fpu(dc, bw_params);
DC_FP_END();
}
static struct resource_funcs dcn351_res_pool_funcs = { static struct resource_funcs dcn351_res_pool_funcs = {
.destroy = dcn351_destroy_resource_pool, .destroy = dcn351_destroy_resource_pool,
.link_enc_create = dcn35_link_encoder_create, .link_enc_create = dcn35_link_encoder_create,
@ -1768,7 +1776,7 @@ static struct resource_funcs dcn351_res_pool_funcs = {
.find_first_free_match_stream_enc_for_link = dcn10_find_first_free_match_stream_enc_for_link, .find_first_free_match_stream_enc_for_link = dcn10_find_first_free_match_stream_enc_for_link,
.acquire_post_bldn_3dlut = dcn30_acquire_post_bldn_3dlut, .acquire_post_bldn_3dlut = dcn30_acquire_post_bldn_3dlut,
.release_post_bldn_3dlut = dcn30_release_post_bldn_3dlut, .release_post_bldn_3dlut = dcn30_release_post_bldn_3dlut,
.update_bw_bounding_box = dcn351_update_bw_bounding_box_fpu, .update_bw_bounding_box = dcn351_update_bw_bounding_box,
.patch_unknown_plane_state = dcn35_patch_unknown_plane_state, .patch_unknown_plane_state = dcn35_patch_unknown_plane_state,
.get_panel_config_defaults = dcn35_get_panel_config_defaults, .get_panel_config_defaults = dcn35_get_panel_config_defaults,
.get_preferred_eng_id_dpia = dcn351_get_preferred_eng_id_dpia, .get_preferred_eng_id_dpia = dcn351_get_preferred_eng_id_dpia,

View File

@ -1725,9 +1725,11 @@ static enum dc_status dcn35_validate_bandwidth(struct dc *dc,
{ {
bool out = false; bool out = false;
DC_FP_START();
out = dml2_validate(dc, context, out = dml2_validate(dc, context,
context->power_source == DC_POWER_SOURCE_DC ? context->bw_ctx.dml2_dc_power_source : context->bw_ctx.dml2, context->power_source == DC_POWER_SOURCE_DC ? context->bw_ctx.dml2_dc_power_source : context->bw_ctx.dml2,
validate_mode); validate_mode);
DC_FP_END();
if (validate_mode != DC_VALIDATE_MODE_AND_PROGRAMMING) if (validate_mode != DC_VALIDATE_MODE_AND_PROGRAMMING)
return out ? DC_OK : DC_FAIL_BANDWIDTH_VALIDATE; return out ? DC_OK : DC_FAIL_BANDWIDTH_VALIDATE;
@ -1775,7 +1777,7 @@ static struct resource_funcs dcn36_res_pool_funcs = {
.find_first_free_match_stream_enc_for_link = dcn10_find_first_free_match_stream_enc_for_link, .find_first_free_match_stream_enc_for_link = dcn10_find_first_free_match_stream_enc_for_link,
.acquire_post_bldn_3dlut = dcn30_acquire_post_bldn_3dlut, .acquire_post_bldn_3dlut = dcn30_acquire_post_bldn_3dlut,
.release_post_bldn_3dlut = dcn30_release_post_bldn_3dlut, .release_post_bldn_3dlut = dcn30_release_post_bldn_3dlut,
.update_bw_bounding_box = dcn35_update_bw_bounding_box_fpu, .update_bw_bounding_box = dcn35_update_bw_bounding_box,
.patch_unknown_plane_state = dcn20_patch_unknown_plane_state, .patch_unknown_plane_state = dcn20_patch_unknown_plane_state,
.get_panel_config_defaults = dcn35_get_panel_config_defaults, .get_panel_config_defaults = dcn35_get_panel_config_defaults,
.get_preferred_eng_id_dpia = dcn36_get_preferred_eng_id_dpia, .get_preferred_eng_id_dpia = dcn36_get_preferred_eng_id_dpia,

View File

@ -1643,8 +1643,10 @@ static struct dc_cap_funcs cap_funcs = {
.get_subvp_en = dcn32_subvp_in_use, .get_subvp_en = dcn32_subvp_in_use,
}; };
static void dcn401_update_bw_bounding_box(struct dc *dc, struct clk_bw_params *bw_params) static void dcn401_update_bw_bounding_box_fpu(struct dc *dc, struct clk_bw_params *bw_params)
{ {
dc_assert_fp_enabled();
/* re-calculate the available MALL size if required */ /* re-calculate the available MALL size if required */
if (bw_params->num_channels > 0) { if (bw_params->num_channels > 0) {
dc->caps.max_cab_allocation_bytes = dcn401_calc_num_avail_chans_for_mall( dc->caps.max_cab_allocation_bytes = dcn401_calc_num_avail_chans_for_mall(
@ -1653,17 +1655,19 @@ static void dcn401_update_bw_bounding_box(struct dc *dc, struct clk_bw_params *b
dc->caps.mall_size_total = dc->caps.max_cab_allocation_bytes; dc->caps.mall_size_total = dc->caps.max_cab_allocation_bytes;
} }
DC_FP_START();
if (dc->debug.using_dml2 && dc->current_state && dc->current_state->bw_ctx.dml2) if (dc->debug.using_dml2 && dc->current_state && dc->current_state->bw_ctx.dml2)
dml2_reinit(dc, &dc->dml2_options, &dc->current_state->bw_ctx.dml2); dml2_reinit(dc, &dc->dml2_options, &dc->current_state->bw_ctx.dml2);
if (dc->debug.using_dml2 && dc->current_state && dc->current_state->bw_ctx.dml2_dc_power_source) if (dc->debug.using_dml2 && dc->current_state && dc->current_state->bw_ctx.dml2_dc_power_source)
dml2_reinit(dc, &dc->dml2_dc_power_options, &dc->current_state->bw_ctx.dml2_dc_power_source); dml2_reinit(dc, &dc->dml2_dc_power_options, &dc->current_state->bw_ctx.dml2_dc_power_source);
DC_FP_END();
} }
static void dcn401_update_bw_bounding_box(struct dc *dc, struct clk_bw_params *bw_params)
{
DC_FP_START();
dcn401_update_bw_bounding_box_fpu(dc, bw_params);
DC_FP_END();
}
enum dc_status dcn401_patch_unknown_plane_state(struct dc_plane_state *plane_state) enum dc_status dcn401_patch_unknown_plane_state(struct dc_plane_state *plane_state)
{ {
plane_state->tiling_info.gfxversion = DcGfxAddr3; plane_state->tiling_info.gfxversion = DcGfxAddr3;
@ -1688,10 +1692,13 @@ enum dc_status dcn401_validate_bandwidth(struct dc *dc,
} }
} }
if (dc->debug.using_dml2) if (dc->debug.using_dml2) {
DC_FP_START();
status = dml2_validate(dc, context, status = dml2_validate(dc, context,
context->power_source == DC_POWER_SOURCE_DC ? context->bw_ctx.dml2_dc_power_source : context->bw_ctx.dml2, context->power_source == DC_POWER_SOURCE_DC ? context->bw_ctx.dml2_dc_power_source : context->bw_ctx.dml2,
validate_mode) ? DC_OK : DC_FAIL_BANDWIDTH_VALIDATE; validate_mode) ? DC_OK : DC_FAIL_BANDWIDTH_VALIDATE;
DC_FP_END();
}
if (validate_mode == DC_VALIDATE_MODE_AND_PROGRAMMING && status == DC_OK && dc_state_is_subvp_in_use(context)) { if (validate_mode == DC_VALIDATE_MODE_AND_PROGRAMMING && status == DC_OK && dc_state_is_subvp_in_use(context)) {
/* check new stream configuration still supports cursor if subvp used */ /* check new stream configuration still supports cursor if subvp used */
@ -1710,10 +1717,13 @@ enum dc_status dcn401_validate_bandwidth(struct dc *dc,
if (validate_mode == DC_VALIDATE_MODE_AND_PROGRAMMING && status == DC_FAIL_HW_CURSOR_SUPPORT) { if (validate_mode == DC_VALIDATE_MODE_AND_PROGRAMMING && status == DC_FAIL_HW_CURSOR_SUPPORT) {
/* attempt to validate again with subvp disabled due to cursor */ /* attempt to validate again with subvp disabled due to cursor */
if (dc->debug.using_dml2) if (dc->debug.using_dml2) {
DC_FP_START();
status = dml2_validate(dc, context, status = dml2_validate(dc, context,
context->power_source == DC_POWER_SOURCE_DC ? context->bw_ctx.dml2_dc_power_source : context->bw_ctx.dml2, context->power_source == DC_POWER_SOURCE_DC ? context->bw_ctx.dml2_dc_power_source : context->bw_ctx.dml2,
validate_mode) ? DC_OK : DC_FAIL_BANDWIDTH_VALIDATE; validate_mode) ? DC_OK : DC_FAIL_BANDWIDTH_VALIDATE;
DC_FP_END();
}
} }
return status; return status;
@ -1722,9 +1732,13 @@ enum dc_status dcn401_validate_bandwidth(struct dc *dc,
void dcn401_prepare_mcache_programming(struct dc *dc, void dcn401_prepare_mcache_programming(struct dc *dc,
struct dc_state *context) struct dc_state *context)
{ {
if (dc->debug.using_dml21) if (dc->debug.using_dml21) {
DC_FP_START();
dml2_prepare_mcache_programming(dc, context, dml2_prepare_mcache_programming(dc, context,
context->power_source == DC_POWER_SOURCE_DC ? context->bw_ctx.dml2_dc_power_source : context->bw_ctx.dml2); context->power_source == DC_POWER_SOURCE_DC ?
context->bw_ctx.dml2_dc_power_source : context->bw_ctx.dml2);
DC_FP_END();
}
} }
static void dcn401_build_pipe_pix_clk_params(struct pipe_ctx *pipe_ctx) static void dcn401_build_pipe_pix_clk_params(struct pipe_ctx *pipe_ctx)

View File

@ -1696,37 +1696,50 @@ static void dcn42_destroy_resource_pool(struct resource_pool **pool)
static struct dc_cap_funcs cap_funcs = { static struct dc_cap_funcs cap_funcs = {
.get_dcc_compression_cap = dcn20_get_dcc_compression_cap}; .get_dcc_compression_cap = dcn20_get_dcc_compression_cap};
static void dcn42_update_bw_bounding_box_fpu(struct dc *dc, struct clk_bw_params *bw_params)
{
dc_assert_fp_enabled();
if (dc->current_state && dc->current_state->bw_ctx.dml2)
dml2_reinit(dc, &dc->dml2_options, &dc->current_state->bw_ctx.dml2);
}
static void dcn42_update_bw_bounding_box(struct dc *dc, struct clk_bw_params *bw_params) static void dcn42_update_bw_bounding_box(struct dc *dc, struct clk_bw_params *bw_params)
{ {
DC_FP_START(); DC_FP_START();
if (dc->current_state && dc->current_state->bw_ctx.dml2) dcn42_update_bw_bounding_box_fpu(dc, bw_params);
dml2_reinit(dc, &dc->dml2_options, &dc->current_state->bw_ctx.dml2);
DC_FP_END(); DC_FP_END();
} }
enum dc_status dcn42_validate_bandwidth(struct dc *dc, enum dc_status dcn42_validate_bandwidth(struct dc *dc,
struct dc_state *context, struct dc_state *context,
enum dc_validate_mode validate_mode) enum dc_validate_mode validate_mode)
{ {
bool out = false; bool out = false;
DC_FP_START();
out = dml2_validate(dc, context, context->bw_ctx.dml2, out = dml2_validate(dc, context, context->bw_ctx.dml2,
validate_mode); validate_mode);
DC_FP_START();
if (validate_mode == DC_VALIDATE_MODE_AND_PROGRAMMING) { if (validate_mode == DC_VALIDATE_MODE_AND_PROGRAMMING) {
/*not required for mode enumeration*/ /*not required for mode enumeration*/
dcn42_decide_zstate_support(dc, context); dcn42_decide_zstate_support(dc, context);
} }
DC_FP_END(); DC_FP_END();
return out ? DC_OK : DC_FAIL_BANDWIDTH_VALIDATE; return out ? DC_OK : DC_FAIL_BANDWIDTH_VALIDATE;
} }
void dcn42_prepare_mcache_programming(struct dc *dc, void dcn42_prepare_mcache_programming(struct dc *dc,
struct dc_state *context) struct dc_state *context)
{ {
if (dc->debug.using_dml21) if (dc->debug.using_dml21) {
DC_FP_START();
dml2_prepare_mcache_programming(dc, context, dml2_prepare_mcache_programming(dc, context,
context->power_source == DC_POWER_SOURCE_DC ? context->power_source == DC_POWER_SOURCE_DC ?
context->bw_ctx.dml2_dc_power_source : context->bw_ctx.dml2); context->bw_ctx.dml2_dc_power_source : context->bw_ctx.dml2);
DC_FP_END();
}
} }
/* Create a minimal link encoder object not associated with a particular /* Create a minimal link encoder object not associated with a particular
* physical connector. * physical connector.