From patchwork Fri Nov 8 16:07:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iulia Tanasescu X-Patchwork-Id: 841795 Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02on2083.outbound.protection.outlook.com [40.107.241.83]) (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 C85537EF09 for ; Fri, 8 Nov 2024 16:07:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.241.83 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731082058; cv=fail; b=C6uuziLT0B0SiFKwDEMvrIdAcG/sT26XW8vmmQFBdHGKWEy9GZKTObN8zo/ui6N/zxl1Y1gVn/U29uWJgVOyfYU860wdeFqnbKwslVMJpjYCXGNfGZQSCkyzHj+5kCNe9LbHlK0AlTVKlhbiVtlF0y/0gJ0GK7G9v5Yb0l/zHzU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731082058; c=relaxed/simple; bh=zQRZHl+RtcEZ/mWoXWOVPcsX3xFfzNZf3BnqQ9P0gY0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=JvOod4AHCA5vak4+BRmYvFwuU8NKFs9tL5rbjQC3WXpZH36HMci0CM/TSAaDOYeAiDB72h9g1zIxLl99kBNaNpicOmCKhFdY9+m2yambPTz3UBM9iqj3th9klCYmMobBmX2PxRmU4RaiI6/6iiWI0rZHz9bb/U+W6XhhYCp114Q= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=gu1r7GeR; arc=fail smtp.client-ip=40.107.241.83 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="gu1r7GeR" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=VXyT2JDJGPWJEWy0Vuv6X9BhOjqkLMLR6ie3S8Vk7qW9NTu3akRyv+PweJk39/wtWWYvnlbO/Vcs8mmk+ZXNq2hC65wQvdsvQFJN5FO44XJvaTkT0WTWIWwsxlLkFIzVVgnvGMKsoOiuCY7QfaBQDBu4/qapoXAPBi78xyKsJBhA83lj63lMfG+bwvDOiQYpFOjGzemQGkDRiDjDGyJ8y6QczegcOGWwmqfxubRs2/h2vZVsuQ3ROTbKGcfRSsfsC8IGxme9KsecuEYqPTNnjR9TBANOSbQG90xllLBVvuukoW7NrElWZOjiaUV939dy70hvbV/YON8s3Dsvcs7URw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=TkuVf6uELHaIs/Edv8jGRVvRioIzLj2z+exUYC01o2g=; b=yNJ26lybZUnl6jGADQqmEIYwyZUB8xyyZ9pTPpOGu5Do4LIqjwc/eyQAcm288QlCnHKQthX+ziIGyEUS5cW3iK49iRfRQi4cCZh7rMvFaSlDItSotNVwMIsjSxDUvG2+CzZ+kBgU7e0i/Sit9sVuH5Mh7Xmiyv0FL/TLWRaipdSjj9VhPeJPa/gBCfAMS/ehKSSCHA7vBs5NwYLVrqFr0U+tQ0jTnXiz0zERlAJnZPmTcpiXXJbK8FfmN//p6BdBUJAMW7btaC40RHNDxGXeOaE9e/Zi3pE28UDh75xmZIWC66kVMc6gD0NiikktmLYpNnVlfm2L22+Axj6G+YmZMw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=TkuVf6uELHaIs/Edv8jGRVvRioIzLj2z+exUYC01o2g=; b=gu1r7GeR8gvvOg6GLT1AQ+6fEYmI6rXqdyJYD8wgyNRyOX0H16E8IfNxNyD5Eb1sh91f4wTm2/aU0D/2TqlwyJ8eh/05nXSKRs4oOGjdXL0LJV4jSZsh4nszHB4hEZ7W9dmzZKttYCmsrUrky8mrB55hQxPwHm6z1z0hr0ea8qA8xnVlJtGizEOY5/gh+eE2PRo6Ih5DNInRUnPHFu31h2QARgyAOddZLjLBIWW8dSN2PDplDIsPeySM6+NTXKi+sSMyhmCUbpD1o6DEH5xYYbE91SdClknr8GJhWTvf4tOQyzdTweqIWeK9qe18XiQtwvUAcUMvAZaMg52KE1cj5Q== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) by VI1PR04MB6829.eurprd04.prod.outlook.com (2603:10a6:803:13b::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.21; Fri, 8 Nov 2024 16:07:33 +0000 Received: from AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654]) by AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654%4]) with mapi id 15.20.8137.019; Fri, 8 Nov 2024 16:07:33 +0000 From: Iulia Tanasescu To: linux-bluetooth@vger.kernel.org Cc: claudia.rosu@nxp.com, mihai-octavian.urzica@nxp.com, andrei.istodorescu@nxp.com, luiz.dentz@gmail.com, Iulia Tanasescu Subject: [PATCH 1/2] Bluetooth: hci_conn: Remove alloc from critical section Date: Fri, 8 Nov 2024 18:07:21 +0200 Message-ID: <20241108160723.3399-2-iulia.tanasescu@nxp.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241108160723.3399-1-iulia.tanasescu@nxp.com> References: <20241108160723.3399-1-iulia.tanasescu@nxp.com> X-ClientProxiedBy: VI1PR04CA0074.eurprd04.prod.outlook.com (2603:10a6:802:2::45) To AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR04MB8898:EE_|VI1PR04MB6829:EE_ X-MS-Office365-Filtering-Correlation-Id: 6f61e465-2651-4344-0434-08dd000f7497 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014; X-Microsoft-Antispam-Message-Info: B0Y+LCRP0LQE1OfI03G2f8H8EklC43PtICfgKv1s896KVyv4494/k8cPGFiNyrdFcQ5kFZ7NUyA3sGPB34A5nTkcJfK/04XzWhRWdXkkG0NKVo6eAdwj+SNXOag+fdYbZ3qcNezetM0+h+2lbhLqfXDI1f/JCDC9wqWgNnc5DO5pYT1KLiDYBqOINP04BucOGwyFuKGxz9BFDfB63wIrVC2+dbyusSmH0cBoUDFybUqyVdZs5e6f9GcLaejIYTdq3L/vWsd1Mg5iv5PsVRPB+GAJJ6cLGJ4o99slejpznG4VHhPudeVacrBdbDT+Kvbs+ag2Sx+ZXZ6JSkIPMm5uDhAk+4VCffN07JGvs/LPLh5rT1uoJp+Xf58WMCfO44J6OQFF7SwSX3ufVe+y3mQme7zEau1vW9Zr91aomw4DbGHGI4hguc446+AyQOpDpuIIjziKovgFNBpg3BfW7Z4YE1M5jhV7pU1A5f2DQV0OPPJfNpFcEXQVw3CtPL8uP3ST9J0vvPUfisoJmT4EAya+IaYFQxt9DexL3v1yBPTpIDBfgp0xXRMp8kVpsJ837hJ5JlglOkQH3lD76VDd59l6YUBO9vmzfS9rRjkEkgNYwfCk1/5ATpdOTiqkViVzPojfIuTQapVt5e7r41dpovDKeyne16XJCSf4divqk5xq31LUbGt75GH5rLS5MEy+qu/Cu4VPPLYaTQB9tuXshR15okZR9fJtyscvBGJ8bF+VNpZXIQFF6LbntPLe1XC4WL839fxP7/QsHHXIJI/QmBLTHn+ar2QqYWzThuOqW7bbE/yxhLMU8MjuK8/iq9GTDabOc2de3r980dZxtCTy9Vk76/x3fA/rIvEfMonJxk0Xl1qS+q0NaYL07ts25Oej5gmXFDYL3vg9LX5g531gPgyqcA7WWqB6rOzDZSt/o+C3yPhVJGP6NnP8/2TDqddFrZdy+ylDHu2CUyue5i5b9G16JwEpUX2b0Mh/4iIHKtiPAoS50LZhoLRCFuuAvKtiTUsub1JWOxPOAZsJIU3Glyo6p4Qu/vC2vNEIN1PoaPaXV28jiR3rEtxL+y0qjmzzaXcHjurWwU6uYSRmXmG0+Lehy2aUPYIs3erC0nbk+eN8W7jvbHIcf6mSHYLKQz6oUUU71RI5oT4HASmduk9OalipYQ0azSfDZQjHPaza6YbSKxN8ANVbaL1ahtsskdYbDOZ1TplWRJt+3J/l7C21eOGdE/JDJNtsRIxIvlXlk/9XselIZl9qRqF+iW3xfWgA5uPqM86Vv/tKztxFzz6QRUNWexZuYBqFdYKS6mAeXJy/l8eVoy7oaZpU4LobwQxlVQhk X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR04MB8898.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(1800799024)(366016)(376014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-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WKSIYDHtAEgnANm5CaDac5Wfd/xv+glKZjRB9Nxdy+3EOdFYuqg/eVKpQ0JthfKsiUqczKw4/0J9u80EqPHq6tTADee1Qip0w8Vy5FRNuUTPAxsgiL4RgSmQiDy/frQ9Q3jc6EWwU+gK9BU0dfwikie29n1d4hmjw7xPOPEV5nPn52X+hCWR/V2IhkNbVVbI6lZS1oqj8Ds54W8Gc5CBCcptODV3UMTDCVVm7wS7nQy7OQrVe/J9u5VnlnhEYBvEnaOo7c2uEzAPv+867nZbfgXv33yBIu7OY0jrI55bt/JY5g5TiRXY7gPGbiN9g0gWKJYUTFHccxrh1PvJ3OWd8JMydxAxfW8yPEKOods7u0Y8whdsHvHzNBQYWZaYvJosUIVdC11Y5bKGAu6Qmh3Zf1mnLF1cm3lnjcP8jGo6tniKmiIZKxmI0ONYIoH+Z39AjiBRd8kv16m3l6YzMUQ2lRn7vxuIzdmaD8SzdTg/8/rwqbnlwjj6fNMCe6LHkFWjkpxiO0B6Lb/27aOkcS6NdGqmgZzIVGbskOdCUvCKMhewoVdjJbTsEuw8K6lcmxaw== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6f61e465-2651-4344-0434-08dd000f7497 X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB8898.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Nov 2024 16:07:33.7927 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: RzzMHh53x9GQu+6/YCkfau+2DFGQOvGSL/w04mm03+TxKB+l3MSu3EE2fxH+A96w6ITJgApBHKqbFMFX3kNBmw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB6829 This removes the kzalloc memory allocation inside critical section in create_pa_sync, fixing the following message that appears when the kernel is compiled with CONFIG_DEBUG_ATOMIC_SLEEP enabled: BUG: sleeping function called from invalid context at include/linux/sched/mm.h:321 Signed-off-by: Iulia Tanasescu --- net/bluetooth/hci_conn.c | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c index e996e9763666..b5b78d469d54 100644 --- a/net/bluetooth/hci_conn.c +++ b/net/bluetooth/hci_conn.c @@ -2079,7 +2079,7 @@ static bool hci_conn_check_create_pa_sync(struct hci_conn *conn) static int create_pa_sync(struct hci_dev *hdev, void *data) { - struct hci_cp_le_pa_create_sync *cp = NULL; + struct hci_cp_le_pa_create_sync cp = {0}; struct hci_conn *conn; int err = 0; @@ -2108,19 +2108,13 @@ static int create_pa_sync(struct hci_dev *hdev, void *data) if (hci_conn_check_create_pa_sync(conn)) { struct bt_iso_qos *qos = &conn->iso_qos; - cp = kzalloc(sizeof(*cp), GFP_KERNEL); - if (!cp) { - err = -ENOMEM; - goto unlock; - } - - cp->options = qos->bcast.options; - cp->sid = conn->sid; - cp->addr_type = conn->dst_type; - bacpy(&cp->addr, &conn->dst); - cp->skip = cpu_to_le16(qos->bcast.skip); - cp->sync_timeout = cpu_to_le16(qos->bcast.sync_timeout); - cp->sync_cte_type = qos->bcast.sync_cte_type; + cp.options = qos->bcast.options; + cp.sid = conn->sid; + cp.addr_type = conn->dst_type; + bacpy(&cp.addr, &conn->dst); + cp.skip = cpu_to_le16(qos->bcast.skip); + cp.sync_timeout = cpu_to_le16(qos->bcast.sync_timeout); + cp.sync_cte_type = qos->bcast.sync_cte_type; break; } @@ -2131,17 +2125,15 @@ static int create_pa_sync(struct hci_dev *hdev, void *data) hci_dev_unlock(hdev); - if (cp) { + if (bacmp(&cp.addr, BDADDR_ANY)) { hci_dev_set_flag(hdev, HCI_PA_SYNC); set_bit(HCI_CONN_CREATE_PA_SYNC, &conn->flags); err = __hci_cmd_sync_status(hdev, HCI_OP_LE_PA_CREATE_SYNC, - sizeof(*cp), cp, HCI_CMD_TIMEOUT); + sizeof(cp), &cp, HCI_CMD_TIMEOUT); if (!err) err = hci_update_passive_scan_sync(hdev); - kfree(cp); - if (err) { hci_dev_clear_flag(hdev, HCI_PA_SYNC); clear_bit(HCI_CONN_CREATE_PA_SYNC, &conn->flags); From patchwork Fri Nov 8 16:07:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iulia Tanasescu X-Patchwork-Id: 842393 Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02on2083.outbound.protection.outlook.com [40.107.241.83]) (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 31092139D0B for ; Fri, 8 Nov 2024 16:07:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.241.83 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731082061; cv=fail; b=YdOq0dBb7Xjth+oXUCqdRl56MmtKv/oSoAjsnBM+DOTiAysvgpKEDPdI4KLeiuKAs565tqImbzwP/HVQcmj9sUV50oi7XyEdNm+23w7QVlAhOackeVvOfQ6MfoPoQrEn25wF/XAcDsVs1KqRbMONAt9S1owtU+CKTFQ2BRnCSfU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731082061; c=relaxed/simple; bh=cUyZWJN4X/RJSVfw1qYZWBU/iQbW1+ZqKx8J9MdzERo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=ovIjryqC/qwBx8DY5X3zhTorGnvtJLGq7TYD0N5Na/iEDqA/5Kdu6qTd6KRzcyLRD5DRaGr9SxjDlhChb1tLKSfoZAT9V63ppR1qwoHl+IAUxVOZWe+IQXJVs7oM0s6GvhEaSFt1lS46tStR6cQkRL6U+txW72SaMAZe9Bz8qz0= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=Q9ZmfTFv; arc=fail smtp.client-ip=40.107.241.83 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="Q9ZmfTFv" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=XM38v7APt+lqeGyZsAN/hRzornNSXRt69YY3boJFYy8fNrxYiSPBzAsYLyYte4pYcgJNFOflZAGqmyahIkypSPw6qKXbc2aHuc5yoqyP+0bMARDbrIKL/1UWq/1Pui3B3ZNprpwnTGNm/S9zPmSf/cifn+Lnk7AuV+NrVSN5/7SvfH5HbqiDbcJoAkYMnr9bWoKgn/QfDr02zOA3OkW+95GuJvoFlZyB+GLTmufbdt/nl9JZvOQ2Jlc8sJvJk1LX9N6077xA3E1F9bRRxTrt61DnW9cae3G1iKzkHpR5tokSR+8wwHhp1fe+oIjjrMMaKu54qn0gkV2G5l+AL4/EhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=7ffrsM3VWLv5zJis/UXp1KKN3h6RPRl+BOVjhcltSwM=; b=SS/AQU7hBrWbT9rfCvkOBZu/SNocINu6Q6iSji20RjQcf/OehAvTd6oONDwWVhiT5XdUFNJLwEaSUWrthNQFIizDJcwh1LnTQgaP/niYi3xOyTX1ZRaIJYmXkWOmk50bh6Vbu5iFzH7jaIAng+/p+zmAAZDdg1WYOvmKjEDMP5X1J+pin6sIUSrJSxiE13uf5fpwh08d7cWaBYLm4MrCtiqeABE+igtw9XGTDq8DWNBmp75rUaqTvWrmvSRUdoEiH8XQ4t1GsZp4dsXc8pAYT64L+W4FtRML8preyNObQFFHz2kPKV9VXkuKQyHfgjOX/0Z6MeD6epmKEeIOEAkj9g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=7ffrsM3VWLv5zJis/UXp1KKN3h6RPRl+BOVjhcltSwM=; b=Q9ZmfTFvC+MGHAtoZZbSHJ8jjJgKM47+77RDYCjeZfpVmYpp6uURPukjQhkZE/yGFqNFk52ENseKHx8x6SD6gqeJptHeGL6n/rJzAtGZdydarO1c+v/XLRsju/kmUk3hMD5nKRHEC49/Fb+eGeTTK0UlvZom9zQr29ptqKbwLI1vm/7paOjtSLaO+G/OKY1LdrqAkDbkD9kvpi9WiFx1zdBmdUCUX16daf7RIbW/XdAXeGhbTTVvs+jPernH6Has3nGHLc4sRA4SqlDAkw+l2EZZ5KmMOIa78R0piAQnQCMTWoVzynJanl9gDoY39F6BrVnLQFIc5VKrn5ksTzgtkA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) by VI1PR04MB6829.eurprd04.prod.outlook.com (2603:10a6:803:13b::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.21; Fri, 8 Nov 2024 16:07:36 +0000 Received: from AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654]) by AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654%4]) with mapi id 15.20.8137.019; Fri, 8 Nov 2024 16:07:36 +0000 From: Iulia Tanasescu To: linux-bluetooth@vger.kernel.org Cc: claudia.rosu@nxp.com, mihai-octavian.urzica@nxp.com, andrei.istodorescu@nxp.com, luiz.dentz@gmail.com, Iulia Tanasescu Subject: [PATCH 2/2] Bluetooth: ISO: Send BIG Create Sync via hci_sync Date: Fri, 8 Nov 2024 18:07:22 +0200 Message-ID: <20241108160723.3399-3-iulia.tanasescu@nxp.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241108160723.3399-1-iulia.tanasescu@nxp.com> References: <20241108160723.3399-1-iulia.tanasescu@nxp.com> X-ClientProxiedBy: VI1PR03CA0045.eurprd03.prod.outlook.com (2603:10a6:803:50::16) To AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR04MB8898:EE_|VI1PR04MB6829:EE_ X-MS-Office365-Filtering-Correlation-Id: 6fff5602-0d37-41ee-7a9d-08dd000f7648 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014; X-Microsoft-Antispam-Message-Info: h3zxSA1Aa5J/wIZ24hk3CDfIsjPKKmOzKN3IammnQozLAEXPd3YIl7TfOuVIXZ+GYna+e93XyY7vS+Fn8DkPqebjW055XcOQwtGuB/CHbsdVQqSNRfk/h9PPdgWHd9Z7r8JSHf3ySOuYKR8bSXPsojHSSi7mcAFoPua2r8ESAgRKw/jIfmBd2AbrQ49X1TOm7wRkK7H9X1a7VwfeIjMA06y9ASfyE1V/ItepzP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UnQVPphvX59zSnWUVsk6gH2+FFN9wc= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR04MB8898.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(1800799024)(366016)(376014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: UQf/dGvgsz1xtb51QHYidiQqfDnLVLfErnV6RvufWd70i59onVHrwipm0392GC6cK9Kw94nb1MtEIO5vAohVD0SFHszg8u4ccP1kFjz42xjbF1Yf/E8kp+SqJt3VW4pcP8I87WPUvGtNWI53rbvIYLLEJcId5TY3AIRdSzUpC6um/1LIZSg1qeLfKC6mGHdrlumlALzk3f2STMbWxiAWbO0OyzVnqkqqVSBCRS1j6vBau5J/ECvxHnIaB31eM5aD5/Cn9ioBvfQpVNmBPDRgljmy/b0ocUHJNoOqSTG2JXEKTUTFj0OIefZACPrzl15h/29fBY0qy+frNBx3Ty8pQubKC6XTZ0Y/9Wv7+6xFWJT5orDAg/4hhGYyntjeivyF6aDWE/7f5fT9jSMdVnxT437haliXPmL2MSmS1BqA26iNV70PhOvHnZhXxprnrl8w5rek88YVSmcd+P0nK3FkIn3vfw1ViWEsbYbCoRYBFLlPx5VpC+UovOAyWa30yCZD65Eh78EoaqSMKrG5+7b2I92djLqMm3KayWPEhkS+JIAtiTA7qYGUcuUBFxysTXXvSqDRkXBZVgFcrwsW5xSpKiVOE1RVMMzsYQbHP/FPZvOIDgklUt+/P9z0QCNYxRVSiVZN8WLfiv9QSQ4bcwsDr7nAJ5nQaSm4dLFVsuuHsdjoBeYj1wo4Y5ETEXTrxepftIHbSyjVxAOEvAa3t89Iv8WgE90nVxen6DabTmO9FCMTYszsIU0nu80zxITHl6SL8aq26+jHZ83WFpsupthWNm/JHevleBeWHnaeF3TEitUlG8Wabhg90hK/x+WZbvWTTDbD3hR5O7g173SF0QJflYqQmIMRy2EJo5BQvg7zpJA2bAO5hdwnlQzfpwaNkXDKCufdpVPU0F7qcFMvutEmWsHksW/7yt4KsY5DvdOD8r0VP1SJWD/I+c9nck2dPRi30lqqvH6d0p1MYb2wjXxhnpCoRkR7mkzfL/TpKvBH7kSooJICWiBHK95JW1CMRKKX7Hlj1d6CltAoMPSVB8FDouXRZBa+5F9aaTU0cCv5W3q5mWoInZGscrM4p2wZ9PEzR1765/iqBfhvhqXV3eiFkdsaEWWo6iPf2FP1LUvDv8gdJgy65LJ7VNAVkuk0xSAoHKzc+BZc65uRxF1g2u8knD+EYnt55IQJJdF7bzTJ1Z7zJ/V7zoiYr4z/YWTTSMtxWcC4HgiGKvzQ6Rcw2j0s6hRHD5XW1IqG2v9jroBopXk97+44BsvkZ2PBRrFlmiXC7vAqi0uxHHw57MVL+OGjDJxDACdIeIUw/lz78j/CbW3gZEW3Gw8CGyEFfGOxZnFiLPdsX44dlLrxeBNR4hIHjsUGDjxwAipVbsiiDPpobR/mi/X+auxoNpgYMnCFInHe5LCRZ8TM2lbjRbEQG0njI3jn1zX9f4BkODWxdIn4p2sTQjgiNEQ9iSahvSZwKYHlyVLmBsOgZbnEsUz2k+rli4UR2ibbu3RdPOc3tpW78mj6+Ytk+thOxF8k6T6NfzkiCfOhxelXVHthObOVJmjgFEG00qm9asPLv9KiSGx64BGok+SNJ+0pV+gnd1DPwetMMtvaavNGgaug08znw1SNIQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6fff5602-0d37-41ee-7a9d-08dd000f7648 X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB8898.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Nov 2024 16:07:36.6775 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 1WOZhUwXQBiOe6r0Yn7ajPCemrLCpy3IFSnHyOjRb47r/RxmzV/yVWzC7IHYYZ4An4P/Xn2A5Kbq/on1ioWfOQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB6829 Before issuing the LE BIG Create Sync command, an available BIG handle is chosen by iterating through the conn_hash list and finding the first unused value. If a BIG is terminated, the associated hcons are removed from the list and the LE BIG Terminate Sync command is sent via hci_sync queue. However, a new LE BIG Create sync command might be issued via hci_send_cmd, before the previous BIG sync was terminated. This can cause the same BIG handle to be reused and the LE BIG Create Sync to fail with Command Disallowed. < HCI Command: LE Broadcast Isochronous Group Create Sync (0x08|0x006b) BIG Handle: 0x00 BIG Sync Handle: 0x0002 Encryption: Unencrypted (0x00) Broadcast Code[16]: 00000000000000000000000000000000 Maximum Number Subevents: 0x00 Timeout: 20000 ms (0x07d0) Number of BIS: 1 BIS ID: 0x01 > HCI Event: Command Status (0x0f) plen 4 LE Broadcast Isochronous Group Create Sync (0x08|0x006b) ncmd 1 Status: Command Disallowed (0x0c) < HCI Command: LE Broadcast Isochronous Group Terminate Sync (0x08|0x006c) BIG Handle: 0x00 This commit fixes the ordering of the LE BIG Create Sync/LE BIG Terminate Sync commands, to make sure that either the previous BIG sync is terminated before reusing the handle, or that a new handle is chosen for a new sync. Signed-off-by: Iulia Tanasescu --- net/bluetooth/hci_conn.c | 19 ++++++++++++++++++- net/bluetooth/iso.c | 4 ++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c index b5b78d469d54..ba74fac823c5 100644 --- a/net/bluetooth/hci_conn.c +++ b/net/bluetooth/hci_conn.c @@ -2180,11 +2180,20 @@ static bool hci_conn_check_create_big_sync(struct hci_conn *conn) return true; } -int hci_le_big_create_sync_pending(struct hci_dev *hdev) +static void big_create_sync_complete(struct hci_dev *hdev, void *data, int err) +{ + bt_dev_dbg(hdev, ""); + + if (err) + bt_dev_err(hdev, "Unable to create BIG sync: %d", err); +} + +static int big_create_sync(struct hci_dev *hdev, void *data) { DEFINE_FLEX(struct hci_cp_le_big_create_sync, pdu, bis, num_bis, 0x11); struct hci_conn *conn; + hci_dev_lock(hdev); rcu_read_lock(); pdu->num_bis = 0; @@ -2229,6 +2238,7 @@ int hci_le_big_create_sync_pending(struct hci_dev *hdev) unlock: rcu_read_unlock(); + hci_dev_unlock(hdev); if (!pdu->num_bis) return 0; @@ -2237,6 +2247,13 @@ int hci_le_big_create_sync_pending(struct hci_dev *hdev) struct_size(pdu, bis, pdu->num_bis), pdu); } +int hci_le_big_create_sync_pending(struct hci_dev *hdev) +{ + /* Queue big_create_sync */ + return hci_cmd_sync_queue(hdev, big_create_sync, + NULL, big_create_sync_complete); +} + int hci_le_big_create_sync(struct hci_dev *hdev, struct hci_conn *hcon, struct bt_iso_qos *qos, __u16 sync_handle, __u8 num_bis, __u8 bis[]) diff --git a/net/bluetooth/iso.c b/net/bluetooth/iso.c index 9e119da43147..ac1598b1e1b6 100644 --- a/net/bluetooth/iso.c +++ b/net/bluetooth/iso.c @@ -1338,6 +1338,8 @@ static void iso_conn_big_sync(struct sock *sk) if (!hdev) return; + hci_dev_lock(hdev); + if (!test_and_set_bit(BT_SK_BIG_SYNC, &iso_pi(sk)->flags)) { err = hci_le_big_create_sync(hdev, iso_pi(sk)->conn->hcon, &iso_pi(sk)->qos, @@ -1348,6 +1350,8 @@ static void iso_conn_big_sync(struct sock *sk) bt_dev_err(hdev, "hci_le_big_create_sync: %d", err); } + + hci_dev_unlock(hdev); } static int iso_sock_recvmsg(struct socket *sock, struct msghdr *msg,