<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:#0000FF;margin:5pt;" align="Left">
[AMD Official Use Only]<br>
</p>
<br>
<div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Please fix the patch title.  E.g.,</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span class="_15gqBTUta5ZVWkGNTkvx90">drm/amdgpu/display: move FPU associated DCN302 code to DML</span><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 Jasdeep Dhillon <jdhillon@amd.com><br>
<b>Sent:</b> Thursday, December 23, 2021 1:36 PM<br>
<b>To:</b> amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org><br>
<b>Cc:</b> Wang, Chao-kai (Stylon) <Stylon.Wang@amd.com>; Chiu, Solomon <Solomon.Chiu@amd.com>; Li, Sun peng (Leo) <Sunpeng.Li@amd.com>; Wentland, Harry <Harry.Wentland@amd.com>; Zhuo, Qingqing (Lillian) <Qingqing.Zhuo@amd.com>; Dhillon, Jasdeep <Jasdeep.Dhillon@amd.com>;
 Siqueira, Rodrigo <Rodrigo.Siqueira@amd.com>; Li, Roman <Roman.Li@amd.com>; Anson.Jacob@amd.com <Anson.Jacob@amd.com>; Pillai, Aurabindo <Aurabindo.Pillai@amd.com>; Lin, Wayne <Wayne.Lin@amd.com>; Lipski, Mikita <Mikita.Lipski@amd.com>; Lakha, Bhawanpreet
 <Bhawanpreet.Lakha@amd.com>; Koenig, Christian <Christian.Koenig@amd.com>; Gutierrez, Agustin <Agustin.Gutierrez@amd.com>; Kotarac, Pavle <Pavle.Kotarac@amd.com><br>
<b>Subject:</b> [PATCH] SWDEV-311259 - dc: move FPU associated DCN302 code to DML</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">[Why & How]<br>
As part of the FPU isolation work documented in<br>
<a href="https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpatchwork.freedesktop.org%2Fseries%2F93042%2F&amp;data=04%7C01%7Calexander.deucher%40amd.com%7C94e344c52d824ae7be1108d9c6432a7a%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637758814062989362%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;sdata=XPEcMjZOJ4rGxJ9I3p1pQUChzYcNj86oMgyKFEHPXPA%3D&amp;reserved=0">https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpatchwork.freedesktop.org%2Fseries%2F93042%2F&amp;data=04%7C01%7Calexander.deucher%40amd.com%7C94e344c52d824ae7be1108d9c6432a7a%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637758814062989362%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;sdata=XPEcMjZOJ4rGxJ9I3p1pQUChzYcNj86oMgyKFEHPXPA%3D&amp;reserved=0</a>,
 isolate<br>
code that uses FPU in DCN302 to DML, where all FPU code<br>
should locate.<br>
<br>
Signed-off-by: Jasdeep Dhillon <jdhillon@amd.com><br>
---<br>
 CMakeLists.txt              |   1 +<br>
 dc/dcn302/Makefile          |  43 ++--<br>
 dc/dcn302/dcn302_resource.c | 340 +-------------------------------<br>
 dc/dcn302/dcn302_resource.h |   3 +<br>
 dc/dml/Makefile             |   2 +<br>
 dc/dml/dcn302/dcn302_fpu.c  | 381 ++++++++++++++++++++++++++++++++++++<br>
 dc/dml/dcn302/dcn302_fpu.h  |  32 +++<br>
 7 files changed, 448 insertions(+), 354 deletions(-)<br>
 create mode 100644 dc/dml/dcn302/dcn302_fpu.c<br>
 create mode 100644 dc/dml/dcn302/dcn302_fpu.h<br>
<br>
diff --git a/CMakeLists.txt b/CMakeLists.txt<br>
index 01c6724df..dfee2cd38 100644<br>
--- a/CMakeLists.txt<br>
+++ b/CMakeLists.txt<br>
@@ -243,6 +243,7 @@ list (APPEND srcs "dc/dcn301/dcn301_hubbub.c")<br>
 list (APPEND srcs "dc/dcn302/dcn302_init.c")<br>
 list (APPEND srcs "dc/dcn302/dcn302_hwseq.c")<br>
 list (APPEND srcs "dc/dcn302/dcn302_resource.c")<br>
+list (APPEND srcs "dc/dml/dcn302/dcn302_fpu.c")<br>
 list (APPEND srcs "dc/dcn303/dcn303_init.c")<br>
 list (APPEND srcs "dc/dcn303/dcn303_hwseq.c")<br>
 list (APPEND srcs "dc/dcn303/dcn303_resource.c")<br>
diff --git a/dc/dcn302/Makefile b/dc/dcn302/Makefile<br>
index 101620a88..35a6ffbdd 100644<br>
--- a/dc/dcn302/Makefile<br>
+++ b/dc/dcn302/Makefile<br>
@@ -1,42 +1,37 @@<br>
 #<br>
 # (c) Copyright 2020 Advanced Micro Devices, Inc. All the rights reserved<br>
 #<br>
-#  All rights reserved.  This notice is intended as a precaution against<br>
-#  inadvertent publication and does not imply publication or any waiver<br>
-#  of confidentiality.  The year included in the foregoing notice is the<br>
-#  year of creation of the work.<br>
-#<br>
 #  Authors: AMD<br>
 #<br>
 # Makefile for dcn302.<br>
 <br>
 DCN3_02 = dcn302_init.o dcn302_hwseq.o dcn302_resource.o<br>
 <br>
-ifdef CONFIG_X86<br>
-CFLAGS_$(AMDDALPATH)/dc/dcn302/dcn302_resource.o := -msse<br>
-endif<br>
+#ifdef CONFIG_X86<br>
+#CFLAGS_$(AMDDALPATH)/dc/dcn302/dcn302_resource.o := -msse<br>
+#endif<br>
 <br>
-ifdef CONFIG_PPC64<br>
-CFLAGS_$(AMDDALPATH)/dc/dcn302/dcn302_resource.o := -mhard-float -maltivec<br>
-endif<br>
+#ifdef CONFIG_PPC64<br>
+#CFLAGS_$(AMDDALPATH)/dc/dcn302/dcn302_resource.o := -mhard-float -maltivec<br>
+#endif<br>
 <br>
