-
Notifications
You must be signed in to change notification settings - Fork 3k
Fix deep sleep lock bugs #5220
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix deep sleep lock bugs #5220
Conversation
/morph test |
Result: SUCCESSYour command has finished executing! Here's what you wrote!
OutputAll builds and test passed! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 For tests
platform/DeepSleepLock.h
Outdated
sleep_manager_lock_deep_sleep(); | ||
} | ||
if (0 == count) { | ||
error("DeepSleepLock underflow (< 0)"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this error report correct? if it is 0 , it already wrapped around (we increment here) ? The conditions seems like reversed (here and in unlock) ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be. The function core_util_atomic_incr_u16
returns the new value, so if lock (which should only make the value bigger) sets the value to 0 then an overflow has occurred.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I realized after your response (pre vs post condition :) ), what about both being underflow? in the case of 0 here, it is overflow
retest uvisor |
Add _lock_count to DeepSleepLock and use this to prevent deep sleep from staying locked when the DeepSleepLock objected is destroyed after an unbalanced number of calls to lock and unlock.
Test that DeepSleepLock and Timer lock deep sleep at the correct time and do no leave sleep locked after they are destroted.
Add a critical section to attach_us so setting _function and locking deep sleep are done atomically.
Unlock sleep in CAN and SerialBase. This prevents deep sleep from staying locked if these objects are destroyed without first clearing the callbacks.
a23b8b2
to
f854f3e
Compare
Fix overflow case error message in DeepSleepLock.h and rebased to master. |
/morph test-nightly |
Result: ABORTEDYour command has finished executing! Here's what you wrote!
|
@pan- Can you review please |
/morph test-nightly |
@@ -113,12 +114,14 @@ class Ticker : public TimerEvent, private NonCopyable<Ticker> { | |||
* | |||
*/ | |||
void attach_us(Callback<void()> func, us_timestamp_t t) { | |||
core_util_critical_section_enter(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if func == NULL
then the lock won't be correctly released.
Result: FAILUREYour command has finished executing! Here's what you wrote!
OutputTest failed! |
This depends on #5242 for testing to pass |
/morph test-nightly |
Result: FAILUREYour command has finished executing! Here's what you wrote!
OutputBuild failed! |
Another utest failure for IAR and one target The error says: cc @studavekar Update: there is actually this error:
|
I'm going to try kicking this off again! |
Result: SUCCESSYour command has finished executing! Here's what you wrote!
OutputAll builds and test passed! |
Fix problems which could leave deep sleep locked unintentionally, along with adding tests to verify this behavior is fixed.