Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1639433pxu; Thu, 17 Dec 2020 15:09:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJz9ywMZ1vlwlrUt+lHB1GKI1vuJjveaJH/Rtc+cEbGO+K0MEpJQbPfN3ee4zqN8GN7pOgE0 X-Received: by 2002:a17:906:7aca:: with SMTP id k10mr1385868ejo.388.1608246560526; Thu, 17 Dec 2020 15:09:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608246560; cv=none; d=google.com; s=arc-20160816; b=S7fZQI8h9FVQ4tN4+2Mw52yw0brpkDhky7PlfR4lek3XRFAtKg3TYLEbgtCjkT8q6J nR92dmr7ldVaacXKKeO1SsE5VHTYQAqNSdvydpFXEQ2Iw42ElQkUny5YGRQnegFWdtCO dDjICwoSIvbGrK2V51cHAkjr/Z50g2Er0RghN5IzPoScpgK5T1apEj9bm8QaiCxvxGa9 nc2RxGu7j0oMWJzXsq9XD5WPQh8g5ow921fpI+1cnlOQe/Nx8wjNX59gGCV1miMVdy04 HhDq7/jZ8XrHmrREPAKTH/1IFwkxhRx7pUfYNON35iO+0pty94HFOHiiwV83PXy+QyBy iPsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=xuN3s87sgv5dYv1RWZnvVr37IV4kzzDZbC355KoF86s=; b=d6wsPxG1JaIPIX1vOh6Qhg4nmPV3RxWW9olg48V/vCN3ypzPWtq16FYtQgeKBUmA7z dAwjzbfa5+3SwVlS8GKS51COapEnukMAaimWSOAro8NxD4r3kiWDi7aSkCERrKHiFW3/ 4ZcnSI75msKakIsEb41KDT3mgbtT/FRLdPJG+lNUWjbQrxScSBpUikhjSqv2I8q3Wm+N MbHCE0T5MlKBIBeLLgbK2NSOdswggOTMQsy3O2K8ErY9+xE8xxigUz1BbR+PLiUZuAM6 2g8j8IE2DBb3b6xigEkYQIhC/eVtDVxDCQMajAvUrrWcZq+lmLfThguZKyM4gGiH/ai8 aErA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=gNYVoiuP; 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 z102si5086363ede.307.2020.12.17.15.08.58; Thu, 17 Dec 2020 15:09:20 -0800 (PST) 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=gNYVoiuP; 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 S1732317AbgLQXE4 (ORCPT + 99 others); Thu, 17 Dec 2020 18:04:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729402AbgLQXE4 (ORCPT ); Thu, 17 Dec 2020 18:04:56 -0500 Received: from mail-pg1-x536.google.com (mail-pg1-x536.google.com [IPv6:2607:f8b0:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 18A43C061794 for ; Thu, 17 Dec 2020 15:04:16 -0800 (PST) Received: by mail-pg1-x536.google.com with SMTP id n7so134794pgg.2 for ; Thu, 17 Dec 2020 15:04:16 -0800 (PST) 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=xuN3s87sgv5dYv1RWZnvVr37IV4kzzDZbC355KoF86s=; b=gNYVoiuPmDtcwNGgz1b29ap/WFF1trap8wB+8F3/ztzMefmOEU7saVMs3StoaqtlAH 9Q8N3sf1nJNiAhPl30mLWT9rNWcMRL/4jESUIXbVfkLi8FQUqfpdgxGE7cbX+EuWkw4P 1zxaKNqHwd03cw5UeRIIdyo4kxBqKz2+CUimc= 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=xuN3s87sgv5dYv1RWZnvVr37IV4kzzDZbC355KoF86s=; b=W4PudPy2J4McU6MjctU7TNKb5/Pz5ugq9+isBHBnUcvZA5TjCOwdAFW4TpJnC4El1u QeBOtwsMNF3lX8pHtrp350t1YdeqwRDqdL2zal/FS11y7e6XP2Ylkbmlw194aM8NRPOL 4FhRW7UlFipHakv32T4z3/S1ITDOdTS3vfmcpHM8uG59+/JII09mfTzM+7opjXOnDXIC z+E7Xme1XrTlIYgQYXvZF/N3d0Nhmu1/P5e9OMp8delhe9PDDpaVaAXzJYmxswCHjWpc 3uIytcDifJ6ABdhLYVpGWSMQ4Lt1BBZfc1yAP+YMMI+YFlUHxWzoaUkhSDT+OV90jdFR RzDg== X-Gm-Message-State: AOAM530zSdM19dKOABK7vmkZxwaHzi4truKRQztCP6nKTLkzWAj7wfz2 L2RoOYlcuhgIVYxwujkN+fhKEQ== X-Received: by 2002:a63:eb4b:: with SMTP id b11mr1435362pgk.351.1608246255566; Thu, 17 Dec 2020 15:04:15 -0800 (PST) Received: from apsdesk.mtv.corp.google.com ([2620:15c:202:1:7220:84ff:fe09:2b94]) by smtp.gmail.com with ESMTPSA id q23sm6001004pgm.89.2020.12.17.15.04.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Dec 2020 15:04:15 -0800 (PST) From: Abhishek Pandit-Subedi To: marcel@holtmann.org, linux-bluetooth@vger.kernel.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 , Luiz Augusto von Dentz Subject: [PATCH] Bluetooth: Pause service discovery for suspend Date: Thu, 17 Dec 2020 15:04:08 -0800 Message-Id: <20201217150346.1.If6feff48e17a881af9cb55526db7f53bf0db40f1@changeid> X-Mailer: git-send-email 2.29.2.729.g45daf8777d-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Just like MGMT_OP_START_DISCOVERY, we should reject MGMT_OP_START_SERVICE_DISCOVERY with MGMT_STATUS_BUSY when we are paused for suspend. Signed-off-by: Abhishek Pandit-Subedi --- On ChromeOS, we started getting reports of scanning failing after resuming from suspend. The root cause was that Start Service Discovery was being called while discovery was supposed to be paused for suspend and it was screwing up some internal state. Adding this check immediately fixed it. The fix was tested by doing the following: * Set Discovery Filter ({'transport': 'auto'}) * Start Discovery * Suspend * Resume * Check the Discovering property Without the fix, this test failed when checking the Discovering property above. net/bluetooth/mgmt.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index fa0f7a4a1d2fc8a..608dda5403b7327 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -4798,6 +4798,14 @@ static int start_service_discovery(struct sock *sk, struct hci_dev *hdev, goto failed; } + if (hdev->discovery_paused) { + err = mgmt_cmd_complete(sk, hdev->id, + MGMT_OP_START_SERVICE_DISCOVERY, + MGMT_STATUS_BUSY, &cp->type, + sizeof(cp->type)); + goto failed; + } + uuid_count = __le16_to_cpu(cp->uuid_count); if (uuid_count > max_uuid_count) { bt_dev_err(hdev, "service_discovery: too big uuid_count value %u", -- 2.29.2.729.g45daf8777d-goog