Skip to contentSkip to conversation

mesh: Add guard against wedging outbound queue

PATCH Applied Brian Gix 1 participant 2 messages Jul 29, 2020 Bluetooth drivers

lore
Share & tools
lore

Brian Gix

author
#0 lore raw

PATCH 1/1 mesh: Add guard against wedging outbound queue

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.

---
 mesh/mesh-io-generic.c | 8 ++++++++
 1 file changed, 8 insertions(+)
mesh/mesh-io-generic.c +8 -0
index 86952516e..4b26b1181 100644
@@ -714,6 +714,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) {
Signature · 1 line
2.25.4
author Applied
#1 lore raw

Applied

Quoted 27 lines · Brian Gix

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.

---
 mesh/mesh-io-generic.c | 8 ++++++++
 1 file changed, 8 insertions(+)
mesh/mesh-io-generic.c +8 -0
index 86952516e..4b26b1181 100644
@@ -714,6 +714,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) {