-ifdef CONFIG_CC_IS_GCC<br>
-ifeq ($(call cc-ifversion, -lt, 0701, y), y)<br>
-IS_OLD_GCC = 1<br>
-endif<br>
-CFLAGS_$(AMDDALPATH)/dc/dcn302/dcn302_resource.o += -mhard-float<br>
-endif<br>
+#ifdef CONFIG_CC_IS_GCC<br>
+#ifeq ($(call cc-ifversion, -lt, 0701, y), y)<br>
+#IS_OLD_GCC = 1<br>
+#endif<br>
+#CFLAGS_$(AMDDALPATH)/dc/dcn302/dcn302_resource.o += -mhard-float<br>
+#endif<br>
 <br>
-ifdef CONFIG_X86<br>
-ifdef IS_OLD_GCC<br>
+#ifdef CONFIG_X86<br>
+#ifdef IS_OLD_GCC<br>
 # Stack alignment mismatch, proceed with caution.<br>
 # GCC < 7.1 cannot compile code using `double` and -mpreferred-stack-boundary=3<br>
 # (8B stack alignment).<br>
-CFLAGS_$(AMDDALPATH)/dc/dcn302/dcn302_resource.o += -mpreferred-stack-boundary=4<br>
-else<br>
-CFLAGS_$(AMDDALPATH)/dc/dcn302/dcn302_resource.o += -msse2<br>
-endif<br>
-endif<br>
+#CFLAGS_$(AMDDALPATH)/dc/dcn302/dcn302_resource.o += -mpreferred-stack-boundary=4<br>
+#else<br>
+#CFLAGS_$(AMDDALPATH)/dc/dcn302/dcn302_resource.o += -msse2<br>
+#endif<br>
+#endif<br>
 <br>
 AMD_DAL_DCN3_02 = $(addprefix $(AMDDALPATH)/dc/dcn302/,$(DCN3_02))<br>
 <br>
diff --git a/dc/dcn302/dcn302_resource.c b/dc/dcn302/dcn302_resource.c<br>
index a0f02aa9c..8fa290164 100644<br>
--- a/dc/dcn302/dcn302_resource.c<br>
+++ b/dc/dcn302/dcn302_resource.c<br>
@@ -65,6 +65,8 @@<br>
 #include "resource.h"<br>
 #include "vm_helper.h"<br>
 <br>
+#include "dml/dcn302/dcn302_fpu.h"<br>
+<br>
 #include "include_legacy/dcn3/sienna_cichlid_ip_offset.h"<br>
 #include "include_legacy/dcn302/dcn_3_0_2_offset.h"<br>
 #include "include_legacy/dcn302/dcn_3_0_2_sh_mask.h"<br>
@@ -81,164 +83,6 @@<br>
 #define DC_LOGGER_INIT(logger)<br>
 #endif<br>
 <br>
