Skip to content

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

Merged
merged 4 commits into from
Oct 5, 2017
Merged

Conversation

c1728p9
Copy link
Contributor

@c1728p9 c1728p9 commented Sep 28, 2017

Fix problems which could leave deep sleep locked unintentionally, along with adding tests to verify this behavior is fixed.

@c1728p9
Copy link
Contributor Author

c1728p9 commented Sep 28, 2017

/morph test

@mbed-bot
Copy link

Result: SUCCESS

Your command has finished executing! Here's what you wrote!

/morph test

Output

mbed Build Number: 1430

All builds and test passed!

Copy link
Contributor

@0xc0170 0xc0170 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 For tests

sleep_manager_lock_deep_sleep();
}
if (0 == count) {
error("DeepSleepLock underflow (< 0)");
Copy link
Contributor

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) ?

Copy link
Contributor Author

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.

Copy link
Contributor

@0xc0170 0xc0170 Sep 30, 2017

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

@0xc0170
Copy link
Contributor

0xc0170 commented Sep 29, 2017

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.
@c1728p9
Copy link
Contributor Author

c1728p9 commented Oct 2, 2017

Fix overflow case error message in DeepSleepLock.h and rebased to master.

@c1728p9
Copy link
Contributor Author

c1728p9 commented Oct 2, 2017

/morph test-nightly

@mbed-bot
Copy link

mbed-bot commented Oct 3, 2017

Result: ABORTED

Your command has finished executing! Here's what you wrote!

/morph test-nightly

@0xc0170
Copy link
Contributor

0xc0170 commented Oct 3, 2017

@pan- Can you review please

@adbridge
Copy link
Contributor

adbridge commented Oct 3, 2017

/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();
Copy link
Member

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.

@mbed-bot
Copy link

mbed-bot commented Oct 3, 2017

Result: FAILURE

Your command has finished executing! Here's what you wrote!

/morph test-nightly

Output

mbed Build Number: 1511

Test failed!

@c1728p9
Copy link
Contributor Author

c1728p9 commented Oct 3, 2017

This depends on #5242 for testing to pass

@0xc0170
Copy link
Contributor

0xc0170 commented Oct 4, 2017

/morph test-nightly

@mbed-bot
Copy link

mbed-bot commented Oct 4, 2017

Result: FAILURE

Your command has finished executing! Here's what you wrote!

/morph test-nightly

Output

mbed Build Number: 1518

Build failed!

@0xc0170
Copy link
Contributor

0xc0170 commented Oct 4, 2017

Another utest failure for IAR and one target HEXIWEAR::IAR::FEATURES-FRAMEWORKS-UTEST-TESTS-UNIT_TESTS-CASE_CONTROL_ASYNC , investigating

The error says: Unknown toolchain for memory statistics IAR

cc @studavekar

Update: there is actually this error:

01:32:39 a'I/O error(28): No space left on device
01:32:39 Traceback (most recent call last):
01:32:39   File "C:\mj\workspace\bm_wrap\1601\mbed-os\tools\test_api.py", line 2114, in build_test_worker
01:32:39     bin_file = build_project(*args, **kwargs)
01:32:39   File "C:\mj\workspace\bm_wrap\1601\mbed-os\tools\build_api.py", line 578, in build_project
01:32:39     cur_result["memory_usage"] = memap_instance.mem_report
01:32:39 AttributeError: 'NoneType' object has no attribute 'mem_report'

@adbridge
Copy link
Contributor

adbridge commented Oct 4, 2017

I'm going to try kicking this off again!
/morph test-nightly

@mbed-bot
Copy link

mbed-bot commented Oct 5, 2017

Result: SUCCESS

Your command has finished executing! Here's what you wrote!

/morph test-nightly

Output

mbed Build Number: 1523

All builds and test passed!

@theotherjimmy theotherjimmy merged commit 4dff32a into ARMmbed:master Oct 5, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants