Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp94456pxa; Tue, 18 Aug 2020 17:08:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzm1OhjLWZ1zLDiP51POB5XUkop9p7gB0a3EetsQtDFlzkF7pCggfJiMHWrXxJLTcWXLabx X-Received: by 2002:a05:6402:1430:: with SMTP id c16mr21838860edx.144.1597795733366; Tue, 18 Aug 2020 17:08:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597795733; cv=none; d=google.com; s=arc-20160816; b=z3V1zKBSXibYktlvi8ncitA3UARsQgVDB17qgB1m55FRUAih+VpFqrXz5JLE8A0MIb CcKQzoiRq9vWyK7rI0XRoI8qbcB2QCZQg5EDh2OnU3fuuq+md9c+3FruzSB6APoUcPcq p8EX5jRt6u7VsTOy8Q9h9vhIqKYyW1x/hPcsgxA91vRiz2Gweeqxuz7h09R01cEaZgHP plA6WcSoFWZ2G75gGF4e3L8x7U1rj9Ieg7HkVyGhmfgJAWmkEZoKoeEHlwVwLle0tdX2 eLrpv8dA7WpkwKOlXy6bN2IpqroaG8Jrp24/hK6btRiEG2CzfUH1dFoiSG1xT/K6Ql5m SyxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=aejUMU5zSaqd7+wMdIKicjWFXZOWAZwkVCeBUjAPWDo=; b=ihfDjGijhAO0Ba99iV8tnj1fonuWProYs5dRry7aLjGpOXwi0fxJNZ+ruE6bUk30eZ TsaLS2T+JMEvWCFy5gyb5rKcmH+qF/HY6Cro+/VAccoTsrB+mFOPjhKmeyim8eEXjwYP C1f4lgamQ7rrzayyymj9P2XCBQILF8lxJgwHAo65wmEjejL1x0Zh3tsghoI1LfiXRfzS Z34dmSj4OAWZO/cF3tMDrOTV/P4NfBt7XUqScUsAIGNnW6qj+hT1VmToFOiyFpGdgaM/ Idr3gE4em5GAvYk5BQykDRRB7WBJm286n/SYgaV9B663FAav8jR1bYqgazx3Je19JszP 0/Lw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=WlylnxkI; 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 y15si14706961edl.354.2020.08.18.17.08.04; Tue, 18 Aug 2020 17:08:53 -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=WlylnxkI; 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 S1726713AbgHRX2a (ORCPT + 99 others); Tue, 18 Aug 2020 19:28:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51754 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726703AbgHRX23 (ORCPT ); Tue, 18 Aug 2020 19:28:29 -0400 Received: from mail-pg1-x536.google.com (mail-pg1-x536.google.com [IPv6:2607:f8b0:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 30648C061389 for ; Tue, 18 Aug 2020 16:28:29 -0700 (PDT) Received: by mail-pg1-x536.google.com with SMTP id m34so10457536pgl.11 for ; Tue, 18 Aug 2020 16:28:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=aejUMU5zSaqd7+wMdIKicjWFXZOWAZwkVCeBUjAPWDo=; b=WlylnxkI57Y1zTA6NXRygvE9ERDqhBsF2EY1i+DnVp6hopJ6eaEgBLEGqUxBbHuUVj 6PwdNpEJeekqjYyMxQZMrnptbVvKO/v7YQdhRe9Qdl6dSA/Aj6Rki2J0naWhuK7x3ey0 Vieu5cpDuS93RHmGP+T8JC0AxeUruh/FkBcu0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=aejUMU5zSaqd7+wMdIKicjWFXZOWAZwkVCeBUjAPWDo=; b=HydFy3tn48PjeqTyQ5YdpYxBoPLi2iruaxIsPCXdjKWvwu/Tho16+PAwDB2cBjY/oI 0QGihD7rX2mZoFgEZq2rJRYT9nSE2dbNPnbdD1aYNyVhQOa2mYfZpkS5jTikjwmnC/ih teP7PMvin0RMpWpBolqrLZJDrFSxhpU55zMPASxgpGKwe/37Q1extVo8UtkVEwPPGKgF MStcQcy0z6rEYjpIZSuoGJ7tA+8VcUSj/lhE7rO3I4ROH25ZTdrMfhujqkpV6+W2O/oh W8BGM3Pa7m4TwlNqOo4/y9WE6CnfoOvYNT+ttZbMBFhzF+DtNThzOICKLdiNtcu8+2Uz BSfg== X-Gm-Message-State: AOAM533aQh43vvD7hIxDtmQtFv5m8zsf09Ph4w1gA5yGz6OUur6o5fsz m1u23JPJvAfCu0YUGGFpnbG29w== X-Received: by 2002:a62:838a:: with SMTP id h132mr16810693pfe.72.1597793308492; Tue, 18 Aug 2020 16:28:28 -0700 (PDT) Received: from apsdesk.mtv.corp.google.com ([2620:15c:202:1:7220:84ff:fe09:2b94]) by smtp.gmail.com with ESMTPSA id 30sm904747pjz.24.2020.08.18.16.28.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Aug 2020 16:28:27 -0700 (PDT) From: Abhishek Pandit-Subedi To: luiz.dentz@gmail.com, marcel@holtmann.org Cc: chromeos-bluetooth-upstreaming@chromium.org, linux-bluetooth@vger.kernel.org, Abhishek Pandit-Subedi Subject: [Bluez PATCH v2 0/3] adapter: Reconnect audio when resuming from suspend Date: Tue, 18 Aug 2020 16:28:19 -0700 Message-Id: <20200818232822.1645054-1-abhishekpandit@chromium.org> X-Mailer: git-send-email 2.28.0.297.g1956fa8f8d-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org 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: * 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). 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. 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