dyn pdch: don't PDCH ACT if gprs mode is none

Skip PDCH activation if the GPRS mode is 'none' at:

* TCH/F_PDCH init after OML Enable (dyn_pdch_init())
* after TCH/F_PDCH is released, in TCH/F mode
* in the T3111 error timer callback after a TCH/F_PDCH was released in error
  state

Assert the GPRS mode in rsl_ipacc_pdch_activate() to make sure all callers
check the GPRS mode.

Closes: OS#1765

Change-Id: I970e5f9dbcb1c625209e914a4c7696294ed34e62
diff --git a/openbsc/src/libbsc/abis_rsl.c b/openbsc/src/libbsc/abis_rsl.c
index 9f76280..013daec 100644
--- a/openbsc/src/libbsc/abis_rsl.c
+++ b/openbsc/src/libbsc/abis_rsl.c
@@ -645,8 +645,9 @@
 	LOGP(DRSL, LOGL_INFO, "%s is back in operation.\n", gsm_lchan_name(lchan));
 	rsl_lchan_set_state(lchan, LCHAN_S_NONE);
 
-	/* Put PDCH channel back into PDCH mode */
-	if (lchan->ts->pchan == GSM_PCHAN_TCH_F_PDCH)
+	/* Put PDCH channel back into PDCH mode, if GPRS is enabled */
+	if (lchan->ts->pchan == GSM_PCHAN_TCH_F_PDCH
+	    && lchan->ts->trx->bts->gprs.mode != BTS_GPRS_NONE)
 		rsl_ipacc_pdch_activate(lchan->ts, 1);
 }
 
@@ -772,9 +773,13 @@
 	 * Any state other than LCHAN_S_REL_ERR became LCHAN_S_NONE after above
 	 * do_lchan_free(). Assert this, because that's what ensures a PDCH ACT
 	 * on a dynamic channel in all cases.
+	 *
+	 * If GPRS is disabled, always skip the PDCH ACT.
 	 */
 	OSMO_ASSERT(lchan->state == LCHAN_S_NONE
 		    || lchan->state == LCHAN_S_REL_ERR);
+	if (lchan->ts->trx->bts->gprs.mode == BTS_GPRS_NONE)
+		return 0;
 	if (lchan->ts->pchan == GSM_PCHAN_TCH_F_PDCH
 	    && lchan->state == LCHAN_S_NONE)
 		return rsl_ipacc_pdch_activate(lchan->ts, 1);
@@ -2042,6 +2047,8 @@
 	}
 
 	if (act){
+		/* Callers should heed the GPRS mode. */
+		OSMO_ASSERT(ts->trx->bts->gprs.mode != BTS_GPRS_NONE);
 		msg_type = RSL_MT_IPAC_PDCH_ACT;
 		ts->flags |= TS_F_PDCH_ACT_PENDING;
 	} else {