From patchwork Sat Oct 22 07:22:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 7353 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1095446wrr; Sat, 22 Oct 2022 01:02:42 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7pvGukkmGJRbff562JfdqlL8nhRRbfVeW+Nui8MNtdTWko08P6ceCwHyrMv50jviLTsigL X-Received: by 2002:a17:902:724b:b0:183:16f:fae4 with SMTP id c11-20020a170902724b00b00183016ffae4mr23429713pll.88.1666425762480; Sat, 22 Oct 2022 01:02:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666425762; cv=none; d=google.com; s=arc-20160816; b=ay9DQCNyN+WCvTwxwPEwyVTOx1CDd8wYaoZm56VbW+0Xhb9ZuMJdFr9WZhLhpjTMPB +0PhVVCIK/qgSBf36WtZIuhN1fOB2RHsgt2078chuojua7RKgwkfdvzEeEv4/RZby5pZ 7lvh46rHLJsKf66+hXxN0m6AKt6B/b5jtQY3tABoDgOKOlkAIB5w1vTG2ATaVl9Pajv9 bQrM0exwL0xUWsxyNZF9R3UmLsAH6v4+bJm76+nnJY8viDXBqwWovQ8TO7hIEmVM+wNV QU5aMRHDkptZ+wVOyc6N9zys6HP5yB9LABrBduKpLGFQ4jVXNWTCjFe6AAuwsnr+z+Tq uUiw== 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=okQH43dtBlvxFDpTBd0/FP9nlOSvC/wS9htzS3JAMKE=; b=PLvigzUmhAflwVjxhmSldwF4bkhhioBg5pgEAa+xFiBk47hpK6LayF0Ig3TTD+EoWa 6F7uTjeUIaMv4yGtPw4XhYe5jTN2mCm5DW4TZ9gxr/GuPuI29M3ot3FtBvKCFF/guzZd W4nE914x5ZJLMUX3CO8MUTIfjNZrtFqDfUCz9SZC+hY/w1xujTY6pAzw4uFsCMMp5qDO 8qofv0iVEusmPndXKAQtPh1VsXE96rqFJ4uPVBfEZQLswKM1BJ8TlY8TkFrmN3oxHtq/ i56r96dlQwfbgpn7ct+q1kNqoM2Ddz4+a4paIVRVsZTtDdsAoHC/wuygeddBaJguXUpw 1+cQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=E5VLJuCD; 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 hg3-20020a17090b300300b0020dba9319fcsi8152445pjb.111.2022.10.22.01.02.29; Sat, 22 Oct 2022 01:02:42 -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=E5VLJuCD; 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 S232514AbiJVICG (ORCPT + 99 others); Sat, 22 Oct 2022 04:02:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39698 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232241AbiJVHya (ORCPT ); Sat, 22 Oct 2022 03:54:30 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E75E2951C1; Sat, 22 Oct 2022 00:47:21 -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 ams.source.kernel.org (Postfix) with ESMTPS id 640FEB82DFC; Sat, 22 Oct 2022 07:46:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BDF63C433C1; Sat, 22 Oct 2022 07:46:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666424772; bh=6F9Q7yQOukegTSuI//Wh9z9S+yPVAsGd+7m722dCw2o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=E5VLJuCDXZ3OI8Z06qMYlpz+ubG41fsypkVPmQJee35YiDVrebSi/k58ES9Bsvj+t KkhKy0DpQ+Kn2/Qaabd/BlBAjCgYdevmr8G5behlFC3LmXxCiYyU6yFmHK1qcwOq87 /tSUz0R1cxKiqwgdyN9YUOan+QQzIEFCAek7JOOk= 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.19 271/717] Bluetooth: hci_core: Fix not handling link timeouts propertly Date: Sat, 22 Oct 2022 09:22:30 +0200 Message-Id: <20221022072502.371046546@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221022072415.034382448@linuxfoundation.org> References: <20221022072415.034382448@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.3 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?1747374060165428217?= X-GMAIL-MSGID: =?utf-8?q?1747374060165428217?= 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 48029a390c65..8ecc0a18df76 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -3370,15 +3370,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 */ @@ -3436,7 +3448,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))) { @@ -3479,8 +3491,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) @@ -3488,6 +3498,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; @@ -3561,7 +3573,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))) {