@@ -376,6 +376,24 @@ void intel_guc_ct_disable(struct intel_guc_ct *ct)
376376 }
377377}
378378
379+ #if IS_ENABLED (CONFIG_DRM_I915_DEBUG_GEM )
380+ static void ct_track_lost_and_found (struct intel_guc_ct * ct , u32 fence , u32 action )
381+ {
382+ unsigned int lost = fence % ARRAY_SIZE (ct -> requests .lost_and_found );
383+ #if IS_ENABLED (CONFIG_DRM_I915_DEBUG_GUC )
384+ unsigned long entries [SZ_32 ];
385+ unsigned int n ;
386+
387+ n = stack_trace_save (entries , ARRAY_SIZE (entries ), 1 );
388+
389+ /* May be called under spinlock, so avoid sleeping */
390+ ct -> requests .lost_and_found [lost ].stack = stack_depot_save (entries , n , GFP_NOWAIT );
391+ #endif
392+ ct -> requests .lost_and_found [lost ].fence = fence ;
393+ ct -> requests .lost_and_found [lost ].action = action ;
394+ }
395+ #endif
396+
379397static u32 ct_get_next_fence (struct intel_guc_ct * ct )
380398{
381399 /* For now it's trivial */
@@ -447,6 +465,11 @@ static int ct_write(struct intel_guc_ct *ct,
447465 }
448466 GEM_BUG_ON (tail > size );
449467
468+ #if IS_ENABLED (CONFIG_DRM_I915_DEBUG_GEM )
469+ ct_track_lost_and_found (ct , fence ,
470+ FIELD_GET (GUC_HXG_EVENT_MSG_0_ACTION , action [0 ]));
471+ #endif
472+
450473 /*
451474 * make sure H2G buffer update and LRC tail update (if this triggering a
452475 * submission) are visible before updating the descriptor tail
@@ -953,6 +976,43 @@ static int ct_read(struct intel_guc_ct *ct, struct ct_incoming_msg **msg)
953976 return - EPIPE ;
954977}
955978
979+ #if IS_ENABLED (CONFIG_DRM_I915_DEBUG_GEM )
980+ static bool ct_check_lost_and_found (struct intel_guc_ct * ct , u32 fence )
981+ {
982+ unsigned int n ;
983+ char * buf = NULL ;
984+ bool found = false;
985+
986+ lockdep_assert_held (& ct -> requests .lock );
987+
988+ for (n = 0 ; n < ARRAY_SIZE (ct -> requests .lost_and_found ); n ++ ) {
989+ if (ct -> requests .lost_and_found [n ].fence != fence )
990+ continue ;
991+ found = true;
992+
993+ #if IS_ENABLED (CONFIG_DRM_I915_DEBUG_GUC )
994+ buf = kmalloc (SZ_4K , GFP_NOWAIT );
995+ if (buf && stack_depot_snprint (ct -> requests .lost_and_found [n ].stack ,
996+ buf , SZ_4K , 0 )) {
997+ CT_ERROR (ct , "Fence %u was used by action %#04x sent at\n%s" ,
998+ fence , ct -> requests .lost_and_found [n ].action , buf );
999+ break ;
1000+ }
1001+ #endif
1002+ CT_ERROR (ct , "Fence %u was used by action %#04x\n" ,
1003+ fence , ct -> requests .lost_and_found [n ].action );
1004+ break ;
1005+ }
1006+ kfree (buf );
1007+ return found ;
1008+ }
1009+ #else
1010+ static bool ct_check_lost_and_found (struct intel_guc_ct * ct , u32 fence )
1011+ {
1012+ return false;
1013+ }
1014+ #endif
1015+
9561016static int ct_handle_response (struct intel_guc_ct * ct , struct ct_incoming_msg * response )
9571017{
9581018 u32 len = FIELD_GET (GUC_CTB_MSG_0_NUM_DWORDS , response -> msg [0 ]);
@@ -996,9 +1056,11 @@ static int ct_handle_response(struct intel_guc_ct *ct, struct ct_incoming_msg *r
9961056 if (!found ) {
9971057 CT_ERROR (ct , "Unsolicited response message: len %u, data %#x (fence %u, last %u)\n" ,
9981058 len , hxg [0 ], fence , ct -> requests .last_fence );
999- list_for_each_entry (req , & ct -> requests .pending , link )
1000- CT_ERROR (ct , "request %u awaits response\n" ,
1001- req -> fence );
1059+ if (!ct_check_lost_and_found (ct , fence )) {
1060+ list_for_each_entry (req , & ct -> requests .pending , link )
1061+ CT_ERROR (ct , "request %u awaits response\n" ,
1062+ req -> fence );
1063+ }
10021064 err = - ENOKEY ;
10031065 }
10041066 spin_unlock_irqrestore (& ct -> requests .lock , flags );
0 commit comments