-struct _vcs_dpi_ip_params_st dcn3_02_ip = {<br>
-               .use_min_dcfclk = 0,<br>
-               .clamp_min_dcfclk = 0,<br>
-               .odm_capable = 1,<br>
-               .gpuvm_enable = 1,<br>
-               .hostvm_enable = 0,<br>
-               .gpuvm_max_page_table_levels = 4,<br>
-               .hostvm_max_page_table_levels = 4,<br>
-               .hostvm_cached_page_table_levels = 0,<br>
-               .pte_group_size_bytes = 2048,<br>
-               .num_dsc = 5,<br>
-               .rob_buffer_size_kbytes = 184,<br>
-               .det_buffer_size_kbytes = 184,<br>
-               .dpte_buffer_size_in_pte_reqs_luma = 64,<br>
-               .dpte_buffer_size_in_pte_reqs_chroma = 34,<br>
-               .pde_proc_buffer_size_64k_reqs = 48,<br>
-               .dpp_output_buffer_pixels = 2560,<br>
-               .opp_output_buffer_lines = 1,<br>
-               .pixel_chunk_size_kbytes = 8,<br>
-               .pte_enable = 1,<br>
-               .max_page_table_levels = 2,<br>
-               .pte_chunk_size_kbytes = 2,  // ?<br>
-               .meta_chunk_size_kbytes = 2,<br>
-               .writeback_chunk_size_kbytes = 8,<br>
-               .line_buffer_size_bits = 789504,<br>
-               .is_line_buffer_bpp_fixed = 0,  // ?<br>
-               .line_buffer_fixed_bpp = 0,     // ?<br>
-               .dcc_supported = true,<br>
-               .writeback_interface_buffer_size_kbytes = 90,<br>
-               .writeback_line_buffer_buffer_size = 0,<br>
-               .max_line_buffer_lines = 12,<br>
-               .writeback_luma_buffer_size_kbytes = 12,  // writeback_line_buffer_buffer_size = 656640<br>
-               .writeback_chroma_buffer_size_kbytes = 8,<br>
-               .writeback_chroma_line_buffer_width_pixels = 4,<br>
-               .writeback_max_hscl_ratio = 1,<br>
-               .writeback_max_vscl_ratio = 1,<br>
-               .writeback_min_hscl_ratio = 1,<br>
-               .writeback_min_vscl_ratio = 1,<br>
-               .writeback_max_hscl_taps = 1,<br>
-               .writeback_max_vscl_taps = 1,<br>
-               .writeback_line_buffer_luma_buffer_size = 0,<br>
-               .writeback_line_buffer_chroma_buffer_size = 14643,<br>
-#ifdef CONFIG_DRM_AMD_DC_DCN3AG<br>
-               .writeback_interleave_and_whole_buf = false,<br>
-#endif<br>
-               .cursor_buffer_size = 8,<br>
-               .cursor_chunk_size = 2,<br>
-               .max_num_otg = 5,<br>
-               .max_num_dpp = 5,<br>
-               .max_num_wb = 1,<br>
-               .max_dchub_pscl_bw_pix_per_clk = 4,<br>
-               .max_pscl_lb_bw_pix_per_clk = 2,<br>
-               .max_lb_vscl_bw_pix_per_clk = 4,<br>
-               .max_vscl_hscl_bw_pix_per_clk = 4,<br>
-               .max_hscl_ratio = 6,<br>
-               .max_vscl_ratio = 6,<br>
-               .hscl_mults = 4,<br>
-               .vscl_mults = 4,<br>
-               .max_hscl_taps = 8,<br>
-               .max_vscl_taps = 8,<br>
-               .dispclk_ramp_margin_percent = 1,<br>
-               .underscan_factor = 1.11,<br>
-               .min_vblank_lines = 32,<br>
-               .dppclk_delay_subtotal = 46,<br>
-               .dynamic_metadata_vm_enabled = true,<br>
-               .dppclk_delay_scl_lb_only = 16,<br>
-               .dppclk_delay_scl = 50,<br>
-               .dppclk_delay_cnvc_formatter = 27,<br>
-               .dppclk_delay_cnvc_cursor = 6,<br>
-               .dispclk_delay_subtotal = 119,<br>
-               .dcfclk_cstate_latency = 5.2, // SRExitTime<br>
-               .max_inter_dcn_tile_repeaters = 8,<br>
-               .max_num_hdmi_frl_outputs = 1,<br>
-               .odm_combine_4to1_supported = true,<br>
-<br>
-               .xfc_supported = false,<br>
-               .xfc_fill_bw_overhead_percent = 10.0,<br>
-               .xfc_fill_constant_bytes = 0,<br>
-               .gfx7_compat_tiling_supported = 0,<br>
-               .number_of_cursors = 1,<br>
-};<br>
-<br>
-struct _vcs_dpi_soc_bounding_box_st dcn3_02_soc = {<br>
-               .clock_limits = {<br>
-                               {<br>
-                                               .state = 0,<br>
-#ifdef CONFIG_DAL_PRODUCTION<br>
-                                               .dcfclk_mhz = 1200.0,<br>
-                                               .fabricclk_mhz = 1400.0,<br>
-                                               .dispclk_mhz = 1217.0,<br>
-                                               .dppclk_mhz = 1217.0,<br>
-                                               .phyclk_mhz = 810.0,<br>
-                                               .dram_speed_mts = 16000.0,<br>
-#else<br>
-                                               .dispclk_mhz = 562.0,<br>
-                                               .dppclk_mhz = 300.0,<br>
-                                               .phyclk_mhz = 300.0,<br>
-#endif<br>
-                                               .phyclk_d18_mhz = 667.0,<br>
-#ifndef LINUX_DM<br>
-                                               .socclk_mhz = 1200.0,<br>
-#endif<br>
-                                               .dscclk_mhz = 405.6,<br>
-#if defined(CONFIG_DRM_AMD_DC_HDMI2_1)<br>
-                                               .dtbclk_mhz = 1217.0,<br>
-#endif<br>
-                               },<br>
-               },<br>
-<br>
-               .min_dcfclk = 500.0, /* TODO: set this to actual min DCFCLK */<br>
-               .num_states = 1,<br>
-               .sr_exit_time_us = 26.5,<br>
-               .sr_enter_plus_exit_time_us = 31,<br>
-               .urgent_latency_us = 4.0,<br>
-               .urgent_latency_pixel_data_only_us = 4.0,<br>
-               .urgent_latency_pixel_mixed_with_vm_data_us = 4.0,<br>
-               .urgent_latency_vm_data_only_us = 4.0,<br>
-               .urgent_out_of_order_return_per_channel_pixel_only_bytes = 4096,<br>
-               .urgent_out_of_order_return_per_channel_pixel_and_vm_bytes = 4096,<br>
-               .urgent_out_of_order_return_per_channel_vm_only_bytes = 4096,<br>
-               .pct_ideal_dram_sdp_bw_after_urgent_pixel_only = 80.0,<br>
-               .pct_ideal_dram_sdp_bw_after_urgent_pixel_and_vm = 60.0,<br>
-               .pct_ideal_dram_sdp_bw_after_urgent_vm_only = 40.0,<br>
-               .max_avg_sdp_bw_use_normal_percent = 60.0,<br>
-               .max_avg_dram_bw_use_normal_percent = 40.0,<br>
-               .writeback_latency_us = 12.0,<br>
-               .max_request_size_bytes = 256,<br>
-#ifndef LINUX_DM<br>
-               .dram_channel_width_bytes = 2,<br>
-#endif<br>
-               .fabric_datapath_to_dcn_data_return_bytes = 64,<br>
-               .dcn_downspread_percent = 0.5,<br>
-               .downspread_percent = 0.38,<br>
-               .dram_page_open_time_ns = 50.0,<br>
-               .dram_rw_turnaround_time_ns = 17.5,<br>
-               .dram_return_buffer_per_channel_bytes = 8192,<br>
-               .round_trip_ping_latency_dcfclk_cycles = 156,<br>
-               .urgent_out_of_order_return_per_channel_bytes = 4096,<br>
-               .channel_interleave_bytes = 256,<br>
-               .num_banks = 8,<br>
-#ifndef LINUX_DM<br>
-               .num_chans = 8,<br>
-#endif<br>
-               .gpuvm_min_page_size_bytes = 4096,<br>
-               .hostvm_min_page_size_bytes = 4096,<br>
-               .dram_clock_change_latency_us = 404,<br>
-               .dummy_pstate_latency_us = 5,<br>
-               .writeback_dram_clock_change_latency_us = 23.0,<br>
-               .return_bus_width_bytes = 64,<br>
-               .dispclk_dppclk_vco_speed_mhz = 3650,<br>
-               .xfc_bus_transport_time_us = 20,      // ?<br>
-               .xfc_xbuf_latency_tolerance_us = 4,  // ?<br>
-               .use_urgent_burst_bw = 1,            // ?<br>
-               .do_urgent_latency_adjustment = true,<br>
-               .urgent_latency_adjustment_fabric_clock_component_us = 1.0,<br>
-               .urgent_latency_adjustment_fabric_clock_reference_mhz = 1000,<br>
-};<br>
-<br>
 static const struct dc_debug_options debug_defaults_drv = {<br>
                 .disable_dmcu = true,<br>
                 .force_abm_enable = false,<br>
@@ -1271,7 +1115,9 @@ static bool init_soc_bounding_box(struct dc *dc,  struct resource_pool *pool)<br>
         loaded_ip->max_num_otg = pool->pipe_count;<br>
         loaded_ip->max_num_dpp = pool->pipe_count;<br>
         loaded_ip->clamp_min_dcfclk = dc->config.clamp_min_dcfclk;<br>
+       DC_FP_START();<br>
         dcn20_patch_bounding_box(dc, loaded_bb);<br>
+       DC_FP_END();<br>
 #ifdef CONFIG_DRM_AMD_DC_DCN3AG<br>
         if (dc->config.host_vm_min_page_size != 0)<br>
                 loaded_bb->hostvm_min_page_size_bytes = dc->config.host_vm_min_page_size;<br>
@@ -1285,17 +1131,10 @@ static bool init_soc_bounding_box(struct dc *dc,  struct resource_pool *pool)<br>
 <br>
                 if (dc->ctx->dc_bios->funcs->get_soc_bb_info(<br>
                             dc->ctx->dc_bios, &bb_info) == BP_RESULT_OK) {<br>
-                       if (bb_info.dram_clock_change_latency_100ns > 0)<br>
-                               dcn3_02_soc.dram_clock_change_latency_us =<br>
-                                       bb_info.dram_clock_change_latency_100ns * 10;<br>
 <br>
-                       if (bb_info.dram_sr_enter_exit_latency_100ns > 0)<br>
-                               dcn3_02_soc.sr_enter_plus_exit_time_us =<br>
-                                       bb_info.dram_sr_enter_exit_latency_100ns * 10;<br>
-<br>
-                       if (bb_info.dram_sr_exit_latency_100ns > 0)<br>
-                               dcn3_02_soc.sr_exit_time_us =<br>
-                                       bb_info.dram_sr_exit_latency_100ns * 10;<br>
+                               DC_FP_START();<br>
+                               dcn302_fpu_init_soc_bounding_box(bb_info);<br>
+                               DC_FP_END();<br>
                 }<br>
         }<br>
 <br>
