Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp5366444rwl; Mon, 3 Apr 2023 19:33:02 -0700 (PDT) X-Google-Smtp-Source: AKy350ZZRnChrihx9QzctxPjM6Z94dBdl2HuKipLZbsr/87f2ZFsuqUeAYy0arEgzXil/WfN57wC X-Received: by 2002:a17:906:7f93:b0:920:7827:302 with SMTP id f19-20020a1709067f9300b0092078270302mr1034131ejr.18.1680575582072; Mon, 03 Apr 2023 19:33:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680575582; cv=none; d=google.com; s=arc-20160816; b=kAgdy6ePh8ZoKjDFSjKLiT7mieiBVUZ6gzoty6alPAo4zM9/+MZhSseh9VWzbTQPsf i5YvPfzbIvfqA0J+gLy49W94Jp/Nc2fMJeV7YDUqRkYF7r07huwyYVOoIgFxsifK2RI6 DNP7UGt790GJOSCks4r6FQse5VvZXFk8SekW9ya7rlyGWwHk+ChLB/TeRowhfybwebjm vjCamguIMIcbGfNUqPEcq5drXRgolT53fESQOHKpsRspj+v/YmtfYbtM15njZZNBBBqu GZVFq38HQQV28QLufhh6WuMK7dMUeDct3ggZ3HciCi6U2pv534NI6iIRD6EP/eEwYRSx oVrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=iLJNJAQHbXGVzmGyDMPKvYm4+92ryBO2l8F/qVKGeTc=; b=rKCyc1pARhvl6AMcCfjNaYS5zoZW+8bxjUTkOyLa3bRo02YtShf1FWU31BmyargsGU MoqH6S3Cs74nXu8aJa+vmPbM+SGJQscKoWW50kzf41rFndhBpA5IzKiIDLTSdDIm6gCb 79MzclYaJwo9yZmLOTVuXr6KyfEzRfpgEh1b3h7Ivynoh7BG4ANxm31Ptm0UlEKH5Lal hMCT4kXJlrkH434JZ6HrxVXsgLOjRAp3WSYCySevy/R5hnuaABuiFn8/6d1kyT4o51jN sGBmGsncDUXrHfjno2j/P5iuG8lyS9CJMjm/5usJIYuBmhI7BPNWrnltGmV2rMJa0HyM xJEA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=rock-chips.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id op10-20020a170906bcea00b0093a9258f5e4si621250ejb.358.2023.04.03.19.32.27; Mon, 03 Apr 2023 19:33:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=rock-chips.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231786AbjDDC1x (ORCPT + 99 others); Mon, 3 Apr 2023 22:27:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38396 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229693AbjDDC1x (ORCPT ); Mon, 3 Apr 2023 22:27:53 -0400 Received: from mail-m11878.qiye.163.com (mail-m11878.qiye.163.com [115.236.118.78]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 300061BFA; Mon, 3 Apr 2023 19:27:51 -0700 (PDT) Received: from localhost.localdomain (unknown [103.29.142.67]) by mail-m11878.qiye.163.com (Hmail) with ESMTPA id 98317740458; Tue, 4 Apr 2023 10:27:47 +0800 (CST) From: Qiqi Zhang To: eddy.zhang@rock-chips.com Cc: johan.hedberg@gmail.com, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, luiz.dentz@gmail.com, marcel@holtmann.org Subject: [PATCH v2] Bluetooth: hci_h5: Complements reliable packet processing logic Date: Tue, 4 Apr 2023 10:27:11 +0800 Message-Id: <20230404022711.86515-1-eddy.zhang@rock-chips.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230403162928.118172-1-eddy.zhang@rock-chips.com> References: <20230403162928.118172-1-eddy.zhang@rock-chips.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFITzdXWS1ZQUlXWQ8JGhUIEh9ZQVlCS0pPVk4aHUhKSBkYGkwdSlUTARMWGhIXJBQOD1 lXWRgSC1lBWUpLSFVJQlVKT0lVTUxZV1kWGg8SFR0UWUFZT0tIVUpKS0hKQ1VKS0tVS1kG X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6PCI6Ihw5ET0cNDgoMQ01QxEy KzEaFE9VSlVKTUNLTkxOSU1DTUpDVTMWGhIXVR4fHwJVARMaFRw7CRQYEFYYExILCFUYFBZFWVdZ EgtZQVlKS0hVSUJVSk9JVU1MWVdZCAFZQUlNQko3Bg++ X-HM-Tid: 0a874a17847d2eb4kusn98317740458 X-HM-MType: 1 X-Spam-Status: No, score=-0.0 required=5.0 tests=RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org As shown in the schematic diagram below.There may be a critical scenario in the current code. If the device does not receive an pure ack sent by the host due to insufficient receive buffer or other reasons and triggers a retransmission, the host will always be in an 'out-of-order' state.The state machine will get stuck. host device SEQ3,ACK4 ---------> <--------- SEQ4,ACK4 pure ACK ---------> (not received) (out-of-order) <--------- SEQ4,ACK4(retransmission) ........ (out-of-order) <--------- SEQ4,ACK4(retransmission) According to the description in the core specification: "whenever a reliable packet is received, an acknowledgment shall be generated." So set H5_TX_ACK_REQ bit to trigger retransmission of pure ack packet when "out-of-order" occurs. Signed-off-by: Qiqi Zhang --- Changes in v2: - Fixed build bot warning. --- --- drivers/bluetooth/hci_h5.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/bluetooth/hci_h5.c b/drivers/bluetooth/hci_h5.c index 6455bc4fb5bb..d05eaeaa4516 100644 --- a/drivers/bluetooth/hci_h5.c +++ b/drivers/bluetooth/hci_h5.c @@ -463,6 +463,8 @@ static int h5_rx_3wire_hdr(struct hci_uart *hu, unsigned char c) if (H5_HDR_RELIABLE(hdr) && H5_HDR_SEQ(hdr) != h5->tx_ack) { bt_dev_err(hu->hdev, "Out-of-order packet arrived (%u != %u)", H5_HDR_SEQ(hdr), h5->tx_ack); + set_bit(H5_TX_ACK_REQ, &h5->flags); + hci_uart_tx_wakeup(hu); h5_reset_rx(h5); return 0; } -- 2.25.1