Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp2963294rdb; Tue, 6 Feb 2024 03:11:42 -0800 (PST) X-Google-Smtp-Source: AGHT+IED59LBoLPbpCy1YGAZXQbagiEMpNqNID6dx9U+4D0wBR5nVL6mAzQSkYPOkpwPfFlg7EPF X-Received: by 2002:a05:6808:908:b0:3bf:d26c:196 with SMTP id w8-20020a056808090800b003bfd26c0196mr2487940oih.53.1707217902168; Tue, 06 Feb 2024 03:11:42 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707217902; cv=pass; d=google.com; s=arc-20160816; b=defQ9JMsG1vGoRneZl+t1HeBuzU1rSgGPCSm6g25k2y5LULGcCvJCZPZwgsKzCOEmw r6sQCuAH9UETp/AyQcy86sP574MWdPAqwf25+JFfTzPVlQV5ciAY2Tj9rzek+NKE3GAl 8GPSNRZZYccXjuHbFGiQpR/AlbhqBvH9YhTlNR85eDCvYYfMB7TzlDG3uSQXl2ZjXwja rqo9l5A1tSq6e/uq5VzONjOtko30mnCeufPCmxcIO7Wmc0Xqqpr2PvYyK33Dds0LrB32 48PLt5gz5NDo5yyhK42/HpdWh68+QHpRbWbGV3+ZeqBm8W2ZknuUfDJzizlQ0rpQ0NMg NwTw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=yYJoAhQEIIVDniMp003+7u/Q7Th/v25GQuhVCVR2cbI=; fh=NGqxD8qLY9Hg+f0C4djBgBZ7PFmWmNAqPt8kCbQaiMw=; b=wo5CbvaP8WoiL/S1vRkcz4ATeOmVlmxseFPCwNRbaip4xM8OK/DlCo7ODj0VHfoeXp 01LX7sCAx9HNjJ9MVu0c3jziZPZ6QZSU5QFAa2DFi3Lf/beSNzivVVlTtF02bacX4DCF h61w7u05FwqfiZyRgsYgr/JRii34AD5EucSFPojTwt1V+qwb+oPwenV5uANY1Kukkmu9 4YxGiLs9EMj/JdjOnafQU2Enuu+hohWmGJrDai555FWNZ4MCA+xnCS9zA5wuPzgTghF6 KgHvBelbrqYhbaHNeRxJUUJ/yMOgDZHMu2mC0sRIyoiXHxwThZq+IiA9ZTXN4Q6UoYDy MX4g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=v0yd.nl); spf=pass (google.com: domain of linux-bluetooth+bounces-1627-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-1627-linux.lists.archive=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=1; AJvYcCUqDCvGAN0Irv/NC/sLOHwF5d9jCULwKRiGi+rMVAWhhOn174q7ss6c5WTX1w2kLzyS+QLg/EShNFM5pE+y2142/Do+Wv0zkhXd8jmBkw== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id h18-20020ac87d52000000b0042c2a78d9absi2106008qtb.373.2024.02.06.03.11.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 03:11:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-bluetooth+bounces-1627-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=v0yd.nl); spf=pass (google.com: domain of linux-bluetooth+bounces-1627-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-1627-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id D2B3E1C23DE1 for ; Tue, 6 Feb 2024 11:11:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 980D3130E26; Tue, 6 Feb 2024 11:08:30 +0000 (UTC) X-Original-To: linux-bluetooth@vger.kernel.org Received: from mout-p-201.mailbox.org (mout-p-201.mailbox.org [80.241.56.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EF989130AD3; Tue, 6 Feb 2024 11:08:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=80.241.56.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707217710; cv=none; b=ICBV5RZ6QXaKQK4knTQPbncmlelyAh2Db3h5bjkH3fM0Ix5sPQ7b3zs1nlxbbz42qUdreUxkJoYPPwgA12AISY9xnNRvF8lahIqObEIExbe5Lq4Sub5NwYl907q7GxDCjX95pklAzZTDQH6KnDmPdkQip8QoLXv7sUdLCHTiymE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707217710; c=relaxed/simple; bh=4oIPZpDeoZVGe7GmWnId7XVlTWi57XyHUKaP1aysZog=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=a7HJNr/Ispd95LggADMwyUoSqmhpdKK5RW5ucX2UDvuXinNjx7z5g5pAeBTk9QaUxRU3tHxtQi1vardjdUX6gn5uIDqr+7scXFCQmNT7XelRhldNNj5ukmTGjss6dSU4BuPy2798rqPOkcLUMfWpQfHb4cvJujaKuubYR/IrI9k= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=v0yd.nl; spf=pass smtp.mailfrom=v0yd.nl; arc=none smtp.client-ip=80.241.56.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=v0yd.nl Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=v0yd.nl Received: from smtp1.mailbox.org (smtp1.mailbox.org [10.196.197.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-201.mailbox.org (Postfix) with ESMTPS id 4TTgTg6L9qz9skM; Tue, 6 Feb 2024 12:08:23 +0100 (CET) From: =?UTF-8?q?Jonas=20Dre=C3=9Fler?= To: Marcel Holtmann , Johan Hedberg , Luiz Augusto von Dentz Cc: =?UTF-8?q?Jonas=20Dre=C3=9Fler?= , linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH v4 2/2] Bluetooth: Remove pending ACL connection attempts Date: Tue, 6 Feb 2024 12:08:14 +0100 Message-ID: <20240206110816.74995-3-verdre@v0yd.nl> In-Reply-To: <20240206110816.74995-1-verdre@v0yd.nl> References: <20240206110816.74995-1-verdre@v0yd.nl> Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit With the last commit we moved to using the hci_sync queue for "Create Connection" requests, removing the need for retrying the paging after finished/failed "Create Connection" requests and after the end of inquiries. hci_conn_check_pending() was used to trigger this retry, we can remove it now. Note that we can also remove the special handling for COMMAND_DISALLOWED errors in the completion handler of "Create Connection", because "Create Connection" requests are now always serialized. This is somewhat reverting commit 4c67bc74f016 ("[Bluetooth] Support concurrent connect requests"). With this, the BT_CONNECT2 state of ACL hci_conn objects should now be back to meaning only one thing: That we received a "Connection Request" from another device (see hci_conn_request_evt), but the response to that is going to be deferred. --- include/net/bluetooth/hci_core.h | 1 - net/bluetooth/hci_conn.c | 16 ---------------- net/bluetooth/hci_event.c | 21 ++++----------------- 3 files changed, 4 insertions(+), 34 deletions(-) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 8f8dd91737..34aa9d0290 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -1480,7 +1480,6 @@ struct hci_conn *hci_conn_add_unset(struct hci_dev *hdev, int type, bdaddr_t *dst, u8 role); void hci_conn_del(struct hci_conn *conn); void hci_conn_hash_flush(struct hci_dev *hdev); -void hci_conn_check_pending(struct hci_dev *hdev); struct hci_chan *hci_chan_create(struct hci_conn *conn); void hci_chan_del(struct hci_chan *chan); diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c index 816be7667a..a4beed8587 100644 --- a/net/bluetooth/hci_conn.c +++ b/net/bluetooth/hci_conn.c @@ -2592,22 +2592,6 @@ void hci_conn_hash_flush(struct hci_dev *hdev) } } -/* Check pending connect attempts */ -void hci_conn_check_pending(struct hci_dev *hdev) -{ - struct hci_conn *conn; - - BT_DBG("hdev %s", hdev->name); - - hci_dev_lock(hdev); - - conn = hci_conn_hash_lookup_state(hdev, ACL_LINK, BT_CONNECT2); - if (conn) - hci_acl_create_connection_sync(hdev, conn); - - hci_dev_unlock(hdev); -} - static u32 get_link_mode(struct hci_conn *conn) { u32 link_mode = 0; diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 271c007928..e7887bae33 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -118,8 +118,6 @@ static u8 hci_cc_inquiry_cancel(struct hci_dev *hdev, void *data, hci_discovery_set_state(hdev, DISCOVERY_STOPPED); hci_dev_unlock(hdev); - hci_conn_check_pending(hdev); - return rp->status; } @@ -150,8 +148,6 @@ static u8 hci_cc_exit_periodic_inq(struct hci_dev *hdev, void *data, hci_dev_clear_flag(hdev, HCI_PERIODIC_INQ); - hci_conn_check_pending(hdev); - return rp->status; } @@ -2312,10 +2308,8 @@ static void hci_cs_inquiry(struct hci_dev *hdev, __u8 status) { bt_dev_dbg(hdev, "status 0x%2.2x", status); - if (status) { - hci_conn_check_pending(hdev); + if (status) return; - } if (hci_sent_cmd_data(hdev, HCI_OP_INQUIRY)) set_bit(HCI_INQUIRY, &hdev->flags); @@ -2340,12 +2334,9 @@ static void hci_cs_create_conn(struct hci_dev *hdev, __u8 status) if (status) { if (conn && conn->state == BT_CONNECT) { - if (status != HCI_ERROR_COMMAND_DISALLOWED || conn->attempt > 2) { - conn->state = BT_CLOSED; - hci_connect_cfm(conn, status); - hci_conn_del(conn); - } else - conn->state = BT_CONNECT2; + conn->state = BT_CLOSED; + hci_connect_cfm(conn, status); + hci_conn_del(conn); } } else { if (!conn) { @@ -3035,8 +3026,6 @@ static void hci_inquiry_complete_evt(struct hci_dev *hdev, void *data, bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); - hci_conn_check_pending(hdev); - if (!test_and_clear_bit(HCI_INQUIRY, &hdev->flags)) return; @@ -3258,8 +3247,6 @@ static void hci_conn_complete_evt(struct hci_dev *hdev, void *data, unlock: hci_dev_unlock(hdev); - - hci_conn_check_pending(hdev); } static void hci_reject_conn(struct hci_dev *hdev, bdaddr_t *bdaddr) -- 2.43.0