Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3159595pxk; Tue, 15 Sep 2020 11:33:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx4el0tGjVdtOLo26fBi2q5dN4l+b44zwW4Xs/Y9aSCMYj/Fw+MsKvE9v4hC2iydBqcMvqN X-Received: by 2002:a05:6402:12d1:: with SMTP id k17mr23289594edx.323.1600194836200; Tue, 15 Sep 2020 11:33:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600194836; cv=none; d=google.com; s=arc-20160816; b=Dz+emLsE4UcsmRafMwole2JzKa//CodKoTRGfp5e9HKX9HUMtsYKLiiCltblOEJOzq o+3j9Y3IhhqLE4Ld/j+tjaaSBhA/LOIUJIc+V3t9WcCStDsn2uTGvvhsv5u9a6OLsiz9 5qWR+QT7ay+fzV0zmXrVsdGLjlE8rRp2QdB/i7VlFoQFjK/27jHcz9iIm/wx5IArri3Y sH2m0SgGnLfLhnTRYi5MwonRkck0/PdVXeBj4AKpShuCjg2ky2m6zyJBcDKiCvjOgkHn 9VS6YK/cAQ6HQK0uHNq20B27dsDq3pTqNYwmYrUtDzFvJDva5GStxESD3U09GZFKvmei lU8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=DckkTMToW/Pd08x0QOBy7IYkr6sSl78D8segN8Yf5Tc=; b=vTp62DCkoV9X8hKGmh7kQ+UqKXyvHllKmph6nLCm5VW9p13RiXVDjkKySdBwIjgsNf tYQr8bcGU1NTeeCH0En307RqOegXonVLhY7f9075ic++AghbZBSv7KfPeCkU6+esyp1I ROVs+h7D2q6Cr+IumYvqh0KE4/WQLaJg44ymYNBtCsn4yhPyAdEg5uDIUGNNpTt66H2r 4jludKFY+S7sj64+Ps0RyZPSryT+YpgZexpA6T7cFYSpXxCkH35SLYa3okbYd/MYj/tN 8fCAPUkVeQvsW25XwXFt4hVz/2w/bVGEmnZNM4K2dL1gANinG3k3nS456L3RJQoQVj6w nWdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=JMBQuVkq; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l3si10488625ejd.163.2020.09.15.11.33.20; Tue, 15 Sep 2020 11:33:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=JMBQuVkq; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727957AbgIOSdO (ORCPT + 99 others); Tue, 15 Sep 2020 14:33:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40962 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727961AbgIOSNI (ORCPT ); Tue, 15 Sep 2020 14:13:08 -0400 Received: from mail-ot1-x342.google.com (mail-ot1-x342.google.com [IPv6:2607:f8b0:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8F96CC061788 for ; Tue, 15 Sep 2020 11:05:16 -0700 (PDT) Received: by mail-ot1-x342.google.com with SMTP id g10so4103514otq.9 for ; Tue, 15 Sep 2020 11:05:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=DckkTMToW/Pd08x0QOBy7IYkr6sSl78D8segN8Yf5Tc=; b=JMBQuVkqCjfCvc5R+aQmYagSsW9rZgC91ygi5XK3BYXSJj4ZZ+zFlT1y6rVbEoYfSk wv5QOn7X+XllvXasyXij9i6Li08oahcN+wd/nkSjnC8XHYM65ImtKZ/ThPYMhlx/C9ue s8RZ3sf28dSaOf8nA5BJZ4G8RoqqV5utAvO2k9pJk3kS6C/qNSVDjCkLLdYQrhO6w2ER KjYLODNJVNTU44AUDlq/sK4FSkPvb4O51HwjkO7swRA1J/KJGSoJczMmiRA2pOdHaWrm cOai9u4giKLRHi/p3VjRkU/AUuKoaGB+hWvzo39NPMYWLcaybCN+s5HE3gO1GVwY/9p4 x08g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=DckkTMToW/Pd08x0QOBy7IYkr6sSl78D8segN8Yf5Tc=; b=Cc+ElL59pqIy8EB7RrW1di14tkiT1VDImdGjitEN05i6xfHpzVdaiH8awgXeSX+lE+ xH90pDTbTGCnG9Z+I5f1rTEvkOKwyPRqp+XHFR9EXfMd0LaeEdOTnw9DdaCsBFhnB7Sr BM4qTISX3okO85dGV8zg0zy6Z95iS6ooRbe3tpkpfCljCINZQMTnPZM2vBOXPmh2NVlY xSgRJJq43g67wbNhLX8FCxszpJgRGvCIQds2y+/L8nH0goua2pXWyGFC4CoTyWt4W2VP hpcYwPi4mJwIcoFEYWd9uQ+JRqD80ZUgMpvN9YxepOpQRqDWKsRzdqHwi+BkxX8Aa97P 0vBA== X-Gm-Message-State: AOAM5336dliwnMYCu6xTBxJH9ICPOF+Y8gIPedT5ahhdZ9qkZ4ZXDJas t7N0MVuQheD9jLUjVKyC9U1Frur2WLo/bMPZZPaCAet6 X-Received: by 2002:a9d:5a8:: with SMTP id 37mr5657965otd.362.1600193115793; Tue, 15 Sep 2020 11:05:15 -0700 (PDT) MIME-Version: 1.0 References: <20200915174146.1693687-1-abhishekpandit@chromium.org> In-Reply-To: <20200915174146.1693687-1-abhishekpandit@chromium.org> From: Luiz Augusto von Dentz Date: Tue, 15 Sep 2020 11:05:04 -0700 Message-ID: Subject: Re: [Bluez PATCH v5 0/4] adapter: Reconnect audio when resuming from suspend To: Abhishek Pandit-Subedi Cc: Marcel Holtmann , ChromeOS Bluetooth Upstreaming , "linux-bluetooth@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Hi Abhishek, On Tue, Sep 15, 2020 at 10:41 AM Abhishek Pandit-Subedi wrote: > > > Hi Luiz and Marcel, > > This is a quality of life improvement for the behavior of audio devices > during system suspend. This depends on a kernel change that emits > suspend/resume events: > > https://patchwork.kernel.org/project/bluetooth/list/?series=325771 > > Right now, audio devices will be disconnected as part of suspend but > won't be reconnected when the system resumes without user interaction. > This is annoying to some users as it causes an interruption to their > normal work flow. > > This change reconnects audio devices that were disconnected for suspend > using the following logic: > > * In the device disconnect callback, mark any devices with the A2DP > service uuid for reconnect. The reconnect will not be queued until > resume. > * In the controller resume callback, queue any policy items that are > marked to reconnect on resume for connection with the ResumeDelay > value (default = 2s). > > A reconnect is queued after the controller resumes and the delay > between resume and reconnect is configurable via the ResumeDelay key in > the Policy settings. The 2s delay was chosen arbitrarily and I think > anywhere up to 10s is probably ok. A longer delay is better to account > for spurious wakeups and Wi-Fi reconnection time (avoiding any co-ex > issues) at the downside of reconnection speed. > > Here are the tests I have done with this: > - Single suspend and verified the headphones reconnect > - Suspend stress test for 25 iterations and verify both Wi-Fi and > Bluetooth audio reconnect on resume. (Ran with wake minimum time of > 10s) > - Suspend test with wake time = 1s to verify that BT reconnect isn't > attempted. Ran 5 iterations with low wake time and then let it stay > awake to confirm reconnect finally completed on last resume. > - Suspend test with wake time between 1s - 4s. Ran with 5 iterations and > verified it connected several times in the middle and finally at the > end. > > I've tested this on a Pixelbook Go (AC-9260 controller) and HP > Chromebook 14a (RTL8822CE controller) with GID6B headset. > > I've also tested this with the Pixel Buds 2. These earbuds actually > reconnect automatically to the Chromebook (even without this policy > change) and I verified that the new changes don't break the reconnection > mechanism. > > Thanks > Abhishek > > > Changes in v5: > - Remove use of !! in has_kernel_features It seems I end up merging the old version by mistake, but I fixed this one change myself and added btd_ prefix to it since that is required to be exported for plugins that are not built-in. > Changes in v4: > - Set reconnect timer in disconnect if resume events aren't supported > - Only set reconnect timer if adapter matches current notification > - Refactor changes in src/adapter to its own commit > - Refactor enabling A2DP_SINK_UUID into its own commit > > Changes in v3: > - Refactored resume notification to use btd_adapter_driver > - Renamed ReconnectAudioDelay to ResumeDelay and set default to 2 > - Added A2DP_SINK_UUID to default reconnect list > > Changes in v2: > - Refactored to use policy instead of connecting directly in adapter > > Abhishek Pandit-Subedi (4): > adapter: Refactor kernel feature globals > adapter: Handle controller resume and notify drivers > policy: Enable reconnect for a2dp-sink in defaults > policy: Reconnect audio on controller resume > > plugins/policy.c | 87 +++++++++++++++++++++++++++++++++------- > src/adapter.c | 102 +++++++++++++++++++++++++++++++++-------------- > src/adapter.h | 11 +++++ > src/main.c | 1 + > src/main.conf | 11 ++++- > 5 files changed, 168 insertions(+), 44 deletions(-) > > -- > 2.28.0.618.gf4bc123cb7-goog > -- Luiz Augusto von Dentz