@@ -1450,170 +1289,11 @@ static void dcn302_destroy_resource_pool(struct resource_pool **pool)<br>
         *pool = NULL;<br>
 }<br>
 <br>
-static void dcn302_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_02_soc.num_chans *<br>
-               dcn3_02_soc.dram_channel_width_bytes * (dcn3_02_soc.max_avg_dram_bw_use_normal_percent / 100);<br>
-       bw_from_dram2 = uclk_mts * dcn3_02_soc.num_chans *<br>
-               dcn3_02_soc.dram_channel_width_bytes * (dcn3_02_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_02_soc.fabric_datapath_to_dcn_data_return_bytes * (dcn3_02_soc.max_avg_sdp_bw_use_normal_percent / 100));<br>
-<br>
-       if (optimal_dcfclk)<br>
-               *optimal_dcfclk =  bw_from_dram /<br>
-               (dcn3_02_soc.return_bus_width_bytes * (dcn3_02_soc.max_avg_sdp_bw_use_normal_percent / 100));<br>
-}<br>
-<br>
 void dcn302_update_bw_bounding_box(struct dc *dc, struct clk_bw_params *bw_params)<br>
 {<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>
-<br>
-       if (dc->ctx->dc_bios->vram_info.num_chans)<br>
-               dcn3_02_soc.num_chans = dc->ctx->dc_bios->vram_info.num_chans;<br>
-<br>
-       if (dc->ctx->dc_bios->vram_info.dram_channel_width_bytes)<br>
-               dcn3_02_soc.dram_channel_width_bytes = dc->ctx->dc_bios->vram_info.dram_channel_width_bytes;<br>
-<br>
-       dcn3_02_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>
-       if (bw_params->clk_table.entries[0].memclk_mhz) {<br>
-               int max_dcfclk_mhz = 0, max_dispclk_mhz = 0, max_dppclk_mhz = 0, max_phyclk_mhz = 0;<br>
-<br>
-               for (i = 0; i < MAX_NUM_DPM_LVL; i++) {<br>
-                       if (bw_params->clk_table.entries[i].dcfclk_mhz > max_dcfclk_mhz)<br>
-                               max_dcfclk_mhz = bw_params->clk_table.entries[i].dcfclk_mhz;<br>
-                       if (bw_params->clk_table.entries[i].dispclk_mhz > max_dispclk_mhz)<br>
-                               max_dispclk_mhz = bw_params->clk_table.entries[i].dispclk_mhz;<br>
-                       if (bw_params->clk_table.entries[i].dppclk_mhz > max_dppclk_mhz)<br>
-                               max_dppclk_mhz = bw_params->clk_table.entries[i].dppclk_mhz;<br>
-                       if (bw_params->clk_table.entries[i].phyclk_mhz > max_phyclk_mhz)<br>
-                               max_phyclk_mhz = bw_params->clk_table.entries[i].phyclk_mhz;<br>
-               }<br>
-               if (!max_dcfclk_mhz)<br>
-                       max_dcfclk_mhz = dcn3_02_soc.clock_limits[0].dcfclk_mhz;<br>
-               if (!max_dispclk_mhz)<br>
-                       max_dispclk_mhz = dcn3_02_soc.clock_limits[0].dispclk_mhz;<br>
-               if (!max_dppclk_mhz)<br>
-                       max_dppclk_mhz = dcn3_02_soc.clock_limits[0].dppclk_mhz;<br>
-               if (!max_phyclk_mhz)<br>
-                       max_phyclk_mhz = dcn3_02_soc.clock_limits[0].phyclk_mhz;<br>
-<br>
-               if (max_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] = max_dcfclk_mhz;<br>
-                       num_dcfclk_sta_targets++;<br>
-               } else if (max_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] > max_dcfclk_mhz) {<br>
-                                       dcfclk_sta_targets[i] = max_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>
-                       dcn302_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] <= max_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] <= max_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>
-               dcn3_02_soc.num_states = num_states;<br>
-               for (i = 0; i < dcn3_02_soc.num_states; i++) {<br>
-                       dcn3_02_soc.clock_limits[i].state = i;<br>
-                       dcn3_02_soc.clock_limits[i].dcfclk_mhz = dcfclk_mhz[i];<br>
-                       dcn3_02_soc.clock_limits[i].fabricclk_mhz = dcfclk_mhz[i];<br>
-                       dcn3_02_soc.clock_limits[i].dram_speed_mts = dram_speed_mts[i];<br>
-<br>
-                       /* Fill all states with max values of all other clocks */<br>
-                       dcn3_02_soc.clock_limits[i].dispclk_mhz = max_dispclk_mhz;<br>
-                       dcn3_02_soc.clock_limits[i].dppclk_mhz  = max_dppclk_mhz;<br>
-                       dcn3_02_soc.clock_limits[i].phyclk_mhz  = max_phyclk_mhz;<br>
-                       /* Populate from bw_params for DTBCLK, SOCCLK */<br>
-                       if (!bw_params->clk_table.entries[i].dtbclk_mhz && i > 0)<br>
-                               dcn3_02_soc.clock_limits[i].dtbclk_mhz  = dcn3_02_soc.clock_limits[i-1].dtbclk_mhz;<br>
-                       else<br>
-                               dcn3_02_soc.clock_limits[i].dtbclk_mhz  = bw_params->clk_table.entries[i].dtbclk_mhz;<br>
-                       if (!bw_params->clk_table.entries[i].socclk_mhz && i > 0)<br>
-                               dcn3_02_soc.clock_limits[i].socclk_mhz = dcn3_02_soc.clock_limits[i-1].socclk_mhz;<br>
-                       else<br>
-                               dcn3_02_soc.clock_limits[i].socclk_mhz = bw_params->clk_table.entries[i].socclk_mhz;<br>
-                       /* These clocks cannot come from bw_params, always fill from dcn3_02_soc[1] */<br>
-                       /* FCLK, PHYCLK_D18, DSCCLK */<br>
-                       dcn3_02_soc.clock_limits[i].phyclk_d18_mhz = dcn3_02_soc.clock_limits[0].phyclk_d18_mhz;<br>
-                       dcn3_02_soc.clock_limits[i].dscclk_mhz = dcn3_02_soc.clock_limits[0].dscclk_mhz;<br>
-               }<br>
-               /* re-init DML with updated bb */<br>
-               dml_init_instance(&dc->dml, &dcn3_02_soc, &dcn3_02_ip, DML_PROJECT_DCN30);<br>
-               if (dc->current_state)<br>
-                       dml_init_instance(&dc->current_state->bw_ctx.dml, &dcn3_02_soc, &dcn3_02_ip, DML_PROJECT_DCN30);<br>
-       }<br>
+       DC_FP_START();<br>
+       dcn302_fpu_update_bw_bounding_box(dc, bw_params);<br>
+       DC_FP_END();<br>
 }<br>
 <br>
 static struct resource_funcs dcn302_res_pool_funcs = {<br>
diff --git a/dc/dcn302/dcn302_resource.h b/dc/dcn302/dcn302_resource.h<br>
index 42d2c73e3..9f24e73b9 100644<br>
--- a/dc/dcn302/dcn302_resource.h<br>
+++ b/dc/dcn302/dcn302_resource.h<br>
@@ -28,6 +28,9 @@<br>
 <br>
 #include "core_types.h"<br>
 <br>
+extern struct _vcs_dpi_ip_params_st dcn3_02_ip;<br>
+extern struct _vcs_dpi_soc_bounding_box_st dcn3_02_soc;<br>
+<br>
 struct resource_pool *dcn302_create_resource_pool(const struct dc_init_data *init_data, struct dc *dc);<br>
 <br>
 void dcn302_update_bw_bounding_box(struct dc *dc, struct clk_bw_params *bw_params);<br>
diff --git a/dc/dml/Makefile b/dc/dml/Makefile<br>
index d8e03ca15..f55f28fe3 100644<br>
--- a/dc/dml/Makefile<br>
+++ b/dc/dml/Makefile<br>
@@ -73,6 +73,7 @@ CFLAGS_$(AMDDALPATH)/dc/dml/dcn30/frl_cap_chk_30.o := $(dml_ccflags)<br>
 #endif<br>
 endif<br>
 CFLAGS_$(AMDDALPATH)/dc/dml/dcn301/dcn301_fpu.o := $(dml_ccflags)<br>
+CFLAGS_$(AMDDALPATH)/dc/dml/dcn302/dcn302_fpu.o := $(dml_ccflags)<br>
 ifdef CONFIG_DRM_AMD_DC_DCN3_1<br>
 CFLAGS_$(AMDDALPATH)/dc/dml/dcn31/display_mode_vba_31.o := $(dml_ccflags) -Wframe-larger-than=2048<br>
 CFLAGS_$(AMDDALPATH)/dc/dml/dcn31/display_rq_dlg_calc_31.o := $(dml_ccflags)<br>
@@ -103,6 +104,7 @@ DML += dcn30/frl_cap_chk_30.o<br>
 #endif<br>
 endif<br>
 DML += dcn301/dcn301_fpu.o<br>
+DML += dcn302/dcn302_fpu.o<br>
 ifdef CONFIG_DRM_AMD_DC_DCN3_1<br>
 DML += dcn31/display_mode_vba_31.o dcn31/display_rq_dlg_calc_31.o<br>
 endif<br>
diff --git a/dc/dml/dcn302/dcn302_fpu.c b/dc/dml/dcn302/dcn302_fpu.c<br>
new file mode 100644<br>
index 000000000..97d9dc80b<br>
--- /dev/null<br>
+++ b/dc/dml/dcn302/dcn302_fpu.c<br>
@@ -0,0 +1,381 @@<br>
+/*<br>
+ * Copyright 2020 Advanced Micro Devices, Inc.<br>
+ *<br>
+ * Permission is hereby granted, free of charge, to any person obtaining a<br>
+ * copy of this software and associated documentation files (the "Software"),<br>
+ * to deal in the Software without restriction, including without limitation<br>
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,<br>
+ * and/or sell copies of the Software, and to permit persons to whom the<br>
+ * Software is furnished to do so, subject to the following conditions:<br>
+ *<br>
+ * The above copyright notice and this permission notice shall be included in<br>
+ * all copies or substantial portions of the Software.<br>
+ *<br>
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br>
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br>
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL<br>
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR<br>
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,<br>
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR<br>
+ * OTHER DEALINGS IN THE SOFTWARE.<br>
+ *<br>
+ * Authors: AMD<br>
+ *<br>
+ */<br>
+<br>
+#include "resource.h"<br>
+#include "clk_mgr.h"<br>
+#include "dcn20/dcn20_resource.h"<br>
+#include "dcn302/dcn302_resource.h"<br>
+<br>
+#include "dml/dcn20/dcn20_fpu.h"<br>
+#include "dcn302_fpu.h"<br>
+<br>
+struct _vcs_dpi_ip_params_st dcn3_02_ip = {<br>
+               .use_min_dcfclk = 0,<br>
+               .clamp_min_dcfclk = 0,<br>
+               .odm_capable = 1,<br>
+               .gpuvm_enable = 1,<br>
+               .hostvm_enable = 0,<br>
+               .gpuvm_max_page_table_levels = 4,<br>
+               .hostvm_max_page_table_levels = 4,<br>
+               .hostvm_cached_page_table_levels = 0,<br>
+               .pte_group_size_bytes = 2048,<br>
+               .num_dsc = 5,<br>
+               .rob_buffer_size_kbytes = 184,<br>
+               .det_buffer_size_kbytes = 184,<br>
+               .dpte_buffer_size_in_pte_reqs_luma = 64,<br>
+               .dpte_buffer_size_in_pte_reqs_chroma = 34,<br>
+               .pde_proc_buffer_size_64k_reqs = 48,<br>
+               .dpp_output_buffer_pixels = 2560,<br>
+               .opp_output_buffer_lines = 1,<br>
+               .pixel_chunk_size_kbytes = 8,<br>
+               .pte_enable = 1,<br>
+               .max_page_table_levels = 2,<br>
+               .pte_chunk_size_kbytes = 2,  // ?<br>
+               .meta_chunk_size_kbytes = 2,<br>
+               .writeback_chunk_size_kbytes = 8,<br>
+               .line_buffer_size_bits = 789504,<br>
+               .is_line_buffer_bpp_fixed = 0,  // ?<br>
+               .line_buffer_fixed_bpp = 0,     // ?<br>
+               .dcc_supported = true,<br>
+               .writeback_interface_buffer_size_kbytes = 90,<br>
+               .writeback_line_buffer_buffer_size = 0,<br>
+               .max_line_buffer_lines = 12,<br>
+               .writeback_luma_buffer_size_kbytes = 12,  // writeback_line_buffer_buffer_size = 656640<br>
+               .writeback_chroma_buffer_size_kbytes = 8,<br>
+               .writeback_chroma_line_buffer_width_pixels = 4,<br>
+               .writeback_max_hscl_ratio = 1,<br>
+               .writeback_max_vscl_ratio = 1,<br>
+               .writeback_min_hscl_ratio = 1,<br>
+               .writeback_min_vscl_ratio = 1,<br>
+               .writeback_max_hscl_taps = 1,<br>
+               .writeback_max_vscl_taps = 1,<br>
+               .writeback_line_buffer_luma_buffer_size = 0,<br>
+               .writeback_line_buffer_chroma_buffer_size = 14643,<br>
+#ifdef CONFIG_DRM_AMD_DC_DCN3AG<br>
+               .writeback_interleave_and_whole_buf = false,<br>
+#endif<br>
+               .cursor_buffer_size = 8,<br>
+               .cursor_chunk_size = 2,<br>
+               .max_num_otg = 5,<br>
+               .max_num_dpp = 5,<br>
+               .max_num_wb = 1,<br>
+               .max_dchub_pscl_bw_pix_per_clk = 4,<br>
+               .max_pscl_lb_bw_pix_per_clk = 2,<br>
+               .max_lb_vscl_bw_pix_per_clk = 4,<br>
+               .max_vscl_hscl_bw_pix_per_clk = 4,<br>
+               .max_hscl_ratio = 6,<br>
+               .max_vscl_ratio = 6,<br>
+               .hscl_mults = 4,<br>
+               .vscl_mults = 4,<br>
+               .max_hscl_taps = 8,<br>
+               .max_vscl_taps = 8,<br>
+               .dispclk_ramp_margin_percent = 1,<br>
+               .underscan_factor = 1.11,<br>
+               .min_vblank_lines = 32,<br>
+               .dppclk_delay_subtotal = 46,<br>
+               .dynamic_metadata_vm_enabled = true,<br>
+               .dppclk_delay_scl_lb_only = 16,<br>
+               .dppclk_delay_scl = 50,<br>
+               .dppclk_delay_cnvc_formatter = 27,<br>
+               .dppclk_delay_cnvc_cursor = 6,<br>
+               .dispclk_delay_subtotal = 119,<br>
+               .dcfclk_cstate_latency = 5.2, // SRExitTime<br>
+               .max_inter_dcn_tile_repeaters = 8,<br>
+               .max_num_hdmi_frl_outputs = 1,<br>
+               .odm_combine_4to1_supported = true,<br>
+<br>
+               .xfc_supported = false,<br>
+               .xfc_fill_bw_overhead_percent = 10.0,<br>
+               .xfc_fill_constant_bytes = 0,<br>
+               .gfx7_compat_tiling_supported = 0,<br>
+               .number_of_cursors = 1,<br>
+};<br>
+<br>
+struct _vcs_dpi_soc_bounding_box_st dcn3_02_soc = {<br>
+               .clock_limits = {<br>
+                               {<br>
+                                               .state = 0,<br>
+#ifdef CONFIG_DAL_PRODUCTION<br>
+                                               .dcfclk_mhz = 1200.0,<br>
+                                               .fabricclk_mhz = 1400.0,<br>
+                                               .dispclk_mhz = 1217.0,<br>
+                                               .dppclk_mhz = 1217.0,<br>
+                                               .phyclk_mhz = 810.0,<br>
+                                               .dram_speed_mts = 16000.0,<br>
+#else<br>
+                                               .dispclk_mhz = 562.0,<br>
+                                               .dppclk_mhz = 300.0,<br>
+                                               .phyclk_mhz = 300.0,<br>
+#endif<br>
+                                               .phyclk_d18_mhz = 667.0,<br>
+#ifndef LINUX_DM<br>
+                                               .socclk_mhz = 1200.0,<br>
+#endif<br>
+                                               .dscclk_mhz = 405.6,<br>
+#if defined(CONFIG_DRM_AMD_DC_HDMI2_1)<br>
+                                               .dtbclk_mhz = 1217.0,<br>
+#endif<br>
+                               },<br>
+               },<br>
+<br>
+               .min_dcfclk = 500.0, /* TODO: set this to actual min DCFCLK */<br>
+               .num_states = 1,<br>
+               .sr_exit_time_us = 26.5,<br>
+               .sr_enter_plus_exit_time_us = 31,<br>
+               .urgent_latency_us = 4.0,<br>
+               .urgent_latency_pixel_data_only_us = 4.0,<br>
+               .urgent_latency_pixel_mixed_with_vm_data_us = 4.0,<br>
+               .urgent_latency_vm_data_only_us = 4.0,<br>
+               .urgent_out_of_order_return_per_channel_pixel_only_bytes = 4096,<br>
+               .urgent_out_of_order_return_per_channel_pixel_and_vm_bytes = 4096,<br>
+               .urgent_out_of_order_return_per_channel_vm_only_bytes = 4096,<br>
+               .pct_ideal_dram_sdp_bw_after_urgent_pixel_only = 80.0,<br>
+               .pct_ideal_dram_sdp_bw_after_urgent_pixel_and_vm = 60.0,<br>
+               .pct_ideal_dram_sdp_bw_after_urgent_vm_only = 40.0,<br>
+               .max_avg_sdp_bw_use_normal_percent = 60.0,<br>
+               .max_avg_dram_bw_use_normal_percent = 40.0,<br>
+               .writeback_latency_us = 12.0,<br>
+               .max_request_size_bytes = 256,<br>
+#ifndef LINUX_DM<br>
+               .dram_channel_width_bytes = 2,<br>
+#endif<br>
+               .fabric_datapath_to_dcn_data_return_bytes = 64,<br>
+               .dcn_downspread_percent = 0.5,<br>
+               .downspread_percent = 0.38,<br>
+               .dram_page_open_time_ns = 50.0,<br>
+               .dram_rw_turnaround_time_ns = 17.5,<br>
+               .dram_return_buffer_per_channel_bytes = 8192,<br>
+               .round_trip_ping_latency_dcfclk_cycles = 156,<br>
+               .urgent_out_of_order_return_per_channel_bytes = 4096,<br>
+               .channel_interleave_bytes = 256,<br>
+               .num_banks = 8,<br>
+#ifndef LINUX_DM<br>
+               .num_chans = 8,<br>
+#endif<br>
+               .gpuvm_min_page_size_bytes = 4096,<br>
+               .hostvm_min_page_size_bytes = 4096,<br>
+               .dram_clock_change_latency_us = 404,<br>
+               .dummy_pstate_latency_us = 5,<br>
+               .writeback_dram_clock_change_latency_us = 23.0,<br>
+               .return_bus_width_bytes = 64,<br>
+               .dispclk_dppclk_vco_speed_mhz = 3650,<br>
+               .xfc_bus_transport_time_us = 20,      // ?<br>
+               .xfc_xbuf_latency_tolerance_us = 4,  // ?<br>
+               .use_urgent_burst_bw = 1,            // ?<br>
+               .do_urgent_latency_adjustment = true,<br>
+               .urgent_latency_adjustment_fabric_clock_component_us = 1.0,<br>
+               .urgent_latency_adjustment_fabric_clock_reference_mhz = 1000,<br>
+};<br>
+<br>
+static void dcn302_get_optimal_dcfclk_fclk_for_uclk(unsigned int uclk_mts,<br>
+       unsigned int *optimal_dcfclk,<br>
+       unsigned int *optimal_fclk)<br>
+{<br>
+<br>
+                       double bw_from_dram, bw_from_dram1, bw_from_dram2;<br>
+<br>
+                       bw_from_dram1 = uclk_mts * dcn3_02_soc.num_chans *<br>
+                               dcn3_02_soc.dram_channel_width_bytes *<br>
+                               (dcn3_02_soc.max_avg_dram_bw_use_normal_percent / 100);<br>
+                       bw_from_dram2 = uclk_mts * dcn3_02_soc.num_chans *<br>
+                               dcn3_02_soc.dram_channel_width_bytes *<br>
+                               (dcn3_02_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_02_soc.fabric_datapath_to_dcn_data_return_bytes *<br>
+                                (dcn3_02_soc.max_avg_sdp_bw_use_normal_percent / 100));<br>
+<br>
+                       if (optimal_dcfclk)<br>
+                               *optimal_dcfclk =  bw_from_dram /<br>
+                               (dcn3_02_soc.return_bus_width_bytes *<br>
+                                (dcn3_02_soc.max_avg_sdp_bw_use_normal_percent / 100));<br>
+}<br>
+<br>
+void dcn302_fpu_update_bw_bounding_box(struct dc *dc, struct clk_bw_params *bw_params)<br>
+{<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>
+       dc_assert_fp_enabled();<br>
+<br>
+       if (dc->ctx->dc_bios->vram_info.num_chans)<br>
+               dcn3_02_soc.num_chans = dc->ctx->dc_bios->vram_info.num_chans;<br>
+<br>
+       if (dc->ctx->dc_bios->vram_info.dram_channel_width_bytes)<br>
+               dcn3_02_soc.dram_channel_width_bytes = dc->ctx->dc_bios->vram_info.dram_channel_width_bytes;<br>
+<br>
+       dcn3_02_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>
+       if (bw_params->clk_table.entries[0].memclk_mhz) {<br>
+               int max_dcfclk_mhz = 0, max_dispclk_mhz = 0, max_dppclk_mhz = 0, max_phyclk_mhz = 0;<br>
+<br>
+               for (i = 0; i < MAX_NUM_DPM_LVL; i++) {<br>
+                       if (bw_params->clk_table.entries[i].dcfclk_mhz > max_dcfclk_mhz)<br>
+                               max_dcfclk_mhz = bw_params->clk_table.entries[i].dcfclk_mhz;<br>
+                       if (bw_params->clk_table.entries[i].dispclk_mhz > max_dispclk_mhz)<br>
+                               max_dispclk_mhz = bw_params->clk_table.entries[i].dispclk_mhz;<br>
+                       if (bw_params->clk_table.entries[i].dppclk_mhz > max_dppclk_mhz)<br>
+                               max_dppclk_mhz = bw_params->clk_table.entries[i].dppclk_mhz;<br>
+                       if (bw_params->clk_table.entries[i].phyclk_mhz > max_phyclk_mhz)<br>
+                               max_phyclk_mhz = bw_params->clk_table.entries[i].phyclk_mhz;<br>
+               }<br>
+               if (!max_dcfclk_mhz)<br>
+                       max_dcfclk_mhz = dcn3_02_soc.clock_limits[0].dcfclk_mhz;<br>
+               if (!max_dispclk_mhz)<br>
+                       max_dispclk_mhz = dcn3_02_soc.clock_limits[0].dispclk_mhz;<br>
+               if (!max_dppclk_mhz)<br>
+                       max_dppclk_mhz = dcn3_02_soc.clock_limits[0].dppclk_mhz;<br>
+               if (!max_phyclk_mhz)<br>
+                       max_phyclk_mhz = dcn3_02_soc.clock_limits[0].phyclk_mhz;<br>
+<br>
+               if (max_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] = max_dcfclk_mhz;<br>
+                       num_dcfclk_sta_targets++;<br>
+               } else if (max_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] > max_dcfclk_mhz) {<br>
+                                       dcfclk_sta_targets[i] = max_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>
+                       dcn302_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>
+               /* 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] <= max_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] <= max_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>
+               dcn3_02_soc.num_states = num_states;<br>
+               for (i = 0; i < dcn3_02_soc.num_states; i++) {<br>
+                       dcn3_02_soc.clock_limits[i].state = i;<br>
+                       dcn3_02_soc.clock_limits[i].dcfclk_mhz = dcfclk_mhz[i];<br>
+                       dcn3_02_soc.clock_limits[i].fabricclk_mhz = dcfclk_mhz[i];<br>
+                       dcn3_02_soc.clock_limits[i].dram_speed_mts = dram_speed_mts[i];<br>
+<br>
+                       /* Fill all states with max values of all other clocks */<br>
+                       dcn3_02_soc.clock_limits[i].dispclk_mhz = max_dispclk_mhz;<br>
+                       dcn3_02_soc.clock_limits[i].dppclk_mhz  = max_dppclk_mhz;<br>
+                       dcn3_02_soc.clock_limits[i].phyclk_mhz  = max_phyclk_mhz;<br>
+                       /* Populate from bw_params for DTBCLK, SOCCLK */<br>
+                       if (!bw_params->clk_table.entries[i].dtbclk_mhz && i > 0)<br>
+                               dcn3_02_soc.clock_limits[i].dtbclk_mhz  = dcn3_02_soc.clock_limits[i-1].dtbclk_mhz;<br>
+                       else<br>
+                               dcn3_02_soc.clock_limits[i].dtbclk_mhz  = bw_params->clk_table.entries[i].dtbclk_mhz;<br>
+                       if (!bw_params->clk_table.entries[i].socclk_mhz && i > 0)<br>
+                               dcn3_02_soc.clock_limits[i].socclk_mhz = dcn3_02_soc.clock_limits[i-1].socclk_mhz;<br>
+                       else<br>
+                               dcn3_02_soc.clock_limits[i].socclk_mhz = bw_params->clk_table.entries[i].socclk_mhz;<br>
+                       /* These clocks cannot come from bw_params, always fill from dcn3_02_soc[1] */<br>
+                       /* FCLK, PHYCLK_D18, DSCCLK */<br>
+                       dcn3_02_soc.clock_limits[i].phyclk_d18_mhz = dcn3_02_soc.clock_limits[0].phyclk_d18_mhz;<br>
+                       dcn3_02_soc.clock_limits[i].dscclk_mhz = dcn3_02_soc.clock_limits[0].dscclk_mhz;<br>
+               }<br>
+               /* re-init DML with updated bb */<br>
+               dml_init_instance(&dc->dml, &dcn3_02_soc, &dcn3_02_ip, DML_PROJECT_DCN30);<br>
+               if (dc->current_state)<br>
+                       dml_init_instance(&dc->current_state->bw_ctx.dml, &dcn3_02_soc, &dcn3_02_ip, DML_PROJECT_DCN30);<br>
+       }<br>
+}<br>
+<br>
+void dcn302_fpu_init_soc_bounding_box(struct bp_soc_bb_info bb_info)<br>
+{<br>
+<br>
+                       dc_assert_fp_enabled();<br>
+<br>
+                       if (bb_info.dram_clock_change_latency_100ns > 0)<br>
+                               dcn3_02_soc.dram_clock_change_latency_us =<br>
+                                       bb_info.dram_clock_change_latency_100ns * 10;<br>
+<br>
+                       if (bb_info.dram_sr_enter_exit_latency_100ns > 0)<br>
+                               dcn3_02_soc.sr_enter_plus_exit_time_us =<br>
+                                       bb_info.dram_sr_enter_exit_latency_100ns * 10;<br>
+<br>
+                       if (bb_info.dram_sr_exit_latency_100ns > 0)<br>
+                               dcn3_02_soc.sr_exit_time_us =<br>
+                                       bb_info.dram_sr_exit_latency_100ns * 10;<br>
+}<br>
+<br>
+<br>
diff --git a/dc/dml/dcn302/dcn302_fpu.h b/dc/dml/dcn302/dcn302_fpu.h<br>
new file mode 100644<br>
index 000000000..548305d96<br>
--- /dev/null<br>
+++ b/dc/dml/dcn302/dcn302_fpu.h<br>
@@ -0,0 +1,32 @@<br>
+/*<br>
+ * Copyright 2019-2021 Advanced Micro Devices, Inc.<br>
+ *<br>
+ * Permission is hereby granted, free of charge, to any person obtaining a<br>
+ * copy of this software and associated documentation files (the "Software"),<br>
+ * to deal in the Software without restriction, including without limitation<br>
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,<br>
+ * and/or sell copies of the Software, and to permit persons to whom the<br>
+ * Software is furnished to do so, subject to the following conditions:<br>
+ *<br>
+ * The above copyright notice and this permission notice shall be included in<br>
+ * all copies or substantial portions of the Software.<br>
+ *<br>
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br>
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br>
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL<br>
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR<br>
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,<br>
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR<br>
+ * OTHER DEALINGS IN THE SOFTWARE.<br>
+ *<br>
+ * Authors: AMD<br>
+ *<br>
+ */<br>
+<br>
+#ifndef __DCN302_FPU_H__<br>
+#define __DCN302_FPU_H__<br>
+<br>
+void dcn302_fpu_init_soc_bounding_box(struct bp_soc_bb_info bb_info);<br>
+void dcn302_fpu_update_bw_bounding_box(struct dc *dc, struct clk_bw_params *bw_params);<br>
+<br>
+#endif /* __DCN302_FPU_H__*/<br>
-- <br>
2.25.1<br>
<br>
</div>
</span></font></div>
</div>
</body>
</html>