<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<p style="font-family:Arial;font-size:10pt;color:#0078D7;margin:15pt;" align="Left">
[AMD Official Use Only - Internal Distribution Only]<br>
</p>
<br>
<div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Series is<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<font size="2"><span style="font-size:11pt">Reviewed-by: </span></font>Bhawanpreet.Lakha<Bhawanpreet.Lakha.amd.com><br>
</div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> amd-gfx <amd-gfx-bounces@lists.freedesktop.org> on behalf of Jerry (Fangzhi) Zuo <Jerry.Zuo@amd.com><br>
<b>Sent:</b> June 15, 2020 3:01 PM<br>
<b>To:</b> amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org><br>
<b>Cc:</b> Deucher, Alexander <Alexander.Deucher@amd.com>; Zuo, Jerry <Jerry.Zuo@amd.com>; Wentland, Harry <Harry.Wentland@amd.com>; Kazlauskas, Nicholas <Nicholas.Kazlauskas@amd.com>; Lee, Alvin <Alvin.Lee2@amd.com><br>
<b>Subject:</b> [PATCH 1/2] drm/amd/display: Update DCN3 bounding box</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">From: Alvin Lee <alvin.lee2@amd.com><br>
<br>
[Why]<br>
We want to update the bounding box to have more granular control of the<br>
DCFCLK.<br>
<br>
[How]<br>
Setup DCFCLK to use STA values and also optimal values based on<br>
UCLK.<br>
<br>
Signed-off-by: Alvin Lee <alvin.lee2@amd.com><br>
Signed-off-by: Jerry (Fangzhi) Zuo <Jerry.Zuo@amd.com><br>
Reviewed-by: Hersen Wu <hersenxs.wu@amd.com><br>
---<br>
.../drm/amd/display/dc/dcn30/dcn30_resource.c | 114 ++++++++++++++++--<br>
1 file changed, 102 insertions(+), 12 deletions(-)<br>
<br>
diff --git a/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_resource.c b/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_resource.c<br>
index 654fdbbff86b..821bde9a376e 100644<br>
--- a/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_resource.c<br>
+++ b/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_resource.c<br>
@@ -2237,9 +2237,41 @@ bool dcn30_validate_bandwidth(struct dc *dc, struct dc_state *context,<br>
return out;<br>
}<br>
<br>
+static void get_optimal_dcfclk_fclk_for_uclk(unsigned int uclk_mts,<br>
+ unsigned int *optimal_dcfclk,<br>
+ unsigned int *optimal_fclk)<br>
+{<br>
+ double bw_from_dram, bw_from_dram1, bw_from_dram2;<br>
+<br>
+ bw_from_dram1 = uclk_mts * dcn3_0_soc.num_chans *<br>
+ dcn3_0_soc.dram_channel_width_bytes * (dcn3_0_soc.max_avg_dram_bw_use_normal_percent / 100);<br>
+ bw_from_dram2 = uclk_mts * dcn3_0_soc.num_chans *<br>
+ dcn3_0_soc.dram_channel_width_bytes * (dcn3_0_soc.max_avg_sdp_bw_use_normal_percent / 100);<br>
+<br>
+ bw_from_dram = (bw_from_dram1 < bw_from_dram2) ? bw_from_dram1 : bw_from_dram2;<br>
+<br>
+ if (optimal_fclk)<br>
+ *optimal_fclk = bw_from_dram /<br>
+ (dcn3_0_soc.fabric_datapath_to_dcn_data_return_bytes * (dcn3_0_soc.max_avg_sdp_bw_use_normal_percent / 100));<br>
+<br>
+ if (optimal_dcfclk)<br>
+ *optimal_dcfclk = bw_from_dram /<br>
+ (dcn3_0_soc.return_bus_width_bytes * (dcn3_0_soc.max_avg_sdp_bw_use_normal_percent / 100));<br>
+}<br>
+<br>
static void dcn30_update_bw_bounding_box(struct dc *dc, struct clk_bw_params *bw_params)<br>
{<br>
- unsigned int i;<br>
+ unsigned int i, j;<br>
+ unsigned int num_states = 0;<br>
+<br>
+ unsigned int dcfclk_mhz[DC__VOLTAGE_STATES] = {0};<br>
+ unsigned int dram_speed_mts[DC__VOLTAGE_STATES] = {0};<br>
+ unsigned int optimal_uclk_for_dcfclk_sta_targets[DC__VOLTAGE_STATES] = {0};<br>
+ unsigned int optimal_dcfclk_for_uclk[DC__VOLTAGE_STATES] = {0};<br>
+<br>
+ unsigned int dcfclk_sta_targets[DC__VOLTAGE_STATES] = {694, 875, 1000, 1200};<br>
+ unsigned int num_dcfclk_sta_targets = 4;<br>
+ unsigned int num_uclk_states;<br>
<br>
if (dc->ctx->dc_bios->vram_info.num_chans)<br>
dcn3_0_soc.num_chans = dc->ctx->dc_bios->vram_info.num_chans;<br>
@@ -2250,13 +2282,78 @@ static void dcn30_update_bw_bounding_box(struct dc *dc, struct clk_bw_params *bw<br>
dcn3_0_soc.dispclk_dppclk_vco_speed_mhz = dc->clk_mgr->dentist_vco_freq_khz / 1000.0;<br>
dc->dml.soc.dispclk_dppclk_vco_speed_mhz = dc->clk_mgr->dentist_vco_freq_khz / 1000.0;<br>
<br>
- /* UCLK first, it determines number of states */<br>
if (bw_params->clk_table.entries[0].memclk_mhz) {<br>
- dcn3_0_soc.num_states = bw_params->clk_table.num_entries;<br>
+<br>
+ if (bw_params->clk_table.entries[1].dcfclk_mhz > dcfclk_sta_targets[num_dcfclk_sta_targets-1]) {<br>
+ // If max DCFCLK is greater than the max DCFCLK STA target, insert into the DCFCLK STA target array<br>
+ dcfclk_sta_targets[num_dcfclk_sta_targets] = bw_params->clk_table.entries[1].dcfclk_mhz;<br>
+ num_dcfclk_sta_targets++;<br>
+ } else if (bw_params->clk_table.entries[1].dcfclk_mhz < dcfclk_sta_targets[num_dcfclk_sta_targets-1]) {<br>
+ // If max DCFCLK is less than the max DCFCLK STA target, cap values and remove duplicates<br>
+ for (i = 0; i < num_dcfclk_sta_targets; i++) {<br>
+ if (dcfclk_sta_targets[i] > bw_params->clk_table.entries[1].dcfclk_mhz) {<br>
+ dcfclk_sta_targets[i] = bw_params->clk_table.entries[1].dcfclk_mhz;<br>
+ break;<br>
+ }<br>
+ }<br>
+ // Update size of array since we "removed" duplicates<br>
+ num_dcfclk_sta_targets = i + 1;<br>
+ }<br>
+<br>
+ num_uclk_states = bw_params->clk_table.num_entries;<br>
+<br>
+ // Calculate optimal dcfclk for each uclk<br>
+ for (i = 0; i < num_uclk_states; i++) {<br>
+ get_optimal_dcfclk_fclk_for_uclk(bw_params->clk_table.entries[i].memclk_mhz * 16,<br>
+ &optimal_dcfclk_for_uclk[i], NULL);<br>
+ if (optimal_dcfclk_for_uclk[i] < bw_params->clk_table.entries[0].dcfclk_mhz) {<br>
+ optimal_dcfclk_for_uclk[i] = bw_params->clk_table.entries[0].dcfclk_mhz;<br>
+ }<br>
+ }<br>
+<br>
+ // Calculate optimal uclk for each dcfclk sta target<br>
+ for (i = 0; i < num_dcfclk_sta_targets; i++) {<br>
+ for (j = 0; j < num_uclk_states; j++) {<br>
+ if (dcfclk_sta_targets[i] < optimal_dcfclk_for_uclk[j]) {<br>
+ optimal_uclk_for_dcfclk_sta_targets[i] =<br>
+ bw_params->clk_table.entries[j].memclk_mhz * 16;<br>
+ break;<br>
+ }<br>
+ }<br>
+ }<br>
+<br>
+ i = 0;<br>
+ j = 0;<br>
+ // create the final dcfclk and uclk table<br>
+ while (i < num_dcfclk_sta_targets && j < num_uclk_states && num_states < DC__VOLTAGE_STATES) {<br>
+ if (dcfclk_sta_targets[i] < optimal_dcfclk_for_uclk[j] && i < num_dcfclk_sta_targets) {<br>
+ dcfclk_mhz[num_states] = dcfclk_sta_targets[i];<br>
+ dram_speed_mts[num_states++] = optimal_uclk_for_dcfclk_sta_targets[i++];<br>
+ } else {<br>
+ if (j < num_uclk_states && optimal_dcfclk_for_uclk[j] <= bw_params->clk_table.entries[1].dcfclk_mhz) {<br>
+ dcfclk_mhz[num_states] = optimal_dcfclk_for_uclk[j];<br>
+ dram_speed_mts[num_states++] = bw_params->clk_table.entries[j++].memclk_mhz * 16;<br>
+ } else {<br>
+ j = num_uclk_states;<br>
+ }<br>
+ }<br>
+ }<br>
+<br>
+ while (i < num_dcfclk_sta_targets && num_states < DC__VOLTAGE_STATES) {<br>
+ dcfclk_mhz[num_states] = dcfclk_sta_targets[i];<br>
+ dram_speed_mts[num_states++] = optimal_uclk_for_dcfclk_sta_targets[i++];<br>
+ }<br>
+<br>
+ while (j < num_uclk_states && num_states < DC__VOLTAGE_STATES &&<br>
+ optimal_dcfclk_for_uclk[j] <= bw_params->clk_table.entries[1].dcfclk_mhz) {<br>
+ dcfclk_mhz[num_states] = optimal_dcfclk_for_uclk[j];<br>
+ dram_speed_mts[num_states++] = bw_params->clk_table.entries[j++].memclk_mhz * 16;<br>
+ }<br>
<br>
for (i = 0; i < dcn3_0_soc.num_states; i++) {<br>
- dcn3_0_soc.clock_limits[i].state = i;<br>
- dcn3_0_soc.clock_limits[i].dram_speed_mts = bw_params->clk_table.entries[i].memclk_mhz * 16;<br>
+ dcn3_0_soc.clock_limits[i].dcfclk_mhz = dcfclk_mhz[i];<br>
+ dcn3_0_soc.clock_limits[i].fabricclk_mhz = dcfclk_mhz[i];<br>
+ dcn3_0_soc.clock_limits[i].dram_speed_mts = dram_speed_mts[i];<br>
}<br>
}<br>
<br>
@@ -2265,12 +2362,6 @@ static void dcn30_update_bw_bounding_box(struct dc *dc, struct clk_bw_params *bw<br>
/* Some clocks can come from bw_params, if so fill from bw_params[1], otherwise fill from dcn3_0_soc[1] */<br>
/* Temporarily ignore bw_params values */<br>
<br>
- /* DCFCLK */<br>
- /*if (bw_params->clk_table.entries[0].dcfclk_mhz)<br>
- dcn3_0_soc.clock_limits[i].dcfclk_mhz = bw_params->clk_table.entries[1].dcfclk_mhz;<br>
- else*/<br>
- dcn3_0_soc.clock_limits[i].dcfclk_mhz = dcn3_0_soc.clock_limits[1].dcfclk_mhz;<br>
-<br>
/* DTBCLK */<br>
/*if (bw_params->clk_table.entries[0].dtbclk_mhz)<br>
dcn3_0_soc.clock_limits[i].dtbclk_mhz = bw_params->clk_table.entries[1].dtbclk_mhz;<br>
@@ -2297,7 +2388,6 @@ static void dcn30_update_bw_bounding_box(struct dc *dc, struct clk_bw_params *bw<br>
<br>
/* These clocks cannot come from bw_params, always fill from dcn3_0_soc[1] */<br>
/* FCLK, PHYCLK_D18, SOCCLK, DSCCLK */<br>
- dcn3_0_soc.clock_limits[i].fabricclk_mhz = dcn3_0_soc.clock_limits[1].fabricclk_mhz;<br>
dcn3_0_soc.clock_limits[i].phyclk_d18_mhz = dcn3_0_soc.clock_limits[1].phyclk_d18_mhz;<br>
dcn3_0_soc.clock_limits[i].socclk_mhz = dcn3_0_soc.clock_limits[1].socclk_mhz;<br>
dcn3_0_soc.clock_limits[i].dscclk_mhz = dcn3_0_soc.clock_limits[1].dscclk_mhz;<br>
-- <br>
2.17.1<br>
<br>
_______________________________________________<br>
amd-gfx mailing list<br>
amd-gfx@lists.freedesktop.org<br>
<a href="https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&data=02%7C01%7Cbhawanpreet.lakha%40amd.com%7Cdea848b9b4c4455dc64008d8115e9215%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637278445192363126&sdata=mMeh3qENOfOBexb5EtAR3sQJ6GZHkEzlQIF97DVI9bI%3D&reserved=0">https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&data=02%7C01%7Cbhawanpreet.lakha%40amd.com%7Cdea848b9b4c4455dc64008d8115e9215%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637278445192363126&sdata=mMeh3qENOfOBexb5EtAR3sQJ6GZHkEzlQIF97DVI9bI%3D&reserved=0</a><br>
</div>
</span></font></div>
</div>
</body>
</html>