All of lore.kernel.org
 help / color / mirror / Atom feed
From: Manish Mandlik <mmandlik@google.com>
To: marcel@holtmann.org, luiz.dentz@gmail.com
Cc: chromeos-bluetooth-upstreaming@chromium.org,
	linux-bluetooth@vger.kernel.org,
	Manish Mandlik <mmandlik@google.com>,
	Miao-chen Chou <mcchou@chromium.org>
Subject: [BlueZ PATCH v2 3/9] adv_monitor: Clear tracked devices on resume
Date: Wed, 13 Apr 2022 13:54:43 -0700	[thread overview]
Message-ID: <20220413135223.BlueZ.v2.3.Icb5e0b991a133d9b8a91a23f1c9b2ca41e151a27@changeid> (raw)
In-Reply-To: <20220413135223.BlueZ.v2.1.I21d5ed25e9a0a2427bddbd6d4ec04d80d735fc53@changeid>

Clear any tracked devices on system resume. Matched devices will be
found again if they are in range after resume.

Reviewed-by: Miao-chen Chou <mcchou@chromium.org>
---

Changes in v2:
- Fix compiler error by replacing btd_adv_monitor_offload_supported()
  with btd_adv_monitor_offload_enabled().

 src/adapter.c     |  1 +
 src/adv_monitor.c | 19 +++++++++++++++++++
 src/adv_monitor.h |  2 ++
 3 files changed, 22 insertions(+)

diff --git a/src/adapter.c b/src/adapter.c
index 97ce26f8e..2ae8a9ae9 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -9183,6 +9183,7 @@ static void controller_resume_callback(uint16_t index, uint16_t length,
 	info("Controller resume with wake event 0x%x", ev->wake_reason);
 
 	controller_resume_notify(adapter);
+	btd_adv_monitor_resume(adapter->adv_monitor_manager);
 }
 
 static void device_blocked_callback(uint16_t index, uint16_t length,
diff --git a/src/adv_monitor.c b/src/adv_monitor.c
index a7763df10..18ce839e9 100644
--- a/src/adv_monitor.c
+++ b/src/adv_monitor.c
@@ -2248,6 +2248,7 @@ static void clear_device_lost_timer(void *data, void *user_data)
 	if (dev->lost_timer) {
 		timeout_remove(dev->lost_timer);
 		dev->lost_timer = 0;
+		dev->found = false;
 
 		monitor = dev->monitor;
 
@@ -2289,3 +2290,21 @@ void btd_adv_monitor_power_down(struct btd_adv_monitor_manager *manager)
 	/* Clear any running DeviceLost timers in case of power down */
 	queue_foreach(manager->apps, clear_lost_timers_from_app, NULL);
 }
+
+/* Handles wake from system suspend scenario */
+void btd_adv_monitor_resume(struct btd_adv_monitor_manager *manager)
+{
+	if (!manager) {
+		error("Unexpected NULL btd_adv_monitor_manager object upon "
+				"system resume");
+		return;
+	}
+
+	/* Clear any tracked devices on system resume. Matched devices will be
+	 * found again if they are in range after resume. (No need to do this if
+	 * the controller based monitoring is supported as the kernel clears all
+	 * monitored devices on resume.
+	 */
+	if (!btd_adv_monitor_offload_enabled(manager))
+		queue_foreach(manager->apps, clear_lost_timers_from_app, NULL);
+}
diff --git a/src/adv_monitor.h b/src/adv_monitor.h
index c6bb8a68a..3b5b1200a 100644
--- a/src/adv_monitor.h
+++ b/src/adv_monitor.h
@@ -42,4 +42,6 @@ void btd_adv_monitor_device_remove(struct btd_adv_monitor_manager *manager,
 
 void btd_adv_monitor_power_down(struct btd_adv_monitor_manager *manager);
 
+void btd_adv_monitor_resume(struct btd_adv_monitor_manager *manager);
+
 #endif /* __ADV_MONITOR_H */
-- 
2.36.0.rc0.470.gd361397f0d-goog


  parent reply	other threads:[~2022-04-13 20:55 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-13 20:54 [BlueZ PATCH v2 1/9] adv_monitor: Disable RSSIHighTimeout for SW based filtering Manish Mandlik
2022-04-13 20:54 ` [BlueZ PATCH v2 2/9] adv_monitor: Don't send DeviceFound for already found devices Manish Mandlik
2022-04-13 20:54 ` Manish Mandlik [this message]
2022-04-13 20:54 ` [BlueZ PATCH v2 4/9] adv_monitor: Do not remove the device while monitoring Manish Mandlik
2022-04-13 20:54 ` [BlueZ PATCH v2 5/9] monitor: Display AdvMonitor DeviceFound/Lost events Manish Mandlik
2022-04-13 20:54 ` [BlueZ PATCH v2 6/9] adv_monitor: Do not merge monitors with non-overlapping RSSI Manish Mandlik
2022-04-13 20:54 ` [BlueZ PATCH v2 7/9] adv_monitor: Add the monitor Release reason Manish Mandlik
2022-04-13 21:48   ` Luiz Augusto von Dentz
     [not found]     ` <CAGPPCLB1j+KV_ZCY7xQe9sHheWWAQPxaRF9pH9R53mAVdmQfHg@mail.gmail.com>
2022-04-13 22:42       ` Luiz Augusto von Dentz
     [not found]         ` <CAGPPCLBaoP=dXKp53F7Q3Pg4pnSELdkt_ns9Aw-A-yYk6Vs0yw@mail.gmail.com>
2022-04-20 20:02           ` Luiz Augusto von Dentz
2022-04-13 20:54 ` [BlueZ PATCH v2 8/9] client: Display the AdvMonitor " Manish Mandlik
2022-04-13 20:54 ` [BlueZ PATCH v2 9/9] test: " Manish Mandlik
2022-04-15  9:34 ` [BlueZ,v2,1/9] adv_monitor: Disable RSSIHighTimeout for SW based filtering bluez.test.bot

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=20220413135223.BlueZ.v2.3.Icb5e0b991a133d9b8a91a23f1c9b2ca41e151a27@changeid \
    --to=mmandlik@google.com \
    --cc=chromeos-bluetooth-upstreaming@chromium.org \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=luiz.dentz@gmail.com \
    --cc=marcel@holtmann.org \
    --cc=mcchou@chromium.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.