Skip to content

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

Merged
merged 3 commits into from
Nov 9, 2017

Conversation

ryankurte
Copy link
Contributor

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.

@ryankurte ryankurte mentioned this pull request Oct 8, 2017
@0xc0170
Copy link
Contributor

0xc0170 commented Oct 9, 2017

@SeppoTakalo Can you please review

Copy link
Contributor

@SeppoTakalo SeppoTakalo left a 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);
Copy link
Contributor

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__)
Copy link
Contributor

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();
}
}
Copy link
Contributor

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.

@ryankurte ryankurte changed the title Fix for Nanostack theading on EFR32 devices Fix for Nanostack threading on EFR32 devices Oct 9, 2017
@ryankurte
Copy link
Contributor Author

Thanks for the feedback @SeppoTakalo! Can squash it down to one commit now if that's useful to you?

@SeppoTakalo
Copy link
Contributor

Yes, please squash because it is one logical change.

waiting_for_ack = false;
#ifdef MBED_CONF_RTOS_PRESENT
//NVIC_DisableIRQ(MacHw_IRQn);
Copy link
Contributor

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

@ryankurte ryankurte force-pushed the fix/nanostack-efr32-threading branch 2 times, most recently from 70f55a3 to 6db6d26 Compare October 9, 2017 12:06
@ryankurte
Copy link
Contributor Author

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.

@ryankurte ryankurte force-pushed the fix/nanostack-efr32-threading branch from 6db6d26 to 8e59dd3 Compare October 10, 2017 01:32
@mbed-ci
Copy link

mbed-ci commented Oct 10, 2017

Build : SUCCESS

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

Triggering tests

/test mbed-os

@ryankurte
Copy link
Contributor Author

Updated an tested on the EFR32FG (#5271) platform, should be ready to go now unless you have any other suggestions?

@mbed-ci
Copy link

mbed-ci commented Oct 10, 2017

continue;
}

platform_enter_critical();
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 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?

Copy link
Contributor

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.

Copy link
Contributor

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.

@SeppoTakalo
Copy link
Contributor

Actually, on a second look, I feel like the rf_start_cca() should be protected by somehow.
Either using own lock like the Atmel one does https://github.com/ARMmbed/atmel-rf-driver/blob/master/source/NanostackRfPhyAtmel.cpp#L1681 or using platform_enter_critical()

@mbed-ci
Copy link

mbed-ci commented Oct 11, 2017

Build : SUCCESS

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

Triggering tests

/test mbed-os

@mbed-ci
Copy link

mbed-ci commented Oct 11, 2017

Build : SUCCESS

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

Triggering tests

/test mbed-os

@0xc0170
Copy link
Contributor

0xc0170 commented Oct 13, 2017

@SeppoTakalo Please review the latest update

@stevew817
Copy link
Contributor

@0xc0170 this looks good to go to me.

@0xc0170
Copy link
Contributor

0xc0170 commented Oct 19, 2017

/morph test

@mbed-ci
Copy link

mbed-ci commented Oct 19, 2017

@adbridge
Copy link
Contributor

"@SeppoTakalo Please review the latest update"
BUMP

Copy link
Contributor

@SeppoTakalo SeppoTakalo left a 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.

@ryankurte ryankurte closed this Oct 31, 2017
@ryankurte ryankurte force-pushed the fix/nanostack-efr32-threading branch from fd8ef87 to 7b2e9b1 Compare October 31, 2017 10:31
@sg- sg- removed the needs: review label Oct 31, 2017
@ryankurte
Copy link
Contributor Author

ryankurte commented Oct 31, 2017

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)
@adbridge
Copy link
Contributor

@SeppoTakalo Are you happy with the updates ?

@SeppoTakalo
Copy link
Contributor

Looks OK.

@@ -254,6 +377,12 @@ static int8_t rf_device_register(void)
radio_state = RADIO_INITING;
}

#ifdef MBED_CONF_RTOS_PRESENT
Copy link
Contributor

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?

@0xc0170
Copy link
Contributor

0xc0170 commented Nov 2, 2017

/morph build

@mbed-ci
Copy link

mbed-ci commented Nov 2, 2017

Build : SUCCESS

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

Triggering tests

/morph test
/morph uvisor-test

@mbed-ci
Copy link

mbed-ci commented Nov 2, 2017

@theotherjimmy
Copy link
Contributor

/morph uvisor-test

1 similar comment
@0xc0170
Copy link
Contributor

0xc0170 commented Nov 8, 2017

/morph uvisor-test

@mbed-ci
Copy link

mbed-ci commented Nov 8, 2017

Build : SUCCESS

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

Triggering tests

/morph test
/morph uvisor-test

@mbed-ci
Copy link

mbed-ci commented Nov 8, 2017

@0xc0170
Copy link
Contributor

0xc0170 commented Nov 9, 2017

@alzix Please trigger uvisor for this patch (seems it is not active for us at the moment for some reason)

@ryankurte
Copy link
Contributor Author

Thanks all for the help with this!

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.

8 participants