Received: by 2002:a05:6a10:6ea6:0:0:0:0 with SMTP id ie38csp638757pxb; Wed, 30 Jun 2021 13:17:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyUXbOInR6ZYo/n0/8AzvWj4Sn9UYgVMcEGaFx26yuKTBAN6UBd5zRSjRymkwAwt7UKbmBg X-Received: by 2002:a17:906:2da1:: with SMTP id g1mr36767973eji.47.1625084236397; Wed, 30 Jun 2021 13:17:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625084236; cv=none; d=google.com; s=arc-20160816; b=fbsl/N9e8/5hkFPJWA4UCI7/RL06iUf19oSr+fs86pBYR5RdRvbbF1P17U2PEaSO9T WfI4PrGOB3AlQzI4b/js/vezDTW3t6Z6A/EMomjEEhUUWMiYH2agK7AARqBqpuiCM4Io vxH341syCgPpZblVOLG5AWpLOB1zJElzZvOBflu7UvPiL7HYxMC/KyUxMFVehiZQh0t2 HYkk+n/ndF1IeUhjhJkk1K6/eHl+w+fkYzWVYAwhftj7t7gaYjxRmUPsGwu3gYWpdFCc Ud4LwfdNVDp/tvlA99ztS5Ih5XvBcNrQp3ojgkTudpuvfbbkhDJFe/qyCBNjK07/3aek rJ2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version; bh=gcdaP2ny9XjKb7d/eNnWLX9CJwH12oZ/m8uQkejNsus=; b=tmjQh9GXmuiSIdgataXAtxWJsaOfy9O6ADhBY15p7TDnjDZ5beIqjeiOmhiJXz/VV4 M3sYt4J9PhT7r1YUt+BDnZr/d/KoiVMP5+rwH0ibxoEfslaTmIIXk/ej87bPblFFp7RB QLRxMsBrsK3LdjX6vl11aF3GC5VXyz/XHgb/ARQ4QOXCwFfz5C2rVNbCW+lLCJp4Vwiy yQmfRJ/HuOldcj/+Il+XhNnckIZosowHQJI6mp1p6NJj3rO9BZgcegDSrNk9GllCFQ41 SGm6rEW1jrJEU/s7LLUHw/TY7jpmLbMvS34GSFWTqMzuYg2H5H7ElVDopRB1S7Ha0wT3 raPg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hx8si20527703ejc.522.2021.06.30.13.16.52; Wed, 30 Jun 2021 13:17:16 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234057AbhF3US2 (ORCPT + 99 others); Wed, 30 Jun 2021 16:18:28 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:38736 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233847AbhF3US2 (ORCPT ); Wed, 30 Jun 2021 16:18:28 -0400 Received: from smtpclient.apple (tmo-122-159.customers.d1-online.com [80.187.122.159]) by mail.holtmann.org (Postfix) with ESMTPSA id B12E4CED24; Wed, 30 Jun 2021 22:15:57 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.100.0.2.22\)) Subject: Re: [PATCH v3] Bluetooth: hci_h5: Disable the hci_suspend_notifier for btrtl devices From: Marcel Holtmann In-Reply-To: <20210629195907.64769-1-hdegoede@redhat.com> Date: Wed, 30 Jun 2021 22:15:55 +0200 Cc: Johan Hedberg , Luiz Augusto von Dentz , Bluetooth Kernel Mailing List , Luiz Augusto von Dentz , Vasily Khoruzhick , Abhishek Pandit-Subedi Content-Transfer-Encoding: 7bit Message-Id: <4AD88FCC-099B-4412-A84D-8A9B00DD3CA0@holtmann.org> References: <20210629195907.64769-1-hdegoede@redhat.com> To: Hans de Goede X-Mailer: Apple Mail (2.3654.100.0.2.22) Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Hi Hans, > The hci_suspend_notifier which was introduced last year, is causing > problems for uart attached btrtl devices. These devices may loose their > firmware and their baudrate setting over a suspend/resume. > > Since we don't even know the baudrate after a suspend/resume recovering > from this is tricky. The driver solves this by treating these devices > the same as USB BT HCIs which drop of the bus during suspend. > > Specifically the driver: > 1. Simply unconditionally turns the device fully off during > system-suspend to save maximum power. > 2. Calls device_reprobe() from a workqueue to fully re-init the device > from scratch on system-resume (unregistering the old HCI and > registering a new HCI). > > This means that 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 in practice this is actually causing problems: > > 1. These btrtl devices seem to not like the HCI_OP_WRITE_SCAN_ENABLE( > SCAN_DISABLED) request being send to them when entering the > BT_SUSPEND_CONFIGURE_WAKE state. The same request send on > BT_SUSPEND_DISCONNECT works fine, but the second one send (unnecessarily?) > from the BT_SUSPEND_CONFIGURE_WAKE transition causes the device to hang: > > [ 573.497754] PM: suspend entry (s2idle) > [ 573.554615] Filesystems sync: 0.056 seconds > [ 575.837753] Bluetooth: hci0: Timed out waiting for suspend events > [ 575.837801] Bluetooth: hci0: Suspend timeout bit: 4 > [ 575.837925] Bluetooth: hci0: Suspend notifier action (3) failed: -110 > > 2. The PM_POST_SUSPEND / BT_RUNNING transition races with the > driver-unbinding done by the device_reprobe() work. > If the hci_suspend_notifier wins the race it is talking to a dead > device leading to the following errors being logged: > > [ 598.686060] Bluetooth: hci0: Timed out waiting for suspend events > [ 598.686124] Bluetooth: hci0: Suspend timeout bit: 5 > [ 598.686237] Bluetooth: hci0: Suspend notifier action (4) failed: -110 > > In both cases things still work, but the suspend-notifier is causing > these ugly errors getting logged and ut increase both the suspend- and > the resume-time by 2 seconds. > > This commit avoids these problems by disabling the hci_suspend_notifier. > > Cc: Luiz Augusto von Dentz > Cc: Vasily Khoruzhick > Cc: Abhishek Pandit-Subedi > Signed-off-by: Hans de Goede > --- > Changes in v3: > - Use hu->flags instead of hu->hdev_flags to store the > HCI_UART_NO_SUSPEND_NOTIFIER flag > > Changes in v2: > - Use the new HCI_QUIRK_NO_SUSPEND_NOTIFIER quirk, instead of directly > unregistering the notifier from hci_h5.c > --- > drivers/bluetooth/hci_h5.c | 7 +++++++ > drivers/bluetooth/hci_serdev.c | 3 +++ > drivers/bluetooth/hci_uart.h | 7 ++++--- > 3 files changed, 14 insertions(+), 3 deletions(-) patch has been applied to bluetooth-next tree. Regards Marcel