Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp750478pxk; Wed, 9 Sep 2020 19:02:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyInouHY623F2Jt9IfPO38rvns+qRGW/qG5pnBzsm6hOrnBFdEn6UOcSsgR5j/brvcp/+6H X-Received: by 2002:a17:906:fa8a:: with SMTP id lt10mr6379921ejb.307.1599703323354; Wed, 09 Sep 2020 19:02:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599703323; cv=none; d=google.com; s=arc-20160816; b=shlkN7M8z8ZPtkCUMevrweZ6c6qN6P/QUeybuV6kQNR9OGFAK+QQKRs3Hwswe67IZl eBSpDFNikVhE0SjR68XLpd/b340muXfmtu6XrRyKIkQP/ZpksUsPjtVVLN1/N93KQQD7 0hR3ZY6rSK9cSWy4h4DVjVVmy7rALKPNCgDKx7sWq6wHJrd+kpBpoli1Y9mCubEBbCPw ow9z/6qElsCoslXNtAANcqovsF13kkKuD+erG4fPz3rBnqtiwR40xeW8sH1rluIexqHJ lFjlfrl8H2C/8FvcT3hxzLkWiLb7yXItTragtanabUSrEA9xP/rEmYDGtGsStNHiiMta h1AQ== 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=gTez5zBL4O/mFCX1yAYIY6uoJGixvvecrhH5yeefCRU=; b=Ah9tD0HXcVye6rePzRre/4CJuxn8DCVDHYdBISFfIIu/rQauoRHQsmj2C2znnaSjGO gF8yk7lxaXSsQnd/muYM5rk9d4jxIgJjncJzsRL2R2jW19SFnF2ifnYv+uos9o0zL3HB E74G+qjYi+uXeI2NJIOkickUJs+LVltT3pmkLzUTAHpZ51tM0osLKWAsrgX8V3gWwLXn PdG2Z+pmMvPNA5ufvilO97FkSNKb6pXu+bZhrkNvdK7bn6NScNlHCcoT1T4ISfwB7BxH l6dGkzGHcXyFVnnsFk4WP24WqDQ7AoJ5ZmLfguVCZYLiz22E4UUVs9v6a2+pc4yj7uaB NEXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=SxkcIkqS; 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 d13si2838680edj.132.2020.09.09.19.01.16; Wed, 09 Sep 2020 19:02:03 -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=SxkcIkqS; 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 S1729521AbgIJCA3 (ORCPT + 99 others); Wed, 9 Sep 2020 22:00:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51292 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730150AbgIJByT (ORCPT ); Wed, 9 Sep 2020 21:54:19 -0400 Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 05CD7C061389 for ; Wed, 9 Sep 2020 16:54:08 -0700 (PDT) Received: by mail-pl1-x644.google.com with SMTP id j7so14223plk.11 for ; Wed, 09 Sep 2020 16:54:08 -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=gTez5zBL4O/mFCX1yAYIY6uoJGixvvecrhH5yeefCRU=; b=SxkcIkqSWelb6AuUlXuHUzy1a16hhmWXJWuq8Eo/23y2lOyPcWQDUSskXt1hEJUyn6 u1wOiYNDBdX/GAOiEZ/EkYArPHBOHNGFUNcC9AVgOMGKko3iXNgtwmArngx7TwMORv1T Q14fEfQF9K7z06eGlkuJ30cEupLsJdCrymIDQ= 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=gTez5zBL4O/mFCX1yAYIY6uoJGixvvecrhH5yeefCRU=; b=EdRBASCggXyFS7lNosDGcVA2aKF8VpPkQzRJtxq/S8q7PH+yrZXomR6Zr3Hauzot1o rA/QUgwBz8FGO2Tf+eV3FA9tkyT5XS98usC+CgX06s95ENrZfCPM1Vg8kIWJs2ZZtkUt ft6SRWJwA3WVbw9m1Ouct53orCNgv/I0TfoTMyd+w2JiCj9lzb8EWh0LQC74YO1YvJwm XbzrZhhkVXotxsikOOhzfyQ7uYapAI/4JpDgt33NWI2XYi3qKPooY3e5oVxLaV7JuaNW Ve2apMQFWrYIebi7E8yYwrgaLmCqVwEInp0nDAr7Zaz5qJj8iLRKtF7KzpmuPyyw0V9w 4JXw== X-Gm-Message-State: AOAM530Q0EN0QLci+fV9gUdpAkfYqaU/9jKjTg0p/OWYWTwF+9qTI4ad f1s0oTVbczN/yrhOUiHvUzRMKA== X-Received: by 2002:a17:90a:4ec4:: with SMTP id v4mr2793960pjl.62.1599695646992; Wed, 09 Sep 2020 16:54:06 -0700 (PDT) Received: from apsdesk.mtv.corp.google.com ([2620:15c:202:1:7220:84ff:fe09:2b94]) by smtp.gmail.com with ESMTPSA id h14sm3817937pfe.67.2020.09.09.16.54.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Sep 2020 16:54:06 -0700 (PDT) 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 Subject: [PATCH] Bluetooth: Re-order clearing suspend tasks Date: Wed, 9 Sep 2020 16:53:59 -0700 Message-Id: <20200909165317.1.Ie55bb8dde9847e8005f24402f3f2d66ea09cd7b2@changeid> X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Unregister_pm_notifier is a blocking call so suspend tasks should be cleared beforehand. Otherwise, the notifier will wait for completion before returning (and we encounter a 2s timeout on resume). Fixes: 0e9952804ec9c8 (Bluetooth: Clear suspend tasks on unregister) Signed-off-by: Abhishek Pandit-Subedi --- Should have caught that unregister_pm_notifier was blocking last time but when testing the earlier patch, I got unlucky and saw that the error message was never hit (the suspend timeout). When re-testing this patch on the same device, I was able to reproduce the problem on an older build with the 0e9952804ec9c8 but not on a newer build with the same patch. Changing the order correctly fixes it everywhere. Confirmed this by adding debug logs in btusb_disconnect and hci_suspend_notifier to confirm what order things were getting called. Sorry about the churn. Next I'm going try to do something about the palm shaped indentation on my forehead... net/bluetooth/hci_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index efc0fe2b47dac2..be9cdf5dabe5dc 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -3794,8 +3794,8 @@ void hci_unregister_dev(struct hci_dev *hdev) cancel_work_sync(&hdev->power_on); - unregister_pm_notifier(&hdev->suspend_notifier); hci_suspend_clear_tasks(hdev); + unregister_pm_notifier(&hdev->suspend_notifier); cancel_work_sync(&hdev->suspend_prepare); hci_dev_do_close(hdev); -- 2.28.0.618.gf4bc123cb7-goog