From patchwork Mon Oct 24 11:28:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 10201 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp642130wru; Mon, 24 Oct 2022 13:37:30 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7XD3ahTLG8bTzbGv8KigmZKvZ5x7eSX5HDioT7n6RkjGxFmTtK+sA9E60169j/GPis6lcj X-Received: by 2002:a62:1a97:0:b0:562:5587:12d6 with SMTP id a145-20020a621a97000000b00562558712d6mr34711263pfa.37.1666643849858; Mon, 24 Oct 2022 13:37:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666643849; cv=none; d=google.com; s=arc-20160816; b=EIGl15SUYstKPOZSO+lEgwFfHDYbjypVlYoGLSrisBLYsMNssGbWBHyoeR1DhwhTrr 0UKO0NqLWMmO8Eg3f4EnOtfaLNQTX5ZDUKZM+ILYUAntqWKDLDQ6NkguRZ75Fh9Igtzz LW6Hc0dw8De9J6sLvxMj/ge4XlYDcSDV8/z/OpDL7OMyb5gsDS8SgfBMWugU6U3ksxa+ ekcseXleUjwOByC+SgOrGd1PwSWg33Xp2pyIdTFUdMpxKpl2azvy47wYCL9MRm9DyJ2P yYOAdTyTuzWffjTnDYjBzIBj9vPaJ29rNI/dd8S2RnP1A5ZlTIfs7KA67zeKDYns4vL5 92Tg== 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=lwUNfuga4vpGf5pXuSJcw6bGV6PJakQ4bqn2f4AtjMA=; b=yJl5F/1JF8T6ZX/jos7DgwjEyeJ+cuZO26VQLpZ/NcADRLQ5JTE1v0Z6eZuqs+CF3b fHpsw7hMdn18JUsUPSo9EtOq80QUbRnxKyhUZ8wr8/ecea4JXlZNYILuApFvTM+jIEAV WPyfQFPzYw/8NhaVcnPvdionAuLhsnlBfdjON7611RMWk9Ikbs6VlIDBOiHwrkryq2vH a6dbILA0TBgMLYibPSXh/RunmLkh3lephXsqR9yH5BKVVa+0L9QnydfUTnTh7cgx6W49 osyaKNEcXpz/U8nhgiJdDTGdJVrpgeC+cgtjDztXp/woO/fhCq6CRHVF+kN4gbz9ZDcA oiBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=trSaFnye; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lk3-20020a17090b33c300b00212e70e2c25si11131784pjb.165.2022.10.24.13.37.17; Mon, 24 Oct 2022 13:37:29 -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=trSaFnye; 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 S231852AbiJXUbP (ORCPT + 99 others); Mon, 24 Oct 2022 16:31:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230397AbiJXUal (ORCPT ); Mon, 24 Oct 2022 16:30:41 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A2862E9EF; Mon, 24 Oct 2022 11:42:36 -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 sin.source.kernel.org (Postfix) with ESMTPS id 9611BCE13C2; Mon, 24 Oct 2022 12:21:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 73335C433C1; Mon, 24 Oct 2022 12:21:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666614084; bh=0DyZJeX3T0yjziilvQrjXReFQ/OlX5VV9uJGfDLijM0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=trSaFnyeLGiykql2/xuBtlAJ/zYL1B+GYv1DD6ay0nFjegGhohqrMkWV7kCk3oHlT WgJnL4BMGmGUyliZps88FZE9qiPnkD1CzX3pwMtdcUr5iU8cr3v9XoUV7LWxzp7Dv0 bWkFZIoH5IZz21guT2Xqjb9rWLlmtujs8dffsneg= 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 5.10 127/390] Bluetooth: hci_core: Fix not handling link timeouts propertly Date: Mon, 24 Oct 2022 13:28:44 +0200 Message-Id: <20221024113028.068869433@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113022.510008560@linuxfoundation.org> References: <20221024113022.510008560@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.6 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747602741697449421?= X-GMAIL-MSGID: =?utf-8?q?1747602741697449421?= 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 2cb0cf035476..866eb22432de 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -4482,15 +4482,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 */ @@ -4548,7 +4560,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))) { @@ -4591,8 +4603,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) @@ -4600,6 +4610,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; @@ -4673,7 +4685,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))) {