Received: by 10.223.185.116 with SMTP id b49csp3504127wrg; Tue, 13 Feb 2018 03:27:03 -0800 (PST) X-Google-Smtp-Source: AH8x227RcSQbtq0muz+tC6cyXnzYb2/Aycf1BpSKfQY3GtSc7IrY7p0SbqmrP+Ez33BetP21ZsOl X-Received: by 10.98.163.135 with SMTP id q7mr949398pfl.82.1518521223305; Tue, 13 Feb 2018 03:27:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518521223; cv=none; d=google.com; s=arc-20160816; b=qNnm2gN+JvM8xoZylo6IoKx4GpD18XhRZ9ngpZ5CXGmVXBSfeVZrzAItLjZyb5QLXv b+nNNDxwNOR8qRSZKGsHHk4q5bk7PWatHN3pJXZcEbQlWN4NWE5g0m/Ev/U+ZxhW2xQZ 7o0ZtAOzhQ4x+eveWogrm0XyPYzYVoyLLFYfIWbIODn/KaNjGG6OaiPXxsh9D2VdgyAu T820BFaTVspNfoJsnu82YJLVRW0C9JXT5gxVp/O9yZhsTupe+JjTMdMgXbNUtBFNm9lX fMXb+lJ2+IUmmf3gl77dFTPB2bqQXDI9XevQwk63HAt5XZvn1DXGpdkZKRlqJe00lmTk zITQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=4INhUsDs16i/619jThK/EUWK2lBoJFEeuJ4ilBEzQn4=; b=ehC62AsfxnAQOHPNyFwpr68fJ/OOqRXjX2v8PN3GmSi62VGWTQK22eV0mArrNF91md sCu8UY6ZAIsqVA5+OZWvHdwlKS5fbdv8pNme9Mr+jbsS4lEfABEWsVMPqVwh0eACQrs/ jDKbPOF5O0pd2LoIn93cI5P5lWWHgy6h72mYb1o9JJdJfkMfYv2dYamfVTnUyqU3taEu jY3Cc9w50hh2qrhuJ1LkVvKgk6+5rOeAC9dOs+M1ZqhYdW/6Ggd2SlmiSbroZukHkou0 uEzz/pzr1uuEmczbc3duwbmG5bhTVAztF/aipenk5/WHSOGL2BJL9ONwUOTcGUe4BoDP obZQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z1-v6si7313928plb.178.2018.02.13.03.26.48; Tue, 13 Feb 2018 03:27:03 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934712AbeBML0C (ORCPT + 99 others); Tue, 13 Feb 2018 06:26:02 -0500 Received: from mail-wm0-f65.google.com ([74.125.82.65]:50921 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934456AbeBMLZ7 (ORCPT ); Tue, 13 Feb 2018 06:25:59 -0500 Received: by mail-wm0-f65.google.com with SMTP id f71so15344639wmf.0 for ; Tue, 13 Feb 2018 03:25:58 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=4INhUsDs16i/619jThK/EUWK2lBoJFEeuJ4ilBEzQn4=; b=Mb/Gaq9D0ZhP0eThu7XzxRnrutyV5kHD4sJUzsREEQWUNxa0DxWZfM/iHgRTAaAyMa W2aGyVcccxG5z/77pdUg4nD4+Mm5fabNFAReDMVwtM1NE9ws8Iw3dpuoh+zEMUy0FPm4 0rci3dkTQk6oYXeYLMtycsP3JzFofEWF/NZmBAc0N/W466GR5RJSJJ2IVNg0Mp5pWk0N nukAd2f+h1ooc0TZKxVIFC62qCEX9yhYqUe2sF3MdNpXLFsnmF6Bus6z7/8OXB/cF9pI OMEKhZKb4GEZ304xhnHlyb2rBbxnx1h/jppSCN6tkoNRp9x0kJmlmvZUlPOKyMh2fsc8 cquQ== X-Gm-Message-State: APf1xPAh6i6uFzJBddLKILINmBRRLJHMGSmuySK21+QE2seYIwD8zu5E wycdlO1aZyfHI4AaedL9IIBoVYxbKLE= X-Received: by 10.80.179.243 with SMTP id t48mr1732064edd.31.1518521157731; Tue, 13 Feb 2018 03:25:57 -0800 (PST) Received: from shalem.localdomain (546A5441.cm-12-3b.dynamic.ziggo.nl. [84.106.84.65]) by smtp.gmail.com with ESMTPSA id i31sm568910edc.48.2018.02.13.03.25.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Feb 2018 03:25:56 -0800 (PST) Subject: Re: [PATCH] Bluetooth: btusb: Restore QCA Rome suspend/resume fix with a "rewritten" version To: Brian Norris Cc: Marcel Holtmann , Gustavo Padovan , Johan Hedberg , linux-bluetooth@vger.kernel.org, linux-serial@vger.kernel.org, linux-acpi@vger.kernel.org, stable@vger.kernel.org, Leif Liddy , Matthias Kaehlcke , Daniel Drake , Kai-Heng Feng , matadeen@qti.qualcomm.com, linux-kernel@vger.kernel.org References: <20180108094416.4789-1-hdegoede@redhat.com> <20180213022455.GA151190@rodete-desktop-imager.corp.google.com> From: Hans de Goede Message-ID: <8cd918fd-bf6f-70ac-e561-e7deffa695f0@redhat.com> Date: Tue, 13 Feb 2018 12:25:55 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <20180213022455.GA151190@rodete-desktop-imager.corp.google.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On 13-02-18 03:24, Brian Norris wrote: > Hi, > > On Mon, Jan 08, 2018 at 10:44:16AM +0100, Hans de Goede wrote: >> Commit 7d06d5895c15 ("Revert "Bluetooth: btusb: fix QCA...suspend/resume"") >> removed the setting of the BTUSB_RESET_RESUME quirk for QCA Rome devices, >> instead favoring adding USB_QUIRK_RESET_RESUME quirks in usb/core/quirks.c. >> >> This was done because the DIY BTUSB_RESET_RESUME reset-resume handling >> has several issues (see the original commit message). An added advantage >> of moving over to the USB-core reset-resume handling is that it also >> disables autosuspend for these devices, which is similarly broken on these. > > Wait, is autosuspend actually broken for all QCA Rome chipsets? I don't > think so -- I'm using one now. And have you manually enabled USB autosuspend for it, or are you running something which might have done so, e.g. powertop --auto-tune ? Because if you did not do that then you're already not using autosuspend for your QCA devices and this patch will change nothing. > Thus, this is a poor solution, which > negatively affects my systems. However, I see that this patch was > applied regardless... Note that there already is a quirk to handle broken suspend/resume behavior on ALL QCA devices in older kernels. Also note that the patches series which this commit builds on top of was already setting USB_QUIRK_RESET_RESUME for some devices in usb/core/quirks.c. All my commit does is instead of duplicating all the QCA USB-ids in usb/core/quirks.c, move the setting of USB_QUIRK_RESET_RESUME to btusb.c so that we don't need to duplicate the USB-id tables. The result of the combination of these patches is that the custom DIY reset on resume handling btusb.c was doing is now replaced by setting the standard USB-core USB_QUIRK_RESET_RESUME quirk. As a (desirable) side effect this also disables USB autosuspend for QCA devices since the USB-core does not allow USB autosuspend on devices with the USB_QUIRK_RESET_RESUME quirk. Testing has shown this to be necessary on at least some QCA devices and given that these devices tend to loose there firmware on a suspend, it seems sensible to not allow autosuspend on them. > What justifications was found for this anyway? AIUI, this is a platform > bug, and not entirely a chipset bug. No this is believed to be a chipset issue, hence also the quirk in older kernels to always reset these devices after a normal suspend/resume. Regards, Hans > > Brian > >> But there are 2 issues with this approach: >> 1) It leaves the broken DIY BTUSB_RESET_RESUME code in place for Realtek >> devices. >> 2) Sofar only 2 of the 10 QCA devices known to the btusb code have been >> added to usb/core/quirks.c and if we fix the Realtek case the same way >> we need to add an additional 14 entries. So in essence we need to >> duplicate a large part of the usb_device_id table in btusb.c in >> usb/core/quirks.c and manually keep them in sync. >> >> This commit instead restores setting a reset-resume quirk for QCA devices >> in the btusb.c code, avoiding the duplicate usb_device_id table problem. >> >> This commit avoids the problems with the original DIY BTUSB_RESET_RESUME >> code by simply setting the USB_QUIRK_RESET_RESUME quirk directly on the >> usb_device. >> >> This commit also moves the BTUSB_REALTEK case over to directly setting the >> USB_QUIRK_RESET_RESUME on the usb_device and removes the now unused >> BTUSB_RESET_RESUME code. >> >> BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=1514836 >> Fixes: 7d06d5895c15 ("Revert "Bluetooth: btusb: fix QCA...suspend/resume"") >> Cc: stable@vger.kernel.org >> Cc: Leif Liddy >> Cc: Matthias Kaehlcke >> Cc: Brian Norris >> Cc: Daniel Drake >> Cc: Kai-Heng Feng >> Signed-off-by: Hans de Goede >> --- >> Note: >> 1) Once this has been merged, the 2 commits adding QCA device entries to >> drivers/usb/core/quirks.c should be reverted or dropped from bluetooth-next. >> 2) I don't have any of the affected devices, please test >> --- >> drivers/bluetooth/btusb.c | 22 ++++++++++------------ >> 1 file changed, 10 insertions(+), 12 deletions(-) >> >> diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c >> index 4764100a5888..c4689f03220f 100644 >> --- a/drivers/bluetooth/btusb.c >> +++ b/drivers/bluetooth/btusb.c >> @@ -23,6 +23,7 @@ >> >> #include >> #include >> +#include >> #include >> #include >> #include >> @@ -388,9 +389,8 @@ static const struct usb_device_id blacklist_table[] = { >> #define BTUSB_FIRMWARE_LOADED 7 >> #define BTUSB_FIRMWARE_FAILED 8 >> #define BTUSB_BOOTING 9 >> -#define BTUSB_RESET_RESUME 10 >> -#define BTUSB_DIAG_RUNNING 11 >> -#define BTUSB_OOB_WAKE_ENABLED 12 >> +#define BTUSB_DIAG_RUNNING 10 >> +#define BTUSB_OOB_WAKE_ENABLED 11 >> >> struct btusb_data { >> struct hci_dev *hdev; >> @@ -3118,6 +3118,12 @@ static int btusb_probe(struct usb_interface *intf, >> if (id->driver_info & BTUSB_QCA_ROME) { >> data->setup_on_usb = btusb_setup_qca; >> hdev->set_bdaddr = btusb_set_bdaddr_ath3012; >> + >> + /* QCA Rome devices lose their updated firmware over suspend, >> + * but the USB hub doesn't notice any status change. >> + * explicitly request a device reset on resume. >> + */ >> + interface_to_usbdev(intf)->quirks |= USB_QUIRK_RESET_RESUME; >> } >> >> #ifdef CONFIG_BT_HCIBTUSB_RTL >> @@ -3128,7 +3134,7 @@ static int btusb_probe(struct usb_interface *intf, >> * but the USB hub doesn't notice any status change. >> * Explicitly request a device reset on resume. >> */ >> - set_bit(BTUSB_RESET_RESUME, &data->flags); >> + interface_to_usbdev(intf)->quirks |= USB_QUIRK_RESET_RESUME; >> } >> #endif >> >> @@ -3297,14 +3303,6 @@ static int btusb_suspend(struct usb_interface *intf, pm_message_t message) >> enable_irq(data->oob_wake_irq); >> } >> >> - /* Optionally request a device reset on resume, but only when >> - * wakeups are disabled. If wakeups are enabled we assume the >> - * device will stay powered up throughout suspend. >> - */ >> - if (test_bit(BTUSB_RESET_RESUME, &data->flags) && >> - !device_may_wakeup(&data->udev->dev)) >> - data->udev->reset_resume = 1; >> - >> return 0; >> } >> >> -- >> 2.14.3 >>