Skip to content

Fix for issue #6054 - interrupts scheduled in the past. #6068

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

Conversation

mprse
Copy link
Contributor

@mprse mprse commented Feb 12, 2018

Description

When ticker is not driven by the 1 MHz clock and HAL driver need to perform conversion between microseconds and ticks, then the interrupt might be scheduled in the past. For details see issue #6054.

This patch provides fix for such case. While scheduling next interrupt an interrupt is fired immediately when ticker last read tick is equal to the calculated tick when interrupt should be generated.

Status

READY

Migrations

NO

Related PRs

List related PRs against other branches:

branch PR
ARMmbed:feature-hal-spec-ticker https://github.com/ARMmbed/mbed-os/pull/5629
ARMmbed:feature-hal-spec-ticker https://github.com/ARMmbed/mbed-os/pull/6052

@0xc0170
Copy link
Contributor

0xc0170 commented Feb 13, 2018

/morph build

@mbed-ci
Copy link

mbed-ci commented Feb 13, 2018

Build : SUCCESS

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

Triggering tests

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

@mbed-ci
Copy link

mbed-ci commented Feb 13, 2018

@mbed-ci
Copy link

mbed-ci commented Feb 13, 2018

@@ -235,6 +235,12 @@ static void schedule_interrupt(const ticker_data_t *const ticker)
}

timestamp_t match_tick = compute_tick(ticker, match_time);
if (match_tick == queue->tick_last_read) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't this suppose to be <= instead of ==?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Basically interrupt which is to be scheduled in the past should be caught by the following check:

if (match_time <= present) {

While debugging issue issue #6054 I did not found case when match_tick < queue->tick_last_read which does not mean that such case can not occur. I think that it is worth to consider proposed change (even it it can never happen) since in such case interrupt for sure should be fired immediately.

@c1728p9 what is your opinion?

Copy link
Contributor Author

@mprse mprse Feb 13, 2018

Choose a reason for hiding this comment

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

I checked the impact of such change (GCC_ARM/K64F) and tests-mbed_hal-ticker test fails (test_insert_event_us_outside_overflow_range test case).

Copy link
Contributor

Choose a reason for hiding this comment

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

Match tick could have rolled over so <= cannot be used.

Copy link
Contributor

Choose a reason for hiding this comment

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

I would maybe add a comment line on this, as it's non-obvious - "The time has been checked to be future, but it could still round to the last tick" or something.

When ticker is not driven by the 1 MHz clock and HAL driver need to perform conversion between microseconds and ticks, then the interrupt might be scheduled in the past. For details see: ARMmbed#6054.

This patch provides fix for such case. Interrupt is fired immidiatelly when last read tick is equal to the calculated tick when interrupt should be generated.
@mprse mprse force-pushed the fix_for_issue_6054_interrupts_scheduled_in_the_past branch from 1ce8f95 to c2760be Compare February 15, 2018 12:34
@mprse
Copy link
Contributor Author

mprse commented Feb 15, 2018

Added comment as suggested.

@0xc0170
Copy link
Contributor

0xc0170 commented Feb 15, 2018

/morph build

@mbed-ci
Copy link

mbed-ci commented Feb 15, 2018

Build : SUCCESS

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

Triggering tests

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

@mbed-ci
Copy link

mbed-ci commented Feb 15, 2018

@mbed-ci
Copy link

mbed-ci commented Feb 15, 2018

@cmonr cmonr merged commit 2fab524 into ARMmbed:master Feb 15, 2018
@cmonr cmonr removed the needs: CI label Feb 15, 2018
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