Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp1824090ybg; Thu, 4 Jun 2020 21:31:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzVXkvHmhCZ+4bW6jQnMz9NwrhfM/EzoPEy6dpSn0GFqPr0ZvdiSdEHIAbpGih0r/+wesOg X-Received: by 2002:a17:906:c831:: with SMTP id dd17mr3181564ejb.40.1591331506133; Thu, 04 Jun 2020 21:31:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591331506; cv=none; d=google.com; s=arc-20160816; b=IAnPiy8aDlhp+WWLhIvELtw5ldl+1/0Ny/kdqzAqqsqlPgcD3+0+Azr4LtzgLSV1Rn YeWLZs3rhLx2m6NZPQJ5vgOBWPCVpWOeaLNjJyoda/5AJ//D2WYMEWknXj01ISgxjGOF 7xQ8yZD7/Bnbc4FBMPwMpmYWERTKC2t79wRA5BW0JTkfZrnHMuoyJXultm4AJmcJV71r nk5wQNQeB8MbRhHBCDlds3J3qkKCMo/vdgxhMKOc8C/ev+2y0icz9IDFKmnbSXNx3seu jafAWTnYyGVVGPaBFtX/1GOEiDP+LES9KpalkoatloKaX/jzdDsL6EW5CPMoM+uIAkyo xvoQ== 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=yh4QPGB6BpMImnDSPQmPa4HQGaoN/XctUaVKXi5QYwY=; b=FrLWsQThDdlHFTnHiMGRyn50DetGeAZahNLufpD/jILUINI39SzM+OvIIBJZL1iMHm bzT4G4CqqzKI6uv98QTQTe653+sludb1f83eEkamk8+HbFLF6mrkphAvprDlsHaK0l5R H5QCmCwDUN/o9xDV3mt3LW6GqfEEf3HlWNrNzud/RQk+kiYWrFz8C1wyoadUiKWKHd94 L+N4h2671MKx+2b6/VqFqeYJpi2DpSLYXOnOj+1R7vHwKtadfdaL+1/nevLlcqB1tvYR CVpl+UgnrpKR+uxYhlmDtdNsGIw3DEapGtAZ/4vdQlFFenKv6S1PLDFzB4pU1DZc0Veb WSmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=PDrkFN97; 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 cc23si3275670edb.115.2020.06.04.21.31.22; Thu, 04 Jun 2020 21:31:46 -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=PDrkFN97; 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 S1726214AbgFEE3r (ORCPT + 99 others); Fri, 5 Jun 2020 00:29:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725968AbgFEE3q (ORCPT ); Fri, 5 Jun 2020 00:29:46 -0400 Received: from mail-ua1-x942.google.com (mail-ua1-x942.google.com [IPv6:2607:f8b0:4864:20::942]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 22432C08C5C1 for ; Thu, 4 Jun 2020 21:29:45 -0700 (PDT) Received: by mail-ua1-x942.google.com with SMTP id b13so2843892uav.3 for ; Thu, 04 Jun 2020 21:29:45 -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=yh4QPGB6BpMImnDSPQmPa4HQGaoN/XctUaVKXi5QYwY=; b=PDrkFN970k1ALTuEhfgcTlUwB71dPxvhGxU0C4VZu6nTHpZ+sXfAM6AMHZbir+bQX3 7z5G2kw9yGZ+5zsqkvnXyaXOISL9lrVRVLvMfkr2sxLbV2+X63lVdLn9xYSDDlAj7Wgj FaiW9XEJ4Ha98qEQZAHR40fvGQ1NwOWOVeP6c= 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=yh4QPGB6BpMImnDSPQmPa4HQGaoN/XctUaVKXi5QYwY=; b=XGjvLMsusp525w0//foYu33676oxDOp9wclhEHTSRDBeWPXS7tVRA+M6LtcIAQ1r1E 9DAZ17eE8dCUrY2706t/d2WSOTmPHZ+arMjT/Ux1bFF4TKQ4ZuozukypXKkkg5avAlFZ CM0BGu8qSc+TxDNahxvWrdUdhtpkAsBSgFF+DMTPhOqcCYn5qn52jnbA48u6Y0+OkIRJ CXxW2bOw0gyTIQ0TcN8JxssMx3rW0k08t7LOZkT1NCEBJYl3Gons2bwMf+Lp7sIL4v23 U/860sI3GiR+MIVTntE3IJVdlh6ZzDBRyVyQgbQ+82vLvI4RIlANMx/4OYlRdB6Tz06c zHPQ== X-Gm-Message-State: AOAM533bmz/z1GezFjX4oD0biAuUmqKe3ekmLBmSg1oG7GjrX0jyc4KV RkKI7tritsVG0zwYsJe8Vu4WY6gOBTCx/1XMGTUNpw== X-Received: by 2002:ab0:2bd4:: with SMTP id s20mr5781588uar.136.1591331384169; Thu, 04 Jun 2020 21:29:44 -0700 (PDT) MIME-Version: 1.0 References: <20200603132148.1.I0ec31d716619532fc007eac081e827a204ba03de@changeid> In-Reply-To: From: Abhishek Pandit-Subedi Date: Thu, 4 Jun 2020 21:29:30 -0700 Message-ID: Subject: Re: [PATCH] Bluetooth: Allow suspend even when preparation has failed To: "Rafael J. Wysocki" Cc: Len Brown , Todd Brandt , Marcel Holtmann , "open list:BLUETOOTH DRIVERS" , ChromeOS Bluetooth Upstreaming , Linux PM , "Zhang, Rui" , "David S. Miller" , Johan Hedberg , netdev , Linux Kernel Mailing List , Jakub Kicinski 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 Sent a v2 with proper fixes and reported-by tags. Thanks Abhishek On Thu, Jun 4, 2020 at 3:46 AM Rafael J. Wysocki wrote: > > On Wed, Jun 3, 2020 at 10:22 PM Abhishek Pandit-Subedi > wrote: > > > > It is preferable to allow suspend even when Bluetooth has problems > > preparing for sleep. When Bluetooth fails to finish preparing for > > suspend, log the error and allow the suspend notifier to continue > > instead. > > > > To also make it clearer why suspend failed, change bt_dev_dbg to > > bt_dev_err when handling the suspend timeout. > > > > Signed-off-by: Abhishek Pandit-Subedi > > Thanks for the patch, it looks reasonable to me. > > It would be good to add a Fixes tag to it to indicate that it works > around an issue introduced by an earlier commit. > > Len, Todd, would it be possible to test this one on the affected machines? > > > --- > > To verify this is properly working, I added an additional change to > > hci_suspend_wait_event to always return -16. This validates that suspend > > continues even when an error has occurred during the suspend > > preparation. > > > > Example on Chromebook: > > [ 55.834524] PM: Syncing filesystems ... done. > > [ 55.841930] PM: Preparing system for sleep (s2idle) > > [ 55.940492] Bluetooth: hci_core.c:hci_suspend_notifier() hci0: Suspend notifier action (3) failed: -16 > > [ 55.940497] Freezing user space processes ... (elapsed 0.001 seconds) done. > > [ 55.941692] OOM killer disabled. > > [ 55.941693] Freezing remaining freezable tasks ... (elapsed 0.000 seconds) done. > > [ 55.942632] PM: Suspending system (s2idle) > > > > I ran this through a suspend_stress_test in the following scenarios: > > * Peer classic device connected: 50+ suspends > > * No devices connected: 100 suspends > > * With the above test case returning -EBUSY: 50 suspends > > > > I also ran this through our automated testing for suspend and wake on > > BT from suspend continues to work. > > > > > > net/bluetooth/hci_core.c | 17 ++++++++++------- > > 1 file changed, 10 insertions(+), 7 deletions(-) > > > > diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c > > index dbe2d79f233fba..54da48441423e0 100644 > > --- a/net/bluetooth/hci_core.c > > +++ b/net/bluetooth/hci_core.c > > @@ -3289,10 +3289,10 @@ static int hci_suspend_wait_event(struct hci_dev *hdev) > > WAKE_COND, SUSPEND_NOTIFIER_TIMEOUT); > > > > if (ret == 0) { > > - bt_dev_dbg(hdev, "Timed out waiting for suspend"); > > + bt_dev_err(hdev, "Timed out waiting for suspend events"); > > for (i = 0; i < __SUSPEND_NUM_TASKS; ++i) { > > if (test_bit(i, hdev->suspend_tasks)) > > - bt_dev_dbg(hdev, "Bit %d is set", i); > > + bt_dev_err(hdev, "Suspend timeout bit: %d", i); > > clear_bit(i, hdev->suspend_tasks); > > } > > > > @@ -3360,12 +3360,15 @@ static int hci_suspend_notifier(struct notifier_block *nb, unsigned long action, > > ret = hci_change_suspend_state(hdev, BT_RUNNING); > > } > > > > - /* If suspend failed, restore it to running */ > > - if (ret && action == PM_SUSPEND_PREPARE) > > - hci_change_suspend_state(hdev, BT_RUNNING); > > - > > done: > > - return ret ? notifier_from_errno(-EBUSY) : NOTIFY_STOP; > > + /* We always allow suspend even if suspend preparation failed and > > + * attempt to recover in resume. > > + */ > > + if (ret) > > + bt_dev_err(hdev, "Suspend notifier action (%x) failed: %d", > > + action, ret); > > + > > + return NOTIFY_STOP; > > } > > > > /* Alloc HCI device */ > > -- > > 2.27.0.rc2.251.g90737beb825-goog > >