All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pauli Virtanen <pav@iki.fi>
To: linux-bluetooth@vger.kernel.org
Cc: Pauli Virtanen <pav@iki.fi>
Subject: [PATCH 3/6] Bluetooth: ISO: don't try to do Set CIG Parameters if CIG known busy
Date: Sun, 28 May 2023 17:44:11 +0000	[thread overview]
Message-ID: <b9da7e6788c218f4c3876a5e68b90af18ba800df.1685294131.git.pav@iki.fi> (raw)
In-Reply-To: <cover.1685294131.git.pav@iki.fi>

Don't try to do set CIG parameters if we know the CIG is busy, because
we drop all connections on command failure in hci_cc_le_set_cig_params.
Trying to connect new CIS while CIG is not configurable shall not cause
other active CIS connections to fail.

Check the CIG is not busy before trying to emit the Set CIG Parameters
command.

Fixes: 26afbd826ee3 ("Bluetooth: Add initial implementation of CIS connections")
Signed-off-by: Pauli Virtanen <pav@iki.fi>
---
 net/bluetooth/hci_conn.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index 182dba4a19b5..47a8ec796d97 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -1815,6 +1815,19 @@ static bool hci_le_set_cig_params(struct hci_conn *conn, struct bt_iso_qos *qos)
 
 		/* Update CIG */
 		qos->ucast.cig = data.cig;
+	} else {
+		/* If CIG is busy, fail early because cmd error closes conns */
+		data.cig = qos->ucast.cig;
+		data.count = 0;
+
+		hci_conn_hash_list_state(hdev, find_cis, ISO_LINK,
+					 BT_CONNECT, &data);
+		if (data.count)
+			return false;
+		hci_conn_hash_list_state(hdev, find_cis, ISO_LINK,
+					 BT_CONNECTED, &data);
+		if (data.count)
+			return false;
 	}
 
 	data.pdu.cp.cig_id = qos->ucast.cig;
-- 
2.40.1


  parent reply	other threads:[~2023-05-28 17:44 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-28 17:44 [PATCH 0/6] LE Set CIG Parameters / Create CIS fixes Pauli Virtanen
2023-05-28 17:44 ` [PATCH 1/6] Bluetooth: ISO: fix maximum number of CIS in Set CIG Parameters Pauli Virtanen
2023-05-28 18:37   ` LE Set CIG Parameters / Create CIS fixes bluez.test.bot
2023-05-28 23:23   ` [PATCH 1/6] Bluetooth: ISO: fix maximum number of CIS in Set CIG Parameters Pauli Virtanen
2023-05-28 17:44 ` [PATCH 2/6] Bluetooth: ISO: use hci_sync for setting CIG parameters Pauli Virtanen
2023-05-28 17:44 ` Pauli Virtanen [this message]
2023-05-28 17:44 ` [PATCH 4/6] Bluetooth: ISO: don't try to remove CIG if there are bound CIS left Pauli Virtanen
2023-05-28 17:44 ` [PATCH 5/6] Bluetooth: ISO: use correct CIS order in Set CIG Parameters event Pauli Virtanen
2023-05-30 17:46   ` Luiz Augusto von Dentz
2023-05-28 17:44 ` [PATCH 6/6] Bluetooth: ISO: do not emit new LE Create CIS if previous is pending Pauli Virtanen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b9da7e6788c218f4c3876a5e68b90af18ba800df.1685294131.git.pav@iki.fi \
    --to=pav@iki.fi \
    --cc=linux-bluetooth@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.