Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp2557574ybn; Thu, 26 Sep 2019 13:51:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqxpLupJ5rCZ8FC1LftAUFBenfsNvRajdGWxvy/1QLdbe3iHRsXz3pvUWv3i/S3o+V9OeYmt X-Received: by 2002:a05:6402:1426:: with SMTP id c6mr901977edx.53.1569531102205; Thu, 26 Sep 2019 13:51:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569531102; cv=none; d=google.com; s=arc-20160816; b=YPmfjFBOn70P+yJYDCpBmSIbBQTZCd59h55laGuuTp31Ca9ZRq5pAEsGzYzeKYZOr/ Vv4L9xjFVoEw5CuWtONctAy7FwGQmaP28sbGucvrx2qTpYRHIwxpfSW8JHAiSn6gI9Q5 34JowXKlHC7jzNau7Fr1OrpUvT02CzO6kZcw2LQ7yAao6jef2sOAtRKXqPd5/tgpC8Tn DWD3wPSkgqn3RgwoV8gFfrlo+ziUkKSGRDOGXaevTTswxC/ZOrLSw/T9J/7SYE7w70ka Gc/lUDTgfpnqefKI0ZZKCTfVTiriJyZbtbrbIaqVPSj4FUhzS8jv5H4AVPmGBTZLcqaB h+Mg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=UFXRrFau2iJzsurfLrZlI44R9YQ5W58lJvvcXaxbZxI=; b=pfj5izOr6FjZoZU4MhoAsdri4rps+Ig3jRoJ5CJt6rm8mWo30M4H35cimh8JPtiTTG lsaPz1v1h+KDBQvJJ41UqbPTuLB36g0CJZqAUCbRMRI+kqqzshzdck/mHx1Bgnv9vV7W S71Q0NxGyfOrW5zUQripoD2l0g/MnQXJRjk0PY6C6lseqwQlrmkZTMXmyLJTDjwrjfRa BgAPM7iDs8qwMTqC7NvdPXKKK7KkiPmr9xWXXG/4ba2aL47UesgibDUAwQUFmrUwX+pa vqjGP/2daQffXCsWgEU2cLvZTb9UhVWizhI1YiJgRlUNbbJnMzCHoYBeJi6ljBMnRaV7 FiZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="KfUP2SE/"; spf=pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id 26si1844927ejl.292.2019.09.26.13.51.15; Thu, 26 Sep 2019 13:51:42 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="KfUP2SE/"; spf=pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 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 S1728841AbfIZUvO (ORCPT + 99 others); Thu, 26 Sep 2019 16:51:14 -0400 Received: from mail-qk1-f195.google.com ([209.85.222.195]:35158 "EHLO mail-qk1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727868AbfIZUvO (ORCPT ); Thu, 26 Sep 2019 16:51:14 -0400 Received: by mail-qk1-f195.google.com with SMTP id w2so229055qkf.2 for ; Thu, 26 Sep 2019 13:51:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=UFXRrFau2iJzsurfLrZlI44R9YQ5W58lJvvcXaxbZxI=; b=KfUP2SE/YczAT4JhpCDujik7WoLJGyfqT3XGtzKI3SNB9DXBFNzL5mRonozZ1n2YQP LJr2eSJSaF5hXp3ti/nJwV7A5FTVzR7PfNvyyF6wpTOQaAg3HkdZCJJSZraM5Ec8+pzT whmvG1e7OsMifGARMfI3T70qIMuG5fdAVlS+o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=UFXRrFau2iJzsurfLrZlI44R9YQ5W58lJvvcXaxbZxI=; b=QVeVncDNnLhH7RgIYmIoiUSPSA1N730hj9iFmJf3yceG4BxmDMIeVCSDie3A9XdJSP qV5gn3HPs17LxcRMJHHf/lwW5nHqM5QbI9PffGjcBlXXveWJKzBXwkFL9gFWozasIGfo qOiAzWUDuxaPDG/Ft1Aw1vs7z6ghm3DZwyTTfWyKdj5JcwyWORaAaVIy2ZhKkx8xYO+N utd0HL28Ibg1Fbu72LbT5oNfM6k6Y1b79tiPlTYXuj2Ar02EWyR6mS6BWoIhFmKhfTqh At6Kl+oEMMzusUJBuACNPXhRcwh0PRkWmZE8+FqBHvUUXgtbW03hTz5Pot+dM9GkSqJX f1fg== X-Gm-Message-State: APjAAAUXMp0vy3Crl0vJdCF6+XRf2c2FVDyPvH1qoo6mwwNeIys/yqr9 iaIIk553p25YC9Ws89Ai3mQHfnv6csm536p5eB+XIw== X-Received: by 2002:a37:498f:: with SMTP id w137mr855825qka.419.1569531073398; Thu, 26 Sep 2019 13:51:13 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Abhishek Pandit-Subedi Date: Thu, 26 Sep 2019 13:51:02 -0700 Message-ID: Subject: Re: [PATCH 0/2] Reset realtek bluetooth devices during user suspend To: Alan Stern Cc: linux-bluetooth@vger.kernel.org, linux-usb@vger.kernel.org, Douglas Anderson , Kai-Heng Feng , Hui Peng , linux-pm@vger.kernel.org, Johan Hedberg , Suzuki K Poulose , Mark Brown , "Rafael J. Wysocki" , Wolfram Sang , linux-kernel@vger.kernel.org, Marcel Holtmann , Len Brown , Mathias Payer , Dmitry Torokhov , Greg Kroah-Hartman , Mans Rullgard , Pavel Machek , YueHaibing Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org On Wed, Sep 18, 2019 at 11:51 AM Alan Stern wrote: > > On Wed, 18 Sep 2019, Abhishek Pandit-Subedi wrote: > > > Sorry, last reply went out with HTML. Re-sending in plain text. > > > > On Wed, Sep 18, 2019 at 7:23 AM Alan Stern wrote: > > > > > > On Tue, 17 Sep 2019, Abhishek Pandit-Subedi wrote: > > > > > > > On a Realtek USB bluetooth device, I wanted a simple and consistent way > > > > to put the device in reset during suspend (2 reasons: to save power and > > > > disable BT as a wakeup source). Resetting it in the suspend callback > > > > causes a detach and the resume callback is not called. Hence the changes > > > > in this series to do the reset in suspend_noirq. > > > > > > What about people who _want_ BT to be a wakeup source? > > > > When BT is enabled as a wakeup source, there is no reset. > > > > > Why does putting the device in reset save power? That is, a suspended > > > device is very strictly limited in the amount of current it's allowed > > > to draw from the USB bus; why should it draw significantly less when it > > > is reset? > > > > I don't know that it's significantly less (only that it's OFF). My > > greater motivation is to make sure the bluetooth chip isn't > > accumulating events while the host is turned off. Sorry, I should have > > made that more clear in the cover letter. > > > > When the host is off, it continues to accumulate events for the host > > to process (packets from connected devices, LE advertisements, etc). > > At some point, the firmware buffers fill up and no more events can be > > stored. When the host is resumed later on, the firmware is in a bad > > state and doesn't respond. I had originally just reset in ->resume but > > then connected wireless devices wouldn't disconnect from the BT either > > and I had trouble getting them to reconnect. > > > > > > > > > I looked into using PERSIST and reset on resume but those seem mainly > > > > for misbehaving devices that reset themselves. > > > > > > They are, but that doesn't mean you can't use them for other things > > > too. > > > > > > > This patch series has been tested with Realtek BT hardware as well as > > > > Intel BT (test procedure = disable as wake source, user suspend and > > > > observe a detach + reattach on resume). > > > > > > This series really seems like overkill for a single kind of device. > > > > > > Is there any way to turn off the device's BT radio during suspend (if > > > wakeup is disabled) and then turn it back on during resume? Wouldn't > > > that accomplish what you want just as well? > > > > Probably (but I couldn't find a way to do that). > > There's no way to turn off the device's BT radio? Then what happens > when the user turns off Bluetooth from the wireless control panel? It looks like bluez invokes hci_dev_do_close. This gracefully clears any packets in flight, clears any pending actions and disables the device as a wakeup source (which for Realtek allows it to enter global suspend). This is approximately what I was trying to achieve. > > I want to prevent > > bluetooth from waking up the host and to reliably be in a good state > > when the host resumes. The reset logic I implemented causes the hci > > device to disappear and reappear, which userspace seems to handle > > gracefully. > > Have you tried out the persist/reset-on-resume approach? > > Alan Stern > I think I'll abandon this patch series. The general sentiment seems to be "don't do this" and it looks like closing the hci device is better in my case. Thanks for the feedback and pointing me this way. Abhishek