Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp3880633rwi; Sat, 22 Oct 2022 01:28:02 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6+ttYQGzmbJT/DfjS3iBkyZeAt7dfnlOTZ8+VBH8hOnQhKsNZTW36gNJnaaacGtdSYxXY2 X-Received: by 2002:a17:902:e885:b0:183:dcb7:c4f8 with SMTP id w5-20020a170902e88500b00183dcb7c4f8mr23425547plg.160.1666427282495; Sat, 22 Oct 2022 01:28:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666427282; cv=none; d=google.com; s=arc-20160816; b=dXYo4rm4Rdp/izJIIN9CgFJO7wBS/WoGmBmbwxBJhGx188zqqmkMMotQTfkxy8/QHh LEhznLzoKxs8oR/LmEEIwKDzDf1wqExP8gvL93f3875pH9XQ9Sb48+v9TMhvljR+oeBf bOk22i6CVtPJ+8MoENThqsHKkOOQEqRAK0w30g/iCGDRTAmvD1fCopRZAZenfnW8wJ8g sM4wOez8RM8FM1W1bxidhx2Unt4dybRpiHja0ld9cpn55qddZPSm5IkB252v1J2Ue9uv nPZ1PEunC/xf9BDfg0ga7y8Sn+eYPV6HwKCBQO2QURKa2s9Yup0N+8vCDEdWyqNXWQwT sKdw== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j7-20020aa78dc7000000b005669cd93898si23236270pfr.233.2022.10.22.01.27.50; Sat, 22 Oct 2022 01:28:02 -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 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 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))) { -- 2.35.1