@@ -70,28 +70,20 @@ void dc_dmub_srv_destroy(struct dc_dmub_srv **dmub_srv)
7070 }
7171}
7272
73- bool dc_dmub_srv_wait_for_pending (struct dc_dmub_srv * dc_dmub_srv )
73+ void dc_dmub_srv_wait_idle (struct dc_dmub_srv * dc_dmub_srv )
7474{
75- struct dmub_srv * dmub ;
76- struct dc_context * dc_ctx ;
75+ struct dmub_srv * dmub = dc_dmub_srv -> dmub ;
76+ struct dc_context * dc_ctx = dc_dmub_srv -> ctx ;
7777 enum dmub_status status ;
7878
79- if (!dc_dmub_srv || !dc_dmub_srv -> dmub )
80- return false;
81-
82- dc_ctx = dc_dmub_srv -> ctx ;
83- dmub = dc_dmub_srv -> dmub ;
84-
8579 do {
86- status = dmub_srv_wait_for_pending (dmub , 100000 );
80+ status = dmub_srv_wait_for_idle (dmub , 100000 );
8781 } while (dc_dmub_srv -> ctx -> dc -> debug .disable_timeout && status != DMUB_STATUS_OK );
8882
8983 if (status != DMUB_STATUS_OK ) {
9084 DC_ERROR ("Error waiting for DMUB idle: status=%d\n" , status );
9185 dc_dmub_srv_log_diagnostic_data (dc_dmub_srv );
9286 }
93-
94- return status == DMUB_STATUS_OK ;
9587}
9688
9789void dc_dmub_srv_clear_inbox0_ack (struct dc_dmub_srv * dc_dmub_srv )
@@ -134,49 +126,7 @@ void dc_dmub_srv_send_inbox0_cmd(struct dc_dmub_srv *dc_dmub_srv,
134126 }
135127}
136128
137- static bool dc_dmub_srv_reg_cmd_list_queue_execute (struct dc_dmub_srv * dc_dmub_srv ,
138- unsigned int count ,
139- union dmub_rb_cmd * cmd_list )
140- {
141- struct dc_context * dc_ctx ;
142- struct dmub_srv * dmub ;
143- enum dmub_status status = DMUB_STATUS_OK ;
144- int i ;
145-
146- if (!dc_dmub_srv || !dc_dmub_srv -> dmub )
147- return false;
148-
149- dc_ctx = dc_dmub_srv -> ctx ;
150- dmub = dc_dmub_srv -> dmub ;
151-
152- for (i = 0 ; i < count ; i ++ ) {
153- /* confirm no messages pending */
154- do {
155- status = dmub_srv_wait_for_idle (dmub , 100000 );
156- } while (dc_dmub_srv -> ctx -> dc -> debug .disable_timeout && status != DMUB_STATUS_OK );
157-
158- /* queue command */
159- if (status == DMUB_STATUS_OK )
160- status = dmub_srv_reg_cmd_execute (dmub , & cmd_list [i ]);
161-
162- /* check for errors */
163- if (status != DMUB_STATUS_OK ) {
164- break ;
165- }
166- }
167-
168- if (status != DMUB_STATUS_OK ) {
169- if (status != DMUB_STATUS_POWER_STATE_D3 ) {
170- DC_ERROR ("Error starting DMUB execution: status=%d\n" , status );
171- dc_dmub_srv_log_diagnostic_data (dc_dmub_srv );
172- }
173- return false;
174- }
175-
176- return true;
177- }
178-
179- static bool dc_dmub_srv_fb_cmd_list_queue_execute (struct dc_dmub_srv * dc_dmub_srv ,
129+ bool dc_dmub_srv_cmd_list_queue_execute (struct dc_dmub_srv * dc_dmub_srv ,
180130 unsigned int count ,
181131 union dmub_rb_cmd * cmd_list )
182132{
@@ -193,16 +143,11 @@ static bool dc_dmub_srv_fb_cmd_list_queue_execute(struct dc_dmub_srv *dc_dmub_sr
193143
194144 for (i = 0 ; i < count ; i ++ ) {
195145 // Queue command
196- if (!cmd_list [i ].cmd_common .header .multi_cmd_pending ||
197- dmub_rb_num_free (& dmub -> inbox1 .rb ) >= count - i ) {
198- status = dmub_srv_fb_cmd_queue (dmub , & cmd_list [i ]);
199- } else {
200- status = DMUB_STATUS_QUEUE_FULL ;
201- }
146+ status = dmub_srv_cmd_queue (dmub , & cmd_list [i ]);
202147
203148 if (status == DMUB_STATUS_QUEUE_FULL ) {
204149 /* Execute and wait for queue to become empty again. */
205- status = dmub_srv_fb_cmd_execute (dmub );
150+ status = dmub_srv_cmd_execute (dmub );
206151 if (status == DMUB_STATUS_POWER_STATE_D3 )
207152 return false;
208153
@@ -211,7 +156,7 @@ static bool dc_dmub_srv_fb_cmd_list_queue_execute(struct dc_dmub_srv *dc_dmub_sr
211156 } while (dc_dmub_srv -> ctx -> dc -> debug .disable_timeout && status != DMUB_STATUS_OK );
212157
213158 /* Requeue the command. */
214- status = dmub_srv_fb_cmd_queue (dmub , & cmd_list [i ]);
159+ status = dmub_srv_cmd_queue (dmub , & cmd_list [i ]);
215160 }
216161
217162 if (status != DMUB_STATUS_OK ) {
@@ -223,7 +168,7 @@ static bool dc_dmub_srv_fb_cmd_list_queue_execute(struct dc_dmub_srv *dc_dmub_sr
223168 }
224169 }
225170
226- status = dmub_srv_fb_cmd_execute (dmub );
171+ status = dmub_srv_cmd_execute (dmub );
227172 if (status != DMUB_STATUS_OK ) {
228173 if (status != DMUB_STATUS_POWER_STATE_D3 ) {
229174 DC_ERROR ("Error starting DMUB execution: status=%d\n" , status );
@@ -235,23 +180,6 @@ static bool dc_dmub_srv_fb_cmd_list_queue_execute(struct dc_dmub_srv *dc_dmub_sr
235180 return true;
236181}
237182
238- bool dc_dmub_srv_cmd_list_queue_execute (struct dc_dmub_srv * dc_dmub_srv ,
239- unsigned int count ,
240- union dmub_rb_cmd * cmd_list )
241- {
242- bool res = false;
243-
244- if (dc_dmub_srv && dc_dmub_srv -> dmub ) {
245- if (dc_dmub_srv -> dmub -> inbox_type == DMUB_CMD_INTERFACE_REG ) {
246- res = dc_dmub_srv_reg_cmd_list_queue_execute (dc_dmub_srv , count , cmd_list );
247- } else {
248- res = dc_dmub_srv_fb_cmd_list_queue_execute (dc_dmub_srv , count , cmd_list );
249- }
250- }
251-
252- return res ;
253- }
254-
255183bool dc_dmub_srv_wait_for_idle (struct dc_dmub_srv * dc_dmub_srv ,
256184 enum dm_dmub_wait_type wait_type ,
257185 union dmub_rb_cmd * cmd_list )
@@ -274,18 +202,16 @@ bool dc_dmub_srv_wait_for_idle(struct dc_dmub_srv *dc_dmub_srv,
274202 DC_LOG_DEBUG ("No reply for DMUB command: status=%d\n" , status );
275203 if (!dmub -> debug .timeout_info .timeout_occured ) {
276204 dmub -> debug .timeout_info .timeout_occured = true;
277- if (cmd_list )
278- dmub -> debug .timeout_info .timeout_cmd = * cmd_list ;
205+ dmub -> debug .timeout_info .timeout_cmd = * cmd_list ;
279206 dmub -> debug .timeout_info .timestamp = dm_get_timestamp (dc_dmub_srv -> ctx );
280207 }
281208 dc_dmub_srv_log_diagnostic_data (dc_dmub_srv );
282209 return false;
283210 }
284211
285212 // Copy data back from ring buffer into command
286- if (wait_type == DM_DMUB_WAIT_TYPE_WAIT_WITH_REPLY && cmd_list ) {
287- dmub_srv_cmd_get_response (dc_dmub_srv -> dmub , cmd_list );
288- }
213+ if (wait_type == DM_DMUB_WAIT_TYPE_WAIT_WITH_REPLY )
214+ dmub_rb_get_return_data (& dmub -> inbox1_rb , cmd_list );
289215 }
290216
291217 return true;
@@ -298,10 +224,74 @@ bool dc_dmub_srv_cmd_run(struct dc_dmub_srv *dc_dmub_srv, union dmub_rb_cmd *cmd
298224
299225bool dc_dmub_srv_cmd_run_list (struct dc_dmub_srv * dc_dmub_srv , unsigned int count , union dmub_rb_cmd * cmd_list , enum dm_dmub_wait_type wait_type )
300226{
301- if (!dc_dmub_srv_cmd_list_queue_execute (dc_dmub_srv , count , cmd_list ))
227+ struct dc_context * dc_ctx ;
228+ struct dmub_srv * dmub ;
229+ enum dmub_status status ;
230+ int i ;
231+
232+ if (!dc_dmub_srv || !dc_dmub_srv -> dmub )
233+ return false;
234+
235+ dc_ctx = dc_dmub_srv -> ctx ;
236+ dmub = dc_dmub_srv -> dmub ;
237+
238+ for (i = 0 ; i < count ; i ++ ) {
239+ // Queue command
240+ status = dmub_srv_cmd_queue (dmub , & cmd_list [i ]);
241+
242+ if (status == DMUB_STATUS_QUEUE_FULL ) {
243+ /* Execute and wait for queue to become empty again. */
244+ status = dmub_srv_cmd_execute (dmub );
245+ if (status == DMUB_STATUS_POWER_STATE_D3 )
246+ return false;
247+
248+ status = dmub_srv_wait_for_idle (dmub , 100000 );
249+ if (status != DMUB_STATUS_OK )
250+ return false;
251+
252+ /* Requeue the command. */
253+ status = dmub_srv_cmd_queue (dmub , & cmd_list [i ]);
254+ }
255+
256+ if (status != DMUB_STATUS_OK ) {
257+ if (status != DMUB_STATUS_POWER_STATE_D3 ) {
258+ DC_ERROR ("Error queueing DMUB command: status=%d\n" , status );
259+ dc_dmub_srv_log_diagnostic_data (dc_dmub_srv );
260+ }
261+ return false;
262+ }
263+ }
264+
265+ status = dmub_srv_cmd_execute (dmub );
266+ if (status != DMUB_STATUS_OK ) {
267+ if (status != DMUB_STATUS_POWER_STATE_D3 ) {
268+ DC_ERROR ("Error starting DMUB execution: status=%d\n" , status );
269+ dc_dmub_srv_log_diagnostic_data (dc_dmub_srv );
270+ }
302271 return false;
272+ }
273+
274+ // Wait for DMUB to process command
275+ if (wait_type != DM_DMUB_WAIT_TYPE_NO_WAIT ) {
276+ if (dc_dmub_srv -> ctx -> dc -> debug .disable_timeout ) {
277+ do {
278+ status = dmub_srv_wait_for_idle (dmub , 100000 );
279+ } while (status != DMUB_STATUS_OK );
280+ } else
281+ status = dmub_srv_wait_for_idle (dmub , 100000 );
303282
304- return dc_dmub_srv_wait_for_idle (dc_dmub_srv , wait_type , cmd_list );
283+ if (status != DMUB_STATUS_OK ) {
284+ DC_LOG_DEBUG ("No reply for DMUB command: status=%d\n" , status );
285+ dc_dmub_srv_log_diagnostic_data (dc_dmub_srv );
286+ return false;
287+ }
288+
289+ // Copy data back from ring buffer into command
290+ if (wait_type == DM_DMUB_WAIT_TYPE_WAIT_WITH_REPLY )
291+ dmub_rb_get_return_data (& dmub -> inbox1_rb , cmd_list );
292+ }
293+
294+ return true;
305295}
306296
307297bool dc_dmub_srv_optimized_init_done (struct dc_dmub_srv * dc_dmub_srv )
@@ -1253,7 +1243,7 @@ static void dc_dmub_srv_notify_idle(const struct dc *dc, bool allow_idle)
12531243 ips_fw -> signals .bits .ips1_commit ,
12541244 ips_fw -> signals .bits .ips2_commit );
12551245
1256- dc_dmub_srv_wait_for_idle (dc -> ctx -> dmub_srv , DM_DMUB_WAIT_TYPE_WAIT , NULL );
1246+ dc_dmub_srv_wait_idle (dc -> ctx -> dmub_srv );
12571247
12581248 memset (& new_signals , 0 , sizeof (new_signals ));
12591249
@@ -1410,7 +1400,7 @@ static void dc_dmub_srv_exit_low_power_state(const struct dc *dc)
14101400 ips_fw -> signals .bits .ips1_commit ,
14111401 ips_fw -> signals .bits .ips2_commit );
14121402
1413- dmub_srv_sync_inboxes (dc -> ctx -> dmub_srv -> dmub );
1403+ dmub_srv_sync_inbox1 (dc -> ctx -> dmub_srv -> dmub );
14141404 }
14151405 }
14161406
@@ -1664,8 +1654,7 @@ void dc_dmub_srv_fams2_update_config(struct dc *dc,
16641654 /* fill in generic command header */
16651655 global_cmd -> header .type = DMUB_CMD__FW_ASSISTED_MCLK_SWITCH ;
16661656 global_cmd -> header .sub_type = DMUB_CMD__FAMS2_CONFIG ;
1667- global_cmd -> header .payload_bytes =
1668- sizeof (struct dmub_rb_cmd_fams2 ) - sizeof (struct dmub_cmd_header );
1657+ global_cmd -> header .payload_bytes = sizeof (struct dmub_rb_cmd_fams2 ) - sizeof (struct dmub_cmd_header );
16691658
16701659 if (enable ) {
16711660 /* send global configuration parameters */
@@ -1684,13 +1673,11 @@ void dc_dmub_srv_fams2_update_config(struct dc *dc,
16841673 /* configure command header */
16851674 stream_base_cmd -> header .type = DMUB_CMD__FW_ASSISTED_MCLK_SWITCH ;
16861675 stream_base_cmd -> header .sub_type = DMUB_CMD__FAMS2_CONFIG ;
1687- stream_base_cmd -> header .payload_bytes =
1688- sizeof (struct dmub_rb_cmd_fams2 ) - sizeof (struct dmub_cmd_header );
1676+ stream_base_cmd -> header .payload_bytes = sizeof (struct dmub_rb_cmd_fams2 ) - sizeof (struct dmub_cmd_header );
16891677 stream_base_cmd -> header .multi_cmd_pending = 1 ;
16901678 stream_sub_state_cmd -> header .type = DMUB_CMD__FW_ASSISTED_MCLK_SWITCH ;
16911679 stream_sub_state_cmd -> header .sub_type = DMUB_CMD__FAMS2_CONFIG ;
1692- stream_sub_state_cmd -> header .payload_bytes =
1693- sizeof (struct dmub_rb_cmd_fams2 ) - sizeof (struct dmub_cmd_header );
1680+ stream_sub_state_cmd -> header .payload_bytes = sizeof (struct dmub_rb_cmd_fams2 ) - sizeof (struct dmub_cmd_header );
16941681 stream_sub_state_cmd -> header .multi_cmd_pending = 1 ;
16951682 /* copy stream static base state */
16961683 memcpy (& stream_base_cmd -> config ,
@@ -1736,8 +1723,7 @@ void dc_dmub_srv_fams2_drr_update(struct dc *dc,
17361723 cmd .fams2_drr_update .dmub_optc_state_req .v_total_mid_frame_num = vtotal_mid_frame_num ;
17371724 cmd .fams2_drr_update .dmub_optc_state_req .program_manual_trigger = program_manual_trigger ;
17381725
1739- cmd .fams2_drr_update .header .payload_bytes =
1740- sizeof (cmd .fams2_drr_update ) - sizeof (cmd .fams2_drr_update .header );
1726+ cmd .fams2_drr_update .header .payload_bytes = sizeof (cmd .fams2_drr_update ) - sizeof (cmd .fams2_drr_update .header );
17411727
17421728 dm_execute_dmub_cmd (dc -> ctx , & cmd , DM_DMUB_WAIT_TYPE_WAIT );
17431729}
@@ -1773,8 +1759,7 @@ void dc_dmub_srv_fams2_passthrough_flip(
17731759 /* build command header */
17741760 cmds [num_cmds ].fams2_flip .header .type = DMUB_CMD__FW_ASSISTED_MCLK_SWITCH ;
17751761 cmds [num_cmds ].fams2_flip .header .sub_type = DMUB_CMD__FAMS2_FLIP ;
1776- cmds [num_cmds ].fams2_flip .header .payload_bytes =
1777- sizeof (struct dmub_rb_cmd_fams2_flip ) - sizeof (struct dmub_cmd_header );
1762+ cmds [num_cmds ].fams2_flip .header .payload_bytes = sizeof (struct dmub_rb_cmd_fams2_flip );
17781763
17791764 /* for chaining multiple commands, all but last command should set to 1 */
17801765 cmds [num_cmds ].fams2_flip .header .multi_cmd_pending = 1 ;
0 commit comments