mstar因裝置讀不到導致,待機重啟問題

Leaf lock發表於2020-09-26

使用mstar 648開發出現待機失敗重啟問題,根據分析是因為某個I2c裝置未正確讀取導致關機時有個執行緒無法關閉導致無法正常待機

 

首先待機失敗log

os    : [TSP_DBG]TSP ISR Proc End!!!

01-01 20:01:36.793  1557  1557 I tvos    :  player get EV_SIGNAL_UNSTABLE event = 536875042

01-01 20:01:36.793  1557  1557 I tvos    : [AutoTest][SourceChange][player finalize END][96823]

01-01 20:01:36.793  1557  1557 I tvos    : [ERROR] MSrv_Picture::SetPictureSetting, enInputSrc = 44

01-01 20:01:36.793  1338  1734 E IPlayerImplClient: Send NOTIFY_CALLBACK

01-01 20:01:36.793  1557  1557 I tvos    : EV_SIGNAL_UNSTABLE  =  536875042

01-01 20:01:36.793  1557  1557 I tvos    : Send NOTIFY_CALLBACK

01-01 20:01:36.793  3020  3034 E PlayerImpl_JNI: notifyCB event = 536875042

01-01 20:01:36.793  3020  3034 D PlayerImpl_JNI: Signal status: SIGNAL_UNSTABLE

01-01 20:01:36.825  1557  1557 I tvos    : ******Amplifier_RT9113B_SWMute(0)

01-01 20:01:36.826  1557  1557 I tvos    : 9113Bwrite fail = 6

01-01 20:01:36.828  1557  1557 I tvos    : error: Input type source number is too large!!!

01-01 20:01:36.828  1557  1557 I tvos    : [AutoTest][SourceChange][SetInputSourceCmd END][96857]

01-01 20:01:36.828  1557  1557 I tvos    : mapi_str::addStrThreadItem ptid=0xd60ff460 m_StrThreadItems.size()=7,this=0xcbf678, name=SSSoundSuspend

01-01 20:01:36.828  1557  1557 I tvos    : ******Amplifier_RT9113B_SWMute(1)

01-01 20:01:36.829  1557  1557 I tvos    : 9113Bwrite fail = 6

01-01 20:01:36.833  1557  1557 I tvos    : mapi_str::removeStrThreadItem ptid=0xd98bf460 m_StrThreadItems.size()=6,this=0xcbf678, name=AudioMonitor

01-01 20:01:36.833  1557  1557 I tvos    : [[utopia]]      Start HAL_AUDIO_DeAllocateVars g_bInitShmFlag=1

01-01 20:01:36.833  1557  1557 I tvos    : [[utopia]]      HAL_AUDIO_DeAllocateVars ClientCounter=3

01-01 20:01:36.833  1557  1557 I tvos    : [[utopia]]      End HAL_AUDIO_DeAllocateVars g_bInitShmFlag=0

01-01 20:01:36.868  1557  1557 I tvos    : IRQ 209 polling thread destroyed

01-01 20:01:36.868  1557  1557 I tvos    : IRQ 209 polling fd closed!!

01-01 20:01:36.868  1557  1557 I tvos    : mapi_str::removeStrThreadItem ptid=0xd3fff460 m_StrThreadItems.size()=5,this=0xcbf678, name=CECMonitor

01-01 20:01:36.868  1557  1557 I tvos    : [CEC] MSrv_CEC::Finalize()

01-01 20:01:36.873  1557  1557 I tvos    : mapi_str::removeStrThreadItem ptid=0xd40ff460 m_StrThreadItems.size()=4,this=0xcbf678, name=Dont Need Delay

01-01 20:01:36.937  1557  1557 I tvos    : IRQ 142 polling thread destroyed

01-01 20:01:36.937  1557  1557 I tvos    : IRQ 142 polling fd closed!!

01-01 20:01:36.937  1557  1557 I tvos    : mapi_str::removeStrThreadItem ptid=0xd60ff460 m_StrThreadItems.size()=3,this=0xcbf678, name=SSSoundSuspend

01-01 20:01:36.974  1557  1557 I tvos    : mapi_str::removeStrThreadItem ptid=0xd41ff460 m_StrThreadItems.size()=2,this=0xcbf678, name=Need Delay SrcD

01-01 20:01:36.984  1557  1557 I tvos    : mapi_str::removeStrThreadItem ptid=0xeda38460 m_StrThreadItems.size()=1,this=0xcbf678, name=Picture Monitor

01-01 20:01:36.984  1338  1338 F HDCP2X  : [HDCP2X] Enter HDCP2_SuspendHDMI() function ((HDCP2_SuspendHDMI:702))

01-01 20:01:36.984  1338  1338 F HDCP2X  : [HDCP2X] Leave HDCP2_SuspendHDMI() function ((HDCP2_SuspendHDMI:708))

01-01 20:01:36.984  1557  1557 I tvos    : mapi_str::waitforAllThreadSuspend begin m_StrThreadItems.size()=1,m_StrThreadItemSuspendNum=0,this=0xcbf678,pthread_self()=0xf63c3210,getpid()=1338

01-01 20:01:36.984  1557  1557 I tvos    : mapi_str::waitforAllThreadSuspend continue thread ptid=0xe2eac460, name=InitSSoundthrea

01-01 20:01:37.037  1557  1557 I tvos    : mapi_str::waitforAllThreadSuspend continue m_StrThreadItems.size()=1,m_StrThreadItemSuspendNum=0,this=0xcbf678,pthread_self()=0xf63c3210,getpid()=1338

01-01 20:01:37.037  1557  1557 I tvos    : mapi_str::waitforAllThreadSuspend continue thread ptid=0xe2eac460, name=InitSSoundthrea

