GUIDINGLI commented on issue #10852:
URL: https://github.com/apache/nuttx/issues/10852#issuecomment-1783081081

   @tmedicci 
   
   I have debugged this issue and find the root cause.
   
   in arch/xtensa/src/esp32/esp32_idle.c esp32_idlepm()
   
   ```
   static enum pm_state_e oldstate = PM_NORMAL;
   newstate = pm_checkstate(PM_IDLE_DOMAIN);
   if (newstate != oldstate)
     {
       ...
     }
   else
     {
         if (oldstate == PM_NORMAL)
           {
             /* Relax normal operation */
   
             pm_relax(PM_IDLE_DOMAIN, PM_NORMAL);  // this meet the assert 
failed
           }
   
        ...
     }
   ```
   
   This code means, if the newstate still in PM_NORMAL, that there must have 
someone doing pm_stay(), then relax it.
   
   And this assume is not suitable for all the situation:
   someone called pm_activity,
   and uart driver will call pm_activity() when received new chars.
   
   In the new version with greedy mode, when someone called pm_activity(), then 
pm_checkstate() will jump over the pm count.
   So, the pm_checkstate() will return PM_NORMAL, then meet the error.
   
   I will commit a patch to change the behavior of pm_activity().
   
   But, this assume is still dangerous:
   `If the newstate still in PM_NORMAL, that there must have someone doing 
pm_stay(), then relax it.`
   Because, in the new architecture of PM, I add the **wakelock** mechanism.
   If someone use an another wakelock handle, then pm_checkstate() may still 
return PM_NORMAL.
   
    


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to