Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp2279638pxp; Mon, 21 Mar 2022 15:44:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyeR6oIngsGevuG+x+WIoz6U6Fz0HY4ZniEXQmJGSwEfr4Et8SZhOVZgrEvtd7pL+OMG3Vk X-Received: by 2002:a17:902:b097:b0:154:2bda:bd38 with SMTP id p23-20020a170902b09700b001542bdabd38mr14125966plr.155.1647902674597; Mon, 21 Mar 2022 15:44:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647902674; cv=none; d=google.com; s=arc-20160816; b=0Ba8IJqLi7J+CAh2eybA+a0zQeniDN7RL6NUhgC87cc1FwmuhwU/RqLwS5G5S56X+Q YXKWtDuLw5fuqSJ1aFZRSdDqfhzIVPawJttQHOFH3Bvs6nN+QkXxeYy7OU3Ztn2huks2 z2TmEEZsiqloKuAS3tb1TCNHtoLYGnKHGnYGhs9lYkBaKePPBXTFN1K8S4NIksSlFmlt Gh4mDopRLLhd++1rrdUrjWaApghn9cZBUlz085OHyKse/0GM3UK+mSppfIPMN7mlF0Lc mKWDd+S0y87XVcw2s3RUlAP8w4wz9oWrwpHK+wbUaEiJ5IG0X1o0u6VG97iIilBgyL4m q0mQ== 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=uLPcmR4K6QwbWhmkn/cTqz/cPCrfSkt7khr1jCpbRs0=; b=Z658fMTn2vOp2/OCTV0QYdLM1usCzJSXbNyAsKdxrf1YlvN++Z+PZWy8r+qzxQWlf5 5gZC+JNgcQ1rwIykTed3zobvzv7fZm+ipdzsnegDtejo74JnxwmdUbaj9082twRNz7Fl rfgEv4EUr1sm0905zQcQHb0Jh5RS2SE2dOFIOo0tbgLxxIGMi7S/MxfbENGIYTuNj0BR BRMi2qtoZ8Vqs/Ux89scVHxz+UirX6MvwAKt8QmcwlU7y0fmFCI5t1KG2G8HFGLFLyFq 21kMEWsURkPXsGhaATCl53lk71syuH4txJX6VZX5kLCQunrECqOBfUpzEwXIonmKzXji ImoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=ly6XuN0p; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id f1-20020a170902ff0100b00153ee8b0c9dsi12661449plj.176.2022.03.21.15.44.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Mar 2022 15:44:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=ly6XuN0p; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 9E4213DFD0A; Mon, 21 Mar 2022 14:53:29 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239687AbiCUBih (ORCPT + 99 others); Sun, 20 Mar 2022 21:38:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244224AbiCUBih (ORCPT ); Sun, 20 Mar 2022 21:38:37 -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 8EF7DDD97C for ; Sun, 20 Mar 2022 18:37:13 -0700 (PDT) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-2e62857e0d2so15123267b3.14 for ; Sun, 20 Mar 2022 18:37:13 -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=uLPcmR4K6QwbWhmkn/cTqz/cPCrfSkt7khr1jCpbRs0=; b=ly6XuN0pDqdkZaJ9yeM+zvnu8PRlOFNeXixNmFxAJ992SmfXVxJ4T/6WWlnGH46/Ah INwSaZiEkuXKjch6wrbU0vE7qKN0FMQZ5Zv6jtB3jW+JFBcbgWMbbWEsDRagH3EiipmK XPa9DSG5pG3orYP0C+Q15h7yjV+FINL3OQvJ9tH+WoONfW/kf/DxXWaVQI4NWJfBAX1Z p/IFXmphlA5j5MhsG0uO8rbTXr2L9nrfS2PRy0SxbYfUPCXlrg1Lm3fASSOSnLOp7KRD L6kJn73PW+HHfsc8EINqhdJF45JN+uD1/BjFmfbqjj7t/vhvUU8Gfmjr7ElCwrUxNzPz ABuw== 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=uLPcmR4K6QwbWhmkn/cTqz/cPCrfSkt7khr1jCpbRs0=; b=BBJ29aIpkxSnOwodfyH6wl4IbtAcaLHTKvh+FdL/93y6u7VqXJtNu8Aub5W3NY96i4 7Lb/2SsoT6RINYFove+AZKJW01QgkUjHNiFMykWvbKmuAIm/4uQT7AJrEc1BNv3iVCfb 1wZ4b08ulX/SCbH6Ttb+PCQfKw+auJSDF3sZyyisrUnBtkokpSFHRCERUYDRdj9vyiLb T1HWxz0WGu8inzxzTZSbe+gKm38eDZRuVUWl2AtGY8ivddbRifOimO0NVz8DqwM726qD 2v+qTfK2T/dju5+/MWzOjrc8Pv1t3BaYZ20DlVnTpjrR/g91X6AzGrVMRO9h83BncnaN UtQw== X-Gm-Message-State: AOAM5332Pd7l9VWu3F9ciL64MatRn2TGdtIQLRsSuDKnxTzXdLwTO+fR SMAWkgpF0NuEWH328zd5myXXxQRtxMI6rA== X-Received: from mmandlik.mtv.corp.google.com ([2620:15c:202:201:e0cb:81c1:7b8f:ab9f]) (user=mmandlik job=sendgmr) by 2002:a81:1458:0:b0:2e5:fa20:3531 with SMTP id 85-20020a811458000000b002e5fa203531mr9455347ywu.387.1647826632782; Sun, 20 Mar 2022 18:37:12 -0700 (PDT) Date: Sun, 20 Mar 2022 18:36:57 -0700 In-Reply-To: <20220320183445.BlueZ.1.I21d5ed25e9a0a2427bddbd6d4ec04d80d735fc53@changeid> Message-Id: <20220320183445.BlueZ.3.Icb5e0b991a133d9b8a91a23f1c9b2ca41e151a27@changeid> Mime-Version: 1.0 References: <20220320183445.BlueZ.1.I21d5ed25e9a0a2427bddbd6d4ec04d80d735fc53@changeid> X-Mailer: git-send-email 2.35.1.894.gb6a874cedc-goog Subject: [BlueZ PATCH 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.5 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=no 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 --- 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..35d9bc9c8 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_supported(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.35.1.894.gb6a874cedc-goog