* [PATCH BlueZ v1] shared: rap: Defer CS Event registration until connection setup
@ 2026-06-22 6:29 Naga Bhavani Akella
2026-06-22 7:49 ` [BlueZ,v1] " bluez.test.bot
0 siblings, 1 reply; 2+ messages in thread
From: Naga Bhavani Akella @ 2026-06-22 6:29 UTC (permalink / raw)
To: linux-bluetooth
Cc: luiz.dentz, quic_mohamull, quic_hbandi, quic_anubhavg,
Naga Bhavani Akella
Move LE CS event registration from rap_probe()
to rap_accept(). rap_probe() runs during service discovery
while no ACL connection or connection handle exists,
so connection-scoped CS events cannot be delivered or
associated with a device. rap_accept() is called
after the ACL link is established, when a valid
connection handle is available and the HCI layer
can route events correctly.
Registering events at this point ensures
proper handling of CS events.
---
profiles/ranging/rap.c | 63 +++++++++++++++++++-----------------------
1 file changed, 29 insertions(+), 34 deletions(-)
diff --git a/profiles/ranging/rap.c b/profiles/ranging/rap.c
index dc57eeda6..fa3e27328 100644
--- a/profiles/ranging/rap.c
+++ b/profiles/ranging/rap.c
@@ -322,35 +322,6 @@ static int rap_probe(struct btd_service *service)
return -EINVAL;
}
- /* Get or create shared adapter-level HCI channel */
- data->adapter_data = rap_adapter_data_ref(adapter);
- if (!data->adapter_data) {
- error("Failed to get adapter HCI channel");
- bt_rap_unref(data->rap);
- free(data);
- return -EINVAL;
- }
-
- DBG("Using shared HCI channel for adapter (ref_count=%d)",
- data->adapter_data->ref_count);
-
- /* Create per-device HCI state machine with valid rap instance */
- DBG("Attaching per-device HCI state machine");
- data->hci_sm = bt_rap_attach_hci(data->rap, data->adapter_data->hci,
- btd_opts.defaults.bcs.role,
- btd_opts.defaults.bcs.cs_sync_ant_sel,
- btd_opts.defaults.bcs.max_tx_power);
-
- if (!data->hci_sm) {
- error("Failed to attach HCI state machine for device");
- rap_adapter_data_unref(data->adapter_data);
- bt_rap_unref(data->rap);
- free(data);
- return -EINVAL;
- }
-
- DBG("HCI state machine attached successfully for device");
-
rap_data_add(data);
data->ready_id = bt_rap_ready_register(data->rap, rap_ready, service,
@@ -382,6 +353,7 @@ static void rap_remove(struct btd_service *service)
static int rap_accept(struct btd_service *service)
{
struct btd_device *device = btd_service_get_device(service);
+ struct btd_adapter *adapter = device_get_adapter(device);
struct bt_gatt_client *client = btd_device_get_gatt_client(device);
struct rap_data *data = btd_service_get_user_data(service);
struct bt_att *att;
@@ -398,6 +370,33 @@ static int rap_accept(struct btd_service *service)
return -EINVAL;
}
+ /* init shared adapter HCI channel */
+ if (!data->adapter_data) {
+ data->adapter_data = rap_adapter_data_ref(adapter);
+ if (!data->adapter_data) {
+ error("Failed to get adapter HCI channel");
+ return -EINVAL;
+ }
+ DBG("Using shared HCI channel for adapter (ref_count=%d)",
+ data->adapter_data->ref_count);
+ }
+
+ /* per-device HCI state machine */
+ if (!data->hci_sm) {
+ data->hci_sm = bt_rap_attach_hci(data->rap,
+ data->adapter_data->hci,
+ btd_opts.defaults.bcs.role,
+ btd_opts.defaults.bcs.cs_sync_ant_sel,
+ btd_opts.defaults.bcs.max_tx_power);
+ if (!data->hci_sm) {
+ error("Failed to attach HCI state machine for device");
+ rap_adapter_data_unref(data->adapter_data);
+ data->adapter_data = NULL;
+ return -EINVAL;
+ }
+ DBG("HCI state machine attached successfully for device");
+ }
+
if (!bt_rap_attach(data->rap, client)) {
error("RAP unable to attach");
return -EINVAL;
@@ -408,11 +407,7 @@ static int rap_accept(struct btd_service *service)
bdaddr = device_get_address(device);
bdaddr_type = device_get_le_address_type(device);
- if (att && data->adapter_data && data->adapter_data->hci &&
- data->hci_sm) {
- /* Use bt_hci_get_conn_handle to find the connection handle
- * by bdaddr using HCIGETCONNLIST ioctl
- */
+ if (att && data->adapter_data->hci && data->hci_sm) {
if (bt_hci_get_conn_handle(data->adapter_data->hci,
(const uint8_t *) bdaddr, &handle)) {
DBG("Found conn handle 0x%04X for %s", handle, addr);
--
^ permalink raw reply related [flat|nested] 2+ messages in thread
* RE: [BlueZ,v1] shared: rap: Defer CS Event registration until connection setup
2026-06-22 6:29 [PATCH BlueZ v1] shared: rap: Defer CS Event registration until connection setup Naga Bhavani Akella
@ 2026-06-22 7:49 ` bluez.test.bot
0 siblings, 0 replies; 2+ messages in thread
From: bluez.test.bot @ 2026-06-22 7:49 UTC (permalink / raw)
To: linux-bluetooth, naga.akella
[-- Attachment #1: Type: text/plain, Size: 825 bytes --]
This is automated email and please do not reply to this email!
Dear submitter,
Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=1114528
---Test result---
Test Summary:
CheckPatch PASS 1.08 seconds
GitLint PASS 0.73 seconds
BuildEll PASS 20.15 seconds
BluezMake PASS 616.98 seconds
CheckSmatch PASS 326.97 seconds
bluezmakeextell PASS 166.59 seconds
IncrementalBuild PASS 619.54 seconds
ScanBuild PASS 932.12 seconds
https://github.com/bluez/bluez/pull/2250
---
Regards,
Linux Bluetooth
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-06-22 7:49 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-22 6:29 [PATCH BlueZ v1] shared: rap: Defer CS Event registration until connection setup Naga Bhavani Akella
2026-06-22 7:49 ` [BlueZ,v1] " bluez.test.bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox