* [RFC] Bluetooth: hci_event: Rework hci_store_wake_reason
@ 2024-01-09 15:30 Luiz Augusto von Dentz
2024-01-09 15:37 ` bluez.test.bot
2024-01-09 17:55 ` bluez.test.bot
0 siblings, 2 replies; 6+ messages in thread
From: Luiz Augusto von Dentz @ 2024-01-09 15:30 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This reworks the hci_store_wake_reason so it doesn't attempt to parse
the events inline and instead just become a helper for event callbacks
to call to when they are considered a valid event to wakeup.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
---
net/bluetooth/hci_event.c | 101 +++++++++++---------------------------
1 file changed, 29 insertions(+), 72 deletions(-)
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 22b22c264c2a..92e673903582 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -3135,6 +3135,26 @@ static void hci_inquiry_result_evt(struct hci_dev *hdev, void *edata,
hci_dev_unlock(hdev);
}
+static void hci_wakeup(struct hci_dev *hdev, bdaddr_t *addr, u8 addr_type)
+{
+ /* If we are currently suspended and this is the first BT event seen,
+ * save the wake reason associated with the event.
+ */
+ if (!hdev->suspended || hdev->wake_reason)
+ return;
+
+ /* Default to remote wake. Values for wake_reason are documented in the
+ * Bluez mgmt api docs.
+ */
+ if (addr) {
+ hdev->wake_reason = MGMT_WAKE_REASON_REMOTE_WAKE;
+ bacpy(&hdev->wake_addr, addr);
+ hdev->wake_addr_type = addr_type;
+ } else {
+ hdev->wake_reason = MGMT_WAKE_REASON_UNEXPECTED;
+ }
+}
+
static void hci_conn_complete_evt(struct hci_dev *hdev, void *data,
struct sk_buff *skb)
{
@@ -3146,6 +3166,8 @@ static void hci_conn_complete_evt(struct hci_dev *hdev, void *data,
hci_dev_lock(hdev);
+ hci_wakeup(hdev, &ev->bdaddr, BDADDR_BREDR);
+
conn = hci_conn_hash_lookup_ba(hdev, ev->link_type, &ev->bdaddr);
if (!conn) {
/* In case of error status and there is no connection pending
@@ -3306,6 +3328,8 @@ static void hci_conn_request_evt(struct hci_dev *hdev, void *data,
hci_dev_lock(hdev);
+ hci_wakeup(hdev, &ev->bdaddr, BDADDR_BREDR);
+
if (hci_bdaddr_list_lookup(&hdev->reject_list, &ev->bdaddr,
BDADDR_BREDR)) {
hci_reject_conn(hdev, &ev->bdaddr);
@@ -6266,6 +6290,8 @@ static void process_adv_report(struct hci_dev *hdev, u8 type, bdaddr_t *bdaddr,
u32 flags;
u8 *ptr;
+ hci_wakeup(hdev, bdaddr, bdaddr_type);
+
switch (type) {
case LE_ADV_IND:
case LE_ADV_DIRECT_IND:
@@ -7393,75 +7419,6 @@ static bool hci_get_cmd_complete(struct hci_dev *hdev, u16 opcode,
return true;
}
-static void hci_store_wake_reason(struct hci_dev *hdev, u8 event,
- struct sk_buff *skb)
-{
- struct hci_ev_le_advertising_info *adv;
- struct hci_ev_le_direct_adv_info *direct_adv;
- struct hci_ev_le_ext_adv_info *ext_adv;
- const struct hci_ev_conn_complete *conn_complete = (void *)skb->data;
- const struct hci_ev_conn_request *conn_request = (void *)skb->data;
-
- hci_dev_lock(hdev);
-
- /* If we are currently suspended and this is the first BT event seen,
- * save the wake reason associated with the event.
- */
- if (!hdev->suspended || hdev->wake_reason)
- goto unlock;
-
- /* Default to remote wake. Values for wake_reason are documented in the
- * Bluez mgmt api docs.
- */
- hdev->wake_reason = MGMT_WAKE_REASON_REMOTE_WAKE;
-
- /* Once configured for remote wakeup, we should only wake up for
- * reconnections. It's useful to see which device is waking us up so
- * keep track of the bdaddr of the connection event that woke us up.
- */
- if (event == HCI_EV_CONN_REQUEST) {
- bacpy(&hdev->wake_addr, &conn_request->bdaddr);
- hdev->wake_addr_type = BDADDR_BREDR;
- } else if (event == HCI_EV_CONN_COMPLETE) {
- bacpy(&hdev->wake_addr, &conn_complete->bdaddr);
- hdev->wake_addr_type = BDADDR_BREDR;
- } else if (event == HCI_EV_LE_META) {
- struct hci_ev_le_meta *le_ev = (void *)skb->data;
- u8 subevent = le_ev->subevent;
- u8 *ptr = &skb->data[sizeof(*le_ev)];
- u8 num_reports = *ptr;
-
- if ((subevent == HCI_EV_LE_ADVERTISING_REPORT ||
- subevent == HCI_EV_LE_DIRECT_ADV_REPORT ||
- subevent == HCI_EV_LE_EXT_ADV_REPORT) &&
- num_reports) {
- adv = (void *)(ptr + 1);
- direct_adv = (void *)(ptr + 1);
- ext_adv = (void *)(ptr + 1);
-
- switch (subevent) {
- case HCI_EV_LE_ADVERTISING_REPORT:
- bacpy(&hdev->wake_addr, &adv->bdaddr);
- hdev->wake_addr_type = adv->bdaddr_type;
- break;
- case HCI_EV_LE_DIRECT_ADV_REPORT:
- bacpy(&hdev->wake_addr, &direct_adv->bdaddr);
- hdev->wake_addr_type = direct_adv->bdaddr_type;
- break;
- case HCI_EV_LE_EXT_ADV_REPORT:
- bacpy(&hdev->wake_addr, &ext_adv->bdaddr);
- hdev->wake_addr_type = ext_adv->bdaddr_type;
- break;
- }
- }
- } else {
- hdev->wake_reason = MGMT_WAKE_REASON_UNEXPECTED;
- }
-
-unlock:
- hci_dev_unlock(hdev);
-}
-
#define HCI_EV_VL(_op, _func, _min_len, _max_len) \
[_op] = { \
.req = false, \
@@ -7726,14 +7683,14 @@ void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb)
skb_pull(skb, HCI_EVENT_HDR_SIZE);
- /* Store wake reason if we're suspended */
- hci_store_wake_reason(hdev, event, skb);
-
bt_dev_dbg(hdev, "event 0x%2.2x", event);
hci_event_func(hdev, event, skb, &opcode, &status, &req_complete,
&req_complete_skb);
+ /* Force hci_wakeup with NULL addr if no event callback had called it */
+ hci_wakeup(hdev, NULL, 0);
+
if (req_complete) {
req_complete(hdev, status, opcode);
} else if (req_complete_skb) {
--
2.43.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* RE: [RFC] Bluetooth: hci_event: Rework hci_store_wake_reason
2024-01-09 15:30 Luiz Augusto von Dentz
@ 2024-01-09 15:37 ` bluez.test.bot
2024-01-09 17:55 ` bluez.test.bot
1 sibling, 0 replies; 6+ messages in thread
From: bluez.test.bot @ 2024-01-09 15:37 UTC (permalink / raw)
To: linux-bluetooth, luiz.dentz
[-- Attachment #1: Type: text/plain, Size: 553 bytes --]
This is an automated email and please do not reply to this email.
Dear Submitter,
Thank you for submitting the patches to the linux bluetooth mailing list.
While preparing the CI tests, the patches you submitted couldn't be applied to the current HEAD of the repository.
----- Output -----
error: patch failed: net/bluetooth/hci_event.c:7393
error: net/bluetooth/hci_event.c: patch does not apply
hint: Use 'git am --show-current-patch' to see the failed patch
Please resolve the issue and submit the patches again.
---
Regards,
Linux Bluetooth
^ permalink raw reply [flat|nested] 6+ messages in thread
* [RFC] Bluetooth: hci_event: Rework hci_store_wake_reason
@ 2024-01-09 16:55 Luiz Augusto von Dentz
2024-01-09 17:22 ` bluez.test.bot
2024-01-09 17:56 ` bluez.test.bot
0 siblings, 2 replies; 6+ messages in thread
From: Luiz Augusto von Dentz @ 2024-01-09 16:55 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This reworks the hci_store_wake_reason so it doesn't attempt to parse
the events inline and instead just become a helper for event callbacks
to call to when they are considered a valid event to wakeup.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
---
net/bluetooth/hci_event.c | 101 +++++++++++---------------------------
1 file changed, 29 insertions(+), 72 deletions(-)
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 22b22c264c2a..92e673903582 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -3135,6 +3135,26 @@ static void hci_inquiry_result_evt(struct hci_dev *hdev, void *edata,
hci_dev_unlock(hdev);
}
+static void hci_wakeup(struct hci_dev *hdev, bdaddr_t *addr, u8 addr_type)
+{
+ /* If we are currently suspended and this is the first BT event seen,
+ * save the wake reason associated with the event.
+ */
+ if (!hdev->suspended || hdev->wake_reason)
+ return;
+
+ /* Default to remote wake. Values for wake_reason are documented in the
+ * Bluez mgmt api docs.
+ */
+ if (addr) {
+ hdev->wake_reason = MGMT_WAKE_REASON_REMOTE_WAKE;
+ bacpy(&hdev->wake_addr, addr);
+ hdev->wake_addr_type = addr_type;
+ } else {
+ hdev->wake_reason = MGMT_WAKE_REASON_UNEXPECTED;
+ }
+}
+
static void hci_conn_complete_evt(struct hci_dev *hdev, void *data,
struct sk_buff *skb)
{
@@ -3146,6 +3166,8 @@ static void hci_conn_complete_evt(struct hci_dev *hdev, void *data,
hci_dev_lock(hdev);
+ hci_wakeup(hdev, &ev->bdaddr, BDADDR_BREDR);
+
conn = hci_conn_hash_lookup_ba(hdev, ev->link_type, &ev->bdaddr);
if (!conn) {
/* In case of error status and there is no connection pending
@@ -3306,6 +3328,8 @@ static void hci_conn_request_evt(struct hci_dev *hdev, void *data,
hci_dev_lock(hdev);
+ hci_wakeup(hdev, &ev->bdaddr, BDADDR_BREDR);
+
if (hci_bdaddr_list_lookup(&hdev->reject_list, &ev->bdaddr,
BDADDR_BREDR)) {
hci_reject_conn(hdev, &ev->bdaddr);
@@ -6266,6 +6290,8 @@ static void process_adv_report(struct hci_dev *hdev, u8 type, bdaddr_t *bdaddr,
u32 flags;
u8 *ptr;
+ hci_wakeup(hdev, bdaddr, bdaddr_type);
+
switch (type) {
case LE_ADV_IND:
case LE_ADV_DIRECT_IND:
@@ -7393,75 +7419,6 @@ static bool hci_get_cmd_complete(struct hci_dev *hdev, u16 opcode,
return true;
}
-static void hci_store_wake_reason(struct hci_dev *hdev, u8 event,
- struct sk_buff *skb)
-{
- struct hci_ev_le_advertising_info *adv;
- struct hci_ev_le_direct_adv_info *direct_adv;
- struct hci_ev_le_ext_adv_info *ext_adv;
- const struct hci_ev_conn_complete *conn_complete = (void *)skb->data;
- const struct hci_ev_conn_request *conn_request = (void *)skb->data;
-
- hci_dev_lock(hdev);
-
- /* If we are currently suspended and this is the first BT event seen,
- * save the wake reason associated with the event.
- */
- if (!hdev->suspended || hdev->wake_reason)
- goto unlock;
-
- /* Default to remote wake. Values for wake_reason are documented in the
- * Bluez mgmt api docs.
- */
- hdev->wake_reason = MGMT_WAKE_REASON_REMOTE_WAKE;
-
- /* Once configured for remote wakeup, we should only wake up for
- * reconnections. It's useful to see which device is waking us up so
- * keep track of the bdaddr of the connection event that woke us up.
- */
- if (event == HCI_EV_CONN_REQUEST) {
- bacpy(&hdev->wake_addr, &conn_request->bdaddr);
- hdev->wake_addr_type = BDADDR_BREDR;
- } else if (event == HCI_EV_CONN_COMPLETE) {
- bacpy(&hdev->wake_addr, &conn_complete->bdaddr);
- hdev->wake_addr_type = BDADDR_BREDR;
- } else if (event == HCI_EV_LE_META) {
- struct hci_ev_le_meta *le_ev = (void *)skb->data;
- u8 subevent = le_ev->subevent;
- u8 *ptr = &skb->data[sizeof(*le_ev)];
- u8 num_reports = *ptr;
-
- if ((subevent == HCI_EV_LE_ADVERTISING_REPORT ||
- subevent == HCI_EV_LE_DIRECT_ADV_REPORT ||
- subevent == HCI_EV_LE_EXT_ADV_REPORT) &&
- num_reports) {
- adv = (void *)(ptr + 1);
- direct_adv = (void *)(ptr + 1);
- ext_adv = (void *)(ptr + 1);
-
- switch (subevent) {
- case HCI_EV_LE_ADVERTISING_REPORT:
- bacpy(&hdev->wake_addr, &adv->bdaddr);
- hdev->wake_addr_type = adv->bdaddr_type;
- break;
- case HCI_EV_LE_DIRECT_ADV_REPORT:
- bacpy(&hdev->wake_addr, &direct_adv->bdaddr);
- hdev->wake_addr_type = direct_adv->bdaddr_type;
- break;
- case HCI_EV_LE_EXT_ADV_REPORT:
- bacpy(&hdev->wake_addr, &ext_adv->bdaddr);
- hdev->wake_addr_type = ext_adv->bdaddr_type;
- break;
- }
- }
- } else {
- hdev->wake_reason = MGMT_WAKE_REASON_UNEXPECTED;
- }
-
-unlock:
- hci_dev_unlock(hdev);
-}
-
#define HCI_EV_VL(_op, _func, _min_len, _max_len) \
[_op] = { \
.req = false, \
@@ -7726,14 +7683,14 @@ void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb)
skb_pull(skb, HCI_EVENT_HDR_SIZE);
- /* Store wake reason if we're suspended */
- hci_store_wake_reason(hdev, event, skb);
-
bt_dev_dbg(hdev, "event 0x%2.2x", event);
hci_event_func(hdev, event, skb, &opcode, &status, &req_complete,
&req_complete_skb);
+ /* Force hci_wakeup with NULL addr if no event callback had called it */
+ hci_wakeup(hdev, NULL, 0);
+
if (req_complete) {
req_complete(hdev, status, opcode);
} else if (req_complete_skb) {
--
2.43.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* RE: [RFC] Bluetooth: hci_event: Rework hci_store_wake_reason
2024-01-09 16:55 [RFC] Bluetooth: hci_event: Rework hci_store_wake_reason Luiz Augusto von Dentz
@ 2024-01-09 17:22 ` bluez.test.bot
2024-01-09 17:56 ` bluez.test.bot
1 sibling, 0 replies; 6+ messages in thread
From: bluez.test.bot @ 2024-01-09 17:22 UTC (permalink / raw)
To: linux-bluetooth, luiz.dentz
[-- Attachment #1: Type: text/plain, Size: 553 bytes --]
This is an automated email and please do not reply to this email.
Dear Submitter,
Thank you for submitting the patches to the linux bluetooth mailing list.
While preparing the CI tests, the patches you submitted couldn't be applied to the current HEAD of the repository.
----- Output -----
error: patch failed: net/bluetooth/hci_event.c:7393
error: net/bluetooth/hci_event.c: patch does not apply
hint: Use 'git am --show-current-patch' to see the failed patch
Please resolve the issue and submit the patches again.
---
Regards,
Linux Bluetooth
^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: [RFC] Bluetooth: hci_event: Rework hci_store_wake_reason
2024-01-09 15:30 Luiz Augusto von Dentz
2024-01-09 15:37 ` bluez.test.bot
@ 2024-01-09 17:55 ` bluez.test.bot
1 sibling, 0 replies; 6+ messages in thread
From: bluez.test.bot @ 2024-01-09 17:55 UTC (permalink / raw)
To: linux-bluetooth, luiz.dentz
[-- Attachment #1: Type: text/plain, Size: 1826 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=815440
---Test result---
Test Summary:
CheckPatch PASS 0.67 seconds
GitLint PASS 0.34 seconds
SubjectPrefix PASS 0.13 seconds
BuildKernel PASS 27.86 seconds
CheckAllWarning PASS 30.76 seconds
CheckSparse WARNING 36.03 seconds
CheckSmatch WARNING 99.10 seconds
BuildKernel32 PASS 27.23 seconds
TestRunnerSetup PASS 431.79 seconds
TestRunner_l2cap-tester PASS 22.75 seconds
TestRunner_iso-tester PASS 46.87 seconds
TestRunner_bnep-tester PASS 6.84 seconds
TestRunner_mgmt-tester PASS 161.82 seconds
TestRunner_rfcomm-tester PASS 10.68 seconds
TestRunner_sco-tester PASS 14.35 seconds
TestRunner_ioctl-tester PASS 12.01 seconds
TestRunner_mesh-tester PASS 8.81 seconds
TestRunner_smp-tester PASS 9.60 seconds
TestRunner_userchan-tester PASS 7.18 seconds
IncrementalBuild PASS 25.99 seconds
Details
##############################
Test: CheckSparse - WARNING
Desc: Run sparse tool with linux kernel
Output:
net/bluetooth/hci_event.c: note: in included file (through include/net/bluetooth/hci_core.h):
##############################
Test: CheckSmatch - WARNING
Desc: Run smatch tool with source
Output:
net/bluetooth/hci_event.c: note: in included file (through include/net/bluetooth/hci_core.h):
---
Regards,
Linux Bluetooth
^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: [RFC] Bluetooth: hci_event: Rework hci_store_wake_reason
2024-01-09 16:55 [RFC] Bluetooth: hci_event: Rework hci_store_wake_reason Luiz Augusto von Dentz
2024-01-09 17:22 ` bluez.test.bot
@ 2024-01-09 17:56 ` bluez.test.bot
1 sibling, 0 replies; 6+ messages in thread
From: bluez.test.bot @ 2024-01-09 17:56 UTC (permalink / raw)
To: linux-bluetooth, luiz.dentz
[-- Attachment #1: Type: text/plain, Size: 1826 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=815468
---Test result---
Test Summary:
CheckPatch PASS 0.67 seconds
GitLint PASS 0.34 seconds
SubjectPrefix PASS 0.13 seconds
BuildKernel PASS 27.93 seconds
CheckAllWarning PASS 30.32 seconds
CheckSparse WARNING 35.68 seconds
CheckSmatch WARNING 98.86 seconds
BuildKernel32 PASS 26.84 seconds
TestRunnerSetup PASS 432.72 seconds
TestRunner_l2cap-tester PASS 22.95 seconds
TestRunner_iso-tester PASS 46.74 seconds
TestRunner_bnep-tester PASS 6.84 seconds
TestRunner_mgmt-tester PASS 167.11 seconds
TestRunner_rfcomm-tester PASS 10.85 seconds
TestRunner_sco-tester PASS 14.38 seconds
TestRunner_ioctl-tester PASS 12.56 seconds
TestRunner_mesh-tester PASS 8.73 seconds
TestRunner_smp-tester PASS 9.68 seconds
TestRunner_userchan-tester PASS 7.24 seconds
IncrementalBuild PASS 26.41 seconds
Details
##############################
Test: CheckSparse - WARNING
Desc: Run sparse tool with linux kernel
Output:
net/bluetooth/hci_event.c: note: in included file (through include/net/bluetooth/hci_core.h):
##############################
Test: CheckSmatch - WARNING
Desc: Run smatch tool with source
Output:
net/bluetooth/hci_event.c: note: in included file (through include/net/bluetooth/hci_core.h):
---
Regards,
Linux Bluetooth
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-01-09 17:56 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-09 16:55 [RFC] Bluetooth: hci_event: Rework hci_store_wake_reason Luiz Augusto von Dentz
2024-01-09 17:22 ` bluez.test.bot
2024-01-09 17:56 ` bluez.test.bot
-- strict thread matches above, loose matches on Subject: below --
2024-01-09 15:30 Luiz Augusto von Dentz
2024-01-09 15:37 ` bluez.test.bot
2024-01-09 17:55 ` 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;
as well as URLs for NNTP newsgroup(s).