Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp924033ybg; Mon, 1 Jun 2020 18:49:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyVY4hh3+yz2d6H+6kafcZKF5IHnRT9peuHxa91sdZsWS+yHWYMO+z5+b1s6QDEdl9muUB/ X-Received: by 2002:a17:906:b04b:: with SMTP id bj11mr17197102ejb.516.1591062580060; Mon, 01 Jun 2020 18:49:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591062580; cv=none; d=google.com; s=arc-20160816; b=Rp8YYULxS5UmPxgH7EPmmCXx8icPo8ugBTPyE6s43As9DHezPtod0aRfibI8fkhrsO F4ktO6kfKj2oOayFSjQgaaUvMSC+qfNCqaEwIINZx331f4AuXlchxVbakYucQzuDv+eA NmVXRV/vSzg9/bmWO63pwb4G//3BhHEkJT/unt2nBxEe3J6WkzzNOxXPuo6f2OqnLVIJ S/gskrsBxOpXehyDMjUSUDYr/ReHUiEN7twGvY7TGxH3KDAZQqeJBAhfpHBlVhSnDnwT dUzsnIYcE8odXHE0xeC604sSvjeNtPN7/tuHaNzacCusbZ0DxItCyaeL8sUc0WuhI3io Vv5w== 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=NDWXl875dqN44wgKFWnb7J8N8ciIKNPrxB/hfgmRf6E=; b=coPp0qRJBB6UUKRG9BT/+CyjCnxJEbu8uIbMAAr1kEEhSKp8T3H+KuSvCGiHJU0GZS jXBPj++616ySVsJjLudLht9F6JnsDQIfZsPO9Ef5iyWwqF6SjNF5cPwI4FFP5IaRlg9H 5+8+Yp9tcgzWjjBH8WYZK1ua7yb4rrqtiz0o1tyVj2aP9JyEtZpgubo2FtMwtitj2Ykb Bz8kl9VZ7yU1jw8sYLRBpnGD1CO48mEAxWJQqFeDvI6iERm/WW1dClQzoadf3I04hbF+ O+Tfpt1s+F0TyKZXzWMHqPmRn8h29E57uLq0b/b/DeKpQKVGCxPBB6jDx9zny6fqJFhn IYQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=JRLmveyb; 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 d4si619917edm.583.2020.06.01.18.49.15; Mon, 01 Jun 2020 18:49:40 -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=JRLmveyb; 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 S1726009AbgFBBtM (ORCPT + 99 others); Mon, 1 Jun 2020 21:49:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54486 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725900AbgFBBtM (ORCPT ); Mon, 1 Jun 2020 21:49:12 -0400 Received: from mail-vs1-xe41.google.com (mail-vs1-xe41.google.com [IPv6:2607:f8b0:4864:20::e41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 43DBBC05BD43 for ; Mon, 1 Jun 2020 18:49:12 -0700 (PDT) Received: by mail-vs1-xe41.google.com with SMTP id q2so1139878vsr.1 for ; Mon, 01 Jun 2020 18:49:12 -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=NDWXl875dqN44wgKFWnb7J8N8ciIKNPrxB/hfgmRf6E=; b=JRLmveybXPnxAdAR5ejEglrEmyOiyP2YL2RN5n/MlBp2MeNBhvGO9anSMkR3eqhh2t MgO/u4vY2vqOpbDz0WmA+G8JfN3AvlcSQNL+pgdrCUxXm7CigG5cODeMhRLWCjwTGpRn 7eZF8CynOwdiB9tMawAwrh2u90FVicvWPMPcM= 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=NDWXl875dqN44wgKFWnb7J8N8ciIKNPrxB/hfgmRf6E=; b=ZXkkzGw8FswpeRkLUeixKvgM0GspltD9wkdJT9B9dY9WThSksctHbSJVccPFIqGFaw VV35yIalgKJxHUMSxsPjWyjxCbulJymClpqzX8ONbxdKuIp3VVAjYI4KbVRHDJ4tpBlo grIAQArnVfCOE2TPiu6eAt/y2pPr/oWDOqI4xGWHc6rkL0WaF5KtPZCDK9NXHqkXs0dk fs/9aFPmGY4oKK44Jf3WKJPmr83qRQKZ9T2NdNJvkAv8W8GgvhtA6XbDEROssEU0znQs dYy5h91P/oScL83FHInxXfPKw6jrRI+5zRxXqHRBWawQsQS4F9Y2U8LFP4DignVYkd1l +gpw== X-Gm-Message-State: AOAM533rJ1uRh2Rol/LPHhrGzM7TOPLRY6J4nOudsXylBTvSjHU1T5sL S9Q7fHc7o9B8SqkkPtRyrhlrG50oTna4vBIjVUTOqA== X-Received: by 2002:a67:b10c:: with SMTP id w12mr2735002vsl.96.1591062551158; Mon, 01 Jun 2020 18:49:11 -0700 (PDT) MIME-Version: 1.0 References: <20200601184223.1.I281c81384150e8fefbebf32fa79cb091d0311208@changeid> In-Reply-To: <20200601184223.1.I281c81384150e8fefbebf32fa79cb091d0311208@changeid> From: Abhishek Pandit-Subedi Date: Mon, 1 Jun 2020 18:48:56 -0700 Message-ID: Subject: Re: [PATCH] Bluetooth: Check scan state before disabling during suspend To: Manish Mandlik Cc: Marcel Holtmann , Luiz Augusto von Dentz , Bluez mailing list , ChromeOS Bluetooth Upstreaming , "David S. Miller" , Johan Hedberg , netdev , LKML , 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 Hey linux-bluetooth, We found this bug when reverting some Chromium maintained patches in our repository that was conditionally dropping LE scan enable commands if it wasn't toggling between true/false. On some Intel controllers, disabling LE scan when it's already disabled resulted in a "Command Disallowed" and this was causing suspend to fail. On Mon, Jun 1, 2020 at 6:43 PM Manish Mandlik wrote: > > Check current scan state by checking HCI_LE_SCAN flag and send scan > disable command only if scan is already enabled. > > Signed-off-by: Manish Mandlik > --- > > net/bluetooth/hci_request.c | 10 ++++++---- > 1 file changed, 6 insertions(+), 4 deletions(-) > > diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c > index 1fc55685da62d..1acf5b8e0910c 100644 > --- a/net/bluetooth/hci_request.c > +++ b/net/bluetooth/hci_request.c > @@ -998,8 +998,9 @@ static void hci_req_set_event_filter(struct hci_request *req) > > static void hci_req_config_le_suspend_scan(struct hci_request *req) > { > - /* Can't change params without disabling first */ > - hci_req_add_le_scan_disable(req); > + /* Before changing params disable scan if enabled */ > + if (hci_dev_test_flag(req->hdev, HCI_LE_SCAN)) > + hci_req_add_le_scan_disable(req); > > /* Configure params and enable scanning */ > hci_req_add_le_passive_scan(req); > @@ -1065,8 +1066,9 @@ void hci_req_prepare_suspend(struct hci_dev *hdev, enum suspended_state next) > page_scan = SCAN_DISABLED; > hci_req_add(&req, HCI_OP_WRITE_SCAN_ENABLE, 1, &page_scan); > > - /* Disable LE passive scan */ > - hci_req_add_le_scan_disable(&req); > + /* Disable LE passive scan if enabled */ > + if (hci_dev_test_flag(hdev, HCI_LE_SCAN)) > + hci_req_add_le_scan_disable(&req); > > /* Mark task needing completion */ > set_bit(SUSPEND_SCAN_DISABLE, hdev->suspend_tasks); > -- > 2.27.0.rc2.251.g90737beb825-goog > Reviewed-by: Abhishek Pandit-Subedi