Skip to content

Commit b6906ec

Browse files
committed
Bluetooth: Controller: Use uint16_t to store ISR profiling value
Use uint16_t to store ISR profiling value to avoid overflow in case of higher latencies. Signed-off-by: Vinayak Kariappa Chettimada <[email protected]>
1 parent b045d34 commit b6906ec

File tree

2 files changed

+24
-24
lines changed

2 files changed

+24
-24
lines changed

subsys/bluetooth/controller/ll_sw/nordic/lll/lll_prof.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,22 @@
2323

2424
static int send(struct node_rx_pdu *rx);
2525
static inline void sample(uint32_t *timestamp);
26-
static inline void delta(uint32_t timestamp, uint8_t *cputime);
26+
static inline void delta(uint32_t timestamp, uint16_t *cputime);
2727

2828
static uint32_t timestamp_radio;
2929
static uint32_t timestamp_lll;
3030
static uint32_t timestamp_ull_high;
3131
static uint32_t timestamp_ull_low;
32-
static uint8_t cputime_radio;
33-
static uint8_t cputime_lll;
34-
static uint8_t cputime_ull_high;
35-
static uint8_t cputime_ull_low;
36-
static uint8_t latency_min = (uint8_t) -1;
37-
static uint8_t latency_max;
38-
static uint8_t latency_prev;
39-
static uint8_t cputime_min = (uint8_t) -1;
40-
static uint8_t cputime_max;
41-
static uint8_t cputime_prev;
32+
static uint16_t cputime_radio;
33+
static uint16_t cputime_lll;
34+
static uint16_t cputime_ull_high;
35+
static uint16_t cputime_ull_low;
36+
static uint16_t latency_min = UINT16_MAX;
37+
static uint16_t latency_max;
38+
static uint16_t latency_prev;
39+
static uint16_t cputime_min = UINT16_MAX;
40+
static uint16_t cputime_max;
41+
static uint16_t cputime_prev;
4242
static uint32_t timestamp_latency;
4343

4444
void lll_prof_enter_radio(void)
@@ -155,7 +155,7 @@ void lll_prof_reserve_send(struct node_rx_pdu *rx)
155155

156156
static int send(struct node_rx_pdu *rx)
157157
{
158-
uint8_t latency, cputime, prev;
158+
uint16_t latency, cputime, prev;
159159
struct pdu_data *pdu;
160160
struct profile *p;
161161
uint8_t chg = 0U;
@@ -248,13 +248,13 @@ static inline void sample(uint32_t *timestamp)
248248
*timestamp = radio_tmr_sample_get();
249249
}
250250

251-
static inline void delta(uint32_t timestamp, uint8_t *cputime)
251+
static inline void delta(uint32_t timestamp, uint16_t *cputime)
252252
{
253253
uint32_t delta;
254254

255255
radio_tmr_sample();
256256
delta = radio_tmr_sample_get() - timestamp;
257-
if (delta < UINT8_MAX && delta > *cputime) {
257+
if (delta < UINT16_MAX && delta > *cputime) {
258258
*cputime = delta;
259259
}
260260
}

subsys/bluetooth/controller/ll_sw/pdu.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -931,16 +931,16 @@ struct pdu_data_llctrl {
931931

932932
#if defined(CONFIG_BT_CTLR_PROFILE_ISR)
933933
struct profile {
934-
uint8_t lcur;
935-
uint8_t lmin;
936-
uint8_t lmax;
937-
uint8_t cur;
938-
uint8_t min;
939-
uint8_t max;
940-
uint8_t radio;
941-
uint8_t lll;
942-
uint8_t ull_high;
943-
uint8_t ull_low;
934+
uint16_t lcur;
935+
uint16_t lmin;
936+
uint16_t lmax;
937+
uint16_t cur;
938+
uint16_t min;
939+
uint16_t max;
940+
uint16_t radio;
941+
uint16_t lll;
942+
uint16_t ull_high;
943+
uint16_t ull_low;
944944
} __packed;
945945
#endif /* CONFIG_BT_CTLR_PROFILE_ISR */
946946

0 commit comments

Comments
 (0)