From patchwork Fri Nov 1 08:23:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iulia Tanasescu X-Patchwork-Id: 13858929 Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02on2042.outbound.protection.outlook.com [40.107.247.42]) (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 476AF153BF8 for ; Fri, 1 Nov 2024 08:24:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.247.42 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730449443; cv=fail; b=pf8nooEEri2vNBKOycjQidk0VUYOMurjbDwmaP1or67OTaR3ulhlybxGxlRloJczqiGV7sNTi6fhT3uKOdnVuTUc+prZw/wYa14SR3lvzGyiYGyItOpUGfRr3XNjBSqswqOccCgMtxpVp8aX3CQHezMmOrawau6M9iOgmA8PcDM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730449443; c=relaxed/simple; bh=xdnHcskDSRtF7JGz+wvqYnnhu6RhK87msODMPxvpfdU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=ViCTNw/yicnZSwpkeFTE3atQBtwwMAu6TAuIkCAfc2DLBZtZFF54dLmZ0dLlAsiVDphNDWfMm3rCZ3baigU4NjXlJajDKihSh1/Sk7bE8QlG6Rt9ubMnNqL5rVr16GQpJhwVzp8F2sWn+M2FUsynY12UDhi07Mnpxdh/8k8XQPU= 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=Eqz4OhU6; arc=fail smtp.client-ip=40.107.247.42 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="Eqz4OhU6" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=mrIsmvq75+zJPiCxVNa4X/+5RDy+Q+wE9VTPe+xkq6lhPYKeA0Kx4Dg2HM70JFp7gNmoRe+kf06QJQsd9gtcQ0+7/deIZJhN3QVOK64UsY0LtH5g87q2fLLI4vkegyGP3Z6vWBTUvGLb5816UtRYAuy3n5q9GJve5DxetRPaPPimFeygl34JF43taHmyfpcd6bn3Z4hHkqa+eURSvD9kyxayL9W40n2Egol/E936GSV+cVvHvFWRoPjcgGycMDtnqN05rFHZy2Q6OZc+MYM+uZk2JjDtSbyVNALfxbLlpUc4V42NvUQXS4O5J7bGwdldGduRAwxDGzddFhqrhliOkQ== 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=T06WRNmvqWSSqCfw3nsNb1mw+Md6bEQ4+8ugsc1STpg=; b=bTaqW9I4GXVD3xyhuTKcSfjhfiNt5q4pSsR0acYChVOGWNyYGeF7tulJ1y5229UoM0RLkrhf7V5p+DIFfToHADpy9tCTJ1z39WjzSylYVWBTJIxXdV6EjMG42V/jouRhq4ozLA2aWG6r9psosfoAVDkRJMinz2D4rUSs4Cpb1bLxSPGYCu60gdvqaPc82vhCy9RvYCz3yR2HwI51WvXfwbsOCxNCCNoAe0xMTNJUCrggzk9bSnI+h7FpZVaqKQAUe3/wiu1gvGoKQAQtGPiRR8cQ8o2yxezSHYFszY6CXp9We/kVSuxucR87kgqB5K04LnR4cqg1kdK2LEDhVq87Qw== 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=T06WRNmvqWSSqCfw3nsNb1mw+Md6bEQ4+8ugsc1STpg=; b=Eqz4OhU6dS2jkGRwEhhYkuit6gKEYB7Yharpn5WfLPHI4jfO7jfmo5RdfZSYg6SZYLRzr60mwUS/Qwddi3VpGDmjd85f8CryN9L4bIrvKLMz/LY5Wxxvbizh6sDXikLiNVDWOLUerFfcRdzVVRqduZsESkVaSKSBG06a42oVY90IuGAJBEMXTbRz2e2/tfiPrlI5g4FZ3CzPxZcpDTeje7IDL+dOipDU6fUeirCxv7bAxdgClvvJuNV92JSuqmwFK9uivHF1eTzM7GlK5mXoAgcmIoRHkQ/33n/guRvNhLedmcxb5VtSgMaSNYD2MAKGC9IheEmCK0NWT0kT/ew7pQ== 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 AM8PR04MB7921.eurprd04.prod.outlook.com (2603:10a6:20b:247::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20; Fri, 1 Nov 2024 08:23:58 +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.8093.027; Fri, 1 Nov 2024 08:23:58 +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/4] Bluetooth: ISO: Do not emit LE PA Create Sync if previous is pending Date: Fri, 1 Nov 2024 10:23:36 +0200 Message-ID: <20241101082339.4278-2-iulia.tanasescu@nxp.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241101082339.4278-1-iulia.tanasescu@nxp.com> References: <20241101082339.4278-1-iulia.tanasescu@nxp.com> X-ClientProxiedBy: AS4P189CA0033.EURP189.PROD.OUTLOOK.COM (2603:10a6:20b:5dd::6) 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_|AM8PR04MB7921:EE_ X-MS-Office365-Filtering-Correlation-Id: 3df6dd10-4315-4b14-63f1-08dcfa4e8897 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|52116014|376014|38350700014; X-Microsoft-Antispam-Message-Info: uEzBZfvixDxi6CaoJkFLNGZEFmII75BN/NEs218n3Je9BkYXWNCz3kLMSFfJXfweOUJ2v4WGWbPX7n/0BCtfl//Zgj07uSb6YaYKsuL9852/sZQ3xfDLwcfQ911nYXBo3aC5ysH0EZqbEqjZLCTudzHOllSRW6cPq5L51AX2bUFvsgQ5DdNyA+UwYgkYUlT3KIohxvfRZZqzyy+F3dJvOInhU/wKQ9UoT+bjxcocL4bG+IBpXc2+C5MK6BGwxUid4fF+nOH41u+nUy7Dy6z+d0zjBodymTXvaewCb07gDZDnPpbIk/GfXfHMYh4rDXe2lLpPQstQOEHYMtrRNY9iHVnl9Y8DBno3IJ7lIbvyqO8yl0hG/VS20Pfbn/rUvCGTTGEvSXPFi5gPz6ccZI0B99XkoxOowspBOimuPg8VV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366016)(1800799024)(52116014)(376014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: V+LSnuydf1Axtxbrmiz+IjGVLCwzDbDGM8jRhKNgpvKDJt4EbQHeIw51GBvATUctwva0dn7+7XOvDO/naCVYZ9cZKGpGcIlnFWXWwdHUIjRXqIGkmhyp8PC8cPRqfrKifNdaaTfsckYg37FDgl5UUx785b1q7i6IthyRcdGcSFTeITL72/qYQfPaEtCftcr9rDRSLEnsPEzhDP5VSg8n7WMHM9pdfZa6HV+H3Yg5RJ8ARM5m1cHKSCFBT7rwu60nu0q6JnogH59k0JXoejliKKCCKCDI2D/NIInh/rv5zfgV1jmpxG1ZJpo9usxlaBwG+RHiUfwtRRGWSDYer8UoQWQ66cdARMT4Y1BrSVXJj74R3nYPEJNMwwMxh7s6CFSb0+aANnmquUCsp7ts9D6mU6ShnuLrx60v0xqXO+I4atRjVNhn1P7Tc+Jc1VX1pa4HZ3AJcjBo5wUuaTYIbiOXRlq1xT+KIODH43RbBiqBxaGkey+h3ovdOsZoTRr024hBH/NVf2HW7z6fsZFxaFWxE3w5g3/9Xpvz0fByefXW2X14v9H/Ou370cSiwL47RRqrWmtYL3xnKKkigvAL+39EC0U4IZ2ggBW+GUeI4xtnjL+YnUM0/Z7TRER2WH0Ak8N/61Drh58IsBwhMvxrlMIukZPD3GXAqJ9gmvQpmsmrk+2i8xU9OXuLzrMynpracfXgDOw9oHWRYxyodNlcWxM85Q4k0RbL2chfoEN3nGIgVtjwV6Lhmluzz+H8Q3yL1d34oiSZ3/z/Xofcf0OQUU24vMEPCXcBJnTAaGNMJXZKKsUerMR/s1Kp2uh7IYzhrHhy2pWKEpPICMj+r6mBlEVtUuTYnl94JbftruMNN81R03mDlA7nDyVb3atXC4YLiswzNaI4wVZRsoUa4wOZQgfnM6teCI2+mkfjIoblAHhLCJbtg3kYpnXPSPTFB9UMLBzigsjb0CNAj9naUClACC1i/gpeg1noYcYIRCduPKZTLRVcYliC/0s/YrtYdGbYvyNYpsUIOkSWMkN873btpkps6iNKi/R4pjb7JihTryKdw+jPpxU7wLCZgf7B+KytG2fHuJVSEdivEb8OGH2MXcy4nO5peDWar5hhPRHHdiIbC1Cc27o4CdlzS+6Jtcpdtp6rCbceh4GaqOcDFbMVd5WnV/M/YLAEiSpnsBh3dqaVofodJ8tQGTo9L0duU5HGGK6C+JN254Qbl5UlTMYCcdP2q8l8D/LhTeOKJgxz402jZNtD3w2VmjNIq938WT2B7J/zdoHylMJqpll4+KRni9wUXgqIoJkXGJCZfWTd+Aa9aNLKL2akjAuLLvMlE9c2tnjEr7DGBHdjiVacGV6FEjsh5QkJ6uCn2MbxRjl62oxXlbvZmXd9kqwMBZD+JiPX+V3wscbnEMAV60meXTktO0vOQ0je6bd+icYKje8Q5KofGd5iNZtJ8KoSYXbpS6F1gvglDjWxOgR71TxnG/ej5NflBPvrOF+Cn4bIdMRaYc4cf3wz/RaIRVRLRMaKCdidVUccaqg02P/nwd5c70xPT0BPlrgqWEMjbEhytk6YN3+ntiYo5ioCb3Pbfe1QE3u/SmUgARF+pcEACGNbE6ej05E2zw== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3df6dd10-4315-4b14-63f1-08dcfa4e8897 X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB8898.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Nov 2024 08:23:58.6777 (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: 6fhxZiOv0V7q6+WZW8Zv9tJu06VhDYpPwU+atfoHLK2xqTdem4PE7AA874d3WKKxon5odgwnGKoFRZ50EIgKXw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR04MB7921 The Bluetooth Core spec does not allow a LE PA Create sync command to be sent to Controller if another one is pending (Vol 4, Part E, page 2493). In order to avoid this issue, the HCI_CONN_CREATE_PA_SYNC was added to mark that the LE PA Create Sync command has been sent for a hcon. Once the PA Sync Established event is received, the hcon flag is erased and the next pending hcon is handled. Signed-off-by: Iulia Tanasescu --- include/net/bluetooth/hci.h | 3 +- include/net/bluetooth/hci_core.h | 34 +++++++++ net/bluetooth/hci_conn.c | 123 +++++++++++++++++++++---------- net/bluetooth/hci_event.c | 19 ++++- 4 files changed, 139 insertions(+), 40 deletions(-) diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h index 4f64066915be..4becf201b063 100644 --- a/include/net/bluetooth/hci.h +++ b/include/net/bluetooth/hci.h @@ -1,7 +1,7 @@ /* BlueZ - Bluetooth protocol stack for Linux Copyright (C) 2000-2001 Qualcomm Incorporated - Copyright 2023 NXP + Copyright 2023-2024 NXP Written 2000,2001 by Maxim Krasnyansky @@ -697,6 +697,7 @@ enum { #define HCI_RSSI_INVALID 127 #define HCI_SYNC_HANDLE_INVALID 0xffff +#define HCI_SID_INVALID 0xff #define HCI_ROLE_MASTER 0x00 #define HCI_ROLE_SLAVE 0x01 diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 94ddc8684973..43474b751a50 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -668,6 +668,7 @@ struct hci_conn { __u8 adv_instance; __u16 handle; __u16 sync_handle; + __u8 sid; __u16 state; __u16 mtu; __u8 mode; @@ -947,6 +948,7 @@ enum { HCI_CONN_CREATE_CIS, HCI_CONN_BIG_SYNC, HCI_CONN_BIG_SYNC_FAILED, + HCI_CONN_CREATE_PA_SYNC, HCI_CONN_PA_SYNC, HCI_CONN_PA_SYNC_FAILED, }; @@ -1099,6 +1101,30 @@ static inline struct hci_conn *hci_conn_hash_lookup_bis(struct hci_dev *hdev, return NULL; } +static inline struct hci_conn *hci_conn_hash_lookup_sid(struct hci_dev *hdev, + __u8 sid, + bdaddr_t *dst, + __u8 dst_type) +{ + struct hci_conn_hash *h = &hdev->conn_hash; + struct hci_conn *c; + + rcu_read_lock(); + + list_for_each_entry_rcu(c, &h->list, list) { + if (c->type != ISO_LINK || bacmp(&c->dst, dst) || + c->dst_type != dst_type || c->sid != sid) + continue; + + rcu_read_unlock(); + return c; + } + + rcu_read_unlock(); + + return NULL; +} + static inline struct hci_conn * hci_conn_hash_lookup_per_adv_bis(struct hci_dev *hdev, bdaddr_t *ba, @@ -1328,6 +1354,13 @@ hci_conn_hash_lookup_pa_sync_handle(struct hci_dev *hdev, __u16 sync_handle) if (c->type != ISO_LINK) continue; + /* Ignore the listen hcon, we are looking + * for the child hcon that was created as + * a result of the PA sync established event. + */ + if (c->state == BT_LISTEN) + continue; + if (c->sync_handle == sync_handle) { rcu_read_unlock(); return c; @@ -1445,6 +1478,7 @@ bool hci_setup_sync(struct hci_conn *conn, __u16 handle); void hci_sco_setup(struct hci_conn *conn, __u8 status); bool hci_iso_setup_path(struct hci_conn *conn); int hci_le_create_cis_pending(struct hci_dev *hdev); +int hci_pa_create_sync_pending(struct hci_dev *hdev); int hci_conn_check_create_cis(struct hci_conn *conn); struct hci_conn *hci_conn_add(struct hci_dev *hdev, int type, bdaddr_t *dst, diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c index 40c4a36d2be3..f9da12339db8 100644 --- a/net/bluetooth/hci_conn.c +++ b/net/bluetooth/hci_conn.c @@ -952,6 +952,7 @@ static struct hci_conn *__hci_conn_add(struct hci_dev *hdev, int type, bdaddr_t conn->tx_power = HCI_TX_POWER_INVALID; conn->max_tx_power = HCI_TX_POWER_INVALID; conn->sync_handle = HCI_SYNC_HANDLE_INVALID; + conn->sid = HCI_SID_INVALID; set_bit(HCI_CONN_POWER_SAVE, &conn->flags); conn->disc_timeout = HCI_DISCONN_TIMEOUT; @@ -2062,73 +2063,119 @@ static int create_big_sync(struct hci_dev *hdev, void *data) static void create_pa_complete(struct hci_dev *hdev, void *data, int err) { - struct hci_cp_le_pa_create_sync *cp = data; - bt_dev_dbg(hdev, ""); if (err) bt_dev_err(hdev, "Unable to create PA: %d", err); +} + +static bool hci_conn_check_create_pa_sync(struct hci_conn *conn) +{ + if (conn->type != ISO_LINK || conn->sid == HCI_SID_INVALID) + return false; - kfree(cp); + return true; } static int create_pa_sync(struct hci_dev *hdev, void *data) { - struct hci_cp_le_pa_create_sync *cp = data; - int err; + struct hci_cp_le_pa_create_sync *cp = NULL; + struct hci_conn *conn; + int err = 0; - err = __hci_cmd_sync_status(hdev, HCI_OP_LE_PA_CREATE_SYNC, - sizeof(*cp), cp, HCI_CMD_TIMEOUT); - if (err) { - hci_dev_clear_flag(hdev, HCI_PA_SYNC); - return err; + hci_dev_lock(hdev); + + rcu_read_lock(); + + /* The spec allows only one pending LE Periodic Advertising Create + * Sync command at a time. If the command is pending now, don't do + * anything. We check for pending connections after each PA Sync + * Established event. + * + * BLUETOOTH CORE SPECIFICATION Version 5.3 | Vol 4, Part E + * page 2493: + * + * If the Host issues this command when another HCI_LE_Periodic_ + * Advertising_Create_Sync command is pending, the Controller shall + * return the error code Command Disallowed (0x0C). + */ + list_for_each_entry_rcu(conn, &hdev->conn_hash.list, list) { + if (test_bit(HCI_CONN_CREATE_PA_SYNC, &conn->flags)) + goto unlock; } - return hci_update_passive_scan_sync(hdev); + list_for_each_entry_rcu(conn, &hdev->conn_hash.list, list) { + 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; + + break; + } + } + +unlock: + rcu_read_unlock(); + + hci_dev_unlock(hdev); + + if (cp) { + 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); + 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); + } + } + + return err; +} + +int hci_pa_create_sync_pending(struct hci_dev *hdev) +{ + /* Queue start pa_create_sync and scan */ + return hci_cmd_sync_queue(hdev, create_pa_sync, + NULL, create_pa_complete); } struct hci_conn *hci_pa_create_sync(struct hci_dev *hdev, bdaddr_t *dst, __u8 dst_type, __u8 sid, struct bt_iso_qos *qos) { - struct hci_cp_le_pa_create_sync *cp; struct hci_conn *conn; - int err; - - if (hci_dev_test_and_set_flag(hdev, HCI_PA_SYNC)) - return ERR_PTR(-EBUSY); conn = hci_conn_add_unset(hdev, ISO_LINK, dst, HCI_ROLE_SLAVE); if (IS_ERR(conn)) return conn; conn->iso_qos = *qos; + conn->dst_type = dst_type; + conn->sid = sid; conn->state = BT_LISTEN; hci_conn_hold(conn); - cp = kzalloc(sizeof(*cp), GFP_KERNEL); - if (!cp) { - hci_dev_clear_flag(hdev, HCI_PA_SYNC); - hci_conn_drop(conn); - return ERR_PTR(-ENOMEM); - } - - cp->options = qos->bcast.options; - cp->sid = sid; - cp->addr_type = dst_type; - bacpy(&cp->addr, 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; - - /* Queue start pa_create_sync and scan */ - err = hci_cmd_sync_queue(hdev, create_pa_sync, cp, create_pa_complete); - if (err < 0) { - hci_conn_drop(conn); - kfree(cp); - return ERR_PTR(err); - } + hci_pa_create_sync_pending(hdev); return conn; } diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 65f5ed2ded70..fd269fcabc2e 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -6352,7 +6352,7 @@ static void hci_le_pa_sync_estabilished_evt(struct hci_dev *hdev, void *data, struct hci_ev_le_pa_sync_established *ev = data; int mask = hdev->link_mode; __u8 flags = 0; - struct hci_conn *pa_sync; + struct hci_conn *pa_sync, *conn; bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); @@ -6360,6 +6360,20 @@ static void hci_le_pa_sync_estabilished_evt(struct hci_dev *hdev, void *data, hci_dev_clear_flag(hdev, HCI_PA_SYNC); + conn = hci_conn_hash_lookup_sid(hdev, ev->sid, &ev->bdaddr, + ev->bdaddr_type); + if (!conn) { + bt_dev_err(hdev, + "Unable to find connection for dst %pMR sid 0x%2.2x", + &ev->bdaddr, ev->sid); + goto unlock; + } + + clear_bit(HCI_CONN_CREATE_PA_SYNC, &conn->flags); + + conn->sync_handle = le16_to_cpu(ev->handle); + conn->sid = HCI_SID_INVALID; + mask |= hci_proto_connect_ind(hdev, &ev->bdaddr, ISO_LINK, &flags); if (!(mask & HCI_LM_ACCEPT)) { hci_le_pa_term_sync(hdev, ev->handle); @@ -6386,6 +6400,9 @@ static void hci_le_pa_sync_estabilished_evt(struct hci_dev *hdev, void *data, } unlock: + /* Handle any other pending PA sync command */ + hci_pa_create_sync_pending(hdev); + hci_dev_unlock(hdev); } From patchwork Fri Nov 1 08:23:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iulia Tanasescu X-Patchwork-Id: 13858930 Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02on2042.outbound.protection.outlook.com [40.107.247.42]) (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 67744156649 for ; Fri, 1 Nov 2024 08:24:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.247.42 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730449445; cv=fail; b=kUlvcbiLEItKwxXFz2XN362C5cKmJOMVyiyPdus0gUfOCWXbsjPvkmQVOty7eJP1SRko7mHwTBvudD+DYH35FPjFgHOrc6nMTMnEFTS9ETsoX2Snz0wmyQJWKx2CobtK6lSY5ycLcK9NTfq+/8D9fRxfENiS3MQPpkHaVio7K4s= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730449445; c=relaxed/simple; bh=2nbQe7PhmP0V1izv4sk6VukJKT0rGtqWx3VmSfxsmFo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=OleY6iIP6NtDFkghcmqnF4TuzAwgv9gX8DSP+vVNRSrG93NZfWYdxe7A7wIkWjTRXKgtTquYjfEiOiTAUK39sGTp0PTsWQ0CMz7wveAof9Y9zKr4j5/7i4qTDm7bqmLaYy4WM/iQamGvio7mhtb2HsQ1m6H14rpoYe2KOA7ee48= 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=JFmRlUj2; arc=fail smtp.client-ip=40.107.247.42 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="JFmRlUj2" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=dZ8Amj8O8CB+V3fDwFL3PgFMPoXYPNB875wNrNgwn/eQvaZBzGusFL+ROHntm/aW38UcgB+WX5He3I9fQtq/9WQ0lYUKTxHWzPlkRIFi8vkrI2uaNgIzWrbwgB+P52JYW6MfH2Ezftv6oA9NIVxIDx/kJUyFJJ9dOEwyjrfLyKqSH2hpB28o5e+wf8pFRnApPhZKD9JW7ehruNq+fXrK/+XwgwAPEN9WnfiaUyCjxJYetYgAU+LkacBevwREdk0hWwwVDnZm+q3n/M0XxZvJDyNlbBWwzba1xXse0C7HqfLBx8gDXCH1hZJfAwmmUm6pwdPKL++O7UiN8yCiWLDASA== 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=MPBWbxWrL+D7/AOru3o9GR6zU8kwbeKEMSr1Hztpxb0=; b=rMy28NITxxP4SNbDn0g/Cn7QD6mHMdD1Xz50hD+29hcofXAm0jBaX7WWMOgc7CD9LtENFzRbElI470kP4WBqIZNkrbss7++VwzQOJ2cZN7Ntt9VEWljVxqfbeYgFsQjLoJNeowTGTEwWLsHB1kkfGlVHK1VElVhrcbHLrIY9FDZEys5mFkK33aIUZ2LZmHXlzJmp4d7gVD5/azkDzmUgj1VhP1jBPZ6nyGxnmr5IzIvk2KebaOoTXnaICYNbynzmdTG/D2vYkKSdwi7wgyDnHWyTLSfd+yfDKzIeaQRcM/KlVVNUncLRUbLmP6ZW7as8EpNxrpRf0zaVcz7dcjBJ3w== 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=MPBWbxWrL+D7/AOru3o9GR6zU8kwbeKEMSr1Hztpxb0=; b=JFmRlUj2SDI+CSDXTd6E9XWLr3LRmHodfT1JSUxyuYboP3XGq7UQtjZKuI2EALGuQs9L0b3AHoeuLMlVbde6NgUKcgHLHa+BwSwGb5cndL1iRyJ30odYVNGISJrUr1+SkAoWAfiS4MIHUMGo5qbE9UrP+YL9/EYPxzagIIu/uJ2XSbj1Pt53eQXK4Ha4SXqY3OtBzj4arIIR1bOHh1f5VvuYWclnEyjh0ytvANYSMahnRlrX0/+qFY5FC/rah9B140Q2RhGS8ArvG5now1EF6YsweD/WXra+cAAJUHbH1dFHFF8ZLO32oKjdz0pnyOIR03Ne+SlZAWaPiHqEOOQquA== 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 AM8PR04MB7921.eurprd04.prod.outlook.com (2603:10a6:20b:247::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20; Fri, 1 Nov 2024 08:24:00 +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.8093.027; Fri, 1 Nov 2024 08:24:00 +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/4] Bluetooth: ISO: Fix matching parent socket for BIS slave Date: Fri, 1 Nov 2024 10:23:37 +0200 Message-ID: <20241101082339.4278-3-iulia.tanasescu@nxp.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241101082339.4278-1-iulia.tanasescu@nxp.com> References: <20241101082339.4278-1-iulia.tanasescu@nxp.com> X-ClientProxiedBy: AS4P189CA0033.EURP189.PROD.OUTLOOK.COM (2603:10a6:20b:5dd::6) 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_|AM8PR04MB7921:EE_ X-MS-Office365-Filtering-Correlation-Id: 37f5f5ba-6853-41e1-6c56-08dcfa4e89a9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|52116014|376014|38350700014; X-Microsoft-Antispam-Message-Info: V3vBdWhe0GQucD+cK9O8+fxid/ijGnsZUwKzH2hHN4fLY/e6iC6kCST++i/3SMolij5IRq4kz34TGTCVbx77jL0MeFA3GG6++/H5mQQpW0Jtrt8tU5CPoSttC5I5LgzDasPwt4YEWDb5mBy0emtK0bEK1ENEanHyQ5Cp9/v71DiUfsbGbENXNosgG4z3T6/vqsdqhju1aCahGWj+cP2XDv280nNNA2hhLltDLH2y/zV7jB7vIq7oCm/REW6t4PdrsZMXMXHMW3uLTG4+NmyE7Xbq9OfOb9bypy//Jf5v3jwtuh+HbwlAdkn3c3a2LKz2OMQNwEEC9yE7wyyK8R90FSTKHyQSwBoPjZB34cN/YtQFGrmDiPmbMPm9HS6knrAjiMqtgZMU+Uhaa+JRCh0dZrNZq8Ikt+OWe6hYczY+6uEr0Ax9qjfRzJwBiSUgS+36BXhgWRWIRElfv8Y3KuYfruJTcYFgvTMZziBhT4g9p9yL5W1E3CLpipZqaZLUEaaqS3abJLrijmEnr0YbHFabEiwoDteFzoEzOQo2CKlvqGngMhf+CxHkz4rKt2NTtEcZt+xDKscpn895jnypuhcer+VAdpU1he5MLyx0pzEg7FoEewvVNVdbq8JCxGbxG4hMEW9NwDHhpy+ADlV1zKQHnfUtOUHdw5OOtIPHDGjsMGjT2dOhQqS+HFbu0FTIZ6rzpBZjOV/s6WNUiDVorcGWjE49PE/4mgUV7EMZn/drw4In156a9PGwHUpDmnvVJWJXHmN90HEXrecB6rzECM9m304CC6jr9KnFOtBwfAP20XSezAKBbsKwTqETGQ764+eMOuddk0Ad4NrGjhaAUsSNN1vbSNMXKQzLhdhBNCo7G9abNMkSZZ0DCna8wU7C1zXohgpqOsyz2A1+eoUNFs1tqfrudmHu8Y1As0dKqkw/WegFumZnTGlSmaCTH/9EBg4PF1BC6hfxXvBStbhU6ZwQqpnkn3NLP9xwfKNxwJpATzYqkSQxD1UhQY84mWGYSV9Pc8coD2m4eStPULj8jzUlZU9BRxtaX4IXL346j7UnhjiRRQ7H/SColdRpTe7S/Dhi+7ghqYwMyEmjjkCaTazZTMuET2KaLnIPg7rMO2YkEC4k+mC6+0jTERQp/SlKfykVfN7ydorBQMmyOddpAyXs6VBz3z1u9CCSu+BkTPRrwn9Tg3R4mucMjKd446+Fesnn+wjJkGfibwcN3Qwd3P/pc1E5SPsgplATkmS295zdCOYn7RamJ0taDFIRSKPXBwZEnyVyqSIxpt/BgdLT6SaaOstifDWG6wHEZjkY9WSAntI1s6irb8RizIARf90au2sovcfmHgauDjDZ8eCvaLvZkEiJbs4DwxLuUqN/1I32NuQ= 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)(366016)(1800799024)(52116014)(376014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 6tiwk1E78M0DHhPxkSvgRkBQGZ1OOMB7yR2azWPb3ce8Z5HAyj5JRfq4FdzJJB4sXhpWO1gwRVhZVPcykNJDcHRmfTevtLHEFCyv2saTGak8lViS5E3FpQPfKiSmck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kVdoAtHyqllRyvwqt97c7+slj/MS0n4fiEnVMQRM7o8G+CobCr0yGevytcpGvIkU2gZfQe1u6poRNqT1lKA2Si4kbY1WvXOQvNDGzj8OYigBd72qqlBZVxRghcJbkwuYXCAdZ6ens/Y3vj6tfxrfiMjT3hazrqS/HWr9YL/QWh7qzXtkz3jGEEwfo1Dd9iMoGsSplJ6yEhdAwA+J55QfLVsdgUxch4+F8oQrX81GJXfyHiSGmgLq5wZ10Twrl8AwbR1L92fMmB+PVaRXCYhfCCht7q0oxE5qdQRlelRNGCHsfuQDYMxRb7db5rzUQMiX2R0qq3m3vens3peHg1BvITI7MnYiDfMZCfWH5ZuS5K2J+2JxjR3elDRwF10GIhSGDYNddWchqyg/3TPtiFedjmdGMWf0YqP007K4nYg== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 37f5f5ba-6853-41e1-6c56-08dcfa4e89a9 X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB8898.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Nov 2024 08:24:00.4568 (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: zLLdWEUlVZQxfikmgSUB9RiUEWBShh086JNu3KIELunJaNGaMW/UNeY5uKYArpG4lisxlrUqqN8WKjYC/wpoaw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR04MB7921 Currently, when a BIS slave connection is notified to the ISO layer, the parent socket is tried to be matched by the HCI_EVT_LE_BIG_SYNC_ESTABILISHED event. However, a BIS slave connection is notified to the ISO layer after the Command Complete for the LE Setup ISO Data Path command is received. This causes the parent to be incorrectly matched if multiple listen sockets are present. This commit adds a fix by matching the parent based on the BIG handle set in the notified connection. Signed-off-by: Iulia Tanasescu --- net/bluetooth/iso.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/net/bluetooth/iso.c b/net/bluetooth/iso.c index 7a83e400ac77..0d98cc16bbac 100644 --- a/net/bluetooth/iso.c +++ b/net/bluetooth/iso.c @@ -1733,6 +1733,13 @@ static bool iso_match_big(struct sock *sk, void *data) return ev->handle == iso_pi(sk)->qos.bcast.big; } +static bool iso_match_big_hcon(struct sock *sk, void *data) +{ + struct hci_conn *hcon = data; + + return hcon->iso_qos.bcast.big == iso_pi(sk)->qos.bcast.big; +} + static bool iso_match_pa_sync_flag(struct sock *sk, void *data) { return test_bit(BT_SK_PA_SYNC, &iso_pi(sk)->flags); @@ -1756,8 +1763,16 @@ static void iso_conn_ready(struct iso_conn *conn) if (!hcon) return; - if (test_bit(HCI_CONN_BIG_SYNC, &hcon->flags) || - test_bit(HCI_CONN_BIG_SYNC_FAILED, &hcon->flags)) { + if (test_bit(HCI_CONN_BIG_SYNC, &hcon->flags)) { + /* A BIS slave hcon is notified to the ISO layer + * after the Command Complete for the LE Setup + * ISO Data Path command is received. Get the + * parent socket that matches the hcon BIG handle. + */ + parent = iso_get_sock(&hcon->src, &hcon->dst, + BT_LISTEN, iso_match_big_hcon, + hcon); + } else if (test_bit(HCI_CONN_BIG_SYNC_FAILED, &hcon->flags)) { ev = hci_recv_event_data(hcon->hdev, HCI_EVT_LE_BIG_SYNC_ESTABILISHED); From patchwork Fri Nov 1 08:23:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iulia Tanasescu X-Patchwork-Id: 13858931 Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02on2042.outbound.protection.outlook.com [40.107.247.42]) (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 0B494156C69 for ; Fri, 1 Nov 2024 08:24:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.247.42 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730449448; cv=fail; b=ra0t9FF/6S0F+7m2IXaMnfM5vf6fYxqYka7IP5R3dnEi2UvqLLTTq5oSr6lfX1qZWz3sYPFG28MBB5HcjmfcHaApG7AF+b4zeSJTfNtLczzoigory4nAURDj7P9R5ZLlopqeVOhWdrpDIaDbFcg2XKdNYbl7pmOFwlrv58iwFq0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730449448; c=relaxed/simple; bh=xSR+JTucWVl582CjC2JPO1+iNcdHwIGXYAKUU2Hy6qk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=mgd1NahNHzm7q1rFUxOLII8jFvaGPaUgtTI3ye7X0anMp4IeCAYMpEhoJzm/HwyTd2K9pvCnJRvRz3573k+GcxpSElQtT1IMLTAj81zu7lJu5MiwpZjIs6kiSK/D/ZEqK1iOpZ6YmYQ2cI9v4owaHXziPaA0Jktas2/+G0OXRXg= 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=l5E/yBxf; arc=fail smtp.client-ip=40.107.247.42 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="l5E/yBxf" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Vjm+2w4RREfoZJR+x4c0HoGBT8UyjQ398KopQ5rD2WNA3S15CeTx9WmzS1Fj6Is/7L9wE0OyUkBMl/FQNZEQYSfEZC3AszTjGYgbrlzLnL3mhzkfY9lJaCEY2kdPNmn7+COM81cW9dzA/3zMDTOWinXQRsFeIegAFGF6mLVYB/h7vFeZn/aY2NtpnfWgl4gYWOIlBf3FtGsqgfr4014U3uLT18dnMetQrrpsakOlgpTj0rzTQbM6W9DZrlqGZTfKLpZCw0y5zC/JmkAU7ClnEFe56XnFAsJWs7jF5NEOZHv43g27zoEogPzY7Ml2oeFMcvF+BTgbvW5qWmr0dikUbg== 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=SkPrVbovLvFqMJH2Fk0MC66SWU6eALhWkAoctEQGQ64=; b=gow0uWdgCQ6NH6DH+IXjQ5QtqV19fRBMjP+N0Cxj+zSGacGgBx8aa2qG6UvL5VfWixAXLDDFFQYgLY7gLVx9Xm8hM1ch9ELqN3y69pme/rU9eJM943lURJbDeBsjfJRNoNGBR0TmUR5UFwSGYFSuc/tU8xaucVZa6fFUtYDnxA9fBc9qFa/L70B15TS4902MvPxiaFlRlDkhwfgT7OJnz66ieCsZz9HBdls1HByd8XlhWqcgys1npA9Ykbdiwes+Pt/4uAwUKU/Sk1g9VNaHwJVUEWKfSVbXDT+wZsbzunriQHUuVlccTfH6lEN1MtubR77R7HBFdWZyverk22cX8w== 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=SkPrVbovLvFqMJH2Fk0MC66SWU6eALhWkAoctEQGQ64=; b=l5E/yBxfKFAS6pmai7hfs/VqFtSaPkYw9pj3GbZon+fViYj7jp0XanHyUm8SeNJA83ZR1xhXEGHUb4YkEgx37V9O5gMp/IB50FjEERIifkrnws5y/ejZcE06N0moBfkM/qjkJERE0DOsVlhPALLUoKRB56ypD0dNTYhlRadGkQ/7RiLNH0Kfco5AaAArDA2Le9wDB5YwaclpcY+JMZK8WuaWzfNJDQOLbjVRHVjY9D6M9e1dNkjuR5bFkKJ3I0D1LBq36wpC5sH7TDwTUdHvfWf9Cz1YluF842fS0TiNJbhQcpT+/kfer5gSHsozLLc0zEBO4toiaHaPKh5nivW4lQ== 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 AM8PR04MB7921.eurprd04.prod.outlook.com (2603:10a6:20b:247::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20; Fri, 1 Nov 2024 08:24:02 +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.8093.027; Fri, 1 Nov 2024 08:24:02 +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 3/4] Bluetooth: ISO: Do not emit LE BIG Create Sync if previous is pending Date: Fri, 1 Nov 2024 10:23:38 +0200 Message-ID: <20241101082339.4278-4-iulia.tanasescu@nxp.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241101082339.4278-1-iulia.tanasescu@nxp.com> References: <20241101082339.4278-1-iulia.tanasescu@nxp.com> X-ClientProxiedBy: AS4P189CA0033.EURP189.PROD.OUTLOOK.COM (2603:10a6:20b:5dd::6) 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_|AM8PR04MB7921:EE_ X-MS-Office365-Filtering-Correlation-Id: b015cf79-b14a-41fd-357b-08dcfa4e8a97 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|52116014|376014|38350700014; X-Microsoft-Antispam-Message-Info: c4dE6KuYcWWSc5v1YQevXDMkWDox5ZgNutqVnjQ7+30QGZAe3l6nsUaTIqr6eZhtLDOvH48ReOQxjrX+YK+BJGPeoN3J9WUvCRoFMk56KkeGOoFQ/+zyaToYWykCp13rXvgh/aZsavUyssQgwoC1j/Yop7hgAeii8WOHO4n1HlXu9lInE9xdYNMsQzWE/BOUUJSje9AoshHxF8LiXTY77R2auagJ14Les5xzJFlnNXZFLtLNnPzVHaOulmI6m3v5BWeKyktqpq7vD6NBRRHKnHgcuqu4VArPKLtnOupTjs9FaPCKI6O3n7xMu3QueYl3+UJt597DwoOuE3c44aIX+ITMoz2lTLap9wnZs0GRb4bn6OehtgtwzkcYi/Q425muKjrVQ0u7NxtgQ4rJ2bWHqcbEJmUeRYz1j0GZtu+NmiIrhZ5VtesayBXPjhHrPjCat1KYlXfyDEz8av1+k4e2wdy+SEetgMvnwRhnflpcncMG6lHyrxVc2rwBfIX10LTkyJ8gvB2YgxkcxHhbOCU/BSJcHEWX+c6DMZxzVeBYquU+9yJEie0qSasqTZzbTp/Z3CwHgcCNbnOqqB1sYkbDo7hlPaKh32SNFziMg6VvALqb1oJLLhYPaGPcCmmPJu67ZQQHAu8Qz/v3UgxCvbPDArLru5Hi8nCPTBaudPpMB3of3ZWzU4b4Rrca96DAlVMEIx4h67gBYai49hxCJHr6ZEqCmvnkxAnjLLSXwTKqpUG6Lvb/OKgbr5GEVX86ppyoIuzLoyhaTQGq2ZyJ3AaqJccOFOlreOQ+7GYRGYzg0zBqknrUAI44/zq4FSYg7t5p16Zp7o5pCkFvzw5lDCXwzOrJ/SLnpvAB2Nc89O19TppsP83yuTeL06SHwnIxJkqiU3lktA+vpEOtYseRxxA6TBxmHf0iIzSh+JyzFg7Xy+iquWdEyVvEdSWUYPfdBc+oOJNDHcBFZINI4pyWo/1c5ZA8Z1dgj+7NSNqNn56iNbj1SNJjsGNRFjutaf0hUCouz1ROxSDYlRjbFMLgO5IwurF9V6EAv45cIeg2l4TGrMHPOLEAneYaaRepu74r9dy/sicfvOvqP0EqxkSnBEPmBl9UYlglXM7KqRCDopAlT99u+1H5+Fzz4FI8/LjSxxCyjew9UFosZca93e1l6zyVu+PTdhplhRtDmv2cU2g5NYVCSkqwIeWSonLM2YOX6OdYyCfrpC9t0prQ+hW5Xm1o1Nswzbm3oCLB3flEsoLYVz/x7J/o9REKdXEv9BMbbhGxcd0P1BDaQmu8qxnDy+3NCszDPp0Oc5hUv4pGUtiG8bv3mIn35ojeUWH7FW4l9IYyYB7bq568CICGYXCfuXm+HLzxc5dOpdbBmvU6KOy989Y= 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)(366016)(1800799024)(52116014)(376014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: FgFdil9Uo2r7vQLS5953XuqT9Iy4H2xBylO5+9MGvSZqgfuPQejJ/5ykuyzG2JYOikl6etRz7AVJ1sKFZMe3AhjXQgWG691vaYKhUSusXc6WDc/9b9VM0MWksO7NSIcKif6Hq5GAAqSl6Z1ga1/AX3FudegPGDzLvP+6o44B9V+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h5VYv5ZqByZ2Ak+XTKosXluuI+9aTARNle3fJ5hCY25L3zqzii8B4D0lY9x1XeO/7w7AlatLe2tMQpeQJbYFgYfbZQvlim83UUK4McvSH/jqGUovQF02wmlRQAhdJJ/XrH3z7gAvbbJXHBTQu0VEugYz7GI5WAwo0C6MD1/GdQ6/0e8CcdgFx2El9LF2u8lo/qkk2kBHeTkhrXDLh506EnZELSUuY8VXNLlwwcSVr4m+3Toe7iPMEO3MMhJUKIBKFvTRFzir8CBtgs+uUPfUV4tLMcfgN1C7YidIuVufIXtUgL3d017EEH0p8tBo6MZ8CextV684hfM90aNqJM52LDXbAK3thoN9E7Jai/pYuOwGlrROg43/OUg== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: b015cf79-b14a-41fd-357b-08dcfa4e8a97 X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB8898.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Nov 2024 08:24:02.0532 (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: eTcIN53ipS8SK4hYYkSjEpUg+4MUPc6KJtum83qLvKoE0WSM7WN1CJX8mmcO87x4gzk1yMLKJrICm5l5WS3EQQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR04MB7921 The Bluetooth Core spec does not allow a LE BIG Create sync command to be sent to Controller if another one is pending (Vol 4, Part E, page 2586). In order to avoid this issue, the HCI_CONN_CREATE_BIG_SYNC was added to mark that the LE BIG Create Sync command has been sent for a hcon. Once the BIG Sync Established event is received, the hcon flag is erased and the next pending hcon is handled. Signed-off-by: Iulia Tanasescu --- include/net/bluetooth/hci.h | 1 + include/net/bluetooth/hci_core.h | 29 +++++++++++ net/bluetooth/hci_conn.c | 87 +++++++++++++++++++++++++++----- net/bluetooth/hci_event.c | 20 +++++++- net/bluetooth/iso.c | 4 +- 5 files changed, 125 insertions(+), 16 deletions(-) diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h index 4becf201b063..5bb4eaa52e14 100644 --- a/include/net/bluetooth/hci.h +++ b/include/net/bluetooth/hci.h @@ -29,6 +29,7 @@ #define HCI_MAX_ACL_SIZE 1024 #define HCI_MAX_SCO_SIZE 255 #define HCI_MAX_ISO_SIZE 251 +#define HCI_MAX_ISO_BIS 31 #define HCI_MAX_EVENT_SIZE 260 #define HCI_MAX_FRAME_SIZE (HCI_MAX_ACL_SIZE + 4) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 43474b751a50..c95f7e6ba255 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -711,6 +711,9 @@ struct hci_conn { __s8 tx_power; __s8 max_tx_power; struct bt_iso_qos iso_qos; + __u8 num_bis; + __u8 bis[HCI_MAX_ISO_BIS]; + unsigned long flags; enum conn_reasons conn_reason; @@ -946,6 +949,7 @@ enum { HCI_CONN_PER_ADV, HCI_CONN_BIG_CREATED, HCI_CONN_CREATE_CIS, + HCI_CONN_CREATE_BIG_SYNC, HCI_CONN_BIG_SYNC, HCI_CONN_BIG_SYNC_FAILED, HCI_CONN_CREATE_PA_SYNC, @@ -1295,6 +1299,30 @@ static inline struct hci_conn *hci_conn_hash_lookup_big(struct hci_dev *hdev, return NULL; } +static inline struct hci_conn * +hci_conn_hash_lookup_big_sync_pend(struct hci_dev *hdev, + __u8 handle, __u8 num_bis) +{ + struct hci_conn_hash *h = &hdev->conn_hash; + struct hci_conn *c; + + rcu_read_lock(); + + list_for_each_entry_rcu(c, &h->list, list) { + if (c->type != ISO_LINK) + continue; + + if (handle == c->iso_qos.bcast.big && num_bis == c->num_bis) { + rcu_read_unlock(); + return c; + } + } + + rcu_read_unlock(); + + return NULL; +} + static inline struct hci_conn * hci_conn_hash_lookup_big_state(struct hci_dev *hdev, __u8 handle, __u16 state) { @@ -1479,6 +1507,7 @@ void hci_sco_setup(struct hci_conn *conn, __u8 status); bool hci_iso_setup_path(struct hci_conn *conn); int hci_le_create_cis_pending(struct hci_dev *hdev); int hci_pa_create_sync_pending(struct hci_dev *hdev); +int hci_le_big_create_sync_pending(struct hci_dev *hdev); int hci_conn_check_create_cis(struct hci_conn *conn); struct hci_conn *hci_conn_add(struct hci_dev *hdev, int type, bdaddr_t *dst, diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c index f9da12339db8..e996e9763666 100644 --- a/net/bluetooth/hci_conn.c +++ b/net/bluetooth/hci_conn.c @@ -2180,34 +2180,93 @@ struct hci_conn *hci_pa_create_sync(struct hci_dev *hdev, bdaddr_t *dst, return conn; } +static bool hci_conn_check_create_big_sync(struct hci_conn *conn) +{ + if (!conn->num_bis) + return false; + + return true; +} + +int hci_le_big_create_sync_pending(struct hci_dev *hdev) +{ + DEFINE_FLEX(struct hci_cp_le_big_create_sync, pdu, bis, num_bis, 0x11); + struct hci_conn *conn; + + rcu_read_lock(); + + pdu->num_bis = 0; + + /* The spec allows only one pending LE BIG Create Sync command at + * a time. If the command is pending now, don't do anything. We + * check for pending connections after each BIG Sync Established + * event. + * + * BLUETOOTH CORE SPECIFICATION Version 5.3 | Vol 4, Part E + * page 2586: + * + * If the Host sends this command when the Controller is in the + * process of synchronizing to any BIG, i.e. the HCI_LE_BIG_Sync_ + * Established event has not been generated, the Controller shall + * return the error code Command Disallowed (0x0C). + */ + list_for_each_entry_rcu(conn, &hdev->conn_hash.list, list) { + if (test_bit(HCI_CONN_CREATE_BIG_SYNC, &conn->flags)) + goto unlock; + } + + list_for_each_entry_rcu(conn, &hdev->conn_hash.list, list) { + if (hci_conn_check_create_big_sync(conn)) { + struct bt_iso_qos *qos = &conn->iso_qos; + + set_bit(HCI_CONN_CREATE_BIG_SYNC, &conn->flags); + + pdu->handle = qos->bcast.big; + pdu->sync_handle = cpu_to_le16(conn->sync_handle); + pdu->encryption = qos->bcast.encryption; + memcpy(pdu->bcode, qos->bcast.bcode, + sizeof(pdu->bcode)); + pdu->mse = qos->bcast.mse; + pdu->timeout = cpu_to_le16(qos->bcast.timeout); + pdu->num_bis = conn->num_bis; + memcpy(pdu->bis, conn->bis, conn->num_bis); + + break; + } + } + +unlock: + rcu_read_unlock(); + + if (!pdu->num_bis) + return 0; + + return hci_send_cmd(hdev, HCI_OP_LE_BIG_CREATE_SYNC, + struct_size(pdu, bis, pdu->num_bis), pdu); +} + 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[]) { - DEFINE_FLEX(struct hci_cp_le_big_create_sync, pdu, bis, num_bis, 0x11); int err; - if (num_bis < 0x01 || num_bis > pdu->num_bis) + if (num_bis < 0x01 || num_bis > ISO_MAX_NUM_BIS) return -EINVAL; err = qos_set_big(hdev, qos); if (err) return err; - if (hcon) - hcon->iso_qos.bcast.big = qos->bcast.big; + if (hcon) { + /* Update hcon QoS */ + hcon->iso_qos = *qos; - pdu->handle = qos->bcast.big; - pdu->sync_handle = cpu_to_le16(sync_handle); - pdu->encryption = qos->bcast.encryption; - memcpy(pdu->bcode, qos->bcast.bcode, sizeof(pdu->bcode)); - pdu->mse = qos->bcast.mse; - pdu->timeout = cpu_to_le16(qos->bcast.timeout); - pdu->num_bis = num_bis; - memcpy(pdu->bis, bis, num_bis); + hcon->num_bis = num_bis; + memcpy(hcon->bis, bis, num_bis); + } - return hci_send_cmd(hdev, HCI_OP_LE_BIG_CREATE_SYNC, - struct_size(pdu, bis, num_bis), pdu); + return hci_le_big_create_sync_pending(hdev); } static void create_big_complete(struct hci_dev *hdev, void *data, int err) diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index fd269fcabc2e..2b5ba8acd1d8 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -6920,7 +6920,7 @@ static void hci_le_big_sync_established_evt(struct hci_dev *hdev, void *data, struct sk_buff *skb) { struct hci_evt_le_big_sync_estabilished *ev = data; - struct hci_conn *bis; + struct hci_conn *bis, *conn; int i; bt_dev_dbg(hdev, "status 0x%2.2x", ev->status); @@ -6931,6 +6931,20 @@ static void hci_le_big_sync_established_evt(struct hci_dev *hdev, void *data, hci_dev_lock(hdev); + conn = hci_conn_hash_lookup_big_sync_pend(hdev, ev->handle, + ev->num_bis); + if (!conn) { + bt_dev_err(hdev, + "Unable to find connection for big 0x%2.2x", + ev->handle); + goto unlock; + } + + clear_bit(HCI_CONN_CREATE_BIG_SYNC, &conn->flags); + + conn->num_bis = 0; + memset(conn->bis, 0, sizeof(conn->num_bis)); + for (i = 0; i < ev->num_bis; i++) { u16 handle = le16_to_cpu(ev->bis[i]); __le32 interval; @@ -6980,6 +6994,10 @@ static void hci_le_big_sync_established_evt(struct hci_dev *hdev, void *data, hci_connect_cfm(bis, ev->status); } +unlock: + /* Handle any other pending BIG sync command */ + hci_le_big_create_sync_pending(hdev); + hci_dev_unlock(hdev); } diff --git a/net/bluetooth/iso.c b/net/bluetooth/iso.c index 0d98cc16bbac..9499ddfd25e7 100644 --- a/net/bluetooth/iso.c +++ b/net/bluetooth/iso.c @@ -1957,6 +1957,7 @@ int iso_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr, __u8 *flags) if (sk) { int err; + struct hci_conn *hcon = iso_pi(sk)->conn->hcon; iso_pi(sk)->qos.bcast.encryption = ev2->encryption; @@ -1965,7 +1966,8 @@ int iso_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr, __u8 *flags) if (!test_bit(BT_SK_DEFER_SETUP, &bt_sk(sk)->flags) && !test_and_set_bit(BT_SK_BIG_SYNC, &iso_pi(sk)->flags)) { - err = hci_le_big_create_sync(hdev, NULL, + err = hci_le_big_create_sync(hdev, + hcon, &iso_pi(sk)->qos, iso_pi(sk)->sync_handle, iso_pi(sk)->bc_num_bis, From patchwork Fri Nov 1 08:23:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iulia Tanasescu X-Patchwork-Id: 13858932 Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02on2042.outbound.protection.outlook.com [40.107.247.42]) (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 2738C156C76 for ; Fri, 1 Nov 2024 08:24:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.247.42 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730449451; cv=fail; b=pouJgTp3N0VYvWXqccX0eSkamrKfKgt4ac2rsGvGMK4mTmQh3k1hJvvquvuPaEn4lcNfCCHIRajsqEQ0/IQVNGJEH9gQwqDifamZgzVEWCeyaSyxdG/xLXJWRdCf7egrMaDmsOlZI2SRPsAHeiiaaYmojEpo0duBwVzgVjU5Fbc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730449451; c=relaxed/simple; bh=wyiwqHmXv/DD2LyGbzxWNdQTggJJRkA4M8xNs2AIpNs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=m67WY7RcDiTsXDGf97Qw+FcLys09+lyxGjrwaq6dBEp7vMjjddP5TTF7rwpinhIK5fIzIWJS5FCbfSOeRindn+cJxcbJayHNsUNvh5GifpN/AbQpSjpp8iGFJlP7FT72ji8fSUIO6CbkW9RaSd5rujY6XyHT0al6bPXYkEEOmL8= 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=mTEvCG/t; arc=fail smtp.client-ip=40.107.247.42 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="mTEvCG/t" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Kf33n76H6Mf4F0APHfCnp8uDjlKqu1AwYl3xlKE8MEIhsMmsEJqzpSzE9IXrVV8MXCLR+jcrkXg2Ab4lSGF52EUbVZw7bwcH9QxfRhxfczWNEPFi910WPJHJc6WY0W4OfrIfFAOufHAPjGTUOzS0eZGEY4uPdeJL+YgJSYRHq4fgSR5gMpP2aBAzdDjOqvUeNGtVRt75gH8fhexmDHG7uI7Jay419gsnyara/0P+lX6dPH3P77IqiGtt8CG6qsyfdrtsYCa160i73kxNO0JYXQXHsl2N0p2wjyCbPd/arHzfxxCJdD8cOUZ2qCIE3wGAkajt0OcF4UJuh8oXz9IyXg== 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=vUfmV/m13OP02gDNwYKJTs22lUcCvXpe9sBkaea0wfE=; b=QSyXrNP17kePuU73Dw6zLbrX8KNaQTWiGhGumo2JS6vYAJBYUdVxRBZQCECDbzA0SVc7TnRIzrbYt+Ctz+Sr6fLfTE67knLXQ3gqaXoo/rvM4Rn6rBYWcIzRYjAuAonnoFUnTahnVxFyRoh0JtEnc/4KKQh0jhD5FG6EYnh2B0xoOwc3qrjnmx40+FE03pCoLohlALSgC+GBzB5V1EQCZY0RFM+MX/gqqz46cxpD28ZnzRi6rnkgSLPotoZRkpOzFoXUT/BPH53v4RaiqN2rUPaV/8rMaxyVlcAaSzE569sEg3z1Di5raKNsbOY7oNUmPhzWnDOYNIwfRe4QKnKZQQ== 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=vUfmV/m13OP02gDNwYKJTs22lUcCvXpe9sBkaea0wfE=; b=mTEvCG/t6BGkRxl+05221nQtca+ovTjl7M5OVhfmIJz3nkVry42v8xUVdTMWuTu3ftqSP+/ljbWEY5miMISGK9wtMVRYcca3XF9N4YS/q/M99g/RzvTLSVADvGAxL6ovrx4SClmtSlgwbzH8AsTzWZ6JqSTEsytzFEY0eUbTaM7N9Qe27aqOXgKb/c2MrvUrOzlcY/ZLAZmEnZXOHLYmwo7ViPL8zxYG4nTPwwShMUXrwsIAv64zzLGt3gRf3bipH2n7tuUufv++O5a6lul1BsOmUqveL5yZZKDCKJzpEPwZd9K4AEZYyW1bU00EDAdWgoP7oO+aqjR0ESZu3yoAtg== 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 AM8PR04MB7921.eurprd04.prod.outlook.com (2603:10a6:20b:247::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20; Fri, 1 Nov 2024 08:24:03 +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.8093.027; Fri, 1 Nov 2024 08:24:03 +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 4/4] Bluetooth: ISO: Update hci_conn_hash_lookup_big for Broadcast slave Date: Fri, 1 Nov 2024 10:23:39 +0200 Message-ID: <20241101082339.4278-5-iulia.tanasescu@nxp.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241101082339.4278-1-iulia.tanasescu@nxp.com> References: <20241101082339.4278-1-iulia.tanasescu@nxp.com> X-ClientProxiedBy: AS4P189CA0033.EURP189.PROD.OUTLOOK.COM (2603:10a6:20b:5dd::6) 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_|AM8PR04MB7921:EE_ X-MS-Office365-Filtering-Correlation-Id: 1d0669ff-5d5c-42b9-c5ef-08dcfa4e8b6e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|52116014|376014|38350700014; X-Microsoft-Antispam-Message-Info: iGK5JSpqAeyvPJCvLcEijJzL1eIkpdVaJXxYIGFnAf/2D8lPLw2inwXbmUM4bgnFoEurNNe3c3MQZmx3AOjKS6jzpsTbl0ORAfvlgr1r/CFvR3k2HsGoU8CXdrOWnMYnMWlWNFYo2INYj/ZNtZi1captfG3Df0mogDVKbLHXxKiKEOs1Hh0EZ9G/RK1noUS66Tf+m11AdxqIH0nq1wNkW5SGjHnj9ky5a3bblpClCdAtlK2BqYoZazxm0SDBPdIs8450EO3Qhb3RysgcCxT5Y1SU7MgFPJUsfG2SSlGrlE4JolN5LEjLoGcAFvpNYVGqT42e+JHBxEHcF3EgJrXra4XmqkeG+CO0O2k6w4qWRnTp1qm+niGOkjdE2BTyR2NYowNwTi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.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(1800799024)(52116014)(376014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 5FQXA6TTWSQ8O+ifW0iiNs+fAoI323I7M+IVjdzKmmpeIrQc7zFiq4WsAwIXflcVMTMHn0KKDVR03JHuEqAvhvvl1201gxJ2nR+xhoL+gKGPM9HLeIqzyQudLQuoGMBu84AoSpzhURQLuS1kt4zFM0kHz0yaoys2D7cz0vF2JcHlidbX9f3Y801iQqonJJI9Fe2Z6d2ok7aGnUdMkGu0XxxBU2mV89lImmzASj5HvgWkirKXbPAZujez0W+eJjLglBWCmC2uSG7oAWiXgWxC9ocGVSYZ11RijSdv2wciLYduHBq7JkbGOxpJbmzmc9RWJtOdV9/Gk1UEHNGz2q+2jEYP14Kq+xH9SaIXEUSC1FSzg9nV7zGKUN/FvgQXuEOBbNY6PhTqJBltuNBqfHyY5rzt3hMwrWqhuxW+Leoz9EXYFv6lHWh9+mqWEG2cMUJNCE4EqJxPcgza9z3JWFVD1WGPg/sOjTQ55+cyMSA0L1nml64/Jrtvyimsl7CS1YHlUfbjAmIt8ZsefKVliq1iTNaeYV1oCuJ+MQNSQ7CCzwgqiJF/sVojtV6pWjK4tuBw6i/qeaw/qxXUIhIIeQakcTQ1KXF/aHRVkGI5ur3SOfifNQDO08IP52/ecT/Y2kUpcopTR6FCTjigRQjALPmNyyiu8iBkbbe7BJn6gaDzDAcxE+mhviQ3cMvN4gBJsGrKTAn6ncjPCX3lDtuanmVpZ6Hpz4NpatzMRKu+ybfiUpsj6z84c/+sPZMoocaevUQgluHMRS8JgO5Xo/Zi4S8oEwZq7zfHJdvR+AH9yql/V5dzonxPRENChH1KX2+kax8gy4OfcCbWXzskebRY25cfHjmzKydf8HXb3wT0Iq4oh1mH55y6pmPjul8OiaVRanWWXWAhe3dLw3PieeHOnreVDMfOSwgltWzScM+SoFRUZuAxpJM6viQ6b4TUy/00jrN6b7THuHaJvDEcj6pjY3/Ldqke7TJfmmNuljwuY9xGk8qNlrNbioxXaNVRTag6qfiODLjbWvduyKCnmbNjQ47+o+n32UT3zZalog0QCKPV3pgaE3+IRC/HpXU5kbRcfKjvEkKcr3ScKqnsW281AvjzZWXTF30FRoVhnGGC917iX0O9p4wSJa+0QQf9If5+WCgftgIrfRB3K/+pTqbzUK0EUuCzQuMuDJoKVniuIawLEsJT4Vo/eUOMG3zMILrN9ORP14YrNs+GfIbtSB/kBeXDz0G4DgK9UAbNF3f8B7mbG4rXBAfdpTpImBEbP8h2mMsjxy6nr8/cZ6CZ0I9RVfJHcodddFAF0vLGevCph7+hbc8da/S7bXw8EBZeTQ/ovifzPNTLYWqebZMSx2w9fqci6HIQBTepRAld9dykAByXcGCCAAM7w91sxXyaPuw0xXDxPtlgimRmW11FO50H85tDX91uREV+Kkq1XFHAh9XlI0QHBzAJLndzWBbfZFFg49p2+xeg5aOk00q8IWiTPeVBTcmo3b4tgbOmDDP91dRH23z5hQC3SAH6MvJgZLS17gZvVdwkuIUY/PK/Rch/QakuONxQfjCpd29tSfatZH5X7O+5Ym+/Jw81Mdj9vfOqhk8nwqEEEQBBKGNhpk0+hAsCGw== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1d0669ff-5d5c-42b9-c5ef-08dcfa4e8b6e X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB8898.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Nov 2024 08:24:03.4686 (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: QoYeLqqmpac2kLugGmN83AY19JmgSKP12CGuVIUo5Gj0m8zOiTsr8z6NEKN0Z1sVj6t9i8p2fdv1EQqmsn2PUw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR04MB7921 Currently, hci_conn_hash_lookup_big only checks for BIS master connections, by filtering out connections with the destination address set. This commit updates this function to also consider BIS slave connections, since it is also used for a Broadcast Receiver to set an available BIG handle before issuing the LE BIG Create Sync command. Signed-off-by: Iulia Tanasescu --- include/net/bluetooth/hci_core.h | 12 +++++++++++- net/bluetooth/hci_event.c | 1 + net/bluetooth/iso.c | 1 - 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index c95f7e6ba255..ea798f07c5a2 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -1285,7 +1285,17 @@ static inline struct hci_conn *hci_conn_hash_lookup_big(struct hci_dev *hdev, rcu_read_lock(); list_for_each_entry_rcu(c, &h->list, list) { - if (bacmp(&c->dst, BDADDR_ANY) || c->type != ISO_LINK) + if (c->type != ISO_LINK) + continue; + + /* An ISO_LINK hcon with BDADDR_ANY as destination + * address is a Broadcast connection. A Broadcast + * slave connection is associated with a PA train, + * so the sync_handle can be used to differentiate + * from unicast. + */ + if (bacmp(&c->dst, BDADDR_ANY) && + c->sync_handle == HCI_SYNC_HANDLE_INVALID) continue; if (handle == c->iso_qos.bcast.big) { diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 2b5ba8acd1d8..aca121408369 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -6965,6 +6965,7 @@ static void hci_le_big_sync_established_evt(struct hci_dev *hdev, void *data, /* Mark PA sync as established */ set_bit(HCI_CONN_PA_SYNC, &bis->flags); + bis->sync_handle = conn->sync_handle; bis->iso_qos.bcast.big = ev->handle; memset(&interval, 0, sizeof(interval)); memcpy(&interval, ev->latency, sizeof(ev->latency)); diff --git a/net/bluetooth/iso.c b/net/bluetooth/iso.c index 9499ddfd25e7..9e119da43147 100644 --- a/net/bluetooth/iso.c +++ b/net/bluetooth/iso.c @@ -1839,7 +1839,6 @@ static void iso_conn_ready(struct iso_conn *conn) if (!bacmp(&hcon->dst, BDADDR_ANY)) { bacpy(&hcon->dst, &iso_pi(parent)->dst); hcon->dst_type = iso_pi(parent)->dst_type; - hcon->sync_handle = iso_pi(parent)->sync_handle; } if (ev3) {