Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1976222pxb; Fri, 5 Mar 2021 04:35:11 -0800 (PST) X-Google-Smtp-Source: ABdhPJwf2gnSnjP4XI5vZWIOPKQTgNgdL7OEJE7LH387KOaw2+ge8Fiwpk1Lmcd+7/XW/wVR5Har X-Received: by 2002:a17:907:94cc:: with SMTP id dn12mr2019901ejc.177.1614947711208; Fri, 05 Mar 2021 04:35:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614947711; cv=none; d=google.com; s=arc-20160816; b=Chwwcbu4lv7i/L6Btr99AFzx3hJhhdLF2itS6iRJum70cK7AmdcSbCJtrrxH6i7pAf STcM1956uL2s+S2yNJY0T1tIQP7R9OhKQg4ZaH46qDdtZneYlWQtbL6iaw2UhAmOk6/V SE+fMpSo937BBbDNR9oQTxw36rW7uBuqwvFGZOmHOqdkOeF9gzf2cAAnR45dc+Te4wz5 SFTWN/JjgCpFEUxdSMMLxxPJd6DiSYMpvd8/tppQ5JFoYle26dWUdXl+EdqfdENt66Vu 9mrQJG5BlxNLKzxI6FCFpJM0c60qwhRMmSvW58PaBjYa+dRoZ3JiHKW0HNPH5ASj9zPv Ssbw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=oX7zgwJjY72yp1PMIqcwV4wERQbOOjiVMQM4F81TJW4=; b=I4xsi9/O4+ry/NiTHn0AvjUgrNRj7hilQbXgR66dm8KK1dWbJsd7lEzCKWJf0Ka7dh +XcNl+iN15yFwU9GPwUuW4lljv7qXJKgjFhN2WT9yn+f+eUNFRKg6pF83GsW6enOK3wO uovvXUJMF5RlEXLm5sohjHnRcNzI4eRngtswGybhjQyUKYJXcvAo+B8s1wHfafySPJa1 CuIganPeZY+Ku/7+KwMIzwZ6VDIGYFpujOi13zQiLuFef7fjT7zVNZBveajsj3Xxe3v1 TDIyWq8cnFWKuOf8vtNyrqX51ZtCSbw4JMPCR5TrgtX0c2YPhAcUi122DeESP1arQ2Rq IndA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="w1owl1/e"; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e22si1510030edu.9.2021.03.05.04.34.46; Fri, 05 Mar 2021 04:35:11 -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=@linuxfoundation.org header.s=korg header.b="w1owl1/e"; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232513AbhCEMcA (ORCPT + 99 others); Fri, 5 Mar 2021 07:32:00 -0500 Received: from mail.kernel.org ([198.145.29.99]:41710 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231713AbhCEMb3 (ORCPT ); Fri, 5 Mar 2021 07:31:29 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1118165037; Fri, 5 Mar 2021 12:31:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1614947483; bh=7uwTKHEL8JkD0rm5wRmW3YlVYJuG/FlrtnHMdD9VSpo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=w1owl1/e/rYLnbr6jA/D7pDcIMGm0l+rNMlBhsTsSt/MCffiKxh1nHKRbL9wOzUUg fH+vVoewkNXsv3JBQucOgpLhUGN74RSsGb9kesZnc90TlkL6ySWX8fA0fGcsAf4HWC nvRzUveRQWFr/w+H97AkOXQU3IeTQv/u0RAOwEg0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hans de Goede , Abhishek Pandit-Subedi , Marcel Holtmann , Sasha Levin Subject: [PATCH 5.10 051/102] Bluetooth: Add new HCI_QUIRK_NO_SUSPEND_NOTIFIER quirk Date: Fri, 5 Mar 2021 13:21:10 +0100 Message-Id: <20210305120905.803451961@linuxfoundation.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210305120903.276489876@linuxfoundation.org> References: <20210305120903.276489876@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Hans de Goede [ Upstream commit 219991e6be7f4a31d471611e265b72f75b2d0538 ] Some devices, e.g. the RTL8723BS bluetooth part, some USB attached devices, completely drop from the bus on a system-suspend. These devices will have their driver unbound and rebound on resume (when the dropping of the bus gets detected) and will show up as a new HCI after resume. These devices do not benefit from the suspend / resume handling work done by the hci_suspend_notifier. At best this unnecessarily adds some time to the suspend/resume time. But this may also actually cause problems, if the code doing the driver unbinding runs after the pm-notifier then the hci_suspend_notifier code will try to talk to a device which is now in an uninitialized state. This commit adds a new HCI_QUIRK_NO_SUSPEND_NOTIFIER quirk which allows drivers to opt-out of the hci_suspend_notifier when they know beforehand that their device will be fully re-initialized / reprobed on resume. Signed-off-by: Hans de Goede Reviewed-by: Abhishek Pandit-Subedi Signed-off-by: Marcel Holtmann Signed-off-by: Sasha Levin --- include/net/bluetooth/hci.h | 8 ++++++++ net/bluetooth/hci_core.c | 18 +++++++++++------- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h index c8e67042a3b1..6da4b3c5dd55 100644 --- a/include/net/bluetooth/hci.h +++ b/include/net/bluetooth/hci.h @@ -238,6 +238,14 @@ enum { * during the hdev->setup vendor callback. */ HCI_QUIRK_BROKEN_ERR_DATA_REPORTING, + + /* + * When this quirk is set, then the hci_suspend_notifier is not + * registered. This is intended for devices which drop completely + * from the bus on system-suspend and which will show up as a new + * HCI after resume. + */ + HCI_QUIRK_NO_SUSPEND_NOTIFIER, }; /* HCI device flags */ diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 7a2f9559e99a..0152bc6b6796 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -3785,10 +3785,12 @@ int hci_register_dev(struct hci_dev *hdev) hci_sock_dev_event(hdev, HCI_DEV_REG); hci_dev_hold(hdev); - hdev->suspend_notifier.notifier_call = hci_suspend_notifier; - error = register_pm_notifier(&hdev->suspend_notifier); - if (error) - goto err_wqueue; + if (!test_bit(HCI_QUIRK_NO_SUSPEND_NOTIFIER, &hdev->quirks)) { + hdev->suspend_notifier.notifier_call = hci_suspend_notifier; + error = register_pm_notifier(&hdev->suspend_notifier); + if (error) + goto err_wqueue; + } queue_work(hdev->req_workqueue, &hdev->power_on); @@ -3823,9 +3825,11 @@ void hci_unregister_dev(struct hci_dev *hdev) cancel_work_sync(&hdev->power_on); - hci_suspend_clear_tasks(hdev); - unregister_pm_notifier(&hdev->suspend_notifier); - cancel_work_sync(&hdev->suspend_prepare); + if (!test_bit(HCI_QUIRK_NO_SUSPEND_NOTIFIER, &hdev->quirks)) { + hci_suspend_clear_tasks(hdev); + unregister_pm_notifier(&hdev->suspend_notifier); + cancel_work_sync(&hdev->suspend_prepare); + } hci_dev_do_close(hdev); -- 2.30.1