Skip to content
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 double low power ticker interrupt #7599

Merged
merged 1 commit into from
Aug 20, 2018

Conversation

c1728p9
Copy link
Contributor

@c1728p9 c1728p9 commented Jul 26, 2018

Description

When computing the next set_interrupt time in the common ticker layer
the absolute time in microseconds is rounded down to the closes low
power tick. Because of this the low power ticker interrupt fires one
cycle too early. This causes ticker_irq_handler to run even though
there are no events ready to run.

To prevent this unnecessary interrupt this patch changes the
computation for the next set_interrupt time to round up rather than
down.

Pull request type

[x] Fix
[ ] Refactor
[ ] New target
[ ] Feature
[ ] Breaking change

When computing the next set_interrupt time in the common ticker layer
the absolute time in microseconds is rounded down to the closes low
power tick. Because of this the low power ticker interrupt fires one
cycle too early. This causes ticker_irq_handler to run even though
there are no events ready to run.

To prevent this unnecessary interrupt this patch changes the
computation for the next set_interrupt time to round up rather than
down.
@cmonr cmonr requested a review from kjbracey August 14, 2018 00:44
@cmonr
Copy link
Contributor

cmonr commented Aug 14, 2018

/morph build

@mbed-ci
Copy link

mbed-ci commented Aug 14, 2018

Build : SUCCESS

Build number : 2789
Build artifacts/logs : http://mbed-os.s3-website-eu-west-1.amazonaws.com/?prefix=builds/7599/

Triggering tests

/morph test
/morph uvisor-test
/morph export-build
/morph mbed2-build

@mbed-ci
Copy link

mbed-ci commented Aug 14, 2018

Copy link
Contributor

@kjbracey kjbracey left a comment

Choose a reason for hiding this comment

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

To check I understand this correctly:

The schedule_interrupt tick conversion rounded down, that rounded-down tick was in the past, so it scheduled an immediate interrupt. That interrupt triggered, but ticker_irq_handler decided it wasn't time yet, so rescheduled. Repeat, spinning interrupts, until time is reached? Seems like it could be more than just double, potentially?

If that's right, then approved.

Slightly wary of it going in a patch release unless it's causing a real observed problem - vaguely possible someone's timing is somehow relying on that spin to get more accurate scheduling - it was working a bit like wait_ms.

@cmonr
Copy link
Contributor

cmonr commented Aug 14, 2018

@c1728p9 Mind ack/nack-ing kjbracey-arm's interpretation?

@cmonr
Copy link
Contributor

cmonr commented Aug 14, 2018

@kjbracey-arm We're close enough to the feature release that we could target it to 5.10 without too much issue. @c1728p9 any objections?

@mbed-ci
Copy link

mbed-ci commented Aug 14, 2018

@studavekar
Copy link
Contributor

Test : FAILURE
Build number : 2524
Test logs :http://mbed-os-logs.s3-website-us-west-1.amazonaws.com/?prefix=logs/7599/2524

This failed as it failed to fetch the test app from AWS

download failed: s3://mbed-os/builds/7599/PASS/NUCLEO_F401RE/ARM/testbin_c36b58a05b0211d3dafe015416d3440eecbe4966.zip to ./testbin_c36b58a05b0211d3dafe015416d3440eecbe4966.zip HTTPSConnectionPool(host='mbed-os.s3.amazonaws.com', port=443): Read timed out.
unzip:  cannot find or open testbin_*.zip, testbin_*.zip.zip or testbin_*.zip.ZIP.

@studavekar
Copy link
Contributor

/morph test

@c1728p9
Copy link
Contributor Author

c1728p9 commented Aug 14, 2018

Hi @kjbracey-arm yeah, that is correctly. In the setup I was using it was firing twice, but for faster devices it could fire many more times. @cmonr, this going into 5.10 sounds good to me.

@mbed-ci
Copy link

mbed-ci commented Aug 14, 2018

@cmonr
Copy link
Contributor

cmonr commented Aug 15, 2018

Hmmm, not liking the trend in silly test failures...
/morph test

@mbed-ci
Copy link

mbed-ci commented Aug 16, 2018

@cmonr
Copy link
Contributor

cmonr commented Aug 16, 2018

Failures don't appear to be related to CI.
/morph test

@mbed-ci
Copy link

mbed-ci commented Aug 17, 2018

@0xc0170 0xc0170 merged commit 5b751e8 into ARMmbed:master Aug 20, 2018
pan- pushed a commit to pan-/mbed that referenced this pull request Aug 22, 2018
…interrupt

Fix double low power ticker interrupt
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.

None yet

6 participants