Received: by 2002:a05:6a10:6006:0:0:0:0 with SMTP id w6csp728202pxa; Thu, 27 Aug 2020 14:13:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzjnfBXJZYjPFUopDjqyMXUTonNqC0MBRw6j2zbATFSatxL+CK7V9teZDXqva/ICF90f4wN X-Received: by 2002:a17:906:f150:: with SMTP id gw16mr15062276ejb.532.1598562838801; Thu, 27 Aug 2020 14:13:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598562838; cv=none; d=google.com; s=arc-20160816; b=vUy99NEQsP8RQHb/HAimtWfs163xqYEav/0haV+QTcaYSACBeQ0x0LPYayUrD7hsig Zx9Ki2wvF0hqdIfMXFP05JVNyGnkzr1pgwoz/P6vGXNvu5SwZJTgjn4XBMmHKvBFidvE 84xLgh1hmckZtPIkf1MdSRPnpnrfoyd48Pv6D7Gdt60shPcno26GlLDB6E+X6Rtos4Xl qLlcviugqllC0cco624FDSjrrt7K1WWtw+6N6G5DLLPbfcbSTBBfP9zZ2lpmoU25cx84 Xpm4ZdwGmQ2Va4qKeRTI25IgZDNU1beH6IPTgYSv2ho2i6uvjyEUDKdovYmqIZOxYWoR 6xPQ== 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=OJMIcRuoc4PEJP8Cu7uCzH3gpj+jS0eHFU0v1DVRwQU=; b=EsbKgOY1GoMLyBKtJsidCLvZI4MZ9E11AqpdSqpIK5FGsVrceOB29q7a2o+v5tjuy9 GFok8Z9PubGtrGYmhwqNDpGIM+9Pq2cGUGCE1P4e5HQBO5ip7ZWCygxjqeUDnZuO5EEa aX0a59/AvVCrkV2YNxRgbr8KG8w+E7T4R4o6i/ZzYun2Akm8skagDXSf10WLGDKrsB0C 02QXjOqTtngY7ikustDvXPGm0gzq7USQ0f9lQ17NemBOUHnZ4K6w3mo6FPiQg8yDYO9p FvZkF5BuZBJCR6MdUJ5K2I+p0DJ3WLrlFW9vUqf9FdasfUnv4cjmtlI0CRWvpKtjw+h1 GCSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="D6TOPJy/"; 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=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h10si2158729ejk.452.2020.08.27.14.13.34; Thu, 27 Aug 2020 14:13:58 -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=@chromium.org header.s=google header.b="D6TOPJy/"; 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=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726120AbgH0VN3 (ORCPT + 99 others); Thu, 27 Aug 2020 17:13:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36580 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726073AbgH0VN3 (ORCPT ); Thu, 27 Aug 2020 17:13:29 -0400 Received: from mail-vk1-xa41.google.com (mail-vk1-xa41.google.com [IPv6:2607:f8b0:4864:20::a41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2E944C061264 for ; Thu, 27 Aug 2020 14:13:28 -0700 (PDT) Received: by mail-vk1-xa41.google.com with SMTP id x142so1590921vke.0 for ; Thu, 27 Aug 2020 14:13:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=OJMIcRuoc4PEJP8Cu7uCzH3gpj+jS0eHFU0v1DVRwQU=; b=D6TOPJy/EOu2QFp/Hm7uIT3bhvHnCvdwriKZVdbKlFWF/xPYy1guHq5+S5Jig+T+gl VIuveAL9m4LJHHnAcSd1zTzOWJIuleY+LGKEE3LM7JmqkrHTrvkpQQ0XdApE7NeBgnOF +eyBMtxcOXXZLHPeL5AHwfRsatfhEBy0CE+bY= 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=OJMIcRuoc4PEJP8Cu7uCzH3gpj+jS0eHFU0v1DVRwQU=; b=UPotu5xxz5/HtKAKIc8oQNVNopvbGYquYa9W1Dd3auMsAen+LhCp2sL0k4IuHyZPb6 mbM3XgYSvLHjjmv+kbwsTElbnuUs95OONtCNPtRtIdNEh3zKPGJL4ebyH2kLHDgn0MWV 8yYm5QFQrWzxhxL+eixpheWQgXBVrPP6FQkXRxGB0kXyNSLI4WEWtRWQJdj8OVFS7QtK iNnCtPKnjL/b8vzIJ/3rAVPzgka9wAD5Vf842MEqJc3BCLitHOYWZsRQ7ohJUfcUKxan GL1NblpFlQPbvuHe3WmVbE1uLa7/cP54UYASEuRgnkhnmyPzmJAQEJvbn2ZHx05SzcTo OgZg== X-Gm-Message-State: AOAM532TIZC27CN3rbytyHmcrlJHsehC5oCNrGPqIlVQEhu21wE60vk8 U06rqHG+qXcl1WMYCLb/CHvR0TJmDO8Sdoe+CXOTgg== X-Received: by 2002:a1f:9bc6:: with SMTP id d189mr14379177vke.54.1598562807235; Thu, 27 Aug 2020 14:13:27 -0700 (PDT) MIME-Version: 1.0 References: <20200818232822.1645054-1-abhishekpandit@chromium.org> In-Reply-To: From: Abhishek Pandit-Subedi Date: Thu, 27 Aug 2020 14:13:13 -0700 Message-ID: Subject: Re: [Bluez PATCH v2 0/3] adapter: Reconnect audio when resuming from suspend To: Luiz Augusto von Dentz Cc: Marcel Holtmann , ChromeOS Bluetooth Upstreaming , Bluez mailing list 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 Luiz, On Wed, Aug 26, 2020 at 11:21 PM Luiz Augusto von Dentz wrote: > > Hi Abhishek, > > On Wed, Aug 26, 2020 at 10:41 AM Abhishek Pandit-Subedi > wrote: > > > > Hi Luiz, > > > > Could you PTAL at this v2 patch series. I refactored the audio > > reconnect to use the policy plugin instead of doing the reconnect as > > part of the adapter logic, as requested. > > > > Thanks > > Abhishek > > > > On Tue, Aug 18, 2020 at 4:28 PM 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 > > So we could not just use the disconnect reason like I suggested? I am using the disconnect reason to mark the device for reconnection and only queueing it for reconnect on resume. As mentioned in the patch, this is to account for resumes that are not user driven and will suspend almost immediately again (i.e. periodic wake up to check battery level and see if we need to shut down). > > > > 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: > > > > > > * Register a callback for controller resume in the policy plugin. > > > * In the device disconnect callback, mark any devices with the A2DP > > > service uuid for reconnect on resume after a delay. > > > * In the controller resume callback, queue any policy items that are > > > marked to reconnect on resume for connection with the > > > ReconnectAudioDelay value (default = 5s for Wi-Fi coexistence). > > Something like ResumeDelay would probably be better. Sure, I will rename this. > > > > A reconnect is only attempted once after the controller resumes and the > > > delay between resume and reconnect is configurable via the > > > ReconnectAudioDelay key in the Policy settings. The 5s 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. > > I would keep the same logic as out of range so the platforms can > customize the number of attempts. So the first reconnect attempt after resume should be separately configurable (i.e. 5s) but subsequent reconnect attempts would use the reconnect-intervals values? That sounds good to me. > > > > 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 < 5s 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 after 5s+ wake time. > > > - Suspend test with wake time between 3s - 6s. Ran with 5 iterations and > > > verified it wasn't connected at the end. A connection attempt was > > > made but not completed due to suspend. A reconnect attempt was not > > > made afterwards, which is by design. > > > > > > Luiz@ Marcel@: Does this sound ok (give up after an attempt)? > > > > > > 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 v2: > > > - Refactored to use policy instead of connecting directly in adapter > > > > > > Abhishek Pandit-Subedi (3): > > > mgmt: Add controller suspend and resume events > > > monitor: Add btmon support for Suspend and Resume events > > > policy: Reconnect audio on controller resume > > > > > > lib/mgmt.h | 14 +++++++++++ > > > monitor/packet.c | 55 +++++++++++++++++++++++++++++++++++++++++ > > > plugins/policy.c | 64 +++++++++++++++++++++++++++++++++++++++++++++--- > > > src/adapter.c | 45 ++++++++++++++++++++++++++++++++++ > > > src/adapter.h | 6 +++++ > > > src/main.c | 1 + > > > src/main.conf | 9 +++++++ > > > 7 files changed, 190 insertions(+), 4 deletions(-) > > > > > > -- > > > 2.28.0.297.g1956fa8f8d-goog > > > > > > > -- > Luiz Augusto von Dentz