mesh: Add guard against wedging outbound queue
authorBrian Gix <brian.gix@intel.com>
Wed, 29 Jul 2020 00:24:49 +0000 (17:24 -0700)
committerAbhay Agarwal <ay.agarwal@samsung.com>
Mon, 28 Dec 2020 06:20:04 +0000 (11:50 +0530)
When using HCI command chains, the first packet send that starts an
outbound sequence needs to still exist when command chain completes, or
the outbound queue will wedge.  The simplest solution is to send packets
at least twice on an empty queue, if there is a chance it could be canceled.

Change-Id: I883422c7143d71fe8309604dd487095de6703f9f
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
mesh/mesh-io-generic.c

index 9252687..018ab61 100644 (file)
@@ -749,6 +749,14 @@ static bool send_tx(struct mesh_io *io, struct mesh_io_send_info *info,
                        sending = !l_queue_isempty(pvt->tx_pkts);
 
                l_queue_push_tail(pvt->tx_pkts, tx);
+
+               /*
+                * If transmitter is idle, send packets at least twice to
+                * guard against in-line cancelation of HCI command chain.
+                */
+               if (info->type == MESH_IO_TIMING_TYPE_GENERAL && !sending &&
+                                                       tx->info.u.gen.cnt == 1)
+                       tx->info.u.gen.cnt++;
        }
 
        if (!sending) {