Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1130551pxb; Thu, 28 Jan 2021 08:40:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJx2OVX5KOKob/mZPRlRXk3VSwq63pwm5U55xbrJig2r8mrqD5OsAfWtwRtIuofjgkROHpBU X-Received: by 2002:aa7:c643:: with SMTP id z3mr436479edr.330.1611852043467; Thu, 28 Jan 2021 08:40:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611852043; cv=none; d=google.com; s=arc-20160816; b=p0nxuqBA9ujzZVpMIu/lX9/ozQSEF3bUHJx+peWHeXBzwRscJpjVJfOw3EnqFVAsR+ HjAH2/0xpuobt2w2zfnkbh+YbudhJodr10CpKnUQYgI7hlq8FS1JmrlDNcDq0VS9ahd3 kLCfPPU/PhnI1sJqtKDINjAW+zkuKV0WUjm8H5PcOZK10Acqky+O+EzG/hsCm/1WwwQ5 UGW0dUDM49b8eslRw4BUEfvkjsRN1Jxl8oHTCNEDQmx/TcFMx3AGDXdFjicMX3SY5JaB iuuJmxFfhwEIfPyrf9fWlufxasxjipazOQ2Ymoy/WFTerVLNLw7RJHc/hLKtj0Vxc+q9 fKxw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=2IPZyAYpapBF8BqK19nNG7kbsPa0a8ESJujLK+gQEZc=; b=Y+fskdeN8pXcJPgeAJenq8FEUj2deksLbRP0S+aozH3FHkoVuXc/SAjaXbSoHNv/qT gDJE0l2/wc0OJ1WXr3wVZcI3RJqcprlmlwexOlZ4wt9CkbTQdL48KHnr/oTnUDefUrfm KuPQiDqCpMw0WXp1WRBrJCwhczyuBbMdPunVbeTEjqSPOODHKsB7NODLTcghxq9VrFSE Z/9LgyXHeVK2JM0DY+8wztC6s0PHu6zLHkum76Riywzk+E0p+r+3EKmuarYNo774PIPk 4vI4FWK3ItGy0Y1endX5qtjpA3Jq30Cqr0xhaz8a6pWDxAGa/SOgDmxBs6bmKM6OnXE5 mo+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=YZfcj9Q0; 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id rh4si3038111ejb.538.2021.01.28.08.39.43; Thu, 28 Jan 2021 08:40:43 -0800 (PST) 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=@redhat.com header.s=mimecast20190719 header.b=YZfcj9Q0; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232611AbhA1QgI (ORCPT + 99 others); Thu, 28 Jan 2021 11:36:08 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:32893 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232578AbhA1Qfg (ORCPT ); Thu, 28 Jan 2021 11:35:36 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1611851649; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2IPZyAYpapBF8BqK19nNG7kbsPa0a8ESJujLK+gQEZc=; b=YZfcj9Q03nw8AJEo+mm7OGV3zIsMCL8YiHJvNHnPG78Mae8z+pa7yKL0HsVxqiLHmWDmuv pyr5cHXx4ixswP4pL1o6ZOQnFMrxBniR0u3jAGq9I1uBgGn8aaj1fJazZ6sJfwiagJUCgS JVLRnutwQDp6OW1ygWkbDebti5BO25I= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-125-hFO-Y1RqM9OvILHs-ugsPg-1; Thu, 28 Jan 2021 11:34:05 -0500 X-MC-Unique: hFO-Y1RqM9OvILHs-ugsPg-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E4CDD1081B2C; Thu, 28 Jan 2021 16:33:17 +0000 (UTC) Received: from x1.localdomain (ovpn-114-250.ams2.redhat.com [10.36.114.250]) by smtp.corp.redhat.com (Postfix) with ESMTP id 63E1E5C233; Thu, 28 Jan 2021 16:33:16 +0000 (UTC) From: Hans de Goede To: Marcel Holtmann , Johan Hedberg Cc: Hans de Goede , linux-bluetooth@vger.kernel.org, Luiz Augusto von Dentz , Vasily Khoruzhick , Abhishek Pandit-Subedi Subject: [PATCH v2 2/2] Bluetooth: hci_h5: Disable the hci_suspend_notifier for btrtl devices Date: Thu, 28 Jan 2021 17:33:13 +0100 Message-Id: <20210128163313.426404-2-hdegoede@redhat.com> In-Reply-To: <20210128163313.426404-1-hdegoede@redhat.com> References: <20210128163313.426404-1-hdegoede@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org 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 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 | 13 +++++++------ 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/drivers/bluetooth/hci_h5.c b/drivers/bluetooth/hci_h5.c index 7be16a7f653b..e8f3afab6587 100644 --- a/drivers/bluetooth/hci_h5.c +++ b/drivers/bluetooth/hci_h5.c @@ -914,6 +914,13 @@ static int h5_btrtl_setup(struct h5 *h5) static void h5_btrtl_open(struct h5 *h5) { + /* + * Since h5_btrtl_resume() does a device_reprobe() the suspend handling + * done by the hci_suspend_notifier is not necessary; it actually causes + * delays and a bunch of errors to get logged, so disable it. + */ + set_bit(HCI_UART_NO_SUSPEND_NOTIFIER, &h5->hu->hdev_flags); + /* Devices always start with these fixed parameters */ serdev_device_set_flow_control(h5->hu->serdev, false); serdev_device_set_parity(h5->hu->serdev, SERDEV_PARITY_EVEN); diff --git a/drivers/bluetooth/hci_serdev.c b/drivers/bluetooth/hci_serdev.c index ef96ad06fa54..dbc14b8ac477 100644 --- a/drivers/bluetooth/hci_serdev.c +++ b/drivers/bluetooth/hci_serdev.c @@ -349,6 +349,9 @@ int hci_uart_register_device(struct hci_uart *hu, if (test_bit(HCI_UART_EXT_CONFIG, &hu->hdev_flags)) set_bit(HCI_QUIRK_EXTERNAL_CONFIG, &hdev->quirks); + if (test_bit(HCI_UART_NO_SUSPEND_NOTIFIER, &hu->hdev_flags)) + set_bit(HCI_QUIRK_NO_SUSPEND_NOTIFIER, &hdev->quirks); + if (test_bit(HCI_UART_CREATE_AMP, &hu->hdev_flags)) hdev->dev_type = HCI_AMP; else diff --git a/drivers/bluetooth/hci_uart.h b/drivers/bluetooth/hci_uart.h index 4e039d7a16f8..4df2330ac103 100644 --- a/drivers/bluetooth/hci_uart.h +++ b/drivers/bluetooth/hci_uart.h @@ -35,12 +35,13 @@ #define HCI_UART_NOKIA 10 #define HCI_UART_MRVL 11 -#define HCI_UART_RAW_DEVICE 0 -#define HCI_UART_RESET_ON_INIT 1 -#define HCI_UART_CREATE_AMP 2 -#define HCI_UART_INIT_PENDING 3 -#define HCI_UART_EXT_CONFIG 4 -#define HCI_UART_VND_DETECT 5 +#define HCI_UART_RAW_DEVICE 0 +#define HCI_UART_RESET_ON_INIT 1 +#define HCI_UART_CREATE_AMP 2 +#define HCI_UART_INIT_PENDING 3 +#define HCI_UART_EXT_CONFIG 4 +#define HCI_UART_VND_DETECT 5 +#define HCI_UART_NO_SUSPEND_NOTIFIER 6 struct hci_uart; struct serdev_device; -- 2.29.2