Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp4807522rwl; Mon, 3 Apr 2023 09:50:58 -0700 (PDT) X-Google-Smtp-Source: AKy350YDZa7xBbHloofXXQhiEn2KEiWA3SL35UIPQvyBYaiZfrS/zZgdZlevEfTBZIPz6CkUjD3s X-Received: by 2002:a05:6a20:b29a:b0:dc:925f:62f1 with SMTP id ei26-20020a056a20b29a00b000dc925f62f1mr18534850pzb.6.1680540658564; Mon, 03 Apr 2023 09:50:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680540658; cv=none; d=google.com; s=arc-20160816; b=bMiepRGAvb4h/17FuAUCpdavonz8imvPreVkU5K6P1FeMe2BEG6xEPEUXjGfCAKJue OrBk6sDWHPgIwIrmDgKr0d7m2JTf+Um5gLqQg8Mp2234uqF3ecWtbak3f9rOb3WKQbGz +wxNrsiJ+zcxyiJ5yFY/FKxzoQD0wmp90Z/vHv/R99n44T0rtDP+sB5Xg5ufU+y9Vy85 ys3aghug2cJuXb3Vm2Vb/d+ch0GA+KMausXXVActPwasmjr2B5hmOfdwXnsRPxJQRsXz biH7jsjqeZrO6dS6oPK9Ihb/wnp7x9n8Yx2A1NE1TLhCNncm0MVFLl2jdp7pgIuosJkt lQkQ== 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 :message-id:date:subject:cc:to:from; bh=4LERICdmiRhuvo2y0B2zRCQ/nbLC7x4F5Q3qggJKuPU=; b=DyDp6JgNSUXLZunAes7Rdm8zENW23p1e6mQTZcUz+4oTeVc2YMASc0Alc9Cxs2PW8u kEjiuouDKJWvAq/gjt4IgnkUJh1EZQMQcMSdS98bOeVnqSzaOSYfvFNM9pY9A7FIZiAl XOMwj61i5ehcf/01tuuNAc5k0G9FNMlbbb9voAwsarffqfIwxNPL16G/eWJC8nUX+dvC Z+vGHncQCiyiksVZ1gAtMOd2ldiO1yEZYJMX9AaVhHSF7ah7b/s2oeJARPvHmljBwfLi hAKZEjkSxP4/qEjOPGkIIZWVM+XYnBRThT1gTmmvUnROatF4cWvEWwidjY/DgMMDdjj4 21eg== 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 h9-20020a631209000000b004fb7e7d565asi8245030pgl.651.2023.04.03.09.50.12; Mon, 03 Apr 2023 09:50:58 -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 S232136AbjDCQis (ORCPT + 99 others); Mon, 3 Apr 2023 12:38:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48766 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231626AbjDCQim (ORCPT ); Mon, 3 Apr 2023 12:38:42 -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 B6C7D270C for ; Mon, 3 Apr 2023 09:38:33 -0700 (PDT) Received: from localhost.localdomain (unknown [103.29.142.67]) by mail-m11878.qiye.163.com (Hmail) with ESMTPA id 1515C740781; Tue, 4 Apr 2023 00:30:22 +0800 (CST) From: Qiqi Zhang To: marcel@holtmann.org, johan.hedberg@gmail.com, luiz.dentz@gmail.com Cc: linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, Qiqi Zhang Subject: [PATCH] Bluetooth: hci_h5: Complements reliable packet processing logic. Date: Tue, 4 Apr 2023 00:29:28 +0800 Message-Id: <20230403162928.118172-1-eddy.zhang@rock-chips.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFITzdXWS1ZQUlXWQ8JGhUIEh9ZQVlCT00dVklOQ0JITUhDTE4ZH1UTARMWGhIXJBQOD1 lXWRgSC1lBWUpLSFVJQlVKT0lVTUxZV1kWGg8SFR0UWUFZT0tIVUpKS0hKQ1VKS0tVS1kG X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6NTY6GCo5GD0QPDkrKzMLMj8I CQ8KFAxVSlVKTUNLTkhCT0lISUpIVTMWGhIXVR4fHwJVARMaFRw7CRQYEFYYExILCFUYFBZFWVdZ EgtZQVlKS0hVSUJVSk9JVU1MWVdZCAFZQUlPSUo3Bg++ X-HM-Tid: 0a8747f48ed72eb4kusn1515c740781 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." we should set H5_TX_ACK_REQ bit to trigger retransmission of pure ack packet when "out-of-order" occurs. Signed-off-by: Qiqi Zhang --- 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