src/occ_405/gpu/gpu.c
// Function Specification
//
// Name:  gpu_sm_handle_idle_state
//
// Description: Called when GPU SM is idle to determine what state (if any) should
//               be done next
// End Function Specification
Function Specification
Name:  gpu_sm_handle_idle_state

Called when GPU SM is idle to determine what state (if any) should
be done next
End Function Specification
Function Specification Name : gpu_sm_handle_idle_state Called when GPU SM is idle to determine what state ( if any ) should be done next End Function Specification
bool gpu_sm_handle_idle_state(bool i_read_temp_start_needed, bool i_mem_temp_needed)
{
    bool l_new_state = FALSE;  
    uint8_t l_gpu_id = 0;
    do
    {
        l_gpu_id = gpu_id_need_set_power_limit();
        if(l_gpu_id != 0xFF)
        {
            G_current_gpu_id = l_gpu_id;
            G_gpu_state = GPU_STATE_SET_PWR_LIMIT;
            l_new_state = TRUE;
            break;
        }
        if (!check_and_update_i2c_lock(GPU_I2C_ENGINE))
        {
            G_gpu_state = GPU_STATE_NO_LOCK;
            l_new_state = FALSE;
            break;
        }
        if(i_read_temp_start_needed)
        {
            l_gpu_id = get_first_gpu();
            if(l_gpu_id != 0xFF)
            {
               G_current_gpu_id = l_gpu_id;
               G_gpu_state = GPU_STATE_READ_TEMP;
               l_new_state = TRUE;
               break;
            }
            else  
            {
               occ_i2c_lock_release(GPU_I2C_ENGINE);
               G_gpu_state = GPU_STATE_NO_LOCK;
               G_gpu_monitoring_allowed = FALSE;
               l_new_state = FALSE;  
               break;
            }
        }
        l_gpu_id = gpu_id_need_driver_check();
        if(l_gpu_id != 0xFF)
        {
            G_current_gpu_id = l_gpu_id;
            G_gpu_state = GPU_STATE_CHECK_DRIVER_LOADED;
            l_new_state = TRUE;
            break;
        }
        l_gpu_id = gpu_id_need_power_limits();
        if(l_gpu_id != 0xFF)
        {
            G_current_gpu_id = l_gpu_id;
            G_gpu_state = GPU_STATE_READ_PWR_LIMIT;
            l_new_state = TRUE;
            break;
        }
        if(i_mem_temp_needed)
        {
            l_gpu_id = gpu_id_need_memory_temp_capability_check();
            if(l_gpu_id != 0xFF)
            {
                G_current_gpu_id = l_gpu_id;
                G_gpu_state = GPU_STATE_CHECK_MEM_TEMP_CAPABLE;
                l_new_state = TRUE;
                break;
            }
            else
            {
               l_gpu_id = get_first_mem_temp_capable_gpu();
               if(l_gpu_id != 0xFF)
               {
                  G_current_gpu_id = l_gpu_id;
                  G_gpu_state = GPU_STATE_READ_MEMORY_TEMP;
                  l_new_state = TRUE;
                  break;
               }
            }
        }
    }while(0);
    return l_new_state;
}
bool gpu_sm_handle_idle_state ( bool i_read_temp_start_needed , bool i_mem_temp_needed ) { bool l_new_state = FALSE ; uint8_t l_gpu_id = 0 ; do { l_gpu_id = gpu_id_need_set_power_limit ( ) ; if ( l_gpu_id != 0xFF ) { G_current_gpu_id = l_gpu_id ; G_gpu_state = GPU_STATE_SET_PWR_LIMIT ; l_new_state = TRUE ; break ; } if ( ! check_and_update_i2c_lock ( GPU_I2C_ENGINE ) ) { G_gpu_state = GPU_STATE_NO_LOCK ; l_new_state = FALSE ; break ; } if ( i_read_temp_start_needed ) { l_gpu_id = get_first_gpu ( ) ; if ( l_gpu_id != 0xFF ) { G_current_gpu_id = l_gpu_id ; G_gpu_state = GPU_STATE_READ_TEMP ; l_new_state = TRUE ; break ; } else { occ_i2c_lock_release ( GPU_I2C_ENGINE ) ; G_gpu_state = GPU_STATE_NO_LOCK ; G_gpu_monitoring_allowed = FALSE ; l_new_state = FALSE ; break ; } } l_gpu_id = gpu_id_need_driver_check ( ) ; if ( l_gpu_id != 0xFF ) { G_current_gpu_id = l_gpu_id ; G_gpu_state = GPU_STATE_CHECK_DRIVER_LOADED ; l_new_state = TRUE ; break ; } l_gpu_id = gpu_id_need_power_limits ( ) ; if ( l_gpu_id != 0xFF ) { G_current_gpu_id = l_gpu_id ; G_gpu_state = GPU_STATE_READ_PWR_LIMIT ; l_new_state = TRUE ; break ; } if ( i_mem_temp_needed ) { l_gpu_id = gpu_id_need_memory_temp_capability_check ( ) ; if ( l_gpu_id != 0xFF ) { G_current_gpu_id = l_gpu_id ; G_gpu_state = GPU_STATE_CHECK_MEM_TEMP_CAPABLE ; l_new_state = TRUE ; break ; } else { l_gpu_id = get_first_mem_temp_capable_gpu ( ) ; if ( l_gpu_id != 0xFF ) { G_current_gpu_id = l_gpu_id ; G_gpu_state = GPU_STATE_READ_MEMORY_TEMP ; l_new_state = TRUE ; break ; } } } } while ( 0 ) ; return l_new_state ; }
Function Specification
Name:  gpu_sm_handle_idle_state
Function Specification Name : gpu_sm_handle_idle_state
// return TRUE if there is a new state for GPU communication // Check for next state in order of priority // 1.  Need to set a power limit on a GPU? // Found a GPU that needs a power limit set // 2.  check if Host needs lock // We don't own the lock anymore // can't do anything until we get ownership back // 3.  Time to start new temperature reads? // Start reading core temp from first present and functional GPU // Read core temp for this GPU // no functional GPUs // release I2C lock to the host for this engine and stop monitoring // No new state for GPU communication // 4.  Need to check if driver is loaded? // Found a GPU that needs driver checked // 5.  Need to read power limits? // Found a GPU that needs power limits read // 6.  Need to read memory temps? // first check if there is a GPU that needs memory temp capability checked // Determine memory temp capability for this GPU // memory temp capability checking is done start reading memory temp from capable GPUs // Read memory temp for this GPU // Else nothing stay idle