msuraev has submitted this change. ( https://gerrit.osmocom.org/c/osmo-bts/+/31383 )
Change subject: bts-virtual: fix segfault ......................................................................
bts-virtual: fix segfault
Premature activation of virtual scheduler in bts_model_phy_link_open() leads to segfault in vbts_sched_start(). Fix this by moving scheduler activation to bts_model_oml_estab()
Change-Id: I116c2548dd4d05df90c16e81fa2e85ed6027a2e1 --- M src/osmo-bts-virtual/l1_if.c M src/osmo-bts-virtual/scheduler_virtbts.c 2 files changed, 29 insertions(+), 11 deletions(-)
Approvals: Jenkins Builder: Verified fixeria: Looks good to me, but someone else must approve dexter: Looks good to me, but someone else must approve msuraev: Looks good to me, approved
diff --git a/src/osmo-bts-virtual/l1_if.c b/src/osmo-bts-virtual/l1_if.c index bba274d..da25554 100644 --- a/src/osmo-bts-virtual/l1_if.c +++ b/src/osmo-bts-virtual/l1_if.c @@ -187,6 +187,19 @@ /* called by common part once OML link is established */ int bts_model_oml_estab(struct gsm_bts *bts) { + struct phy_instance *pinst = trx_phy_instance(bts->c0); + + if (vbts_sched_start(pinst->trx->bts) < 0) + return -ENOLINK; + + /* Only start the scheduler for the transceiver on C0. + * If we have multiple transceivers, CCCH is always on C0 + * and has to be auto active */ + pinst->trx->ts[0].lchan[CCCH_LCHAN].rel_act_kind = LCHAN_REL_ACT_OML; + + /* Other TRX are activated via OML by a PRIM_INFO_MODIFY / PRIM_INFO_ACTIVATE */ + lchan_set_state(&pinst->trx->ts[0].lchan[CCCH_LCHAN], LCHAN_S_ACTIVE); + return 0; }
@@ -217,17 +230,6 @@ if (pinst->trx == NULL) continue; trx_sched_init(pinst->trx); - /* Only start the scheduler for the transceiver on C0. - * If we have multiple transceivers, CCCH is always on C0 - * and has to be auto active */ - /* Other TRX are activated via OML by a PRIM_INFO_MODIFY - * / PRIM_INFO_ACTIVATE */ - if (pinst->trx == pinst->trx->bts->c0) { - vbts_sched_start(pinst->trx->bts); - /* FIXME: This is probably the wrong location to set the CCCH to active... the OML link def. needs to be reworked and fixed. */ - pinst->trx->ts[0].lchan[CCCH_LCHAN].rel_act_kind = LCHAN_REL_ACT_OML; - lchan_set_state(&pinst->trx->ts[0].lchan[CCCH_LCHAN], LCHAN_S_ACTIVE); - } }
/* this will automatically update the MO state of all associated TRX objects */ diff --git a/src/osmo-bts-virtual/scheduler_virtbts.c b/src/osmo-bts-virtual/scheduler_virtbts.c index d20cc39..72f03b4 100644 --- a/src/osmo-bts-virtual/scheduler_virtbts.c +++ b/src/osmo-bts-virtual/scheduler_virtbts.c @@ -541,6 +541,9 @@ struct bts_virt_priv *bts_virt = (struct bts_virt_priv *)bts->model_priv; LOGP(DL1P, LOGL_NOTICE, "starting VBTS scheduler\n");
+ if (!bts_virt) + return -EINVAL; + memset(&bts_virt->fn_timer, 0, sizeof(bts_virt->fn_timer)); bts_virt->fn_timer.cb = vbts_fn_timer_cb; bts_virt->fn_timer.data = bts;