From patchwork Wed Jul 29 15:52:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Gix X-Patchwork-Id: 11691285 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EABF513B1 for ; Wed, 29 Jul 2020 15:52:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DD2A320829 for ; Wed, 29 Jul 2020 15:52:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726449AbgG2Pwo (ORCPT ); Wed, 29 Jul 2020 11:52:44 -0400 Received: from mga11.intel.com ([192.55.52.93]:63644 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726341AbgG2Pwo (ORCPT ); Wed, 29 Jul 2020 11:52:44 -0400 IronPort-SDR: jsfo0hs3NWOczz6wZw+AUjnj70/cbXiIqtLO+zbXxJhP6yFphSclJoLfwsEOkV5ffOp7ojS48e GEAZePiVxO/Q== X-IronPort-AV: E=McAfee;i="6000,8403,9697"; a="149283067" X-IronPort-AV: E=Sophos;i="5.75,410,1589266800"; d="scan'208";a="149283067" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Jul 2020 08:52:43 -0700 IronPort-SDR: MvvlNpOmdFWKilwNfBISpyZB4Rf0AMkkzQNWe4WoRGlP3pP9kPrE8JjtxPbbbbALyGom0T5R8d 0TXsUzks3+ow== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,410,1589266800"; d="scan'208";a="330443559" Received: from bgi1-mobl2.amr.corp.intel.com ([10.254.114.231]) by orsmga007.jf.intel.com with ESMTP; 29 Jul 2020 08:52:42 -0700 From: Brian Gix To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, inga.stotland@intel.com, mike@mnmoran.org Subject: [PATCH BlueZ] mesh: Add guard against wedging outbound queue Date: Wed, 29 Jul 2020 08:52:34 -0700 Message-Id: <20200729155234.547679-1-brian.gix@intel.com> X-Mailer: git-send-email 2.25.4 MIME-Version: 1.0 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org 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(+) diff --git a/mesh/mesh-io-generic.c b/mesh/mesh-io-generic.c index 86952516e..4b26b1181 100644 --- a/mesh/mesh-io-generic.c +++ b/mesh/mesh-io-generic.c @@ -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) {