01-01 20:01:37.090  1557  1557 I tvos    : mapi_str::waitforAllThreadSuspend continue m_StrThreadItems.size()=1,m_StrThreadItemSuspendNum=0,this=0xcbf678,pthread_self()=0xf63c3210,getpid()=1338

01-01 20:01:37.090  1557  1557 I tvos    : mapi_str::waitforAllThreadSuspend continue thread ptid=0xe2eac460, name=InitSSoundthrea

01-01 20:01:37.122  1557  1557 I tvos    : [INFO] Change to Voltage: 1150 mV (0x30)

從log可以看出執行removeStrThreadItem時AudioMonitor項出現失敗問題

removeStrThreadItem方法程式碼

supernova\MStarSDK\src\str\mapi_str.cpp

void mapi_str::removeStrThreadItem()

{

    pthread_t ptid = pthread_self();

    char name[32];

    int intPTHChk;

    prctl(PR_GET_NAME,(unsigned long)name);

    intPTHChk = PTH_RET_CHK(pthread_mutex_lock(&m_mutex));

    ASSERT(intPTHChk == 0);

    for (vector<ST_STR_THREAD_ITEM>::iterator it=m_StrThreadItems.begin();  it!=m_StrThreadItems.end();)

    {

        if (it->ptid == ptid)

        {

            it = m_StrThreadItems.erase(it);

            printf("mapi_str::removeStrThreadItem ptid=%p  m_StrThreadItems.size()=%d,this=%p, name=%s\n", (void*)ptid,  m_StrThreadItems.size(), this, name);

        }

        else

        {

            ++it;

        }

    }

    intPTHChk = PTH_RET_CHK(pthread_mutex_unlock(&m_mutex));

    ASSERT(intPTHChk == 0);

}

從程式碼可以看出當出現問題時m_StrThreadItems陣列並未能刪除問題執行緒記錄

接著檢視mapi_str::waitforAllThreadSuspend 列印log處程式碼

void mapi_str::waitforAllThreadSuspend()
{
    printf("mapi_str::waitforAllThreadSuspend begin  m_StrThreadItems.size()=%d,m_StrThreadItemSuspendNum=%u,this=%p,pthread_self()=%p,getpid()=%d\n", m_StrThreadItems.size(), m_StrThreadItemSuspendNum, this,  (void*)pthread_self(), getpid());
    while(m_StrThreadItems.size() != m_StrThreadItemSuspendNum)
    {
         for (unsigned int i = 0; i < m_StrThreadItems.size(); i++)
        {
            printf("mapi_str::waitforAllThreadSuspend continue thread ptid=%p,  name=%s\n", (void *)m_StrThreadItems[i].ptid, m_StrThreadItems[i].name.c_str());
        }
        for(int i=0;i<50;i++)
        {
            if(m_StrThreadItems.size() == m_StrThreadItemSuspendNum)break;
            usleep(1000);
        }
        printf("mapi_str::waitforAllThreadSuspend continue  m_StrThreadItems.size()=%d,m_StrThreadItemSuspendNum=%u,this=%p,pthread_self()=%p,getpid()=%d\n", m_StrThreadItems.size(), m_StrThreadItemSuspendNum, this,  (void*)pthread_self(), getpid());
    }
    printf("mapi_str::waitforAllThreadSuspend complete  m_StrThreadItems.size()=%d,m_StrThreadItemSuspendNum=%u,this=%p,pthread_self()=%p,getpid()=%d\n", m_StrThreadItems.size(), m_StrThreadItemSuspendNum, this,  (void*)pthread_self(), getpid());
}

檢視程式碼發現,啥都沒幹只是列印,阻塞時間?難道是在等有其他地方執行緒去把執行緒結束刪除?分析這邊應該就是導致系統待機失敗,阻塞時間過長其他地方出現問題直接重啟了

這時就有幾種修改方法,第一種解決釋放不了執行緒問題,第二種解決這個啥都不幹在這阻塞的程式碼

明顯第二種會簡單很多新增程式碼:

void mapi_str::waitforAllThreadSuspend()
{
    printf("mapi_str::waitforAllThreadSuspend begin m_StrThreadItems.size()=%d,m_StrThreadItemSuspendNum=%u,this=%p,pthread_self()=%p,getpid()=%d\n", m_StrThreadItems.size(), m_StrThreadItemSuspendNum, this, (void*)pthread_self(), getpid());
    while(m_StrThreadItems.size() != m_StrThreadItemSuspendNum)
    {
          for (unsigned int i = 0; i < m_StrThreadItems.size(); i++)
        {
            printf("mapi_str::waitforAllThreadSuspend continue thread ptid=%p, name=%s\n", (void *)m_StrThreadItems[i].ptid, m_StrThreadItems[i].name.c_str());
        }
        for(int i=0;i<50;i++)
        {
            if(m_StrThreadItems.size() == m_StrThreadItemSuspendNum)break;
            usleep(1000);
            m_StrThreadItems.clear();
        }
        printf("mapi_str::waitforAllThreadSuspend continue m_StrThreadItems.size()=%d,m_StrThreadItemSuspendNum=%u,this=%p,pthread_self()=%p,getpid()=%d\n", m_StrThreadItems.size(), m_StrThreadItemSuspendNum, this, (void*)pthread_self(), getpid());
    }
    printf("mapi_str::waitforAllThreadSuspend complete m_StrThreadItems.size()=%d,m_StrThreadItemSuspendNum=%u,this=%p,pthread_self()=%p,getpid()=%d\n", m_StrThreadItems.size(), m_StrThreadItemSuspendNum, this, (void*)pthread_self(), getpid());
}

 

重新升級,驗證問題成功解決,不過第二種雖然簡單但是會不會引起什麼問題呢?理論來說待機時候這個沒影響,但是最優的解決方法還是第一種

相關文章