Skip to content

Commit 6281902

Browse files
ppryga-nordicnashif
authored andcommitted
Bluetooth: controller: Add release of periodic advertising sync set
Add release of memory acquired for periodic advetising sync. set when: - advertising set is removed - advertising parameters are changed and past PDU type was extended advertising PDU Signed-off-by: Piotr Pryga <[email protected]>
1 parent c8475b9 commit 6281902

File tree

5 files changed

+33
-2
lines changed

5 files changed

+33
-2
lines changed

subsys/bluetooth/controller/ll_sw/nordic/lll/lll_adv.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,15 @@ static inline struct pdu_adv *lll_adv_sync_data_alloc(struct lll_adv_sync *lll,
219219
#endif /* CONFIG_BT_CTLR_ADV_EXT_PDU_EXTRA_DATA_MEMORY */
220220
}
221221

222+
static inline void lll_adv_sync_data_release(struct lll_adv_sync *lll)
223+
{
224+
#if IS_ENABLED(CONFIG_BT_CTLR_ADV_EXT_PDU_EXTRA_DATA_MEMORY)
225+
lll_adv_and_extra_data_release(&lll->data);
226+
#else
227+
lll_adv_data_release(&lll->data);
228+
#endif /* CONFIG_BT_CTLR_ADV_EXT_PDU_EXTRA_DATA_MEMORY */
229+
}
230+
222231
static inline void lll_adv_sync_data_enqueue(struct lll_adv_sync *lll,
223232
uint8_t idx)
224233
{

subsys/bluetooth/controller/ll_sw/ull_adv.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,9 +291,13 @@ uint8_t ll_adv_params_set(uint16_t interval, uint8_t adv_type,
291291
if (is_new_set) {
292292
pdu->type = pdu_adv_type[adv_type];
293293
is_pdu_type_changed = 1;
294+
/* check if new PDU type is different that past one */
294295
} else if (pdu->type != pdu_adv_type[adv_type]) {
295296
is_pdu_type_changed = 1;
296297

298+
/* If old PDU was extended advertising PDU, release
299+
* auxiliary and periodic advertising sets.
300+
*/
297301
if (pdu->type == PDU_ADV_TYPE_EXT_IND) {
298302
struct lll_adv_aux *lll_aux = adv->lll.aux;
299303

@@ -306,8 +310,14 @@ uint8_t ll_adv_params_set(uint16_t interval, uint8_t adv_type,
306310
pdu->len = 0;
307311

308312
#if defined(CONFIG_BT_CTLR_ADV_PERIODIC)
309-
/* FIXME: release periodic adv set */
310-
LL_ASSERT(!adv->lll.sync);
313+
if (adv->lll.sync) {
314+
struct ll_adv_sync_set *sync;
315+
316+
sync = (void *)HDR_LLL2EVT(adv->lll.sync);
317+
adv->lll.sync = NULL;
318+
319+
ull_adv_sync_release(sync);
320+
}
311321
#endif /* CONFIG_BT_CTLR_ADV_PERIODIC */
312322

313323
/* Release auxiliary channel set */

subsys/bluetooth/controller/ll_sw/ull_adv_aux.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,9 @@ uint8_t ll_adv_aux_set_remove(uint8_t handle)
355355
if (sync->is_enabled) {
356356
return BT_HCI_ERR_CMD_DISALLOWED;
357357
}
358+
lll->sync = NULL;
359+
360+
ull_adv_sync_release(sync);
358361
}
359362
#endif /* CONFIG_BT_CTLR_ADV_PERIODIC */
360363

subsys/bluetooth/controller/ll_sw/ull_adv_internal.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,9 @@ uint8_t ull_adv_aux_hdr_set_clear(struct ll_adv_set *adv,
101101
struct pdu_adv_adi *adi,
102102
uint8_t *pri_idx);
103103

104+
/* helper function to release periodic advertising instance */
105+
void ull_adv_sync_release(struct ll_adv_sync_set *sync);
106+
104107
/* helper function to set/clear common extended header format fields
105108
* for AUX_SYNC_IND PDU.
106109
*/

subsys/bluetooth/controller/ll_sw/ull_adv_sync.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,12 @@ uint32_t ull_adv_sync_start(struct ll_adv_set *adv,
511511
return ret;
512512
}
513513

514+
void ull_adv_sync_release(struct ll_adv_sync_set *sync)
515+
{
516+
lll_adv_sync_data_release(&sync->lll);
517+
sync_release(sync);
518+
}
519+
514520
void ull_adv_sync_offset_get(struct ll_adv_set *adv)
515521
{
516522
static memq_link_t link;

0 commit comments

Comments
 (0)