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 for issue #6054 - interrupts scheduled in the past. #6068

Merged
merged 1 commit into from Feb 15, 2018

Conversation

Projects
None yet
6 participants
@mprse
Member

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
@cmonr

cmonr approved these changes Feb 12, 2018

@0xc0170

This comment has been minimized.

Member

0xc0170 commented Feb 13, 2018

/morph build

@0xc0170 0xc0170 added needs: CI and removed needs: review labels Feb 13, 2018

@mbed-ci

This comment has been minimized.

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

This comment has been minimized.

@mbed-ci

This comment has been minimized.

@@ -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) {

This comment has been minimized.

@cmonr

cmonr Feb 13, 2018

Contributor

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

This comment has been minimized.

@mprse

mprse Feb 13, 2018

Member

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?

This comment has been minimized.

@mprse

mprse Feb 13, 2018

Member

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

This comment has been minimized.

@c1728p9

c1728p9 Feb 13, 2018

Contributor

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

This comment has been minimized.

@kjbracey-arm

kjbracey-arm Feb 15, 2018

Contributor

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.

Fix for issue #6054 - interrupts scheduled in the past.
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: #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 mprse:fix_for_issue_6054_interrupts_scheduled_in_the_past branch from 1ce8f95 to c2760be Feb 15, 2018

@mprse

This comment has been minimized.

Member

mprse commented Feb 15, 2018

Added comment as suggested.

@0xc0170

This comment has been minimized.

Member

0xc0170 commented Feb 15, 2018

/morph build

@0xc0170 0xc0170 added needs: CI and removed ready for merge labels Feb 15, 2018

@mbed-ci

This comment has been minimized.

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

This comment has been minimized.

@mbed-ci

This comment has been minimized.

@cmonr cmonr merged commit 2fab524 into ARMmbed:master Feb 15, 2018

17 checks passed

AWS-CI uVisor Build & Test Success
Details
ci-morph-build build completed
Details
ci-morph-exporter build completed
Details
ci-morph-test test completed
Details
continuous-integration/jenkins/pr-head This commit looks good
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
mbed-ci-generic Build finished.
Details
travis-ci/docs/ Local docs testing has passed
Details
travis-ci/events/ Local events testing has passed
Details
travis-ci/littlefs/ Local littlefs testing has passed
Details
travis-ci/mbed2-ATMEL/ Local mbed2-ATMEL testing has passed
Details
travis-ci/mbed2-MAXIM/ Local mbed2-MAXIM testing has passed
Details
travis-ci/mbed2-NORDIC/ Local mbed2-NORDIC testing has passed
Details
travis-ci/mbed2-NUVOTON/ Local mbed2-NUVOTON testing has passed
Details
travis-ci/mbed2-NXP/ Local mbed2-NXP testing has passed
Details
travis-ci/mbed2-SILICON_LABS/ Local mbed2-SILICON_LABS testing has passed
Details
travis-ci/mbed2-STM/ Local mbed2-STM testing has passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment