Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp1537566rwb; Tue, 27 Sep 2022 14:50:53 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6gV43zR3C8lHoPpNujdKoQrUf2CAdKQ9ge+QIpthf+wZVMKnqfxIX74771GeSlXRo1sUNV X-Received: by 2002:a17:903:441:b0:179:f1cc:ba89 with SMTP id iw1-20020a170903044100b00179f1ccba89mr3742503plb.146.1664315453039; Tue, 27 Sep 2022 14:50:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664315453; cv=none; d=google.com; s=arc-20160816; b=a77a46Y6M5bnuY6JZFzRg+2tQ5xUD3zuz7vfQ46Po3GFn4dTcBR3IKnP7pRKnDAEZX UH7vWj9okdKcPmHne0+EKXVEq6TZculVBBuxyJWt2xiXSe67KwfWzhejRhfwZtxmnGPw wFqeQhoj4hgg7B8mCnYh3HzM3+zCeCSlI9eVkIZxobiAArgKufPUgfbacMKP/niQ073e yi1PcSPx6i2cZsdZU4E/leX6Ut6jJJXS1y6/yWd0ytqTB++HCURRAeWyB5fNHYS2tnzy DAXP5xiJ34iPG8Isb2fMQZW4RsbtqjPbDdZ4Hlc9zKpO28KyVbtPNOHAt5d9wOCuInOX aqbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:to:content-language:subject:user-agent:mime-version:date :message-id:dkim-signature; bh=62/P9GafbAKMBLYOB9Q+s+PkUfeNdTj/8LGCNLYzpQc=; b=EmYimRpwOL5bVe1Dj2FrWXuUA9/UTUwb+vpIcyrxzGBfZdzYbV1TFitT6/0M5xnSw4 3IMCAK3IYsNhe82DR9ook8m8jdg18MWeGCC0z6k1QHsw6SMqA8OTf+SWmx5ZhSJGUhEU 6eep/9gI/Fv+umKgeV+zQuCVYLp5tMfSkQ9swoQAtHAgPP5LB9yvR4CgJg96az+32KXN oO5pKG7Mfgs2KuW+HddFgc52MoOK2lnsYbBxn170+EPX21yIskytJM4s4F0PqWYMYsqa Qx/aMTsJzNhwigywcNBdMaVbHjXJUG9ydzfBpo7naaEBbQUjldSeVkuWwziGA+KmRDzg 3E1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@beinder.at header.s=gm1 header.b=fiGJWD2v; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k9-20020a633d09000000b0043936ba9994si3704275pga.186.2022.09.27.14.50.23; Tue, 27 Sep 2022 14:50:53 -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; dkim=pass header.i=@beinder.at header.s=gm1 header.b=fiGJWD2v; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230131AbiI0Vkl (ORCPT + 99 others); Tue, 27 Sep 2022 17:40:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50894 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230283AbiI0Vkj (ORCPT ); Tue, 27 Sep 2022 17:40:39 -0400 Received: from relay12.mail.gandi.net (relay12.mail.gandi.net [IPv6:2001:4b98:dc4:8::232]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 82A5C42AC0 for ; Tue, 27 Sep 2022 14:40:37 -0700 (PDT) Received: (Authenticated sender: david@beinder.at) by mail.gandi.net (Postfix) with ESMTPSA id B26DE200002; Tue, 27 Sep 2022 21:40:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=beinder.at; s=gm1; t=1664314836; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=62/P9GafbAKMBLYOB9Q+s+PkUfeNdTj/8LGCNLYzpQc=; b=fiGJWD2vtLdOKFjgtNtGRC5P37n7+39ofaiZStfbahybDiR2Fh1xpu0zCS8TOAwqil0DzV yv3yhK4cjXmbXhjRc2Fr6FgGllM8Y/HS6U7A1JFKkBxrI/RVW6G2Fw99qoRhP097/eCU3t yc6oEA6Gc28SNrqh2ZDl6GogU1ew13SmLp37g0FBsUjgZjm/qZTwZ5uSfO6Wj4XhSW2j55 CmEiSH9pJ17eLw8VezHsC7WgJ/r84PpvL1xvXZBvzLr52cDl3ZgbShnODS9uf8fYLAS0Q0 ADjDCuJn/NTzadP4yowpgB5LxQ2UL32hzpIpDsh+hDvFx2kZobOJk/z7Qe3g5A== Message-ID: Date: Tue, 27 Sep 2022 23:40:34 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.3.0 Subject: Re: [PATCH] Bluetooth: hci_core: Fix not handling link timeouts propertly Content-Language: en-US To: Luiz Augusto von Dentz , linux-bluetooth@vger.kernel.org References: <20220926225107.3226470-1-luiz.dentz@gmail.com> From: David Beinder In-Reply-To: <20220926225107.3226470-1-luiz.dentz@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NEUTRAL autolearn=ham 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 On 2022-09-27 00:51, Luiz Augusto von Dentz wrote: > From: Luiz Augusto von Dentz > > Change that introduced the use of __check_timeout did not account for > link types properly, it always assumes ACL_LINK is used thus causing > hdev->acl_last_tx to be used even in case of LE_LINK and then again > uses ACL_LINK with hci_link_tx_to. > > To fix this __check_timeout now takes the link type as parameter and > then procedure to use the right last_tx based on the link type and pass > it to hci_link_tx_to. > > Fixes: 1b1d29e51499 ("Bluetooth: Make use of __check_timeout on hci_sched_le") > Signed-off-by: Luiz Augusto von Dentz Tested-by: David Beinder Patch tested on 5.10.136-cip14 (sunxi / armv7l), with a RTL8821CU adapter in LE-only mode. Spurious "link tx timeout" errors during LE data transfers are now gone. > --- > net/bluetooth/hci_core.c | 34 +++++++++++++++++++++++----------- > 1 file changed, 23 insertions(+), 11 deletions(-) > > diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c > index 66c7cdba0d32..063fbb8e07ca 100644 > --- a/net/bluetooth/hci_core.c > +++ b/net/bluetooth/hci_core.c > @@ -3485,15 +3485,27 @@ static inline int __get_blocks(struct hci_dev *hdev, struct sk_buff *skb) > return DIV_ROUND_UP(skb->len - HCI_ACL_HDR_SIZE, hdev->block_len); > } > > -static void __check_timeout(struct hci_dev *hdev, unsigned int cnt) > +static void __check_timeout(struct hci_dev *hdev, unsigned int cnt, u8 type) > { > - if (!hci_dev_test_flag(hdev, HCI_UNCONFIGURED)) { > - /* ACL tx timeout must be longer than maximum > - * link supervision timeout (40.9 seconds) */ > - if (!cnt && time_after(jiffies, hdev->acl_last_tx + > - HCI_ACL_TX_TIMEOUT)) > - hci_link_tx_to(hdev, ACL_LINK); > + unsigned long last_tx; > + > + if (hci_dev_test_flag(hdev, HCI_UNCONFIGURED)) > + return; > + > + switch (type) { > + case LE_LINK: > + last_tx = hdev->le_last_tx; > + break; > + default: > + last_tx = hdev->acl_last_tx; > + break; > } > + > + /* tx timeout must be longer than maximum link supervision timeout > + * (40.9 seconds) > + */ > + if (!cnt && time_after(jiffies, last_tx + HCI_ACL_TX_TIMEOUT)) > + hci_link_tx_to(hdev, type); > } > > /* Schedule SCO */ > @@ -3551,7 +3563,7 @@ static void hci_sched_acl_pkt(struct hci_dev *hdev) > struct sk_buff *skb; > int quote; > > - __check_timeout(hdev, cnt); > + __check_timeout(hdev, cnt, ACL_LINK); > > while (hdev->acl_cnt && > (chan = hci_chan_sent(hdev, ACL_LINK, "e))) { > @@ -3594,8 +3606,6 @@ static void hci_sched_acl_blk(struct hci_dev *hdev) > int quote; > u8 type; > > - __check_timeout(hdev, cnt); > - > BT_DBG("%s", hdev->name); > > if (hdev->dev_type == HCI_AMP) > @@ -3603,6 +3613,8 @@ static void hci_sched_acl_blk(struct hci_dev *hdev) > else > type = ACL_LINK; > > + __check_timeout(hdev, cnt, type); > + > while (hdev->block_cnt > 0 && > (chan = hci_chan_sent(hdev, type, "e))) { > u32 priority = (skb_peek(&chan->data_q))->priority; > @@ -3676,7 +3688,7 @@ static void hci_sched_le(struct hci_dev *hdev) > > cnt = hdev->le_pkts ? hdev->le_cnt : hdev->acl_cnt; > > - __check_timeout(hdev, cnt); > + __check_timeout(hdev, cnt, LE_LINK); > > tmp = cnt; > while (cnt && (chan = hci_chan_sent(hdev, LE_LINK, "e))) {