@@ -298,13 +298,14 @@ static int pm_map_queues_v9(struct packet_manager *pm, uint32_t *buffer,
298298}
299299
300300static inline void pm_build_dequeue_wait_counts_packet_info (struct packet_manager * pm ,
301- uint32_t sch_value , uint32_t * reg_offset ,
301+ uint32_t sch_value , uint32_t que_sleep , uint32_t * reg_offset ,
302302 uint32_t * reg_data )
303303{
304- pm -> dqm -> dev -> kfd2kgd -> build_grace_period_packet_info (
304+ pm -> dqm -> dev -> kfd2kgd -> build_dequeue_wait_counts_packet_info (
305305 pm -> dqm -> dev -> adev ,
306306 pm -> dqm -> wait_times ,
307307 sch_value ,
308+ que_sleep ,
308309 reg_offset ,
309310 reg_data );
310311}
@@ -319,27 +320,43 @@ static int pm_config_dequeue_wait_counts_v9(struct packet_manager *pm,
319320 uint32_t reg_data = 0 ;
320321
321322 switch (cmd ) {
322- case KFD_DEQUEUE_WAIT_INIT :
323- /* Set CWSR grace period to 1x1000 cycle for GFX9.4.3 APU */
324- if (amdgpu_emu_mode == 0 && pm -> dqm -> dev -> adev -> gmc .is_app_apu &&
325- (KFD_GC_VERSION (pm -> dqm -> dev ) == IP_VERSION (9 , 4 , 3 )))
326- pm_build_dequeue_wait_counts_packet_info (pm , 1 , & reg_offset , & reg_data );
327- else
323+ case KFD_DEQUEUE_WAIT_INIT : {
324+ uint32_t sch_wave = 0 , que_sleep = 0 ;
325+ /* Reduce CP_IQ_WAIT_TIME2.QUE_SLEEP to 0x1 from default 0x40.
326+ * On a 1GHz machine this is roughly 1 microsecond, which is
327+ * about how long it takes to load data out of memory during
328+ * queue connect
329+ * QUE_SLEEP: Wait Count for Dequeue Retry.
330+ */
331+ if (KFD_GC_VERSION (pm -> dqm -> dev ) >= IP_VERSION (9 , 4 , 1 ) &&
332+ KFD_GC_VERSION (pm -> dqm -> dev ) < IP_VERSION (10 , 0 , 0 )) {
333+ que_sleep = 1 ;
334+
335+ /* Set CWSR grace period to 1x1000 cycle for GFX9.4.3 APU */
336+ if (amdgpu_emu_mode == 0 && pm -> dqm -> dev -> adev -> gmc .is_app_apu &&
337+ (KFD_GC_VERSION (pm -> dqm -> dev ) == IP_VERSION (9 , 4 , 3 )))
338+ sch_wave = 1 ;
339+ } else {
328340 return 0 ;
341+ }
342+ pm_build_dequeue_wait_counts_packet_info (pm , sch_wave , que_sleep ,
343+ & reg_offset , & reg_data );
344+
329345 break ;
346+ }
330347 case KFD_DEQUEUE_WAIT_RESET :
331- /* function called only to get reg_offset */
332- pm_build_dequeue_wait_counts_packet_info (pm , 0 , & reg_offset , & reg_data );
333- reg_data = pm -> dqm -> wait_times ;
348+ /* reg_data would be set to dqm->wait_times */
349+ pm_build_dequeue_wait_counts_packet_info (pm , 0 , 0 , & reg_offset , & reg_data );
334350 break ;
335351
336352 case KFD_DEQUEUE_WAIT_SET_SCH_WAVE :
337353 /* The CP cannot handle value 0 and it will result in
338- * an infinite grace period being set so set to 1 to prevent this.
354+ * an infinite grace period being set so set to 1 to prevent this. Also
355+ * avoid debugger API breakage as it sets 0 and expects a low value.
339356 */
340357 if (!value )
341358 value = 1 ;
342- pm_build_dequeue_wait_counts_packet_info (pm , value , & reg_offset , & reg_data );
359+ pm_build_dequeue_wait_counts_packet_info (pm , value , 0 , & reg_offset , & reg_data );
343360 break ;
344361 default :
345362 pr_err ("Invalid dequeue wait cmd\n" );
0 commit comments