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

nanostack-hal: add alternative critical section implementation #6185

Merged
merged 1 commit into from Feb 27, 2018

Conversation

Projects
None yet
6 participants
@TeroJaasko
Contributor

TeroJaasko commented Feb 23, 2018

Description

(This PR has the same content as already merged https://github.com/ARMmbed/mbed-os-confidential-m/pull/8 and
#5754, only the target branch differs)

The nanostack hal's critical section uses a mutex for mutual exclusion,
which is nice for many use cases. But when one needs to use the critical
section from interrupts, the RTX will have a assertion failure and panic.

Add a configurable for mbed_lib, which can be used to enable a alternative
version of critical section, which uses the underlying OS primitives, which
disables the interrupts.

Note: the default behavior is not changed, one needs to override the
"nanostack-hal.critical-section-usable-from-interrupt" to have "true".

Reason for this change is that there is a need for sending events using
nanostack event queue from interrupt context, eg. from a socket callback.

Status

READY

Migrations

YES | NO

Related PRs

Todos

  • Tests
  • Documentation

Deploy notes

Note: this should not be the first and/or only fix, as it may cause troubles on drivers which can not tolerate delays on interrupt deliveries.

Steps to test or reproduce

K64F with ESP8266, debug profile:
"Mutex 0x200017ec error -6: Not allowed in ISR context"

@0xc0170 0xc0170 requested a review from kjbracey-arm Feb 23, 2018

@kjbracey-arm

Fine with the change - just wondering if a little more of the big comment, or a pointer to it, should be in the JSON help. That makes no mention of any downside.

@TeroJaasko

This comment has been minimized.

Contributor

TeroJaasko commented Feb 26, 2018

Would something like this be better?
"Make critical section API usable from interrupt context. Else a mutex is used as locking primitive. Consult arm_hal_interrupt.c for possible side effects on interrupt latency."

@kjbracey-arm

This comment has been minimized.

Contributor

kjbracey-arm commented Feb 26, 2018

I think that's reasonable. Can't really write an essay in there.

nanostack-hal: add alternative critical section implementation
The nanostack hal's critical section uses a mutex for mutual exclusion,
which is nice for many use cases. But when one needs to use the critical
section from interrupts, the RTX will have a assertion failure and panic.

Add a configurable for mbed_lib, which can be used to enable a alternative
version of critical section, which uses the underlying OS primitives, which
disables the interrupts.

Note: the default behavior is not changed, one needs to override the
"nanostack-hal.critical-section-usable-from-interrupt" to have "true".

Reason for this change is that there is a need for sending events using
nanostack event queue from interrupt context, eg. from a socket callback.

@TeroJaasko TeroJaasko force-pushed the TeroJaasko:ns_hal_critical_section_changes_to_master branch from 5643dea to 7bfcf69 Feb 26, 2018

@TeroJaasko

This comment has been minimized.

Contributor

TeroJaasko commented Feb 26, 2018

Fixed the JSON documentation. It is unfortunate that help in JSON string needs to be a one line inside quotes.

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

@0xc0170

This comment has been minimized.

Member

0xc0170 commented Feb 26, 2018

/morph build

@mbed-ci

This comment has been minimized.

mbed-ci commented Feb 26, 2018

Build : SUCCESS

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

Triggering tests

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

@mbed-ci

This comment has been minimized.

@mbed-ci

This comment has been minimized.

@cmonr

This comment has been minimized.

Contributor

cmonr commented Feb 27, 2018

/morph export-build

@mbed-ci

This comment has been minimized.

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

@kjbracey-arm kjbracey-arm merged commit f0cc00e into ARMmbed:master Feb 27, 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-mbed2-build 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
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

@sg- sg- removed the ready for merge label Feb 27, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment