Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp383962pxu; Wed, 25 Nov 2020 05:48:11 -0800 (PST) X-Google-Smtp-Source: ABdhPJxEAKpstOsW7gAZc8MO548JFxC9+xh8n+2fqOdfsiZOIePzqn24/IWg9blD6bpQheCDW/aj X-Received: by 2002:a17:906:6947:: with SMTP id c7mr3231460ejs.533.1606312091078; Wed, 25 Nov 2020 05:48:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606312091; cv=none; d=google.com; s=arc-20160816; b=O5aWcFr+tpdDai+vzudm9lHDJTQA0TP+EZOMUChsyppg13OFmqipKfcXNd5MnIon4W 8ZVxfvhnoMsdfskHhjui7Md8H7NqF0vIhJ5MJaVAzXUit5bKf18vRgORLI8msJhq6tBM bxvNSkGLCuU9/cIAty6vqWqcWNX7PB29JAcjYPMOqh6cDcFkmEaf6UN/R5Er4JeebkJ1 WpsW49W2+A7OA+bioKLJt4g9MyQBRUSvkm/mDSSAujYOx7BrE+4hUZjG4XlAkEL2L1sV LxjdDn7U2IvPlE+aGZ7geUwH5JE6dyvd+XHyWDxvcj1OdZ4nwN975ltEuGkaPET3KrG2 gzsw== 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=+xjs3/HpZm0tih5dCStK5T0ZiN//K/gBcz/ZehjhKRc=; b=yOgdEcxbdNU/Kpp/HawBucCRUSrrjUyBzhutHLyDITBHZu+Q5K9MWzfomc26FlnFX3 AaH+4LOyrwQHOIzrBTf4jxYUKiMuH0o16wu40Ujs4D6VQSz+IIWu17bFDwjroLnKQfcT WiPrLUQL/CHh4mJcJptoU2X39enHSi7aXPEincyikYntZLZgcBkjmPkjdeMDR5mw96OR F2iQCERFG0a5QdfX+kLlZB+WhlJnbGqIDf3hu+rEK+YSGS0S72CYU8MuBuxQj65LdfzR hVp65eIL+ed19EkNjbBZMIE/DH/Oge8DPpsdp/Ik4KIw++6Q1bZ8s41X0kjMeIOo9NG6 8y0Q== 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 l34si1170681ede.416.2020.11.25.05.47.29; Wed, 25 Nov 2020 05:48:11 -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; 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 S1728792AbgKYNrU convert rfc822-to-8bit (ORCPT + 99 others); Wed, 25 Nov 2020 08:47:20 -0500 Received: from coyote.holtmann.net ([212.227.132.17]:59644 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725792AbgKYNrU (ORCPT ); Wed, 25 Nov 2020 08:47:20 -0500 Received: from marcel-macbook.holtmann.net (unknown [37.83.193.87]) by mail.holtmann.org (Postfix) with ESMTPSA id B42A0CED07; Wed, 25 Nov 2020 14:54:29 +0100 (CET) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.20.0.2.21\)) Subject: Re: [PATCH 0/3] Bluetooth: Power down controller when suspending From: Marcel Holtmann In-Reply-To: Date: Wed, 25 Nov 2020 14:47:16 +0100 Cc: crlo@marvell.com, akarwar@marvell.com, BlueZ development , ChromeOS Bluetooth Upstreaming , Miao-chen Chou , Daniel Winkler , "David S. Miller" , Johan Hedberg , netdev , LKML , Jakub Kicinski Content-Transfer-Encoding: 8BIT Message-Id: References: <20201118234352.2138694-1-abhishekpandit@chromium.org> <7235CD4E-963C-4BCB-B891-62494AD7F10D@holtmann.org> To: Abhishek Pandit-Subedi X-Mailer: Apple Mail (2.3654.20.0.2.21) Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Hi Abhishek, >>> This patch series adds support for a quirk that will power down the >>> Bluetooth controller when suspending and power it back up when resuming. >>> >>> On Marvell SDIO Bluetooth controllers (SD8897 and SD8997), we are seeing >>> a large number of suspend failures with the following log messages: >>> >>> [ 4764.773873] Bluetooth: hci_cmd_timeout() hci0 command 0x0c14 tx timeout >>> [ 4767.777897] Bluetooth: btmrvl_enable_hs() Host sleep enable command failed >>> [ 4767.777920] Bluetooth: btmrvl_sdio_suspend() HS not actived, suspend failed! >>> [ 4767.777946] dpm_run_callback(): pm_generic_suspend+0x0/0x48 returns -16 >>> [ 4767.777963] call mmc2:0001:2+ returned -16 after 4882288 usecs >>> >>> The daily failure rate with this signature is quite significant and >>> users are likely facing this at least once a day (and some unlucky users >>> are likely facing it multiple times a day). >>> >>> Given the severity, we'd like to power off the controller during suspend >>> so the driver doesn't need to take any action (or block in any way) when >>> suspending and power on during resume. This will break wake-on-bt for >>> users but should improve the reliability of suspend. >>> >>> We don't want to force all users of MVL8897 and MVL8997 to encounter >>> this behavior if they're not affected (especially users that depend on >>> Bluetooth for keyboard/mouse input) so the new behavior is enabled via >>> module param. We are limiting this quirk to only Chromebooks (i.e. >>> laptop). Chromeboxes will continue to have the old behavior since users >>> may depend on BT HID to wake and use the system. >> >> I don’t have a super great feeling with this change. >> >> So historically only hciconfig hci0 up/down was doing a power cycle of the controller and when adding the mgmt interface we moved that to the mgmt interface. In addition we added a special case of power up via hdev->setup. We never had an intention that the kernel otherwise can power up/down the controller as it pleases. > > Aside from the powered setting, the stack is resilient to the > controller crashing (which would be akin to a power off and power on). > From the view of bluez, adapter lost and power down should be almost > equivalent right? ChromeOS has several platforms where Bluetooth has > been reset after suspend, usually due USB being powered off in S3, and > the stack is still well-behaving when that occurs. it gets multitudes more complicated if you look at HCI User Channel and other pieces that utilize the core HCI infrastructure. HCI interface lost, because of USB disconnect is different. That is a clean path. Similar to RFKILL that just only does a power down. >> Can we ask Marvell first to investigate why this is fundamentally broken with their hardware? > > +Chin-Ran Lo and +Amitkumar Karwar (added based on changes to > drivers/bluetooth/btmrvl_main.c) > > Could you please take a look at the original cover letter and comment > (or add others at Marvell who may be able to)? Is this a known issue > or a fix? I wonder if sending a HCI Reset at before entering suspend would be enough. Meaning clear all controller states first and then suspend. This will still disable any kind of remote wakeup support, but might avoid having to fully power down and power up again. >> Since what you are proposing is a pretty heavy change that might has side affects. For example the state machine for the mgmt interface has no concept of a power down/up from the kernel. It is all triggered by bluetoothd. >> >> I am careful here since the whole power up/down path is already complicated enough. >> > > That sounds reasonable. I have landed this within ChromeOS so we can > test whether a) this improves stability enough and b) whether the > power off/on in the kernel has significant side effects. This will go > through our automated testing and dogfooding over the next few weeks > and hopefully identify those side-effects. I will re-raise this topic > with updates once we have more data. > > Also, in case it wasn't very clear, I put this behind a module param > that defaults to False because this is so heavy handed. We're only > using it on specific Chromebooks that are exhibiting the worst > behavior and not disabling it wholesale for all btmrvl controllers. We really need a conformance hci-tester that checks if a controller is behaving correctly as promised. Regards Marcel