-
Notifications
You must be signed in to change notification settings - Fork 3k
Fix for Nanostack threading on EFR32 devices #5270
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 Nanostack threading on EFR32 devices #5270
Conversation
@SeppoTakalo Can you please review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks quite OK except I don't like that much of debugging prints from high priority threads.
I could imagine lots of timing related errors when all prints are enabled.
void* handle = (void*) rx_queue[rx_queue_tail]; | ||
|
||
RAIL_RxPacketInfo_t* info = (RAIL_RxPacketInfo_t*) memoryPtrFromHandle(handle); | ||
tr_debug("rf_thread_loop: rx %d bytes with rssi: %d\n", info->dataLength - 1, info->appendedInfo.rssiLatch); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quite extensive debugging. Two prints, total of 89 bytes, for every RX event.
In baud rate of 115200 takes about 773 us or more.
Also has potential of dead blocking if normal priority thread have already started to print.
@@ -22,6 +23,39 @@ | |||
|
|||
#include "mbed-trace/mbed_trace.h" | |||
#define TRACE_GROUP "SLRF" | |||
//#define tr_debug(...) printf(__VA_ARGS__) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't leave commented code blocks in commits.
|
||
platform_exit_critical(); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, I would recommend to remove all debugging prints from this function unless it actually means error, or unhandled signal.
Thanks for the feedback @SeppoTakalo! Can squash it down to one commit now if that's useful to you? |
Yes, please squash because it is one logical change. |
waiting_for_ack = false; | ||
#ifdef MBED_CONF_RTOS_PRESENT | ||
//NVIC_DisableIRQ(MacHw_IRQn); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please remove any dead code, it is on multiple lines in this code file
70f55a3
to
6db6d26
Compare
WOAH squashing that broke something and I seem to have two halves of the implementation there now :-/ Gotta sleep now but will fix / update tomorrow. |
6db6d26
to
8e59dd3
Compare
Build : SUCCESSBuild number : 32 Triggering tests/test mbed-os |
Updated an tested on the EFR32FG (#5271) platform, should be ready to go now unless you have any other suggestions? |
Test : SUCCESSBuild number : 12 |
continue; | ||
} | ||
|
||
platform_enter_critical(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this going to create the same issue with nanostack? You're calling nanostack (phy_rx_cb) from within a critical section... Not sure you can do mutex operations in there?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since what you're protecting is _head and _tail, I'd suggest caching their values into a local variable, to not run into a concurrent-update situation, and keep that critical section as short as possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In Mbed OS the Nanostack's platform_enter_critical()
is just a mutex.
See here.
So it is a way of protecting Nanostack to call you when you are in a state that you cannot receive TX-start of any of this sort events.
Actually, on a second look, I feel like the |
Build : SUCCESSBuild number : 109 Triggering tests/test mbed-os |
Build : SUCCESSBuild number : 135 Triggering tests/test mbed-os |
@SeppoTakalo Please review the latest update |
@0xc0170 this looks good to go to me. |
/morph test |
Test : SUCCESSBuild number : 123 |
"@SeppoTakalo Please review the latest update" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These changes cannot be accepted here.
These are API changes for Trace library. Nothing to do with the topic of the PR anymore.
Trace library is originating from a external repository: https://github.com/ARMmbed/mbed-trace
so no changes should be applied here.
fd8ef87
to
7b2e9b1
Compare
Ahh, I messed up with my working copy (which has all the changes) and merged that into the wrong branch, then failed at fixing it. Trying to work out how to sort it out now. update fixed / back up to date, still have to replace those trace calls with macros. |
Updated NanostackRfPhyEfr32 with a receive queue. Cleaned up debug messages, re-added to non-threaded calls. Removed debug print override Removed tr_debug override Removed normal-operation prints that could have timing implications if enabled Removed dead NVIC code (and a couple of dead log outputs)
@SeppoTakalo Are you happy with the updates ? |
Looks OK. |
@@ -254,6 +377,12 @@ static int8_t rf_device_register(void) | |||
radio_state = RADIO_INITING; | |||
} | |||
|
|||
#ifdef MBED_CONF_RTOS_PRESENT |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this make sense if this file already defines a thread above (line 69), thus assuming that without this conf macro present, this file would not compile anyway?
/morph build |
Build : SUCCESSBuild number : 411 Triggering tests/morph test |
Test : SUCCESSBuild number : 202 |
/morph uvisor-test |
1 similar comment
/morph uvisor-test |
Build : SUCCESSBuild number : 459 Triggering tests/morph test |
Test : SUCCESSBuild number : 279 |
@alzix Please trigger uvisor for this patch (seems it is not active for us at the moment for some reason) |
Thanks all for the help with this! |
Description
This PR introduces a threaded wrapper for the SiliconLabs RAIL radio driver in NanostackRfPhyEfr32.cpp resolving the issue raised in #5155.
Status
READY
Tested on the EFR32FG target which will be the subject of another PR.