From 90d264b77bde9f575b292e3ff94f58adab198fd9 Mon Sep 17 00:00:00 2001 From: Aleksander Wasaznik Date: Thu, 19 Sep 2024 11:05:27 +0200 Subject: [PATCH] Bluetooth: host: Process adv report in prio Since advertising report event processing defers the application callback to a different context, it's non-blocking and should be performed on in prio context to avoid blocking prio events. Signed-off-by: Aleksander Wasaznik --- subsys/bluetooth/host/hci_core.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/subsys/bluetooth/host/hci_core.c b/subsys/bluetooth/host/hci_core.c index 999ee6ec1e9b70..302d39827a8c2d 100644 --- a/subsys/bluetooth/host/hci_core.c +++ b/subsys/bluetooth/host/hci_core.c @@ -28,6 +28,7 @@ #include #include #include +#include #if DT_HAS_CHOSEN(zephyr_bt_hci) #include #else @@ -2950,6 +2951,13 @@ static inline uint8_t bt_hci_evt_get_flags(uint8_t evt[static 3]) case BT_HCI_EVT_CMD_COMPLETE: case BT_HCI_EVT_CMD_STATUS: return BT_HCI_EVT_FLAG_RECV_PRIO; + case BT_HCI_EVT_LE_META_EVENT: + switch (evt[2]) { + case BT_HCI_EVT_LE_EXT_ADVERTISING_REPORT: + return BT_HCI_EVT_FLAG_RECV_PRIO; + default: + return BT_HCI_EVT_FLAG_RECV; + } default: return BT_HCI_EVT_FLAG_RECV; } @@ -4016,6 +4024,11 @@ static const struct event_handler prio_events[] = { sizeof(struct bt_hci_evt_cmd_complete)), EVENT_HANDLER(BT_HCI_EVT_CMD_STATUS, hci_cmd_status, sizeof(struct bt_hci_evt_cmd_status)), +#if defined(CONFIG_BT_OBSERVER) + /* Redirect to handle only BT_HCI_EVT_LE_EXT_ADVERTISING_REPORT */ + EVENT_HANDLER(BT_HCI_EVT_LE_META_EVENT, hci_le_meta_event, + sizeof(struct bt_hci_evt_le_meta_event)), +#endif /* CONFIG_BT_OBSERVER */ #if defined(CONFIG_BT_CONN) EVENT_HANDLER(BT_HCI_EVT_DATA_BUF_OVERFLOW, hci_data_buf_overflow,