2 * Copyright 2019-2021 Advanced Micro Devices, Inc.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
29 #include "dml/dcn20/dcn20_fpu.h"
30 #include "dcn31_fpu.h"
33 * DOC: DCN31x FPU manipulation Overview
35 * The DCN architecture relies on FPU operations, which require special
36 * compilation flags and the use of kernel_fpu_begin/end functions; ideally, we
37 * want to avoid spreading FPU access across multiple files. With this idea in
38 * mind, this file aims to centralize all DCN3.1.x functions that require FPU
39 * access in a single place. Code in this file follows the following code
42 * 1. Functions that use FPU operations should be isolated in static functions.
43 * 2. The FPU functions should have the noinline attribute to ensure anything
44 * that deals with FP register is contained within this call.
45 * 3. All function that needs to be accessed outside this file requires a
46 * public interface that not uses any FPU reference.
47 * 4. Developers **must not** use DC_FP_START/END in this file, but they need
48 * to ensure that the caller invokes it before access any function available
49 * in this file. For this reason, public functions in this file must invoke
50 * dc_assert_fp_enabled();
53 struct _vcs_dpi_ip_params_st dcn3_1_ip = {
55 .gpuvm_max_page_table_levels = 1,
57 .hostvm_max_page_table_levels = 2,
58 .rob_buffer_size_kbytes = 64,
59 .det_buffer_size_kbytes = DCN3_1_DEFAULT_DET_SIZE,
60 .config_return_buffer_size_in_kbytes = 1792,
61 .compressed_buffer_segment_size_in_kbytes = 64,
62 .meta_fifo_size_in_kentries = 32,
63 .zero_size_buffer_entries = 512,
64 .compbuf_reserved_space_64b = 256,
65 .compbuf_reserved_space_zs = 64,
66 .dpp_output_buffer_pixels = 2560,
67 .opp_output_buffer_lines = 1,
68 .pixel_chunk_size_kbytes = 8,
69 .meta_chunk_size_kbytes = 2,
70 .min_meta_chunk_size_bytes = 256,
71 .writeback_chunk_size_kbytes = 8,
72 .ptoi_supported = false,
74 .maximum_dsc_bits_per_component = 10,
75 .dsc422_native_support = false,
76 .is_line_buffer_bpp_fixed = true,
77 .line_buffer_fixed_bpp = 48,
78 .line_buffer_size_bits = 789504,
79 .max_line_buffer_lines = 12,
80 .writeback_interface_buffer_size_kbytes = 90,
83 .max_num_hdmi_frl_outputs = 1,
85 .max_dchub_pscl_bw_pix_per_clk = 4,
86 .max_pscl_lb_bw_pix_per_clk = 2,
87 .max_lb_vscl_bw_pix_per_clk = 4,
88 .max_vscl_hscl_bw_pix_per_clk = 4,
93 .dpte_buffer_size_in_pte_reqs_luma = 64,
94 .dpte_buffer_size_in_pte_reqs_chroma = 34,
95 .dispclk_ramp_margin_percent = 1,
96 .max_inter_dcn_tile_repeaters = 8,
97 .cursor_buffer_size = 16,
98 .cursor_chunk_size = 2,
99 .writeback_line_buffer_buffer_size = 0,
100 .writeback_min_hscl_ratio = 1,
101 .writeback_min_vscl_ratio = 1,
102 .writeback_max_hscl_ratio = 1,
103 .writeback_max_vscl_ratio = 1,
104 .writeback_max_hscl_taps = 1,
105 .writeback_max_vscl_taps = 1,
106 .dppclk_delay_subtotal = 46,
107 .dppclk_delay_scl = 50,
108 .dppclk_delay_scl_lb_only = 16,
109 .dppclk_delay_cnvc_formatter = 27,
110 .dppclk_delay_cnvc_cursor = 6,
111 .dispclk_delay_subtotal = 119,
112 .dynamic_metadata_vm_enabled = false,
113 .odm_combine_4to1_supported = false,
114 .dcc_supported = true,
117 struct _vcs_dpi_soc_bounding_box_st dcn3_1_soc = {
118 /*TODO: correct dispclk/dppclk voltage level determination*/
122 .dispclk_mhz = 1200.0,
123 .dppclk_mhz = 1200.0,
125 .phyclk_d18_mhz = 667.0,
131 .dispclk_mhz = 1200.0,
132 .dppclk_mhz = 1200.0,
134 .phyclk_d18_mhz = 667.0,
140 .dispclk_mhz = 1200.0,
141 .dppclk_mhz = 1200.0,
143 .phyclk_d18_mhz = 667.0,
149 .dispclk_mhz = 1200.0,
150 .dppclk_mhz = 1200.0,
152 .phyclk_d18_mhz = 667.0,
158 .dispclk_mhz = 1200.0,
159 .dppclk_mhz = 1200.0,
161 .phyclk_d18_mhz = 667.0,
167 .sr_exit_time_us = 9.0,
168 .sr_enter_plus_exit_time_us = 11.0,
169 .sr_exit_z8_time_us = 442.0,
170 .sr_enter_plus_exit_z8_time_us = 560.0,
171 .writeback_latency_us = 12.0,
172 .dram_channel_width_bytes = 4,
173 .round_trip_ping_latency_dcfclk_cycles = 106,
174 .urgent_latency_pixel_data_only_us = 4.0,
175 .urgent_latency_pixel_mixed_with_vm_data_us = 4.0,
176 .urgent_latency_vm_data_only_us = 4.0,
177 .urgent_out_of_order_return_per_channel_pixel_only_bytes = 4096,
178 .urgent_out_of_order_return_per_channel_pixel_and_vm_bytes = 4096,
179 .urgent_out_of_order_return_per_channel_vm_only_bytes = 4096,
180 .pct_ideal_sdp_bw_after_urgent = 80.0,
181 .pct_ideal_dram_sdp_bw_after_urgent_pixel_only = 65.0,
182 .pct_ideal_dram_sdp_bw_after_urgent_pixel_and_vm = 60.0,
183 .pct_ideal_dram_sdp_bw_after_urgent_vm_only = 30.0,
184 .max_avg_sdp_bw_use_normal_percent = 60.0,
185 .max_avg_dram_bw_use_normal_percent = 60.0,
186 .fabric_datapath_to_dcn_data_return_bytes = 32,
187 .return_bus_width_bytes = 64,
188 .downspread_percent = 0.38,
189 .dcn_downspread_percent = 0.5,
190 .gpuvm_min_page_size_bytes = 4096,
191 .hostvm_min_page_size_bytes = 4096,
192 .do_urgent_latency_adjustment = false,
193 .urgent_latency_adjustment_fabric_clock_component_us = 0,
194 .urgent_latency_adjustment_fabric_clock_reference_mhz = 0,
197 struct _vcs_dpi_ip_params_st dcn3_15_ip = {
199 .gpuvm_max_page_table_levels = 1,
201 .hostvm_max_page_table_levels = 2,
202 .rob_buffer_size_kbytes = 64,
203 .det_buffer_size_kbytes = DCN3_15_DEFAULT_DET_SIZE,
204 .min_comp_buffer_size_kbytes = 64,
205 .config_return_buffer_size_in_kbytes = 1024,
206 .compressed_buffer_segment_size_in_kbytes = 64,
207 .meta_fifo_size_in_kentries = 32,
208 .zero_size_buffer_entries = 512,
209 .compbuf_reserved_space_64b = 256,
210 .compbuf_reserved_space_zs = 64,
211 .dpp_output_buffer_pixels = 2560,
212 .opp_output_buffer_lines = 1,
213 .pixel_chunk_size_kbytes = 8,
214 .meta_chunk_size_kbytes = 2,
215 .min_meta_chunk_size_bytes = 256,
216 .writeback_chunk_size_kbytes = 8,
217 .ptoi_supported = false,
219 .maximum_dsc_bits_per_component = 10,
220 .dsc422_native_support = false,
221 .is_line_buffer_bpp_fixed = true,
222 .line_buffer_fixed_bpp = 49,
223 .line_buffer_size_bits = 789504,
224 .max_line_buffer_lines = 12,
225 .writeback_interface_buffer_size_kbytes = 90,
228 .max_num_hdmi_frl_outputs = 1,
230 .max_dchub_pscl_bw_pix_per_clk = 4,
231 .max_pscl_lb_bw_pix_per_clk = 2,
232 .max_lb_vscl_bw_pix_per_clk = 4,
233 .max_vscl_hscl_bw_pix_per_clk = 4,
238 .dpte_buffer_size_in_pte_reqs_luma = 64,
239 .dpte_buffer_size_in_pte_reqs_chroma = 34,
240 .dispclk_ramp_margin_percent = 1,
241 .max_inter_dcn_tile_repeaters = 9,
242 .cursor_buffer_size = 16,
243 .cursor_chunk_size = 2,
244 .writeback_line_buffer_buffer_size = 0,
245 .writeback_min_hscl_ratio = 1,
246 .writeback_min_vscl_ratio = 1,
247 .writeback_max_hscl_ratio = 1,
248 .writeback_max_vscl_ratio = 1,
249 .writeback_max_hscl_taps = 1,
250 .writeback_max_vscl_taps = 1,
251 .dppclk_delay_subtotal = 46,
252 .dppclk_delay_scl = 50,
253 .dppclk_delay_scl_lb_only = 16,
254 .dppclk_delay_cnvc_formatter = 27,
255 .dppclk_delay_cnvc_cursor = 6,
256 .dispclk_delay_subtotal = 119,
257 .dynamic_metadata_vm_enabled = false,
258 .odm_combine_4to1_supported = false,
259 .dcc_supported = true,
262 struct _vcs_dpi_soc_bounding_box_st dcn3_15_soc = {
263 .sr_exit_time_us = 9.0,
264 .sr_enter_plus_exit_time_us = 11.0,
265 .sr_exit_z8_time_us = 50.0,
266 .sr_enter_plus_exit_z8_time_us = 50.0,
267 .writeback_latency_us = 12.0,
268 .dram_channel_width_bytes = 4,
269 .round_trip_ping_latency_dcfclk_cycles = 106,
270 .urgent_latency_pixel_data_only_us = 4.0,
271 .urgent_latency_pixel_mixed_with_vm_data_us = 4.0,
272 .urgent_latency_vm_data_only_us = 4.0,
273 .urgent_out_of_order_return_per_channel_pixel_only_bytes = 4096,
274 .urgent_out_of_order_return_per_channel_pixel_and_vm_bytes = 4096,
275 .urgent_out_of_order_return_per_channel_vm_only_bytes = 4096,
276 .pct_ideal_sdp_bw_after_urgent = 80.0,
277 .pct_ideal_dram_sdp_bw_after_urgent_pixel_only = 65.0,
278 .pct_ideal_dram_sdp_bw_after_urgent_pixel_and_vm = 60.0,
279 .pct_ideal_dram_sdp_bw_after_urgent_vm_only = 30.0,
280 .max_avg_sdp_bw_use_normal_percent = 60.0,
281 .max_avg_dram_bw_use_normal_percent = 60.0,
282 .fabric_datapath_to_dcn_data_return_bytes = 32,
283 .return_bus_width_bytes = 64,
284 .downspread_percent = 0.38,
285 .dcn_downspread_percent = 0.38,
286 .gpuvm_min_page_size_bytes = 4096,
287 .hostvm_min_page_size_bytes = 4096,
288 .do_urgent_latency_adjustment = false,
289 .urgent_latency_adjustment_fabric_clock_component_us = 0,
290 .urgent_latency_adjustment_fabric_clock_reference_mhz = 0,
293 struct _vcs_dpi_ip_params_st dcn3_16_ip = {
295 .gpuvm_max_page_table_levels = 1,
297 .hostvm_max_page_table_levels = 2,
298 .rob_buffer_size_kbytes = 64,
299 .det_buffer_size_kbytes = DCN3_16_DEFAULT_DET_SIZE,
300 .min_comp_buffer_size_kbytes = 64,
301 .config_return_buffer_size_in_kbytes = 1024,
302 .compressed_buffer_segment_size_in_kbytes = 64,
303 .meta_fifo_size_in_kentries = 32,
304 .zero_size_buffer_entries = 512,
305 .compbuf_reserved_space_64b = 256,
306 .compbuf_reserved_space_zs = 64,
307 .dpp_output_buffer_pixels = 2560,
308 .opp_output_buffer_lines = 1,
309 .pixel_chunk_size_kbytes = 8,
310 .meta_chunk_size_kbytes = 2,
311 .min_meta_chunk_size_bytes = 256,
312 .writeback_chunk_size_kbytes = 8,
313 .ptoi_supported = false,
315 .maximum_dsc_bits_per_component = 10,
316 .dsc422_native_support = false,
317 .is_line_buffer_bpp_fixed = true,
318 .line_buffer_fixed_bpp = 48,
319 .line_buffer_size_bits = 789504,
320 .max_line_buffer_lines = 12,
321 .writeback_interface_buffer_size_kbytes = 90,
324 .max_num_hdmi_frl_outputs = 1,
326 .max_dchub_pscl_bw_pix_per_clk = 4,
327 .max_pscl_lb_bw_pix_per_clk = 2,
328 .max_lb_vscl_bw_pix_per_clk = 4,
329 .max_vscl_hscl_bw_pix_per_clk = 4,
334 .dpte_buffer_size_in_pte_reqs_luma = 64,
335 .dpte_buffer_size_in_pte_reqs_chroma = 34,
336 .dispclk_ramp_margin_percent = 1,
337 .max_inter_dcn_tile_repeaters = 8,
338 .cursor_buffer_size = 16,
339 .cursor_chunk_size = 2,
340 .writeback_line_buffer_buffer_size = 0,
341 .writeback_min_hscl_ratio = 1,
342 .writeback_min_vscl_ratio = 1,
343 .writeback_max_hscl_ratio = 1,
344 .writeback_max_vscl_ratio = 1,
345 .writeback_max_hscl_taps = 1,
346 .writeback_max_vscl_taps = 1,
347 .dppclk_delay_subtotal = 46,
348 .dppclk_delay_scl = 50,
349 .dppclk_delay_scl_lb_only = 16,
350 .dppclk_delay_cnvc_formatter = 27,
351 .dppclk_delay_cnvc_cursor = 6,
352 .dispclk_delay_subtotal = 119,
353 .dynamic_metadata_vm_enabled = false,
354 .odm_combine_4to1_supported = false,
355 .dcc_supported = true,
358 struct _vcs_dpi_soc_bounding_box_st dcn3_16_soc = {
359 /*TODO: correct dispclk/dppclk voltage level determination*/
363 .dispclk_mhz = 556.0,
366 .phyclk_d18_mhz = 445.0,
372 .dispclk_mhz = 625.0,
375 .phyclk_d18_mhz = 667.0,
381 .dispclk_mhz = 625.0,
384 .phyclk_d18_mhz = 667.0,
390 .dispclk_mhz = 1112.0,
391 .dppclk_mhz = 1112.0,
393 .phyclk_d18_mhz = 667.0,
399 .dispclk_mhz = 1250.0,
400 .dppclk_mhz = 1250.0,
402 .phyclk_d18_mhz = 667.0,
408 .sr_exit_time_us = 9.0,
409 .sr_enter_plus_exit_time_us = 11.0,
410 .sr_exit_z8_time_us = 442.0,
411 .sr_enter_plus_exit_z8_time_us = 560.0,
412 .writeback_latency_us = 12.0,
413 .dram_channel_width_bytes = 4,
414 .round_trip_ping_latency_dcfclk_cycles = 106,
415 .urgent_latency_pixel_data_only_us = 4.0,
416 .urgent_latency_pixel_mixed_with_vm_data_us = 4.0,
417 .urgent_latency_vm_data_only_us = 4.0,
418 .urgent_out_of_order_return_per_channel_pixel_only_bytes = 4096,
419 .urgent_out_of_order_return_per_channel_pixel_and_vm_bytes = 4096,
420 .urgent_out_of_order_return_per_channel_vm_only_bytes = 4096,
421 .pct_ideal_sdp_bw_after_urgent = 80.0,
422 .pct_ideal_dram_sdp_bw_after_urgent_pixel_only = 65.0,
423 .pct_ideal_dram_sdp_bw_after_urgent_pixel_and_vm = 60.0,
424 .pct_ideal_dram_sdp_bw_after_urgent_vm_only = 30.0,
425 .max_avg_sdp_bw_use_normal_percent = 60.0,
426 .max_avg_dram_bw_use_normal_percent = 60.0,
427 .fabric_datapath_to_dcn_data_return_bytes = 32,
428 .return_bus_width_bytes = 64,
429 .downspread_percent = 0.38,
430 .dcn_downspread_percent = 0.5,
431 .gpuvm_min_page_size_bytes = 4096,
432 .hostvm_min_page_size_bytes = 4096,
433 .do_urgent_latency_adjustment = false,
434 .urgent_latency_adjustment_fabric_clock_component_us = 0,
435 .urgent_latency_adjustment_fabric_clock_reference_mhz = 0,
438 void dcn31_zero_pipe_dcc_fraction(display_e2e_pipe_params_st *pipes,
441 dc_assert_fp_enabled();
443 pipes[pipe_cnt].pipe.src.dcc_fraction_of_zs_req_luma = 0;
444 pipes[pipe_cnt].pipe.src.dcc_fraction_of_zs_req_chroma = 0;
447 void dcn31_update_soc_for_wm_a(struct dc *dc, struct dc_state *context)
449 dc_assert_fp_enabled();
451 if (dc->clk_mgr->bw_params->wm_table.entries[WM_A].valid) {
452 context->bw_ctx.dml.soc.dram_clock_change_latency_us = dc->clk_mgr->bw_params->wm_table.entries[WM_A].pstate_latency_us;
453 context->bw_ctx.dml.soc.sr_enter_plus_exit_time_us = dc->clk_mgr->bw_params->wm_table.entries[WM_A].sr_enter_plus_exit_time_us;
454 context->bw_ctx.dml.soc.sr_exit_time_us = dc->clk_mgr->bw_params->wm_table.entries[WM_A].sr_exit_time_us;
458 void dcn31_calculate_wm_and_dlg_fp(
459 struct dc *dc, struct dc_state *context,
460 display_e2e_pipe_params_st *pipes,
465 double dcfclk = context->bw_ctx.dml.vba.DCFCLKState[vlevel][context->bw_ctx.dml.vba.maxMpcComb];
467 dc_assert_fp_enabled();
469 if (context->bw_ctx.dml.soc.min_dcfclk > dcfclk)
470 dcfclk = context->bw_ctx.dml.soc.min_dcfclk;
472 /* We don't recalculate clocks for 0 pipe configs, which can block
473 * S0i3 as high clocks will block low power states
474 * Override any clocks that can block S0i3 to min here
477 context->bw_ctx.bw.dcn.clk.dcfclk_khz = dcfclk; // always should be vlevel 0
481 pipes[0].clks_cfg.voltage = vlevel;
482 pipes[0].clks_cfg.dcfclk_mhz = dcfclk;
483 pipes[0].clks_cfg.socclk_mhz = context->bw_ctx.dml.soc.clock_limits[vlevel].socclk_mhz;
489 if (dc->clk_mgr->bw_params->wm_table.nv_entries[WM_B].valid) {
491 pipes[0].clks_cfg.voltage = 1;
492 pipes[0].clks_cfg.dcfclk_mhz = context->bw_ctx.dml.soc.clock_limits[0].dcfclk_mhz;
494 context->bw_ctx.dml.soc.dram_clock_change_latency_us = dc->clk_mgr->bw_params->wm_table.nv_entries[WM_B].dml_input.pstate_latency_us;
495 context->bw_ctx.dml.soc.sr_enter_plus_exit_time_us = dc->clk_mgr->bw_params->wm_table.nv_entries[WM_B].dml_input.sr_enter_plus_exit_time_us;
496 context->bw_ctx.dml.soc.sr_exit_time_us = dc->clk_mgr->bw_params->wm_table.nv_entries[WM_B].dml_input.sr_exit_time_us;
498 context->bw_ctx.bw.dcn.watermarks.b.urgent_ns = get_wm_urgent(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000;
499 context->bw_ctx.bw.dcn.watermarks.b.cstate_pstate.cstate_enter_plus_exit_ns = get_wm_stutter_enter_exit(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000;
500 context->bw_ctx.bw.dcn.watermarks.b.cstate_pstate.cstate_exit_ns = get_wm_stutter_exit(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000;
501 context->bw_ctx.bw.dcn.watermarks.b.cstate_pstate.cstate_enter_plus_exit_z8_ns = get_wm_z8_stutter_enter_exit(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000;
502 context->bw_ctx.bw.dcn.watermarks.b.cstate_pstate.cstate_exit_z8_ns = get_wm_z8_stutter_exit(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000;
503 context->bw_ctx.bw.dcn.watermarks.b.cstate_pstate.pstate_change_ns = get_wm_dram_clock_change(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000;
504 context->bw_ctx.bw.dcn.watermarks.b.pte_meta_urgent_ns = get_wm_memory_trip(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000;
505 context->bw_ctx.bw.dcn.watermarks.b.frac_urg_bw_nom = get_fraction_of_urgent_bandwidth(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000;
506 context->bw_ctx.bw.dcn.watermarks.b.frac_urg_bw_flip = get_fraction_of_urgent_bandwidth_imm_flip(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000;
507 context->bw_ctx.bw.dcn.watermarks.b.urgent_latency_ns = get_urgent_latency(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000;
509 pipes[0].clks_cfg.voltage = vlevel;
510 pipes[0].clks_cfg.dcfclk_mhz = dcfclk;
515 if (dc->clk_mgr->bw_params->wm_table.nv_entries[WM_C].valid) {
516 context->bw_ctx.dml.soc.dram_clock_change_latency_us = dc->clk_mgr->bw_params->wm_table.nv_entries[WM_C].dml_input.pstate_latency_us;
517 context->bw_ctx.dml.soc.sr_enter_plus_exit_time_us = dc->clk_mgr->bw_params->wm_table.nv_entries[WM_C].dml_input.sr_enter_plus_exit_time_us;
518 context->bw_ctx.dml.soc.sr_exit_time_us = dc->clk_mgr->bw_params->wm_table.nv_entries[WM_C].dml_input.sr_exit_time_us;
520 context->bw_ctx.bw.dcn.watermarks.c.urgent_ns = get_wm_urgent(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000;
521 context->bw_ctx.bw.dcn.watermarks.c.cstate_pstate.cstate_enter_plus_exit_ns = get_wm_stutter_enter_exit(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000;
522 context->bw_ctx.bw.dcn.watermarks.c.cstate_pstate.cstate_exit_ns = get_wm_stutter_exit(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000;
523 context->bw_ctx.bw.dcn.watermarks.c.cstate_pstate.cstate_enter_plus_exit_z8_ns = get_wm_z8_stutter_enter_exit(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000;
524 context->bw_ctx.bw.dcn.watermarks.c.cstate_pstate.cstate_exit_z8_ns = get_wm_z8_stutter_exit(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000;
525 context->bw_ctx.bw.dcn.watermarks.c.cstate_pstate.pstate_change_ns = get_wm_dram_clock_change(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000;
526 context->bw_ctx.bw.dcn.watermarks.c.pte_meta_urgent_ns = get_wm_memory_trip(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000;
527 context->bw_ctx.bw.dcn.watermarks.c.frac_urg_bw_nom = get_fraction_of_urgent_bandwidth(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000;
528 context->bw_ctx.bw.dcn.watermarks.c.frac_urg_bw_flip = get_fraction_of_urgent_bandwidth_imm_flip(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000;
529 context->bw_ctx.bw.dcn.watermarks.c.urgent_latency_ns = get_urgent_latency(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000;
534 if (dc->clk_mgr->bw_params->wm_table.nv_entries[WM_D].valid) {
535 context->bw_ctx.dml.soc.dram_clock_change_latency_us = dc->clk_mgr->bw_params->wm_table.nv_entries[WM_D].dml_input.pstate_latency_us;
536 context->bw_ctx.dml.soc.sr_enter_plus_exit_time_us = dc->clk_mgr->bw_params->wm_table.nv_entries[WM_D].dml_input.sr_enter_plus_exit_time_us;
537 context->bw_ctx.dml.soc.sr_exit_time_us = dc->clk_mgr->bw_params->wm_table.nv_entries[WM_D].dml_input.sr_exit_time_us;
539 context->bw_ctx.bw.dcn.watermarks.d.urgent_ns = get_wm_urgent(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000;
540 context->bw_ctx.bw.dcn.watermarks.d.cstate_pstate.cstate_enter_plus_exit_ns = get_wm_stutter_enter_exit(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000;
541 context->bw_ctx.bw.dcn.watermarks.d.cstate_pstate.cstate_exit_ns = get_wm_stutter_exit(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000;
542 context->bw_ctx.bw.dcn.watermarks.d.cstate_pstate.pstate_change_ns = get_wm_dram_clock_change(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000;
543 context->bw_ctx.bw.dcn.watermarks.d.cstate_pstate.cstate_enter_plus_exit_z8_ns = get_wm_z8_stutter_enter_exit(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000;
544 context->bw_ctx.bw.dcn.watermarks.d.cstate_pstate.cstate_exit_z8_ns = get_wm_z8_stutter_exit(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000;
545 context->bw_ctx.bw.dcn.watermarks.d.pte_meta_urgent_ns = get_wm_memory_trip(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000;
546 context->bw_ctx.bw.dcn.watermarks.d.frac_urg_bw_nom = get_fraction_of_urgent_bandwidth(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000;
547 context->bw_ctx.bw.dcn.watermarks.d.frac_urg_bw_flip = get_fraction_of_urgent_bandwidth_imm_flip(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000;
548 context->bw_ctx.bw.dcn.watermarks.d.urgent_latency_ns = get_urgent_latency(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000;
552 * All clocks min required
554 * Set A calculated last so that following calculations are based on Set A
556 dc->res_pool->funcs->update_soc_for_wm_a(dc, context);
557 context->bw_ctx.bw.dcn.watermarks.a.urgent_ns = get_wm_urgent(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000;
558 context->bw_ctx.bw.dcn.watermarks.a.cstate_pstate.cstate_enter_plus_exit_ns = get_wm_stutter_enter_exit(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000;
559 context->bw_ctx.bw.dcn.watermarks.a.cstate_pstate.cstate_exit_ns = get_wm_stutter_exit(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000;
560 context->bw_ctx.bw.dcn.watermarks.a.cstate_pstate.pstate_change_ns = get_wm_dram_clock_change(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000;
561 context->bw_ctx.bw.dcn.watermarks.a.cstate_pstate.cstate_enter_plus_exit_z8_ns = get_wm_z8_stutter_enter_exit(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000;
562 context->bw_ctx.bw.dcn.watermarks.a.cstate_pstate.cstate_exit_z8_ns = get_wm_z8_stutter_exit(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000;
563 context->bw_ctx.bw.dcn.watermarks.a.pte_meta_urgent_ns = get_wm_memory_trip(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000;
564 context->bw_ctx.bw.dcn.watermarks.a.frac_urg_bw_nom = get_fraction_of_urgent_bandwidth(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000;
565 context->bw_ctx.bw.dcn.watermarks.a.frac_urg_bw_flip = get_fraction_of_urgent_bandwidth_imm_flip(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000;
566 context->bw_ctx.bw.dcn.watermarks.a.urgent_latency_ns = get_urgent_latency(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000;
568 context->bw_ctx.bw.dcn.watermarks.b = context->bw_ctx.bw.dcn.watermarks.a;
569 context->bw_ctx.bw.dcn.watermarks.c = context->bw_ctx.bw.dcn.watermarks.a;
570 context->bw_ctx.bw.dcn.watermarks.d = context->bw_ctx.bw.dcn.watermarks.a;
573 for (i = 0, pipe_idx = 0; i < dc->res_pool->pipe_count; i++) {
574 if (!context->res_ctx.pipe_ctx[i].stream)
577 pipes[pipe_idx].clks_cfg.dispclk_mhz = get_dispclk_calculated(&context->bw_ctx.dml, pipes, pipe_cnt);
578 pipes[pipe_idx].clks_cfg.dppclk_mhz = get_dppclk_calculated(&context->bw_ctx.dml, pipes, pipe_cnt, pipe_idx);
580 if (dc->config.forced_clocks || dc->debug.max_disp_clk) {
581 pipes[pipe_idx].clks_cfg.dispclk_mhz = context->bw_ctx.dml.soc.clock_limits[0].dispclk_mhz;
582 pipes[pipe_idx].clks_cfg.dppclk_mhz = context->bw_ctx.dml.soc.clock_limits[0].dppclk_mhz;
584 if (dc->debug.min_disp_clk_khz > pipes[pipe_idx].clks_cfg.dispclk_mhz * 1000)
585 pipes[pipe_idx].clks_cfg.dispclk_mhz = dc->debug.min_disp_clk_khz / 1000.0;
586 if (dc->debug.min_dpp_clk_khz > pipes[pipe_idx].clks_cfg.dppclk_mhz * 1000)
587 pipes[pipe_idx].clks_cfg.dppclk_mhz = dc->debug.min_dpp_clk_khz / 1000.0;
592 dcn20_calculate_dlg_params(dc, context, pipes, pipe_cnt, vlevel);
595 void dcn31_update_bw_bounding_box(struct dc *dc, struct clk_bw_params *bw_params)
597 struct clk_limit_table *clk_table = &bw_params->clk_table;
598 unsigned int i, closest_clk_lvl;
601 dc_assert_fp_enabled();
603 memcpy(&dcn3_1_soc._clock_tmp, &dcn3_1_soc.clock_limits,
604 sizeof(dcn3_1_soc.clock_limits));
606 // Default clock levels are used for diags, which may lead to overclocking.
607 if (!IS_DIAG_DC(dc->ctx->dce_environment)) {
608 int max_dispclk_mhz = 0, max_dppclk_mhz = 0;
610 dcn3_1_ip.max_num_otg = dc->res_pool->res_cap->num_timing_generator;
611 dcn3_1_ip.max_num_dpp = dc->res_pool->pipe_count;
612 dcn3_1_soc.num_chans = bw_params->num_channels;
614 ASSERT(clk_table->num_entries);
616 /* Prepass to find max clocks independent of voltage level. */
617 for (i = 0; i < clk_table->num_entries; ++i) {
618 if (clk_table->entries[i].dispclk_mhz > max_dispclk_mhz)
619 max_dispclk_mhz = clk_table->entries[i].dispclk_mhz;
620 if (clk_table->entries[i].dppclk_mhz > max_dppclk_mhz)
621 max_dppclk_mhz = clk_table->entries[i].dppclk_mhz;
624 for (i = 0; i < clk_table->num_entries; i++) {
626 for (closest_clk_lvl = 0, j = dcn3_1_soc.num_states - 1; j >= 0; j--) {
627 if ((unsigned int) dcn3_1_soc.clock_limits[j].dcfclk_mhz <= clk_table->entries[i].dcfclk_mhz) {
633 dcn3_1_soc._clock_tmp[i].state = i;
635 /* Clocks dependent on voltage level. */
636 dcn3_1_soc._clock_tmp[i].dcfclk_mhz = clk_table->entries[i].dcfclk_mhz;
637 dcn3_1_soc._clock_tmp[i].fabricclk_mhz = clk_table->entries[i].fclk_mhz;
638 dcn3_1_soc._clock_tmp[i].socclk_mhz = clk_table->entries[i].socclk_mhz;
639 dcn3_1_soc._clock_tmp[i].dram_speed_mts = clk_table->entries[i].memclk_mhz * 2 * clk_table->entries[i].wck_ratio;
641 /* Clocks independent of voltage level. */
642 dcn3_1_soc._clock_tmp[i].dispclk_mhz = max_dispclk_mhz ? max_dispclk_mhz :
643 dcn3_1_soc.clock_limits[closest_clk_lvl].dispclk_mhz;
645 dcn3_1_soc._clock_tmp[i].dppclk_mhz = max_dppclk_mhz ? max_dppclk_mhz :
646 dcn3_1_soc.clock_limits[closest_clk_lvl].dppclk_mhz;
648 dcn3_1_soc._clock_tmp[i].dram_bw_per_chan_gbps = dcn3_1_soc.clock_limits[closest_clk_lvl].dram_bw_per_chan_gbps;
649 dcn3_1_soc._clock_tmp[i].dscclk_mhz = dcn3_1_soc.clock_limits[closest_clk_lvl].dscclk_mhz;
650 dcn3_1_soc._clock_tmp[i].dtbclk_mhz = dcn3_1_soc.clock_limits[closest_clk_lvl].dtbclk_mhz;
651 dcn3_1_soc._clock_tmp[i].phyclk_d18_mhz = dcn3_1_soc.clock_limits[closest_clk_lvl].phyclk_d18_mhz;
652 dcn3_1_soc._clock_tmp[i].phyclk_mhz = dcn3_1_soc.clock_limits[closest_clk_lvl].phyclk_mhz;
654 if (clk_table->num_entries) {
655 dcn3_1_soc.num_states = clk_table->num_entries;
659 memcpy(&dcn3_1_soc.clock_limits, &dcn3_1_soc._clock_tmp,
660 sizeof(dcn3_1_soc.clock_limits));
662 dcn3_1_soc.dispclk_dppclk_vco_speed_mhz = dc->clk_mgr->dentist_vco_freq_khz / 1000.0;
663 dc->dml.soc.dispclk_dppclk_vco_speed_mhz = dc->clk_mgr->dentist_vco_freq_khz / 1000.0;
665 if (!IS_FPGA_MAXIMUS_DC(dc->ctx->dce_environment))
666 dml_init_instance(&dc->dml, &dcn3_1_soc, &dcn3_1_ip, DML_PROJECT_DCN31);
668 dml_init_instance(&dc->dml, &dcn3_1_soc, &dcn3_1_ip, DML_PROJECT_DCN31_FPGA);
671 void dcn315_update_bw_bounding_box(struct dc *dc, struct clk_bw_params *bw_params)
673 struct clk_limit_table *clk_table = &bw_params->clk_table;
674 int i, max_dispclk_mhz = 0, max_dppclk_mhz = 0;
676 dc_assert_fp_enabled();
678 dcn3_15_ip.max_num_otg = dc->res_pool->res_cap->num_timing_generator;
679 dcn3_15_ip.max_num_dpp = dc->res_pool->pipe_count;
680 dcn3_15_soc.num_chans = bw_params->num_channels;
682 ASSERT(clk_table->num_entries);
684 /* Setup soc to always use max dispclk/dppclk to avoid odm-to-lower-voltage */
685 for (i = 0; i < clk_table->num_entries; ++i) {
686 if (clk_table->entries[i].dispclk_mhz > max_dispclk_mhz)
687 max_dispclk_mhz = clk_table->entries[i].dispclk_mhz;
688 if (clk_table->entries[i].dppclk_mhz > max_dppclk_mhz)
689 max_dppclk_mhz = clk_table->entries[i].dppclk_mhz;
692 for (i = 0; i < clk_table->num_entries; i++) {
693 dcn3_15_soc.clock_limits[i].state = i;
695 /* Clocks dependent on voltage level. */
696 dcn3_15_soc.clock_limits[i].dcfclk_mhz = clk_table->entries[i].dcfclk_mhz;
697 dcn3_15_soc.clock_limits[i].fabricclk_mhz = clk_table->entries[i].fclk_mhz;
698 dcn3_15_soc.clock_limits[i].socclk_mhz = clk_table->entries[i].socclk_mhz;
699 dcn3_15_soc.clock_limits[i].dram_speed_mts = clk_table->entries[i].memclk_mhz * 2 * clk_table->entries[i].wck_ratio;
701 /* These aren't actually read from smu, but rather set in clk_mgr defaults */
702 dcn3_15_soc.clock_limits[i].dtbclk_mhz = clk_table->entries[i].dtbclk_mhz;
703 dcn3_15_soc.clock_limits[i].phyclk_d18_mhz = clk_table->entries[i].phyclk_d18_mhz;
704 dcn3_15_soc.clock_limits[i].phyclk_mhz = clk_table->entries[i].phyclk_mhz;
706 /* Clocks independent of voltage level. */
707 dcn3_15_soc.clock_limits[i].dispclk_mhz = max_dispclk_mhz;
708 dcn3_15_soc.clock_limits[i].dppclk_mhz = max_dppclk_mhz;
709 dcn3_15_soc.clock_limits[i].dscclk_mhz = max_dispclk_mhz / 3.0;
711 dcn3_15_soc.num_states = clk_table->num_entries;
714 /* Set vco to max_dispclk * 2 to make sure the highest dispclk is always available for dml calcs,
715 * no impact outside of dml validation
717 dcn3_15_soc.dispclk_dppclk_vco_speed_mhz = max_dispclk_mhz * 2;
719 if (!IS_FPGA_MAXIMUS_DC(dc->ctx->dce_environment))
720 dml_init_instance(&dc->dml, &dcn3_15_soc, &dcn3_15_ip, DML_PROJECT_DCN31);
722 dml_init_instance(&dc->dml, &dcn3_15_soc, &dcn3_15_ip, DML_PROJECT_DCN31_FPGA);
725 void dcn316_update_bw_bounding_box(struct dc *dc, struct clk_bw_params *bw_params)
727 struct clk_limit_table *clk_table = &bw_params->clk_table;
728 unsigned int i, closest_clk_lvl;
729 int max_dispclk_mhz = 0, max_dppclk_mhz = 0;
732 dc_assert_fp_enabled();
734 memcpy(&dcn3_16_soc._clock_tmp, &dcn3_16_soc.clock_limits,
735 sizeof(dcn3_16_soc.clock_limits));
737 // Default clock levels are used for diags, which may lead to overclocking.
738 if (!IS_DIAG_DC(dc->ctx->dce_environment)) {
740 dcn3_16_ip.max_num_otg = dc->res_pool->res_cap->num_timing_generator;
741 dcn3_16_ip.max_num_dpp = dc->res_pool->pipe_count;
742 dcn3_16_soc.num_chans = bw_params->num_channels;
744 ASSERT(clk_table->num_entries);
746 /* Prepass to find max clocks independent of voltage level. */
747 for (i = 0; i < clk_table->num_entries; ++i) {
748 if (clk_table->entries[i].dispclk_mhz > max_dispclk_mhz)
749 max_dispclk_mhz = clk_table->entries[i].dispclk_mhz;
750 if (clk_table->entries[i].dppclk_mhz > max_dppclk_mhz)
751 max_dppclk_mhz = clk_table->entries[i].dppclk_mhz;
754 for (i = 0; i < clk_table->num_entries; i++) {
756 for (closest_clk_lvl = 0, j = dcn3_16_soc.num_states - 1; j >= 0; j--) {
757 if ((unsigned int) dcn3_16_soc.clock_limits[j].dcfclk_mhz <= clk_table->entries[i].dcfclk_mhz) {
762 // Ported from DCN315
763 if (clk_table->num_entries == 1) {
764 /*smu gives one DPM level, let's take the highest one*/
765 closest_clk_lvl = dcn3_16_soc.num_states - 1;
768 dcn3_16_soc._clock_tmp[i].state = i;
770 /* Clocks dependent on voltage level. */
771 dcn3_16_soc._clock_tmp[i].dcfclk_mhz = clk_table->entries[i].dcfclk_mhz;
772 if (clk_table->num_entries == 1 &&
773 dcn3_16_soc._clock_tmp[i].dcfclk_mhz < dcn3_16_soc.clock_limits[closest_clk_lvl].dcfclk_mhz) {
774 /*SMU fix not released yet*/
775 dcn3_16_soc._clock_tmp[i].dcfclk_mhz = dcn3_16_soc.clock_limits[closest_clk_lvl].dcfclk_mhz;
777 dcn3_16_soc._clock_tmp[i].fabricclk_mhz = clk_table->entries[i].fclk_mhz;
778 dcn3_16_soc._clock_tmp[i].socclk_mhz = clk_table->entries[i].socclk_mhz;
779 dcn3_16_soc._clock_tmp[i].dram_speed_mts = clk_table->entries[i].memclk_mhz * 2 * clk_table->entries[i].wck_ratio;
781 /* Clocks independent of voltage level. */
782 dcn3_16_soc._clock_tmp[i].dispclk_mhz = max_dispclk_mhz ? max_dispclk_mhz :
783 dcn3_16_soc.clock_limits[closest_clk_lvl].dispclk_mhz;
785 dcn3_16_soc._clock_tmp[i].dppclk_mhz = max_dppclk_mhz ? max_dppclk_mhz :
786 dcn3_16_soc.clock_limits[closest_clk_lvl].dppclk_mhz;
788 dcn3_16_soc._clock_tmp[i].dram_bw_per_chan_gbps = dcn3_16_soc.clock_limits[closest_clk_lvl].dram_bw_per_chan_gbps;
789 dcn3_16_soc._clock_tmp[i].dscclk_mhz = dcn3_16_soc.clock_limits[closest_clk_lvl].dscclk_mhz;
790 dcn3_16_soc._clock_tmp[i].dtbclk_mhz = dcn3_16_soc.clock_limits[closest_clk_lvl].dtbclk_mhz;
791 dcn3_16_soc._clock_tmp[i].phyclk_d18_mhz = dcn3_16_soc.clock_limits[closest_clk_lvl].phyclk_d18_mhz;
792 dcn3_16_soc._clock_tmp[i].phyclk_mhz = dcn3_16_soc.clock_limits[closest_clk_lvl].phyclk_mhz;
794 if (clk_table->num_entries) {
795 dcn3_16_soc.num_states = clk_table->num_entries;
799 memcpy(&dcn3_16_soc.clock_limits, &dcn3_16_soc._clock_tmp,
800 sizeof(dcn3_16_soc.clock_limits));
802 if (max_dispclk_mhz) {
803 dcn3_16_soc.dispclk_dppclk_vco_speed_mhz = max_dispclk_mhz * 2;
804 dc->dml.soc.dispclk_dppclk_vco_speed_mhz = max_dispclk_mhz * 2;
807 if (!IS_FPGA_MAXIMUS_DC(dc->ctx->dce_environment))
808 dml_init_instance(&dc->dml, &dcn3_16_soc, &dcn3_16_ip, DML_PROJECT_DCN31);
810 dml_init_instance(&dc->dml, &dcn3_16_soc, &dcn3_16_ip, DML_PROJECT_DCN31_FPGA);