From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 921DFC4360C for ; Thu, 26 Sep 2019 20:51:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5D1EB21D7C for ; Thu, 26 Sep 2019 20:51:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="KfUP2SE/" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728880AbfIZUvQ (ORCPT ); Thu, 26 Sep 2019 16:51:16 -0400 Received: from mail-qk1-f196.google.com ([209.85.222.196]:40792 "EHLO mail-qk1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728855AbfIZUvP (ORCPT ); Thu, 26 Sep 2019 16:51:15 -0400 Received: by mail-qk1-f196.google.com with SMTP id y144so200886qkb.7 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=DbvrHpkZ2RvtIh9ueHjwxMtNSGMSlfo8ACIUkzWRnlX8fqYUZO2ekOiw8jrXf5mKpD bmsUE6ZM3O584lRwDG3DlZ+RgyhRnD0rJxRSPF8TVrFzRbR3NY4560acSHkrGmudnlMg gw5D6mFedImDSPHIbNZnNl/Ad1CokyPuteceWi327gBZixqDOJtqcF48sEuwRWpPMcm9 3mkSvscjU8d23TFMAGpuw01iEHT+aesOZ+auiUrVPsrJCiRwJzWeJNse6ZgZDva3o/Nh IWfgalG8mg5sWljR9lkKXmZ/YYT3MkgCBZ5zhgd1DANYzoLltiSPIBBA5m5fVLMB+hG8 kPXQ== X-Gm-Message-State: APjAAAXTa6WMbQA1plnooyB2ySW/gSR7p7cTJ8D2YhJphyg/zg5xUJbT 1UW6dIFIY1Oc3TY+Cf0BXrUlNNfGrFjc/HtOS/43qA== X-Google-Smtp-Source: APXvYqyOH46/TFqgHUrRLcD+R2H/hvTOilF7SBW1cOWfI7cZ6m4E2KFuCxu8bdmVWQs6LfcrJZg983Bh2DYShcIK4bE= 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-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@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