Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp1455333pxb; Thu, 14 Apr 2022 06:40:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzZlU7vFnTOUe8UYxr6ucFZ8NHpctRuyn2pXlJ/PGvPLIZ0Iw475kIJhtQkvWMnktxxM+hE X-Received: by 2002:a63:5d1c:0:b0:39c:c5d7:ebbb with SMTP id r28-20020a635d1c000000b0039cc5d7ebbbmr2345978pgb.54.1649943609233; Thu, 14 Apr 2022 06:40:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649943609; cv=none; d=google.com; s=arc-20160816; b=ZKPB/2JeAe5QEiYV3msSKt1eXqoWVvZmu2Co6bHGKYx3PfZH8qzlbQC/0ND2jTjpTv HSVvB1uqxik9Va3pbWxgJWo1FUBUsD+iq7MoxwdWH/bse+Rsv3Y+7tW+mrCExTZt8mef ivw/NcW5/ryH2XTGEzKcCIbJdnhnzMLTitKDTPWWtenlASX0KUJSLaeQmFCMibOkGjPg WmuWHGB31xVKnfrw9fiRLGyZFGEHFXlJj83CVd9TmwAXAYsVN0Qg6Rith3U0pMFjYfDQ OEOKtHxnSkBW5AmTnvpJU/GUFmWT632XjYK2GY2+reIbB73HNVOINF664OaGMBjW9t/o 7cuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=xWK0YHOGJv6pMBeiWUrPqa8co5ypF3AZhZlrNIFGl8s=; b=lnHCBJspxQBsgEO/NGvJLnfv31zXB6JedRE2LTuRv8CcuzvMVluDuf3GiKYwu1TdNo Ww76pULJdxw8dHUNlQnNp2Zztlfh6jUzbK8IRr3R+1beDhM4Hx9ZBJsw7Unpc1ow/1vU yMHI2wExwgm+dQk6Q2wObYCBRhFbC0nJVyzHAvJzmuxRgrslvZXtse5JcPWKowv1O0kz 84fhPgPAiJGw3IbvZt/YfCEz3BaLs6IZ4fN4mEPQm6zD7y+oDdqDeV7Vha79giA82OLT u9DbgiiWxi2ndt2SJlwAOI2MYWPAIBwzqb1sZI3PvXEyW4kyV58/npxN4CjDX1bGMxHS 9Dlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=Zv4mgHJK; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t189-20020a6381c6000000b003a1c51d9e28si989802pgd.610.2022.04.14.06.39.24; Thu, 14 Apr 2022 06:40:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=Zv4mgHJK; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236230AbiDMU5Z (ORCPT + 99 others); Wed, 13 Apr 2022 16:57:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40390 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237910AbiDMU5X (ORCPT ); Wed, 13 Apr 2022 16:57:23 -0400 Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DBDEF55BEA for ; Wed, 13 Apr 2022 13:55:01 -0700 (PDT) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-2ec08c1dd2dso26249087b3.20 for ; Wed, 13 Apr 2022 13:55:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=xWK0YHOGJv6pMBeiWUrPqa8co5ypF3AZhZlrNIFGl8s=; b=Zv4mgHJKAUoN290A0tMeH3nMjTefK74/4A6oWPrDt8Sw4FWprkc1Uk2J9knt96E5iT rxVWah42f/PkWALrP8cynxMmfIlN6hvwmVxrEaiF/QZcB+1hIBaAF1J8XvhBUnngbPnN DMcMP3f505Sefu5H65MbcdKsPizqhoWu9U0h51iUMldVySHdzsvgxxZR+hOyWZasaZKx JkC0lTjQLhtEqFF04aYU+MVKzViW4vtnnS8RDYS/3wP4Qa7AKrgLQbgJ+5d/vHxd+poT AUHFw4ZWsMKjb0ClaEdVnIpRN9IODcdKGOvIiT2zTQflxoY5salG+udQ6gh+6+W2fzB1 sJ8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=xWK0YHOGJv6pMBeiWUrPqa8co5ypF3AZhZlrNIFGl8s=; b=A8hX9Vol4/hNZK4n64n69jbLfwbqZy1uv6+ocst3xqBQ2qAw6n7U6U8iiz//su6OaS cE4j2gkq9hr6iOkP/NmmDVrz4j9SQzgoaUqc2i3PEbY6tqWnYFC/1vTD9x1jjakkdtBu KC4evSsk9F0tlRdAQMfJC4Eijrm70qaHQS2ltX4jPF8Wmp+0seesRezwI1GsIJSVsGGu E09Q+RIa/A6XxxLyFYZ3mYPR1bA7nMVodqeWUG73lfN2hoyt8FIoiyo5xiBzOLcfB21F VEWdM9tDmgqZKylhWZf8xp/LEzfmyHuyHov8Vs7ZscddVo12TEWJ9DjaRDiY+3HymfuW X9vQ== X-Gm-Message-State: AOAM530LJk8Vt3tnlG9nW4Tn/kGw+lIjjCKmRpm1sjwXooMtQwKJDQNv 1gNvoOiZ1bW0fcEKxDO81aXQMztZV1r3aQ== X-Received: from mmandlik.mtv.corp.google.com ([2620:15c:202:201:2620:46aa:79ff:778d]) (user=mmandlik job=sendgmr) by 2002:a25:32c3:0:b0:641:4d40:3065 with SMTP id y186-20020a2532c3000000b006414d403065mr635084yby.403.1649883301130; Wed, 13 Apr 2022 13:55:01 -0700 (PDT) Date: Wed, 13 Apr 2022 13:54:43 -0700 In-Reply-To: <20220413135223.BlueZ.v2.1.I21d5ed25e9a0a2427bddbd6d4ec04d80d735fc53@changeid> Message-Id: <20220413135223.BlueZ.v2.3.Icb5e0b991a133d9b8a91a23f1c9b2ca41e151a27@changeid> Mime-Version: 1.0 References: <20220413135223.BlueZ.v2.1.I21d5ed25e9a0a2427bddbd6d4ec04d80d735fc53@changeid> X-Mailer: git-send-email 2.36.0.rc0.470.gd361397f0d-goog Subject: [BlueZ PATCH v2 3/9] adv_monitor: Clear tracked devices on resume From: Manish Mandlik To: marcel@holtmann.org, luiz.dentz@gmail.com Cc: chromeos-bluetooth-upstreaming@chromium.org, linux-bluetooth@vger.kernel.org, Manish Mandlik , Miao-chen Chou Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org 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 --- 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