You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ry...@apache.org on 2019/11/19 11:08:02 UTC

[mynewt-nimble] branch master updated (bcf0962 -> e735b56)

This is an automated email from the ASF dual-hosted git repository.

rymek pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git.


    from bcf0962  npl/riot/syscfg: fix BLE_LL_CONN_INIT_MAX_TX_BYTES
     new 7bd0886  nimble/ll: Fix for race which leads to assert in ble_ll_conn
     new e735b56  nimble/ll: Clear connsm->rxd_disconnect_reason on initialization

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 nimble/controller/src/ble_ll_conn.c | 38 +++++++++++++++++++++++++++----------
 1 file changed, 28 insertions(+), 10 deletions(-)


[mynewt-nimble] 02/02: nimble/ll: Clear connsm->rxd_disconnect_reason on initialization

Posted by ry...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git

commit e735b56a97510a8b2234d39bc84d17cc79711990
Author: Łukasz Rymanowski <lu...@codecoup.pl>
AuthorDate: Fri Nov 15 14:45:34 2019 +0100

    nimble/ll: Clear connsm->rxd_disconnect_reason on initialization
---
 nimble/controller/src/ble_ll_conn.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/nimble/controller/src/ble_ll_conn.c b/nimble/controller/src/ble_ll_conn.c
index 405ad13..133bab8 100644
--- a/nimble/controller/src/ble_ll_conn.c
+++ b/nimble/controller/src/ble_ll_conn.c
@@ -1660,6 +1660,7 @@ ble_ll_conn_sm_new(struct ble_ll_conn_sm *connsm)
     connsm->event_cntr = 0;
     connsm->conn_state = BLE_LL_CONN_STATE_IDLE;
     connsm->disconnect_reason = 0;
+    connsm->rxd_disconnect_reason = 0;
     connsm->conn_features = BLE_LL_CONN_INITIAL_FEATURES;
     memset(connsm->remote_features, 0, sizeof(connsm->remote_features));
     connsm->vers_nr = 0;


[mynewt-nimble] 01/02: nimble/ll: Fix for race which leads to assert in ble_ll_conn

Posted by ry...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git

commit 7bd088634ade6447daea921b7b99a99820d421ab
Author: Łukasz Rymanowski <lu...@codecoup.pl>
AuthorDate: Fri Nov 15 14:31:56 2019 +0100

    nimble/ll: Fix for race which leads to assert in ble_ll_conn
    
    This is fix for following assert:
    __assert_func (file=file@entry=0x5a643 "repos/apache-mynewt-nimble/nimble/controller/src/ble_ll_conn.c", line=2302,
    
    That assert means that LL is trying to close connection which is already
    closed.
---
 nimble/controller/src/ble_ll_conn.c | 37 +++++++++++++++++++++++++++----------
 1 file changed, 27 insertions(+), 10 deletions(-)

diff --git a/nimble/controller/src/ble_ll_conn.c b/nimble/controller/src/ble_ll_conn.c
index e01879e..405ad13 100644
--- a/nimble/controller/src/ble_ll_conn.c
+++ b/nimble/controller/src/ble_ll_conn.c
@@ -181,6 +181,7 @@ STATS_SECT_START(ble_ll_conn_stats)
     STATS_SECT_ENTRY(mic_failures)
     STATS_SECT_ENTRY(sched_start_in_idle)
     STATS_SECT_ENTRY(sched_end_in_idle)
+    STATS_SECT_ENTRY(conn_event_while_tmo)
 STATS_SECT_END
 STATS_SECT_DECL(ble_ll_conn_stats) ble_ll_conn_stats;
 
@@ -213,6 +214,7 @@ STATS_NAME_START(ble_ll_conn_stats)
     STATS_NAME(ble_ll_conn_stats, mic_failures)
     STATS_NAME(ble_ll_conn_stats, sched_start_in_idle)
     STATS_NAME(ble_ll_conn_stats, sched_end_in_idle)
+    STATS_NAME(ble_ll_conn_stats, conn_event_while_tmo)
 STATS_NAME_END(ble_ll_conn_stats)
 
 static void ble_ll_conn_event_end(struct ble_npl_event *ev);
@@ -353,8 +355,7 @@ ble_ll_conn_get_ce_end_time(void)
 }
 
 /**
- * Called when the current connection state machine is no longer being used.
- * This function will:
+ * Called when connection state machine needs to halt. This function will:
  *  -> Disable the PHY, which will prevent any transmit/receive interrupts.
  *  -> Disable the wait for response timer, if running.
  *  -> Remove the connection state machine from the scheduler.
@@ -366,19 +367,22 @@ ble_ll_conn_get_ce_end_time(void)
  *  standby and set the current state machine pointer to NULL.
  */
 static void
-ble_ll_conn_current_sm_over(struct ble_ll_conn_sm *connsm)
+ble_ll_conn_halt(void)
 {
-    /* Disable the PHY */
     ble_phy_disable();
-
-    /* Disable the wfr timer */
     ble_ll_wfr_disable();
-
-    /* Link-layer is in standby state now */
     ble_ll_state_set(BLE_LL_STATE_STANDBY);
-
-    /* Set current LL connection to NULL */
     g_ble_ll_conn_cur_sm = NULL;
+}
+
+/**
+ * Called when the current connection state machine is no longer being used.
+ */
+static void
+ble_ll_conn_current_sm_over(struct ble_ll_conn_sm *connsm)
+{
+
+    ble_ll_conn_halt();
 
     /*
      * NOTE: the connection state machine may be NULL if we are calling
@@ -1808,6 +1812,7 @@ ble_ll_conn_end(struct ble_ll_conn_sm *connsm, uint8_t ble_err)
 {
     struct os_mbuf *m;
     struct os_mbuf_pkthdr *pkthdr;
+    os_sr_t sr;
 #if MYNEWT_VAL(BLE_LL_STRICT_CONN_SCHEDULING)
     os_sr_t sr;
 #endif
@@ -1815,6 +1820,18 @@ ble_ll_conn_end(struct ble_ll_conn_sm *connsm, uint8_t ble_err)
     /* Remove scheduler events just in case */
     ble_ll_sched_rmv_elem(&connsm->conn_sch);
 
+    /* In case of the supervision timeout we shall make sure
+     * that there is no ongoing connection event. It could happen
+     * because we scheduled connection event before checking connection timeout.
+     * If connection event managed to start, let us drop it.
+     */
+    OS_ENTER_CRITICAL(sr);
+    if (g_ble_ll_conn_cur_sm == connsm) {
+        ble_ll_conn_halt();
+        STATS_INC(ble_ll_conn_stats, conn_event_while_tmo);
+    }
+    OS_EXIT_CRITICAL(sr);
+
     /* Stop any control procedures that might be running */
     ble_npl_callout_stop(&connsm->ctrl_proc_rsp_timer);