src/occ_405/gpu/gpu.c
// Function Specification
//
// Name:  gpu_check_driver_loaded_sm
//
// Description: Called from gpu_task_sm to check if driver is loaded for G_current_gpu_id
//              This function should only return that complete is TRUE when the check
//              is complete (or determined failed) and ready for a different GPU
//
// Pre-Req:  Caller must have G_current_gpu_id set for GPU to check
//
// End Function Specification
Function Specification
Name:  gpu_check_driver_loaded_sm

Called from gpu_task_sm to check if driver is loaded for G_current_gpu_id
This function should only return that complete is TRUE when the check
is complete (or determined failed) and ready for a different GPU

Pre-Req:  Caller must have G_current_gpu_id set for GPU to check

End Function Specification
Function Specification Name : gpu_check_driver_loaded_sm Called from gpu_task_sm to check if driver is loaded for G_current_gpu_id This function should only return that complete is TRUE when the check is complete ( or determined failed ) and ready for a different GPU Pre - Req : Caller must have G_current_gpu_id set for GPU to check End Function Specification
bool gpu_check_driver_loaded_sm()
{
    bool l_complete = FALSE;   
    bool l_new_driver_loaded = FALSE;
    static bool L_scheduled = FALSE;  
    static uint8_t L_check_driver_failure_count[MAX_NUM_GPU_PER_DOMAIN] = {0};
    static uint8_t L_state_failure_count = 0;
    static gpuCheckDriverLoadedState_e L_check_driver_state = GPU_STATE_CHECK_DRIVER_LOADED_NEW;
    static bool L_error_logged[MAX_NUM_GPU_PER_DOMAIN] = {FALSE};
    static uint32_t L_num_ticks = 0;
    L_num_ticks++;
    if (async_request_is_idle(&G_gpu_op_request.request))
    {
       if( (L_check_driver_state != GPU_STATE_CHECK_DRIVER_LOADED_NEW) &&
           (!L_scheduled || (GPE_RC_SUCCESS != G_gpu_op_req_args.error.rc)) )
       {
          if(G_gpu_op_req_args.error.rc == GPE_RC_GPU_DRIVER_CHANGE)
          {
             handle_driver_change();
             L_state_failure_count = 0;
             L_check_driver_failure_count[G_current_gpu_id] = 0; 
             L_check_driver_state = GPU_STATE_CHECK_DRIVER_LOADED_NEW;
             return TRUE;  
          }
          else if(L_state_failure_count > MAX_GPU_READ_ATTEMPT)
          {
             if(g_amec->gpu[G_current_gpu_id].status.notReset)
             {
                if(++L_check_driver_failure_count[G_current_gpu_id] > GPU_CHECK_DRIVER_ERROR_COUNT)
                {
                    INTR_TRAC_ERR("gpu_check_driver_loaded: Failed to check driver loaded for GPU%d RC: 0x%02X",
                                   G_current_gpu_id,
                                   G_gpu_op_req_args.gpu_rc);
                    g_amec->gpu[G_current_gpu_id].status.checkDriverLoaded = false;
                    L_check_driver_failure_count[G_current_gpu_id] = 0;
                    g_amec->gpu[G_current_gpu_id].status.memTempFailure = true;
                    g_amec->gpu[G_current_gpu_id].status.memTempNotAvailable = true;
                    if(!L_error_logged[G_current_gpu_id])
                    {
                       L_error_logged[G_current_gpu_id] = TRUE;
                       errlHndl_t l_err = createErrl(GPU_MID_GPU_CHECK_DRIVER_LOADED,
                                                     GPU_FAILURE,
                                                     ERC_GPU_CHECK_DRIVER_LOADED_FAILURE,
                                                     ERRL_SEV_PREDICTIVE,
                                                     NULL,
                                                     DEFAULT_TRACE_SIZE,
                                                     G_current_gpu_id,
                                                     G_gpu_op_req_args.gpu_rc);
                       if(G_sysConfigData.gpu_sensor_ids[G_current_gpu_id])
                       {
                          addCalloutToErrl(l_err,
                                           ERRL_CALLOUT_TYPE_GPU_ID,
                                           G_sysConfigData.gpu_sensor_ids[G_current_gpu_id],
                                           ERRL_CALLOUT_PRIORITY_MED);
                       }
                       commitErrl(&l_err);
                    } 
                } 
             } 
             L_check_driver_state = GPU_STATE_CHECK_DRIVER_LOADED_NEW;
             L_state_failure_count = 0;
             return TRUE;  
          } 
          else
          {
             L_state_failure_count++;
          }
       }
       else 
       {
          L_state_failure_count = 0;
          L_check_driver_state++;
       }
       L_scheduled = FALSE;  
       switch (L_check_driver_state)
       {
           case GPU_STATE_CHECK_DRIVER_LOADED_START:
               L_num_ticks = 1;
               L_scheduled = schedule_gpu_req(GPU_REQ_CHECK_DRIVER_START, G_new_gpu_req_args);
               break;
           case GPU_STATE_CHECK_DRIVER_LOADED_2:
               L_scheduled = schedule_gpu_req(GPU_REQ_CHECK_DRIVER_2, G_new_gpu_req_args);
               break;
           case GPU_STATE_CHECK_DRIVER_LOADED_3:
               L_scheduled = schedule_gpu_req(GPU_REQ_CHECK_DRIVER_3, G_new_gpu_req_args);
               break;
           case GPU_STATE_CHECK_DRIVER_LOADED_READ:
               L_scheduled = schedule_gpu_req(GPU_REQ_CHECK_DRIVER_FINISH, G_new_gpu_req_args);
               break;
           case GPU_STATE_CHECK_DRIVER_LOADED_COMPLETE:
                update_gpu_tick_sensor(&G_gpu_tick_times.checkdriver[G_current_gpu_id], L_num_ticks);
               l_new_driver_loaded = G_gpu_op_req_args.data[0] & 0x01;
               if(l_new_driver_loaded != g_amec->gpu[G_current_gpu_id].status.driverLoaded)
               {
                  GPU_DBG("gpu_check_driver_loaded: GPU%d driver loaded changed to %d",
                          G_current_gpu_id,
                          l_new_driver_loaded);
                  if(l_new_driver_loaded)
                  {
                     g_amec->gpu[G_current_gpu_id].pcap.check_pwr_limit = true;
                     g_amec->gpu[G_current_gpu_id].status.checkMemTempSupport = true;
                     g_amec->gpu[G_current_gpu_id].status.checkDriverLoaded = false;
                  }
                  else
                  {
                     clear_gpu_driver_status(G_current_gpu_id);
                     g_amec->gpu[G_current_gpu_id].status.memTempFailure = false;
                     g_amec->gpu[G_current_gpu_id].status.memTempNotAvailable = true;
                     g_amec->gpu[G_current_gpu_id].status.checkDriverLoaded = true;
                  }
                  g_amec->gpu[G_current_gpu_id].status.driverLoaded = l_new_driver_loaded;
               }
               L_check_driver_failure_count[G_current_gpu_id] = 0;
               L_check_driver_state = GPU_STATE_CHECK_DRIVER_LOADED_NEW;
               l_complete = TRUE;
               break;
           default:
               INTR_TRAC_ERR("gpu_check_driver_loaded: INVALID STATE: 0x%02X", L_check_driver_state);
               L_check_driver_state = GPU_STATE_CHECK_DRIVER_LOADED_NEW;
               l_complete = TRUE;
               break;
       } 
       if(L_scheduled)
       {
          GPU_DBG("gpu_check_driver_loaded: Scheduled check driver loaded state 0x%02X at tick %d",
                   L_check_driver_state, GPU_TICK);
       }
       else if(!l_complete)  
       {
          INTR_TRAC_ERR("gpu_check_driver_loaded: failed to schedule state 0x%02X", L_check_driver_state);
       }
    } 
    else
    {
       INTR_TRAC_ERR("gpu_check_driver_loaded: NOT idle for state 0x%02X", L_check_driver_state);
    }
    return l_complete;
}
bool gpu_check_driver_loaded_sm ( ) { bool l_complete = FALSE ; bool l_new_driver_loaded = FALSE ; static bool L_scheduled = FALSE ; static uint8_t L_check_driver_failure_count [ MAX_NUM_GPU_PER_DOMAIN ] = { 0 } ; static uint8_t L_state_failure_count = 0 ; static gpuCheckDriverLoadedState_e L_check_driver_state = GPU_STATE_CHECK_DRIVER_LOADED_NEW ; static bool L_error_logged [ MAX_NUM_GPU_PER_DOMAIN ] = { FALSE } ; static uint32_t L_num_ticks = 0 ; L_num_ticks ++ ; if ( async_request_is_idle ( & G_gpu_op_request . request ) ) { if ( ( L_check_driver_state != GPU_STATE_CHECK_DRIVER_LOADED_NEW ) && ( ! L_scheduled || ( GPE_RC_SUCCESS != G_gpu_op_req_args . error . rc ) ) ) { if ( G_gpu_op_req_args . error . rc == GPE_RC_GPU_DRIVER_CHANGE ) { handle_driver_change ( ) ; L_state_failure_count = 0 ; L_check_driver_failure_count [ G_current_gpu_id ] = 0 ; L_check_driver_state = GPU_STATE_CHECK_DRIVER_LOADED_NEW ; return TRUE ; } else if ( L_state_failure_count > MAX_GPU_READ_ATTEMPT ) { if ( g_amec -> gpu [ G_current_gpu_id ] . status . notReset ) { if ( ++ L_check_driver_failure_count [ G_current_gpu_id ] > GPU_CHECK_DRIVER_ERROR_COUNT ) { INTR_TRAC_ERR ( " " , G_current_gpu_id , G_gpu_op_req_args . gpu_rc ) ; g_amec -> gpu [ G_current_gpu_id ] . status . checkDriverLoaded = false ; L_check_driver_failure_count [ G_current_gpu_id ] = 0 ; g_amec -> gpu [ G_current_gpu_id ] . status . memTempFailure = true ; g_amec -> gpu [ G_current_gpu_id ] . status . memTempNotAvailable = true ; if ( ! L_error_logged [ G_current_gpu_id ] ) { L_error_logged [ G_current_gpu_id ] = TRUE ; errlHndl_t l_err = createErrl ( GPU_MID_GPU_CHECK_DRIVER_LOADED , GPU_FAILURE , ERC_GPU_CHECK_DRIVER_LOADED_FAILURE , ERRL_SEV_PREDICTIVE , NULL , DEFAULT_TRACE_SIZE , G_current_gpu_id , G_gpu_op_req_args . gpu_rc ) ; if ( G_sysConfigData . gpu_sensor_ids [ G_current_gpu_id ] ) { addCalloutToErrl ( l_err , ERRL_CALLOUT_TYPE_GPU_ID , G_sysConfigData . gpu_sensor_ids [ G_current_gpu_id ] , ERRL_CALLOUT_PRIORITY_MED ) ; } commitErrl ( & l_err ) ; } } } L_check_driver_state = GPU_STATE_CHECK_DRIVER_LOADED_NEW ; L_state_failure_count = 0 ; return TRUE ; } else { L_state_failure_count ++ ; } } else { L_state_failure_count = 0 ; L_check_driver_state ++ ; } L_scheduled = FALSE ; switch ( L_check_driver_state ) { case GPU_STATE_CHECK_DRIVER_LOADED_START : L_num_ticks = 1 ; L_scheduled = schedule_gpu_req ( GPU_REQ_CHECK_DRIVER_START , G_new_gpu_req_args ) ; break ; case GPU_STATE_CHECK_DRIVER_LOADED_2 : L_scheduled = schedule_gpu_req ( GPU_REQ_CHECK_DRIVER_2 , G_new_gpu_req_args ) ; break ; case GPU_STATE_CHECK_DRIVER_LOADED_3 : L_scheduled = schedule_gpu_req ( GPU_REQ_CHECK_DRIVER_3 , G_new_gpu_req_args ) ; break ; case GPU_STATE_CHECK_DRIVER_LOADED_READ : L_scheduled = schedule_gpu_req ( GPU_REQ_CHECK_DRIVER_FINISH , G_new_gpu_req_args ) ; break ; case GPU_STATE_CHECK_DRIVER_LOADED_COMPLETE : update_gpu_tick_sensor ( & G_gpu_tick_times . checkdriver [ G_current_gpu_id ] , L_num_ticks ) ; l_new_driver_loaded = G_gpu_op_req_args . data [ 0 ] & 0x01 ; if ( l_new_driver_loaded != g_amec -> gpu [ G_current_gpu_id ] . status . driverLoaded ) { GPU_DBG ( " " , G_current_gpu_id , l_new_driver_loaded ) ; if ( l_new_driver_loaded ) { g_amec -> gpu [ G_current_gpu_id ] . pcap . check_pwr_limit = true ; g_amec -> gpu [ G_current_gpu_id ] . status . checkMemTempSupport = true ; g_amec -> gpu [ G_current_gpu_id ] . status . checkDriverLoaded = false ; } else { clear_gpu_driver_status ( G_current_gpu_id ) ; g_amec -> gpu [ G_current_gpu_id ] . status . memTempFailure = false ; g_amec -> gpu [ G_current_gpu_id ] . status . memTempNotAvailable = true ; g_amec -> gpu [ G_current_gpu_id ] . status . checkDriverLoaded = true ; } g_amec -> gpu [ G_current_gpu_id ] . status . driverLoaded = l_new_driver_loaded ; } L_check_driver_failure_count [ G_current_gpu_id ] = 0 ; L_check_driver_state = GPU_STATE_CHECK_DRIVER_LOADED_NEW ; l_complete = TRUE ; break ; default : INTR_TRAC_ERR ( " " , L_check_driver_state ) ; L_check_driver_state = GPU_STATE_CHECK_DRIVER_LOADED_NEW ; l_complete = TRUE ; break ; } if ( L_scheduled ) { GPU_DBG ( " " , L_check_driver_state , GPU_TICK ) ; } else if ( ! l_complete ) { INTR_TRAC_ERR ( " " , L_check_driver_state ) ; } } else { INTR_TRAC_ERR ( " " , L_check_driver_state ) ; } return l_complete ; }
Function Specification
Name:  gpu_check_driver_loaded_sm
Function Specification Name : gpu_check_driver_loaded_sm
// only return TRUE when the read is complete or failed // indicates if a GPU GPE request was scheduled // If not starting a new read then need to check status of current state before moving on // stay in current state if the schedule failed or the state isn't finished/failed // Check if failure was due to driver change // Request can't be processed by GPU at this time so we are done with this GPU // setup to start new request // clear driver failure count since there's a driver change // Done with this GPU, let GPU SM move to next // If reached state retry count give up on this read // if GPU is not in reset then INC error count and check if reached threshold // give up checking driver loaded for this GPU // It will be retried if detected that GPU is put in reset and then taken out // without driver loaded cannot read memory temp, mark memory temp as failed // log one time error that driver loaded couldn't be determined // Log error /* @
                        * @errortype
                        * @moduleid    GPU_MID_GPU_CHECK_DRIVER_LOADED
                        * @reasoncode  GPU_FAILURE
                        * @userdata1   GPU ID
                        * @userdata2   GPU RC
                        * @userdata4   ERC_GPU_CHECK_DRIVER_LOADED_FAILURE
                        * @devdesc     Failure to check GPU driver loaded
                        *
                        */ // Callout the GPU if have sensor ID for it // Commit Error // if error not logged // if reached error count // if notReset // Done with this GPU, let GPU SM move to next // if reached state retry count // INC failure count and retry current state // success on last state go to next state and process it // default nothing scheduled // Update GPU tick timing table // Update driver loaded // Driver loaded status changed // Driver is now loaded do checking that required driver to be loaded // done checking for driver to be loaded // Driver is no longer loaded // memory temp only available when driver is loaded // clear error and set not available // Need to keep query for driver loaded to detect when driver is loaded // Done with this GPU ready to move to new one // switch L_check_driver_state // if not complete there must have been a failure on the schedule // if async_request_is_idle