Received: by 2002:ac0:e34a:0:0:0:0:0 with SMTP id g10csp252726imn; Mon, 25 Jul 2022 15:33:47 -0700 (PDT) X-Google-Smtp-Source: AGRyM1u422VhOL7Bakih0iXDtOFFMB27tY4kOis8T5coixfhTu5jQ4M8L1aqOsk4GmdsCjNpzyft X-Received: by 2002:a05:6402:26cd:b0:43b:e3eb:241b with SMTP id x13-20020a05640226cd00b0043be3eb241bmr12269730edd.133.1658788427249; Mon, 25 Jul 2022 15:33:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658788427; cv=none; d=google.com; s=arc-20160816; b=ScU4g5h7YTGAy1cZRgq/p/qrmOo2ZGBwatVZq0IhqVNEPXmyBIms+rqnuKMi8fZ6UZ qJCi+/GkCB1cf/DhjhoHkveH3ASeEx+rWH0AzLp/VXZYLNCwwb2JZ4h5xCFKduw7oyLG EPAMxd6ixlpINHM2fFZzb/gD9V6UxG5VPuNZo5fACQX+waxaXBwQ/eQiLsl6d48+wT4K UaVxsmuXhp2sbPyDLzCackw4NFqc0n69w1d1zmG93eIHn50WVolaJUice0tOEptx2NaH kHtc4dRYajg1t0Wfcw2Zklg0pZ55uq7kp04mFlrzJ1r8pT3lsPivf9BsXP07q0OfMlwP Tbag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=s5F5bTPmIWsgz/PHUFTiPwn7ArH62vLQlD0Ro1hOzT8=; b=lFqOWZ9EYo0BPIy2EAqQrJicjSHJwZrumfjZAivwl6BaI8iGlzGR1BsjKwhwuYLg3a UCNwZp3y6Umx1FJtvCX4PKmcah6/QfsifKl7tMFPSnmoHjDai8io/Kst9BfC2IL83kZR sXWiZnSNbMRmCIgTx0mXbInYUtu9eujK4peGrTLan9LA9qdMG25eWcWWZOl5vHtdHcpS ZgG/MLYWhcZcH6Ez0NvcYz+m835gJDPn1xIMtZZNbIrU6EqAWSbWDxzitjAPVDnHgzyW ZnQcuaGXu/pHWG021hoAqbWnjxhG7rv/NGaziMbNwY4KAU9L8naNaLOHNp2apVvh19Yl zk0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=EYVKVy9G; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i12-20020aa7dd0c000000b0043a7384a858si10905890edv.299.2022.07.25.15.33.08; Mon, 25 Jul 2022 15:33:47 -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=@gmail.com header.s=20210112 header.b=EYVKVy9G; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229491AbiGYW2r (ORCPT + 99 others); Mon, 25 Jul 2022 18:28:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37016 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237021AbiGYW2p (ORCPT ); Mon, 25 Jul 2022 18:28:45 -0400 Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [IPv6:2a00:1450:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 36C2D255AD; Mon, 25 Jul 2022 15:28:44 -0700 (PDT) Received: by mail-ed1-x52a.google.com with SMTP id c12so8345512ede.3; Mon, 25 Jul 2022 15:28:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=s5F5bTPmIWsgz/PHUFTiPwn7ArH62vLQlD0Ro1hOzT8=; b=EYVKVy9GR8tIisHmLoKIAUDGdhGTgA+V+O8Z1DMo3OCm/8lIX+f2pBj5Fg2PBSooVF VzXhmo5+5SRh+gS/j/TCjZm9g3wuPPfIJR/lHwPjJL/VEagtHu4Dj8nzh2Yo4SFJGt3q zAUrZThxpZhnqya/xFcQ4ZsSQixW2/qBTznI3inG+qxqjP1qimuGWnkE5ilwBjyN3+/y raASv3WxXlCYKvPPX5tYi45XmgelBIcFRlQ0HkBw+VCjLX907GaOeSAK/FU3cnRM4b9W MPdErn+DQYwABxF4eRq6GZgzE3ovur6veftazbNX8N0e8zULCGOPcg3f8KMdCnw0nJuq TVHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=s5F5bTPmIWsgz/PHUFTiPwn7ArH62vLQlD0Ro1hOzT8=; b=sP+54nMD81yYcOMQuGpRqWintABlzDRcMesavl3I5iFmQMlSdzYeadGPvN5mIQqygq aa+2d8s4VD700HGOk5ckr+ulKjj5JbExyeBnGuiPJ0UUNKmDNLMwqHN/I8d3Ui7kWOmL e6KR6t45hI7U6JqErsi5+nuGw4CZAAJHXMoNgRnWfnSZmvNpIvjy4uMYBY1Kd95u3s97 lA8BPU6viHRrt22jCAgz1RvPu1T9IFAVy8zk0ABzXaMfjq3XxalAfN2FKwHQoyYBTmZr wBdtwfskFhvd8DB1MaA+Y57rFbZ6zQ77eVVaBFUzZZ1dzpNO8lwmZ82T5cBaGqPV3Wro xdpA== X-Gm-Message-State: AJIora/VUpFaMZVQvlXAwXoTTOvhT2csd25Z1943Q4Lz+mW5qAFP7FgZ LBgzfIrrttKIAiEHKskuYvYL1gNuHGSuyH8huP4= X-Received: by 2002:a05:6402:5412:b0:435:5997:ccb5 with SMTP id ev18-20020a056402541200b004355997ccb5mr14756047edb.167.1658788122613; Mon, 25 Jul 2022 15:28:42 -0700 (PDT) MIME-Version: 1.0 References: <20220725135026.1.Ia18502557c4ba9ba7cd2d1da2bae3aeb71b37e4e@changeid> In-Reply-To: <20220725135026.1.Ia18502557c4ba9ba7cd2d1da2bae3aeb71b37e4e@changeid> From: Luiz Augusto von Dentz Date: Mon, 25 Jul 2022 15:28:31 -0700 Message-ID: Subject: Re: [PATCH] Bluetooth: Always set event mask on suspend To: Abhishek Pandit-Subedi Cc: "linux-bluetooth@vger.kernel.org" , Abhishek Pandit-Subedi , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Johan Hedberg , Marcel Holtmann , Paolo Abeni , Linux Kernel Mailing List , "open list:NETWORKING [GENERAL]" Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham 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 Hi Abhishek, On Mon, Jul 25, 2022 at 1:50 PM Abhishek Pandit-Subedi wrote: > > 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. > Please include the commit hash it fixes, also it may be a good idea to tag it for stable as well. > 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 > -- Luiz Augusto von Dentz