Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp1130530rwi; Wed, 19 Oct 2022 07:06:07 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4v7Wd5ra9nFoQxrUIazrmXyW6sUYqrP0RolsHiHbWdraMruOywc9RfnntBOOguglsgGjM0 X-Received: by 2002:a17:902:f78a:b0:184:f2e2:a5fa with SMTP id q10-20020a170902f78a00b00184f2e2a5famr8816653pln.161.1666188367343; Wed, 19 Oct 2022 07:06:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666188367; cv=none; d=google.com; s=arc-20160816; b=rTxzldbubAXVlQcSW0Dzf8R0bY6dx/RK28Phi+My9cA9ulgaywZpHtbI+zouJo3oPf pMhkr36Hbn+cHOn9eoTpuVZdFX82s12/FP0J9w85iYLB5JNjT2txkJ6nuhM7yYWwS2Up hCqh4ChaxOrlN8s0URNMRSyPLqgbv2A0lloDqjkx6WwZlGYgpflMQzddIAzn9sYRK1Ez oh7a8XzVlsja6zzs33AwXOTZrbVzLDjwv+8XYnlpxucc2nII0zKKXCwX5kX2dMlinpxJ 2TOsgIaPhzSsyn9QNCfHH3XO4dQi25FzqQu6llpataebOZQIIFby8fEjyarcjGvYHnkk iKfA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=N5+6W52oNuwX1MYAtGC48SwvfaoTk37ZkQUM1d9OjUY=; b=VLl5fNWdODo0QX/oc0bauwHNIgutBHni+U+yFvPdfdDlpuSpdsDvd2MsVovJ12oXXn jVj+QHXamGt0qd88fDIf0bNRzbNSsKJwH/1E+uB2DZb/cW3ZxSA0NZb/LdyzL9eOqXNg J9JIXAyOiiV2SNKCKruigNbjLUdnOJxniRyjWlWE6qAcTjhnR5gRNJLBWj4LoezQ4bWm OyFaFFl2yhRVDBBbjG0Sr/vPhMwQOUUarO667GHYWSVXccTRm8HGmewQnjx/+Crm2Hn+ o6siRYUl0LW3Jwvd6/gezgUjXAJ4j70UUItBabvJiIssV+EWGgXww8gBiPDy3BNznSaG pavA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Nqy2lxy2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y124-20020a636482000000b0042bb607f75esi17808018pgb.284.2022.10.19.07.05.53; Wed, 19 Oct 2022 07:06:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=@linuxfoundation.org header.s=korg header.b=Nqy2lxy2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231572AbiJSNcQ (ORCPT + 99 others); Wed, 19 Oct 2022 09:32:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39476 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231881AbiJSNbr (ORCPT ); Wed, 19 Oct 2022 09:31:47 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 95EC21DCCE7; Wed, 19 Oct 2022 06:18:58 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id C96F6617FE; Wed, 19 Oct 2022 08:52:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DDB36C433D6; Wed, 19 Oct 2022 08:52:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666169555; bh=m67spaPwy6G0W7GWUEBmAnkxzPcnmPiPMNmD2VWVvX4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Nqy2lxy2ibtpCWSOtTGgTbyF/dQ6n90xaeTQtj46m0+z7aITG2BgPt3xshD3ZZF9Q UtpfmfzVl/JG5HDdnmVXETRKA1UOL+MMLW7eYw4aN2OayP5ifjr23rz0gjsXfVurIM cBACfyA/jnDKI0BW/wVlWVVCNlKGgNtjpnHdL/e4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Luiz Augusto von Dentz , David Beinder , Sasha Levin Subject: [PATCH 6.0 321/862] Bluetooth: hci_core: Fix not handling link timeouts propertly Date: Wed, 19 Oct 2022 10:26:48 +0200 Message-Id: <20221019083304.209428283@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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-kernel@vger.kernel.org From: Luiz Augusto von Dentz [ Upstream commit 116523c8fac05d1d26f748fee7919a4ec5df67ea ] 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 Signed-off-by: Sasha Levin --- 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 9873d2e67988..e6be18eb7fe6 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -3478,15 +3478,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 */ @@ -3544,7 +3556,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))) { @@ -3587,8 +3599,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) @@ -3596,6 +3606,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; @@ -3669,7 +3681,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))) { -- 2.35.1