Received: by 2002:ac0:e34a:0:0:0:0:0 with SMTP id g10csp198836imn; Mon, 25 Jul 2022 13:53:05 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vMUE83PpEDpneog4JWO63x439eBz/N57FHtvca8lQBCGukLllIsZJpI82gCDwXQdyjoQbf X-Received: by 2002:a17:90b:2684:b0:1f2:3c98:cf5d with SMTP id pl4-20020a17090b268400b001f23c98cf5dmr23772946pjb.55.1658782385800; Mon, 25 Jul 2022 13:53:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658782385; cv=none; d=google.com; s=arc-20160816; b=PvrBEeuDBvRnH8sMkOjiOvWrGmAoekCaDcG56xlfhEx6tTacHYw3re94Xv7D61DoB2 M/KhBnFsT41XRnA0N8K10ZQxGWvN5YZDa5y8OHOOpxWDchFY6VuhrjklsekDmM7xEdGv AjWlpEywfczzil2BZrmc23NaJyuZUK61e502qqN3RTfQTkF3pEAOgHk+EWJbalqd4/HB HGlBh2Rnrnv14jtGwanr3V1GladnjD231ga306nQg6spjY4VBRwpkUqe2yN5MD3b2866 9SyW3H67mPZA4rRqbslTja809HUmEDiNN5O7X/gc51w0cU3XKXksvfz6sqjyyRuJpTY/ kAUw== 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:mime-version:message-id:date :dkim-signature; bh=1Za1Aa1XyejlriGsxVodfndQYPiCoycbGfY9ypYSrVk=; b=tt5TDrHC6vKjAlmVe3Qo51NdHiSq4PxsHjlD+bgWLAzoHVEX07MJKzmYicZcghhqz5 P9mw7B+ZUKKJgea8f+pjxT7TcTWrCR6zAJbcNFCT735weLZEfPS3S5P86Pe6ud/YYrxR IQx8pvy0PZd39vcJVIv/jCdAkGc4UKIOfc06TavDVm7RLhBagN5jM0eA1knmOxt9Gjse /7jxsvQnI655Ci6EX1Rd0F4/Kj4Uz2ydLAqKrBN7p6sHITHL2GxxRLukzrxgLhdR031o tInj/C/jhwb+3GXRK6SKL+/NRp7uGZvkeN7N4RyZyZ+6SkbFefUanDRm8Zo0fPFNZRXq v9LQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=WCjWFx92; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t11-20020a170902e84b00b0016d6c939317si6125453plg.601.2022.07.25.13.52.33; Mon, 25 Jul 2022 13:53:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=WCjWFx92; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229537AbiGYUu7 (ORCPT + 99 others); Mon, 25 Jul 2022 16:50:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52146 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232640AbiGYUu6 (ORCPT ); Mon, 25 Jul 2022 16:50:58 -0400 Received: from mail-pg1-x549.google.com (mail-pg1-x549.google.com [IPv6:2607:f8b0:4864:20::549]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 853F3140BD for ; Mon, 25 Jul 2022 13:50:57 -0700 (PDT) Received: by mail-pg1-x549.google.com with SMTP id r142-20020a632b94000000b0041a18177a5dso5466266pgr.10 for ; Mon, 25 Jul 2022 13:50:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:message-id:mime-version:subject:from:to:cc; bh=1Za1Aa1XyejlriGsxVodfndQYPiCoycbGfY9ypYSrVk=; b=WCjWFx92rpMcqBq+k47HLwVRSXboTSm3ylECC4lQ8uG8VugsZjAt8ZTygSLtkrtTw+ GUn12mwOjnk7iexUKu4lDqJGDE1MMRZ14RpZsnTY32JcJDWV2M1soLipxHmSyhBBx4Tg hEFacU4wAzTwRUXfg5Ge0vYJalqQjMgMj0PfzCneZUhGct4pTkF38zDZBVJX7u2IxbfO C4XsFNgFvbKxNuX6G8k1rtCntwBHrDXg6xrE5yUxWbVXDuwcpBSRbn6UhqkojYj2tbA+ vjj/rhDU/RrK318zoUQJpwBxoDrnkpXyBOT/AMoSTMJEsJ/u2EDFSANIl/39N51EkPLH bRrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=1Za1Aa1XyejlriGsxVodfndQYPiCoycbGfY9ypYSrVk=; b=2lF1fi1UQXIP2R2pDdtKD0rQqsy2eVPn/rls2FEv7vgUeUWZhyHv4TTyEAnk1K72G/ zz72AoHNvp5f37qGLQj2oDbA8h5PfNLklC+mx6MqNsOA2Rv1KeVCub4kFfxCQ2h966Yc nHZULa84aeZ9MFrAjZPIQskF4LrhwXGM7dGmgx01thXtjzR0U3VFmwsUjQgsK35xFHBn 17UyEH2NhoaoCex1p7KXdJPs8SQgWvYIkDvX20WQ8eCBjSpLts9/RZqPrvyeizAWLA9X 5GKIdvLhY60Bx3zWHGYHyEBC4NuQgV9zTNmCMHQLz1xqNauxDwh+0IAjqK73otj+tWS7 Pceg== X-Gm-Message-State: AJIora8fP4nFZ5ihgTlPtFWe7M2/DLArUqTZxpf09MxMBMsh7zRSH+PY GcF5KaLCYcATkjsKZMdiQ5agzQikyV+ReYVfwv/pgQ== X-Received: from abps.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:9b4]) (user=abhishekpandit job=sendgmr) by 2002:a05:6a00:892:b0:52b:c986:c781 with SMTP id q18-20020a056a00089200b0052bc986c781mr14664144pfj.64.1658782257066; Mon, 25 Jul 2022 13:50:57 -0700 (PDT) Date: Mon, 25 Jul 2022 13:50:53 -0700 Message-Id: <20220725135026.1.Ia18502557c4ba9ba7cd2d1da2bae3aeb71b37e4e@changeid> Mime-Version: 1.0 X-Mailer: git-send-email 2.37.1.359.gd136c6c3e2-goog Subject: [PATCH] Bluetooth: Always set event mask on suspend From: Abhishek Pandit-Subedi To: luiz.dentz@gmail.com, linux-bluetooth@vger.kernel.org Cc: Abhishek Pandit-Subedi , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Johan Hedberg , Marcel Holtmann , Paolo Abeni , linux-kernel@vger.kernel.org, netdev@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable 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 From: Abhishek Pandit-Subedi When suspending, always set the event mask once disconnects are successful. Otherwise, if wakeup is disallowed, the event mask is not set before suspend continues and can result in an early wakeup. Signed-off-by: Abhishek Pandit-Subedi --- Observed on ChromeOS as follows: < HCI Command: Disconnect (0x01|0x0006) plen 3 Handle: 256 Reason: Remote Device Terminated due to Power Off (0x15) > HCI Event: Command Status (0x0f) plen 4 Disconnect (0x01|0x0006) ncmd 1 Status: Success (0x00) @ MGMT Event: Device Disconnected (0x000c) plen 8 BR/EDR Address: 04:52:C7:C3:65:B5 (Bose Corporation) Reason: Connection terminated by local host for suspend (0x05) @ MGMT Event: Controller Suspended (0x002d) plen 1 Suspend state: Disconnected and not scanning (1) > HCI Event: Disconnect Complete (0x05) plen 4 Status: Success (0x00) Handle: 256 Reason: Connection Terminated By Local Host (0x16) The expectation is that we should see Set Event Mask before completing the suspend so that the `Disconnect Complete` doesn't wake us up. net/bluetooth/hci_sync.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/net/bluetooth/hci_sync.c b/net/bluetooth/hci_sync.c index 148ce629a59f..e6d804b82b67 100644 --- a/net/bluetooth/hci_sync.c +++ b/net/bluetooth/hci_sync.c @@ -5297,6 +5297,9 @@ int hci_suspend_sync(struct hci_dev *hdev) return err; } + /* Update event mask so only the allowed event can wakeup the host */ + hci_set_event_mask_sync(hdev); + /* Only configure accept list if disconnect succeeded and wake * isn't being prevented. */ @@ -5308,9 +5311,6 @@ int hci_suspend_sync(struct hci_dev *hdev) /* Unpause to take care of updating scanning params */ hdev->scanning_paused = false; - /* Update event mask so only the allowed event can wakeup the host */ - hci_set_event_mask_sync(hdev); - /* Enable event filter for paired devices */ hci_update_event_filter_sync(hdev); -- 2.37.1.359.gd136c6c3e2-goog