Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp1566624rwb; Wed, 26 Jul 2023 14:52:29 -0700 (PDT) X-Google-Smtp-Source: APBJJlFGtvR6car0ehDoiiSRIXhw/aIl8h+B/VoVxu+z5jU+F7JDvoQu/8sBoWlObalgenGxKCa+ X-Received: by 2002:a05:6a20:914d:b0:135:4527:efcc with SMTP id x13-20020a056a20914d00b001354527efccmr3159674pzc.46.1690408348985; Wed, 26 Jul 2023 14:52:28 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1690408348; cv=pass; d=google.com; s=arc-20160816; b=f8nmGvaNmz79qyuXq/H8WGSM6S51YjjGX6tczhxEIc4Ue/tWN2e/v3dhLodx6SKEC2 0L1oqG1p2qBT/Z/O5yflLyck6ZX5UxV1bsmOtI0sOElEy6zQOejpAcVEbL1E0qg35gwR sxpUZyBYgGPysKnAa7lvfqP0YW8TOp326KHVp+EL7JMnk4QCgnn1UTuN2TYMImAUlJYE zGxX4+eI4nEP/ffA9JDb+iAJFmHKuRcJGewHkr66xOaZiIevTfvjscUw1ZZ2/XREb9Ni SUQcIL8NFrcW73ZixQdLvIOjuRqj/0ovGkN+9xCbpm4H/fvToO/V8pKAtxbclFyqXGaQ F4iw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=cStnu3uRKmISA/8+0oThhWnWzX9S6j2dgsNQupODTH0=; fh=raBgKoRsHCwQLc6ReOhmOoEQ+DtSaNc74fugaHBwryI=; b=j/+g5H/ID2WvYHg+7paFRryjqfKdLL68LLbPS35YfyfKouDv7yw0BpaX0q5JIjzcJ9 htknL8Q6fVoW14T+aC6gkZiUT/kgzyo12Ct5Vp+VZAhCuf3GixFc4/dzs0ZpunFypuT9 uMVJ9XUq5U4SEGZolrNrdaBOdl6ezGHOq310RndtiiwvMFWd5Tg+3aUdU1eH9K14CT35 o0zXaPcVD/ZFpK6qER8qIa4SfJT1mMIPoz2AG4vGdKq32NHB/jgUFv59E190L9ADAOdi tTt9RzGUBcwFnzZCkFr+WPq6NUhZ/NY7kGIAi2DV9JCmLbT3TzqAtd8vReaJ9I0xUrQD gPiQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@iki.fi header.s=meesny header.b=Cxs1Ml+x; arc=pass (i=1); spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y19-20020aa78053000000b00686bc5cd56fsi131620pfm.29.2023.07.26.14.52.12; Wed, 26 Jul 2023 14:52:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-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=@iki.fi header.s=meesny header.b=Cxs1Ml+x; arc=pass (i=1); spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231547AbjGZV0F (ORCPT + 99 others); Wed, 26 Jul 2023 17:26:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45324 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231500AbjGZV0C (ORCPT ); Wed, 26 Jul 2023 17:26:02 -0400 Received: from meesny.iki.fi (meesny.iki.fi [195.140.195.201]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EFCE5269E for ; Wed, 26 Jul 2023 14:25:47 -0700 (PDT) Received: from monolith.lan (91-152-120-101.elisa-laajakaista.fi [91.152.120.101]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: pav) by meesny.iki.fi (Postfix) with ESMTPSA id 4RB6Q11Gkgzyhc; Thu, 27 Jul 2023 00:25:45 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=meesny; t=1690406745; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cStnu3uRKmISA/8+0oThhWnWzX9S6j2dgsNQupODTH0=; b=Cxs1Ml+x+UbjKtpPG1TkGExgmubCzwPcQKRcf3WPnunzmY3WpEqfvN3OoRP2w70LoKbXxF UfjX3/WFK4CFk4EgUZcu0eS4p/5jqkArhgAS/hqCHrF4MJPNA6sIqLS4HetccrnatQ/HMC mOgVtv7aUg5fU0gV8BnE3V7ywZZuvWU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=meesny; t=1690406745; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cStnu3uRKmISA/8+0oThhWnWzX9S6j2dgsNQupODTH0=; b=q5ctp2/J7By+6X1Jp0uAins5jCxv7WSSHnWdQcHAhZtHElqaHy1nKC2bPnJ20ONY/T1OWn zUGyQqSFhVJWNU2Bq/1zq0afBNMwvhXI2fLiyl9lUKzdCoVT4urFSIwXpC3498x1BHH6oH vfdc/jzM2fADAv8DhXsh4MfS+FJ1WZo= ARC-Authentication-Results: i=1; ORIGINATING; auth=pass smtp.auth=pav smtp.mailfrom=pav@iki.fi ARC-Seal: i=1; s=meesny; d=iki.fi; t=1690406745; a=rsa-sha256; cv=none; b=EosX0/9lrf+3m2IgynUDxBnIMNKHULhWhBGI+3ISeEHLzsQJsGYvtH2/emagO2hYvLvxfX qq8SM1BoOCK0hjWPpPQP5I5jDdP1vfjNiikl/SyuK6EIzjHRpirNHQqkI3mh/wLzgpwuxq YWHyewmJc1AugRBIZ+QdP8HNj+eH2Yg= From: Pauli Virtanen To: linux-bluetooth@vger.kernel.org Cc: Pauli Virtanen Subject: [PATCH RFC 1/6] Bluetooth: hci_conn: hci_conn_cleanup is not needed, combine with del Date: Thu, 27 Jul 2023 00:25:21 +0300 Message-ID: <30c5e6a7dc62ce209a2b9916fe8b2579d1b27756.1690399379.git.pav@iki.fi> X-Mailer: git-send-email 2.41.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE 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-bluetooth@vger.kernel.org hci_conn_cleanup is no longer needed, so move the code back to hci_conn_del to keep the hci_conn teardown in a single place. This undoes commit b958f9a3e877 ("Bluetooth: Fix reference counting for LE-scan based connections"), but keeps the current order of cleanup operations. Signed-off-by: Pauli Virtanen --- net/bluetooth/hci_conn.c | 78 +++++++++++++++++----------------------- 1 file changed, 33 insertions(+), 45 deletions(-) diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c index cccc2b8b60a8..a71a54a5c8d8 100644 --- a/net/bluetooth/hci_conn.c +++ b/net/bluetooth/hci_conn.c @@ -139,45 +139,6 @@ static void hci_connect_le_scan_cleanup(struct hci_conn *conn, u8 status) hci_update_passive_scan(hdev); } -static void hci_conn_cleanup(struct hci_conn *conn) -{ - struct hci_dev *hdev = conn->hdev; - - if (test_bit(HCI_CONN_PARAM_REMOVAL_PEND, &conn->flags)) - hci_conn_params_del(conn->hdev, &conn->dst, conn->dst_type); - - if (test_and_clear_bit(HCI_CONN_FLUSH_KEY, &conn->flags)) - hci_remove_link_key(hdev, &conn->dst); - - hci_chan_list_flush(conn); - - hci_conn_hash_del(hdev, conn); - - if (conn->cleanup) - conn->cleanup(conn); - - if (conn->type == SCO_LINK || conn->type == ESCO_LINK) { - switch (conn->setting & SCO_AIRMODE_MASK) { - case SCO_AIRMODE_CVSD: - case SCO_AIRMODE_TRANSP: - if (hdev->notify) - hdev->notify(hdev, HCI_NOTIFY_DISABLE_SCO); - break; - } - } else { - if (hdev->notify) - hdev->notify(hdev, HCI_NOTIFY_CONN_DEL); - } - - hci_conn_del_sysfs(conn); - - debugfs_remove_recursive(conn->debugfs); - - hci_dev_put(hdev); - - hci_conn_put(conn); -} - static void hci_acl_create_connection(struct hci_conn *conn) { struct hci_dev *hdev = conn->hdev; @@ -1127,12 +1088,39 @@ void hci_conn_del(struct hci_conn *conn) skb_queue_purge(&conn->data_q); - /* Remove the connection from the list and cleanup its remaining - * state. This is a separate function since for some cases like - * BT_CONNECT_SCAN we *only* want the cleanup part without the - * rest of hci_conn_del. - */ - hci_conn_cleanup(conn); + if (test_bit(HCI_CONN_PARAM_REMOVAL_PEND, &conn->flags)) + hci_conn_params_del(conn->hdev, &conn->dst, conn->dst_type); + + if (test_and_clear_bit(HCI_CONN_FLUSH_KEY, &conn->flags)) + hci_remove_link_key(hdev, &conn->dst); + + hci_chan_list_flush(conn); + + hci_conn_hash_del(hdev, conn); + + if (conn->cleanup) + conn->cleanup(conn); + + if (conn->type == SCO_LINK || conn->type == ESCO_LINK) { + switch (conn->setting & SCO_AIRMODE_MASK) { + case SCO_AIRMODE_CVSD: + case SCO_AIRMODE_TRANSP: + if (hdev->notify) + hdev->notify(hdev, HCI_NOTIFY_DISABLE_SCO); + break; + } + } else { + if (hdev->notify) + hdev->notify(hdev, HCI_NOTIFY_CONN_DEL); + } + + hci_conn_del_sysfs(conn); + + debugfs_remove_recursive(conn->debugfs); + + hci_dev_put(hdev); + + hci_conn_put(conn); } struct hci_dev *hci_get_route(bdaddr_t *dst, bdaddr_t *src, uint8_t src_type) -- 2.41.0