From 6a5fa60ad4c8d615a68977fbe828ec07e962d2c0 Mon Sep 17 00:00:00 2001 From: Troels Nilsson Date: Thu, 10 Apr 2025 15:19:52 +0200 Subject: [PATCH] Bluetooth: Controller: Fix missing window widening in ull_periph_setup No window widening was applied to conn_offset_us causing the initial ticker_cb to get called slightly too late Apply window_widening_periodic_us to conn_offset_us, since this is the worst-case window widening (win_offset is not allowed to be larger than a connection interval) and is applied in the LLL window size already Fixes EBQ failure in LL/TIM/PER/BV-02-C Signed-off-by: Troels Nilsson --- subsys/bluetooth/controller/ll_sw/ull_peripheral.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/subsys/bluetooth/controller/ll_sw/ull_peripheral.c b/subsys/bluetooth/controller/ll_sw/ull_peripheral.c index d23d50f2bf9..290627b2819 100644 --- a/subsys/bluetooth/controller/ll_sw/ull_peripheral.c +++ b/subsys/bluetooth/controller/ll_sw/ull_peripheral.c @@ -418,6 +418,19 @@ void ull_periph_setup(struct node_rx_pdu *rx, struct node_rx_ftr *ftr, conn_offset_us -= EVENT_TICKER_RES_MARGIN_US; conn_offset_us -= EVENT_JITTER_US; conn_offset_us -= ready_delay_us; + /* + * NOTE: Correct window widening for the first connection will be: + * + * conn_offset_us -= + * DIV_ROUND_UP(((lll_clock_ppm_local_get() + + * lll_clock_ppm_get(conn->periph.sca)) * + * (win_offset * CONN_INT_UNIT_US + win_delay_us)), USEC_PER_SEC); + * + * But, as currently in the implementation the drift compensation uses the + * `lll->periph.window_widening_periodic_us` value, we may as well use that value here + * as well. Adding another value for LLL to use seems overkill for this one case. + */ + conn_offset_us -= lll->periph.window_widening_periodic_us; #if (CONFIG_BT_CTLR_ULL_HIGH_PRIO == CONFIG_BT_CTLR_ULL_LOW_PRIO) /* disable ticker job, in order to chain stop and start to avoid RTC