Skip to content

Commit 3ea9439

Browse files
Dillon Varonealexdeucher
authored andcommitted
drm/amd/display: Add SMU interface to get UMC count for dcn401
[WHY&HOW] BIOS table will not always contain accurate UMC channel info when harvesting is enabled, so get the correct info from SMU. Reviewed-by: Alvin Lee <[email protected]> Signed-off-by: Dillon Varone <[email protected]> Signed-off-by: Tom Chung <[email protected]> Tested-by: Daniel Wheeler <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent e2c4c6c commit 3ea9439

File tree

6 files changed

+65
-26
lines changed

6 files changed

+65
-26
lines changed

drivers/gpu/drm/amd/display/dc/clk_mgr/dcn401/dalsmc.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@
4343
#define DALSMC_MSG_ActiveUclkFclk 0x18
4444
#define DALSMC_MSG_IdleUclkFclk 0x19
4545
#define DALSMC_MSG_SetUclkPstateAllow 0x1A
46-
#define DALSMC_Message_Count 0x1B
46+
#define DALSMC_MSG_SubvpUclkFclk 0x1B
47+
#define DALSMC_MSG_GetNumUmcChannels 0x1C
48+
#define DALSMC_Message_Count 0x1D
4749

4850
typedef enum {
4951
FCLK_SWITCH_DISALLOW,

drivers/gpu/drm/amd/display/dc/clk_mgr/dcn401/dcn401_clk_mgr.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1403,6 +1403,15 @@ static void dcn401_get_memclk_states_from_smu(struct clk_mgr *clk_mgr_base)
14031403
if (clk_mgr->dpm_present && !num_levels)
14041404
clk_mgr->dpm_present = false;
14051405

1406+
clk_mgr_base->bw_params->num_channels = dcn401_smu_get_num_of_umc_channels(clk_mgr);
1407+
if (clk_mgr_base->ctx->dc_bios) {
1408+
/* use BIOS values if none provided by PMFW */
1409+
if (clk_mgr_base->bw_params->num_channels == 0) {
1410+
clk_mgr_base->bw_params->num_channels = clk_mgr_base->ctx->dc_bios->vram_info.num_chans;
1411+
}
1412+
clk_mgr_base->bw_params->dram_channel_width_bytes = clk_mgr_base->ctx->dc_bios->vram_info.dram_channel_width_bytes;
1413+
}
1414+
14061415
/* Refresh bounding box */
14071416
clk_mgr_base->ctx->dc->res_pool->funcs->update_bw_bounding_box(
14081417
clk_mgr->base.ctx->dc, clk_mgr_base->bw_params);

drivers/gpu/drm/amd/display/dc/clk_mgr/dcn401/dcn401_clk_mgr_smu_msg.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525
#ifndef DALSMC_MSG_SubvpUclkFclk
2626
#define DALSMC_MSG_SubvpUclkFclk 0x1B
2727
#endif
28+
#ifndef DALSMC_MSG_GetNumUmcChannels
29+
#define DALSMC_MSG_GetNumUmcChannels 0x1C
30+
#endif
2831

2932
/*
3033
* Function to be used instead of REG_WAIT macro because the wait ends when
@@ -334,3 +337,14 @@ void dcn401_smu_set_num_of_displays(struct clk_mgr_internal *clk_mgr, uint32_t n
334337
dcn401_smu_send_msg_with_param(clk_mgr,
335338
DALSMC_MSG_NumOfDisplays, num_displays, NULL);
336339
}
340+
341+
unsigned int dcn401_smu_get_num_of_umc_channels(struct clk_mgr_internal *clk_mgr)
342+
{
343+
unsigned int response = 0;
344+
345+
dcn401_smu_send_msg_with_param(clk_mgr, DALSMC_MSG_GetNumUmcChannels, 0, &response);
346+
347+
smu_print("SMU Get Num UMC Channels: num_umc_channels = %d\n", response);
348+
349+
return response;
350+
}

drivers/gpu/drm/amd/display/dc/clk_mgr/dcn401/dcn401_clk_mgr_smu_msg.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,6 @@ bool dcn401_smu_set_subvp_uclk_fclk_hardmin(struct clk_mgr_internal *clk_mgr,
2828
uint16_t fclk_freq_mhz);
2929
void dcn401_smu_set_min_deep_sleep_dcef_clk(struct clk_mgr_internal *clk_mgr, uint32_t freq_mhz);
3030
void dcn401_smu_set_num_of_displays(struct clk_mgr_internal *clk_mgr, uint32_t num_displays);
31+
unsigned int dcn401_smu_get_num_of_umc_channels(struct clk_mgr_internal *clk_mgr);
3132

3233
#endif /* __DCN401_CLK_MGR_SMU_MSG_H_ */

drivers/gpu/drm/amd/display/dc/dml2/dml21/dml21_translation_helper.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,12 +294,17 @@ void dml21_apply_soc_bb_overrides(struct dml2_initialize_instance_in_out *dml_in
294294
dml_soc_bb->power_management_parameters.stutter_exit_latency_us =
295295
(in_dc->ctx->dc_bios->bb_info.dram_sr_exit_latency_100ns + 9) / 10;
296296

297-
if (in_dc->ctx->dc_bios->vram_info.num_chans) {
297+
if (dc_bw_params->num_channels) {
298+
dml_clk_table->dram_config.channel_count = dc_bw_params->num_channels;
299+
dml_soc_bb->mall_allocated_for_dcn_mbytes = in_dc->caps.mall_size_total / 1048576;
300+
} else if (in_dc->ctx->dc_bios->vram_info.num_chans) {
298301
dml_clk_table->dram_config.channel_count = in_dc->ctx->dc_bios->vram_info.num_chans;
299302
dml_soc_bb->mall_allocated_for_dcn_mbytes = in_dc->caps.mall_size_total / 1048576;
300303
}
301304

302-
if (in_dc->ctx->dc_bios->vram_info.dram_channel_width_bytes) {
305+
if (dc_bw_params->dram_channel_width_bytes) {
306+
dml_clk_table->dram_config.channel_width_bytes = dc_bw_params->dram_channel_width_bytes;
307+
} else if (in_dc->ctx->dc_bios->vram_info.dram_channel_width_bytes) {
303308
dml_clk_table->dram_config.channel_width_bytes = in_dc->ctx->dc_bios->vram_info.dram_channel_width_bytes;
304309
}
305310

drivers/gpu/drm/amd/display/dc/resource/dcn401/dcn401_resource.c

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1297,6 +1297,29 @@ static struct hpo_dp_link_encoder *dcn401_hpo_dp_link_encoder_create(
12971297
return &hpo_dp_enc31->base;
12981298
}
12991299

1300+
static unsigned int dcn401_calc_num_avail_chans_for_mall(struct dc *dc, unsigned int num_chans)
1301+
{
1302+
unsigned int num_available_chans = 1;
1303+
1304+
/* channels for MALL must be a power of 2 */
1305+
while (num_chans > 1) {
1306+
num_available_chans = (num_available_chans << 1);
1307+
num_chans = (num_chans >> 1);
1308+
}
1309+
1310+
/* cannot be odd */
1311+
num_available_chans &= ~1;
1312+
1313+
/* clamp to max available channels for MALL per ASIC */
1314+
if (ASICREV_IS_GC_12_0_0_A0(dc->ctx->asic_id.hw_internal_rev)) {
1315+
num_available_chans = num_available_chans > 16 ? 16 : num_available_chans;
1316+
} else if (ASICREV_IS_GC_12_0_1_A0(dc->ctx->asic_id.hw_internal_rev)) {
1317+
num_available_chans = num_available_chans > 8 ? 8 : num_available_chans;
1318+
}
1319+
1320+
return num_available_chans;
1321+
}
1322+
13001323
static struct dce_hwseq *dcn401_hwseq_create(
13011324
struct dc_context *ctx)
13021325
{
@@ -1592,6 +1615,14 @@ static void dcn401_update_bw_bounding_box(struct dc *dc, struct clk_bw_params *b
15921615

15931616
memcpy(dml2_opt, &dc->dml2_options, sizeof(dc->dml2_options));
15941617

1618+
/* re-calculate the available MALL size if required */
1619+
if (bw_params->num_channels > 0) {
1620+
dc->caps.max_cab_allocation_bytes = dcn401_calc_num_avail_chans_for_mall(
1621+
dc, bw_params->num_channels) *
1622+
dc->caps.mall_size_per_mem_channel * 1024 * 1024;
1623+
dc->caps.mall_size_total = dc->caps.max_cab_allocation_bytes;
1624+
}
1625+
15951626
DC_FP_START();
15961627

15971628
dcn401_update_bw_bounding_box_fpu(dc, bw_params);
@@ -1714,29 +1745,6 @@ static unsigned int dcn401_get_vstartup_for_pipe(struct pipe_ctx *pipe_ctx)
17141745
return pipe_ctx->global_sync.dcn4x.vstartup_lines;
17151746
}
17161747

1717-
static unsigned int dcn401_calc_num_avail_chans_for_mall(struct dc *dc, unsigned int num_chans)
1718-
{
1719-
unsigned int num_available_chans = 1;
1720-
1721-
/* channels for MALL must be a power of 2 */
1722-
while (num_chans > 1) {
1723-
num_available_chans = (num_available_chans << 1);
1724-
num_chans = (num_chans >> 1);
1725-
}
1726-
1727-
/* cannot be odd */
1728-
num_available_chans &= ~1;
1729-
1730-
/* clamp to max available channels for MALL per ASIC */
1731-
if (ASICREV_IS_GC_12_0_0_A0(dc->ctx->asic_id.hw_internal_rev)) {
1732-
num_available_chans = num_available_chans > 16 ? 16 : num_available_chans;
1733-
} else if (ASICREV_IS_GC_12_0_1_A0(dc->ctx->asic_id.hw_internal_rev)) {
1734-
num_available_chans = num_available_chans > 8 ? 8 : num_available_chans;
1735-
}
1736-
1737-
return num_available_chans;
1738-
}
1739-
17401748
static struct resource_funcs dcn401_res_pool_funcs = {
17411749
.destroy = dcn401_destroy_resource_pool,
17421750
.link_enc_create = dcn401_link_encoder_create,

0 commit comments

Comments
 (0)