Skip to content

Commit

Permalink
Bluetooth: controller: split: Support Zero Latency IRQs
Browse files Browse the repository at this point in the history
Add support for Zero Latency IRQs, which avoids any Zephyr
OS or application influenced ISR latencies on the
controller's ISRs.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
  • Loading branch information
cvinayak authored and ioannisg committed Dec 3, 2019
1 parent dab1828 commit 92e017f
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
2 changes: 1 addition & 1 deletion subsys/bluetooth/controller/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ config BT_CTLR_PHY_CODED

config BT_CTLR_ZLI
bool "Use Zero Latency IRQs"
depends on ZERO_LATENCY_IRQS
depends on ZERO_LATENCY_IRQS && BT_LL_SW_SPLIT
help
Enable support for use of Zero Latency IRQ feature. Note, applications
shall not use Zero Latency IRQ themselves when this option is selected,
Expand Down
10 changes: 8 additions & 2 deletions subsys/bluetooth/controller/ll_sw/nordic/lll/lll.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@
#include "common/log.h"
#include "hal/debug.h"

#if defined(CONFIG_BT_CTLR_ZLI)
#define IRQ_CONNECT_FLAGS IRQ_ZERO_LATENCY
#else
#define IRQ_CONNECT_FLAGS 0
#endif

static struct {
struct {
void *param;
Expand Down Expand Up @@ -158,11 +164,11 @@ int lll_init(void)

/* Connect ISRs */
IRQ_DIRECT_CONNECT(RADIO_IRQn, CONFIG_BT_CTLR_LLL_PRIO,
radio_nrf5_isr, 0);
radio_nrf5_isr, IRQ_CONNECT_FLAGS);
IRQ_CONNECT(RTC0_IRQn, CONFIG_BT_CTLR_ULL_HIGH_PRIO,
rtc0_nrf5_isr, NULL, 0);
IRQ_CONNECT(HAL_SWI_RADIO_IRQ, CONFIG_BT_CTLR_LLL_PRIO,
swi_lll_nrf5_isr, NULL, 0);
swi_lll_nrf5_isr, NULL, IRQ_CONNECT_FLAGS);
#if defined(CONFIG_BT_CTLR_LOW_LAT) || \
(CONFIG_BT_CTLR_ULL_HIGH_PRIO != CONFIG_BT_CTLR_ULL_LOW_PRIO)
IRQ_CONNECT(HAL_SWI_JOB_IRQ, CONFIG_BT_CTLR_ULL_LOW_PRIO,
Expand Down
21 changes: 19 additions & 2 deletions subsys/bluetooth/controller/ll_sw/ull.c
Original file line number Diff line number Diff line change
Expand Up @@ -406,21 +406,36 @@ void ll_reset(void)

/* Reset LLL via mayfly */
{
u32_t retval;
struct k_sem sem;
static memq_link_t link;
static struct mayfly mfy = {0, 0, &link, NULL,
perform_lll_reset};
u32_t retval;

/* NOTE: If Zero Latency Interrupt is used, then LLL context
* will be the highest priority IRQ in the system, hence
* mayfly_enqueue will be done running the callee inline
* (vector to the callee function) in this function. Else
* we use semaphore to wait for perform_lll_reset to
* complete.
*/

#if !defined(CONFIG_BT_CTLR_ZLI)
struct k_sem sem;

k_sem_init(&sem, 0, 1);
mfy.param = &sem;
#endif /* !CONFIG_BT_CTLR_ZLI */

retval = mayfly_enqueue(TICKER_USER_ID_THREAD,
TICKER_USER_ID_LLL, 0, &mfy);
LL_ASSERT(!retval);

#if !defined(CONFIG_BT_CTLR_ZLI)
/* LLL reset must complete before returning - wait for
* reset completion in LLL mayfly thread
*/
k_sem_take(&sem, K_FOREVER);
#endif /* !CONFIG_BT_CTLR_ZLI */
}

/* Common to init and reset */
Expand Down Expand Up @@ -1210,7 +1225,9 @@ static void perform_lll_reset(void *param)
LL_ASSERT(!err);
#endif /* CONFIG_BT_CONN */

#if !defined(CONFIG_BT_CTLR_ZLI)
k_sem_give(param);
#endif /* !CONFIG_BT_CTLR_ZLI */
}

static inline void *mark_set(void **m, void *param)
Expand Down

0 comments on commit 92e017f

Please sign in to comment.