Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp916844pxk; Fri, 25 Sep 2020 00:56:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyhzOASjXC7AIunjATqFwANTif+IxJwmXJxGgxQ+5bdsqtY64pRGmVqlb1V6PqhDeO7uAXF X-Received: by 2002:a17:906:bc47:: with SMTP id s7mr1601338ejv.354.1601020612606; Fri, 25 Sep 2020 00:56:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601020612; cv=none; d=google.com; s=arc-20160816; b=E6Zx7GpoxXl9d/vO9nUCop2/kGs5k+QtEN47+GfQMsnlHORawBl4W9O0rtg1nLogIV d4KvfLATNSeQ/tEcRg3qAAJKdpMjF585+4/IfyUY2mymXh0fVy/l7t0HGpLHsu0AP16Z ZLuevBuyPgeNRR3Iv5V7n5ReYJ484YW1wiSi7Yjq8PEM4FWb/ROYNDA9zFbZwwlFxD4v 5g0mHjNCoTMNwv9xfFi29H0ybW86dkD2OyJNqXeFEXDCEZCyUpy6j/VD3zkf77E1ajtM FjFa2o7QYjf+C1KzPj1V7+NCppXhk+w6przHO9HWddls7q7fsJHWo40aCKo+IwwjOlrd zexA== 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=Buh0HZu+12jEAQI5cf7YffYXdvDRKIalBAks1DCLfgM=; b=esGUHl3bUjd50UemJkbH0PWheVJx/aG6AGAFGy/NZxnuTsMRYFywHlCZKxoT3h3JXF Zd5ufz8kQ7K7EdSTizRSPBhj1MA+LD9li1LtIf1aiSkWrNI4DZUM94yDDrVH66reFHbU NU40LJgt0hAbnTOpAiHvMsuXN3HK/5xWE8dXcQp4YsrXfEa3F2KFjXhKx96s9Y7460mu yNHVcnUb9tPZ2w8QEygQpxv6u72iYA9nuhLw4Ff6tF/vGJfz0JTG4Dxmnk2NKo20jYEE 3+a97BcXrfM8v8hDCqVMfDj6d0TNyyqkeDA7u8Y9EsNduiS1KrxrJXwS+Kxa3wDjxXTu vUmw== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m25si1415585ejb.269.2020.09.25.00.56.21; Fri, 25 Sep 2020 00:56:52 -0700 (PDT) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727555AbgIYH4I convert rfc822-to-8bit (ORCPT + 99 others); Fri, 25 Sep 2020 03:56:08 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:57083 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727238AbgIYH4I (ORCPT ); Fri, 25 Sep 2020 03:56:08 -0400 Received: from mail-pf1-f198.google.com ([209.85.210.198]) by youngberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1kLiaL-00022r-Nr for linux-bluetooth@vger.kernel.org; Fri, 25 Sep 2020 07:56:05 +0000 Received: by mail-pf1-f198.google.com with SMTP id q5so1518383pfl.16 for ; Fri, 25 Sep 2020 00:56:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=8ugg/DkpzBwuYR7dhD22Q37qdrmr6sS3PgbT3G/CEuk=; b=G34FcPA6D9NUY0hMFfrtihhMRMctvCQTy9vun0Sg7UM/neTdpL1W+jVU2kFO1Iz0jI yp0xT3LKQyglrtV4v2mYJSv/z6CYarqm5aWp5fR70FdYoQEF7e69r13UT0ksaTu6TlG4 QEnL8gUF9aKZ0XDk28luxP2icm2tLGoAcsxVzXTcqRmIyyBCFVlY8PpWZYw2JC1Ztcgc /88fCU8HkKwAHCRH4V1pkTse4EmVU6PQNw2cuYJPOVKvyRAuMxTo7IFxG4SQcDb1JXIm XZ1mj8ZcTngZ1a3130M03wWy//sXkM+OtOmjQYbnEEcpO8qKYHl5x7/tryWCYWOknnZx 9FfQ== X-Gm-Message-State: AOAM531craKIwGODhiWPU4FaV27+tTdCHmcVrAb8bVDn7Ci++PGkBSd0 0kKC/PzX49vTv3st2tMz5zMgePbq9ntLOQU41d7uVv2deKWgJtq4tQRLjGgLWXz3eJT+W0taFuZ 8hcfRi+LAmNpAlN+3kLwiGHPXiRy/lojh6SkbuSXoZhWsGA== X-Received: by 2002:a17:90a:5a48:: with SMTP id m8mr1520792pji.181.1601020563775; Fri, 25 Sep 2020 00:56:03 -0700 (PDT) X-Received: by 2002:a17:90a:5a48:: with SMTP id m8mr1520775pji.181.1601020563365; Fri, 25 Sep 2020 00:56:03 -0700 (PDT) Received: from [192.168.1.208] (220-133-187-190.HINET-IP.hinet.net. [220.133.187.190]) by smtp.gmail.com with ESMTPSA id 27sm1433719pgy.26.2020.09.25.00.56.01 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 25 Sep 2020 00:56:02 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.1\)) Subject: Re: [PATCH] Bluetooth: btusb: Avoid unnecessary reset upon system resume From: Kai-Heng Feng In-Reply-To: <70edd6da224048488806d2af89294d3e@realsil.com.cn> Date: Fri, 25 Sep 2020 15:56:00 +0800 Cc: Abhishek Pandit-Subedi , Marcel Holtmann , Johan Hedberg , "open list:BLUETOOTH DRIVERS" , open list , "open list:USB XHCI DRIVER" Content-Transfer-Encoding: 8BIT Message-Id: References: <6b46b6bca9d3486499d0374eb277b00c@realsil.com.cn> <4055CF26-9A1F-42E6-A88A-3726B4532669@canonical.com> <70edd6da224048488806d2af89294d3e@realsil.com.cn> To: =?utf-8?B?6ZmG5pyx5Lyf?= X-Mailer: Apple Mail (2.3608.120.23.2.1) Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Hi Alex, > On Sep 25, 2020, at 15:42, 陆朱伟 wrote: > > Hi Kai-Heng, > >> On 25 September 2020 at 15:14, Kai-Heng Feng wrote: >> >> Hi Alex, [snipped] >> Apparently for my case, RTL8821CE, firmware was kept without setting >> remote wakeup. > > So you got the btusb disconnect and reprobe sequence after resume, and " Bluetooth: hci0: command 0x1001 tx timeout " before firmware downloading ? USB power wasn't lost, but it got USB warm reset because btusb driver explicitly flagged "reset_resume = 1". Then the issue appeared as "Bluetooth: hci0: command 0x1001 tx timeout", before downloading firmware. > >> Is it okay to also set remote wakeup for global suspend to retain the >> firmware? > > Yes, it's ok. Abhishek, does setting remote wakeup during global suspend works for you? > >> If firmware was retained, does USB warm reset affect BT controller in >> anyway? > > USB warm reset shouldn't affect BT controller. > But hci device will not work after resume, because btrtl will find "unknown IC info, lmp subvert ..." and return error when hci device setup is called. > Tips: The lmp subver in controller changes after firmware downloading. And driver will find " unknown IC info, lmp subver ..." when setup is called with firmware retained. This should already be fixed by "Bluetooth: btrtl: Restore old logic to assume firmware is already loaded". Kai-Heng > >> >> Kai-Heng >> >>> >>>> >>>> Kai-Heng >>>> >>>>> >>>>> @Alex -- What is the common behavior for Realtek controllers? Should >>>>> we set BTUSB_WAKEUP_DISABLE only on RTL8822CE or should we unset >> it >>>>> only on RTL8821CE? >>>>> >>>>>>> >>>>>>> I would prefer this doesn't get accepted in its current state. >>>>>> >>>>>> Of course. >>>>>> I think we need to find the root cause for your case before applying this >>>> one. >>>>>> >>>>>> Kai-Heng >>>>>> >>>>>>> >>>>>>> Abhishek >>>>>>> >>>>>>> On Wed, Sep 23, 2020 at 10:56 AM Kai-Heng Feng >>>>>>> wrote: >>>>>>>> >>>>>>>> Realtek bluetooth controller may fail to work after system sleep: >>>>>>>> [ 1272.707670] Bluetooth: hci0: command 0x1001 tx timeout >>>>>>>> [ 1280.835712] Bluetooth: hci0: RTL: HCI_OP_READ_LOCAL_VERSION >>>> failed (-110) >>>>>>>> >>>>>>>> If platform firmware doesn't cut power off during suspend, the >>>> firmware >>>>>>>> is considered retained in controller but the driver is still asking USB >>>>>>>> core to perform a reset-resume. This can make bluetooth controller >>>>>>>> unusable. >>>>>>>> >>>>>>>> So avoid unnecessary reset to resolve the issue. >>>>>>>> >>>>>>>> For devices that really lose power during suspend, USB core will >> detect >>>>>>>> and handle reset-resume correctly. >>>>>>>> >>>>>>>> Signed-off-by: Kai-Heng Feng >>>>>>>> --- >>>>>>>> drivers/bluetooth/btusb.c | 8 +++----- >>>>>>>> 1 file changed, 3 insertions(+), 5 deletions(-) >>>>>>>> >>>>>>>> diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c >>>>>>>> index 8d2608ddfd08..de86ef4388f9 100644 >>>>>>>> --- a/drivers/bluetooth/btusb.c >>>>>>>> +++ b/drivers/bluetooth/btusb.c >>>>>>>> @@ -4255,17 +4255,15 @@ static int btusb_suspend(struct >>>> usb_interface *intf, pm_message_t message) >>>>>>>> enable_irq(data->oob_wake_irq); >>>>>>>> } >>>>>>>> >>>>>>>> - /* For global suspend, Realtek devices lose the loaded fw >>>>>>>> - * in them. But for autosuspend, firmware should remain. >>>>>>>> - * Actually, it depends on whether the usb host sends >>>>>>>> + /* For global suspend, Realtek devices lose the loaded fw in >> them >>>> if >>>>>>>> + * platform firmware cut power off. But for autosuspend, >>>> firmware >>>>>>>> + * should remain. Actually, it depends on whether the usb host >>>> sends >>>>>>>> * set feature (enable wakeup) or not. >>>>>>>> */ >>>>>>>> if (test_bit(BTUSB_WAKEUP_DISABLE, &data->flags)) { >>>>>>>> if (PMSG_IS_AUTO(message) && >>>>>>>> device_can_wakeup(&data->udev->dev)) >>>>>>>> data->udev->do_remote_wakeup = 1; >>>>>>>> - else if (!PMSG_IS_AUTO(message)) >>>>>>>> - data->udev->reset_resume = 1; >>>>>>>> } >>>>>>>> >>>>>>>> return 0; >>>>>>>> -- >>>>>>>> 2.17.1 >>>> >>>> >>>> ------Please consider the environment before printing this e-mail.