Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp804468ybt; Wed, 24 Jun 2020 11:35:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyBDx79IfNZT+Ve71e8gWDgWixs5ehDifBVzylnypjfb0mpzUtPeYuCU3zbXCYZcfGwCFzM X-Received: by 2002:a17:907:11ce:: with SMTP id va14mr5182511ejb.189.1593023737472; Wed, 24 Jun 2020 11:35:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593023737; cv=none; d=google.com; s=arc-20160816; b=VLv+aC187QTwQ2Vy+IWcKC14gMOLNg4l/Ya6ilfmjoheGB0j9PUNZeHueA2/3Jcp1F CoBfL1+ApZfSLQ6vJojINSdbv5OvLKXMsPx+kx14f3wd5CYd1ki6Lr6cjAoePPVFmni4 8hY9js3QRu76OfkV8jbov27bw/FQgsEjGVTYSKbnYaPn0jVHX5sDbl28aiAgoiahc0dX KzLDgF/xl9cnNSwscw+32oClG0rcVhtN1JKX+XEFddD8Xbg376I4nuLZzg94AboRZYxs yT4m0IxJ3fC3LdZRD1+nV88juuStT/98nGViED81xqbkGzq3nbk7g1T80ASNQVbbLUnK QvDw== 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=Q0SFa2U1n/gw/Ov9iaCh0A1BsBXlbDSR7iGMtKgrzh4=; b=o4yLMM6rQsnj29liZaOHfzKm98MWcD3trL0BqWzlzbcuCDg7AcNrGtZrxGNpTHQrH2 mNxeCU2zUXIm+McE71BY/P6vdHw2RSr4nbCNBcPsQBfyzFfqPDdUK0U97ODDZIxmomJc FoVgjb2IOOTq5eV8NmzSkf6I0peWcDmNLymlVwWVDxP/I6OmwWostaWxzbSXJfdJRo4Z U7OoJlS6Sqj1Q+TRrhMOES+ChGK4EaWjaiD7Lgr97uJ+R6Y2vbSMCj8VvmR2kqxds9e2 ZRnqEH6MvLvoX/n+zH5lMoIOSARbJwR4C8jobX0/O84Eky+Ohw1OXd5ILm/VtvxTIRy/ fyJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=M3ywDaEt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 dt20si16678598ejc.24.2020.06.24.11.35.13; Wed, 24 Jun 2020 11:35:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=M3ywDaEt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 S2406147AbgFXSe0 (ORCPT + 99 others); Wed, 24 Jun 2020 14:34:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60494 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405581AbgFXSeZ (ORCPT ); Wed, 24 Jun 2020 14:34:25 -0400 Received: from mail-pl1-x641.google.com (mail-pl1-x641.google.com [IPv6:2607:f8b0:4864:20::641]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 63B23C061573 for ; Wed, 24 Jun 2020 11:34:25 -0700 (PDT) Received: by mail-pl1-x641.google.com with SMTP id 35so1398657ple.0 for ; Wed, 24 Jun 2020 11:34:25 -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=Q0SFa2U1n/gw/Ov9iaCh0A1BsBXlbDSR7iGMtKgrzh4=; b=M3ywDaEt0dPEA9Zei6WnBet8lO2g/RxcJupW42tD+Z1GN89NYkAYWwE6kIpHPpB0rJ qipLOy0qWQtG00GCJnzFKZbMB+Xv9r3oZKL4ZEHNE01UTf/rThsqs1IcKn+PXnSXydf/ vmxiMyxlqV4w21Dy8aual9+OdpoY+1TEwWh6c= 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=Q0SFa2U1n/gw/Ov9iaCh0A1BsBXlbDSR7iGMtKgrzh4=; b=iG03qpV8dITUkmsshPyMoLr60+8gyOBWd/Ywpoxwl6kD5qxX6WXkzmpLrTfkun0omx QF3zsc68NvqxG+xiLnGgyJ8mVGy9ZHlP65T9+GHKe7cnmDDUcMp5h+Ulfv6deFGslvLc j4QI8ockQqA9My76zNonPamnIhB9AGNdEzSzv3rYJAT4cc42Ki3VOirb5eLwOihX6TZC 8eLf6LSsL+RmOqKh2UMf7Q9TWL9/Dk3UVeDHb8hPc8FpiQ45AHf7Ii51MLtuVrzCbBLz /Pf1WA0mxWT8dQwQUNDD/u23Zkdm2QyoswVPWOTjJuCd9+Zjn0cfD63Y1sEEd1wfWH1x 7EUw== X-Gm-Message-State: AOAM530K0b27LYicGxu7vAphLCGGZYC5DEDo4ZyL236k/u75XwGGPqeO uGspYqmMXciNRL70cKCdx2guIg== X-Received: by 2002:a17:90a:294f:: with SMTP id x15mr28400108pjf.97.1593023664707; Wed, 24 Jun 2020 11:34:24 -0700 (PDT) Received: from apsdesk.mtv.corp.google.com ([2620:15c:202:1:e09a:8d06:a338:aafb]) by smtp.gmail.com with ESMTPSA id e15sm11983263pgt.17.2020.06.24.11.34.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jun 2020 11:34:24 -0700 (PDT) From: Abhishek Pandit-Subedi To: marcel@holtmann.org, linux-bluetooth@vger.kernel.org, alainm@chromium.org Cc: chromeos-bluetooth-upstreaming@chromium.org, Abhishek Pandit-Subedi , "David S. Miller" , Johan Hedberg , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Jakub Kicinski Subject: [PATCH] Bluetooth: Don't restart scanning if paused Date: Wed, 24 Jun 2020 11:34:19 -0700 Message-Id: <20200624113351.1.Ic6b1fca2b1b3fe989db21ceae76bab80bd87d387@changeid> X-Mailer: git-send-email 2.27.0.111.gc72c7da667-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When restarting LE scanning, check if it's currently paused before enabling passive scanning. Signed-off-by: Abhishek Pandit-Subedi --- When running suspend stress tests on Chromebooks, we discovered instances where the Chromebook didn't enter the deepest idle states (i.e. S0ix). After some debugging, we found that passive scanning was being enabled AFTER the suspend notifier had run (and disabled all scanning). For this fix, I simply looked at all the places where we call HCI_OP_LE_SET_SCAN_ENABLE and added a guard clause for suspend. With this fix, we were able to get through 100+ iterations of the suspend stress test without any problems entering S0ix. net/bluetooth/hci_request.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c index 86ae4b953a011e..116207009dde01 100644 --- a/net/bluetooth/hci_request.c +++ b/net/bluetooth/hci_request.c @@ -819,6 +819,11 @@ static void hci_req_start_scan(struct hci_request *req, u8 type, u16 interval, { struct hci_dev *hdev = req->hdev; + if (hdev->scanning_paused) { + bt_dev_dbg(hdev, "Scanning is paused for suspend"); + return; + } + /* Use ext scanning if set ext scan param and ext scan enable is * supported */ @@ -2657,6 +2662,11 @@ static int le_scan_restart(struct hci_request *req, unsigned long opt) if (!hci_dev_test_flag(hdev, HCI_LE_SCAN)) return 0; + if (hdev->scanning_paused) { + bt_dev_dbg(hdev, "Scanning is paused for suspend"); + return 0; + } + hci_req_add_le_scan_disable(req); if (use_ext_scan(hdev)) { -- 2.27.0.111.gc72c7da667-goog