linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kai Heng Feng <kai.heng.feng@canonical.com>
To: Marcel Holtmann <marcel@holtmann.org>
Cc: Johan Hedberg <johan.hedberg@gmail.com>,
	linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] Bluetooth: btusb: Disable LE Advertising on system suspend
Date: Fri, 26 Apr 2019 00:27:32 +0800	[thread overview]
Message-ID: <0AA2825C-2286-4A72-AA88-5E57BC55DFE8@canonical.com> (raw)
In-Reply-To: <3E3982D2-2912-4467-A8BF-C0BE53C9B82C@holtmann.org>

Hi Marcel,

> On Apr 24, 2019, at 12:28 AM, Marcel Holtmann <marcel@holtmann.org> wrote:
> 
> Hi Kai-Heng,
> 
>> System may freeze during suspend, and it's caused by btusb early wakeup:
>> 
>> kernel: pci_pm_suspend(): hcd_pci_suspend+0x0/0x30 returns -16
>> kernel: dpm_run_callback(): pci_pm_suspend+0x0/0x130 returns -16
>> kernel: PM: Device 0000:00:14.0 failed to suspend async: error -16
>> kernel: PM: Some devices failed to suspend, or early wake event detected
>> kernel: usb usb1: usb resume
>> kernel: hub 1-0:1.0: hub_resume
>> kernel: usb usb1-port1: status 0507 change 0000
>> kernel: usb usb1-port6: status 0103 change 0004
>> kernel: usb usb1-port10: status 0107 change 0000
>> 
>> where btusb is connecte to usb1-port6.
>> 
>> The expirement shows that the early wakeup is caused by LE Advertising
>> packet.
>> 
>> Disabling it via event mask can prevent the issue from happening.
>> 
>> BugLink: https://bugs.launchpad.net/bugs/1823029
>> Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
>> ---
>> drivers/bluetooth/btusb.c | 12 ++++++++++++
>> 1 file changed, 12 insertions(+)
>> 
>> diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
>> index 10c8f9872ee5..f03fcf5687e4 100644
>> --- a/drivers/bluetooth/btusb.c
>> +++ b/drivers/bluetooth/btusb.c
>> @@ -490,6 +490,7 @@ struct btusb_data {
>> 	int (*setup_on_usb)(struct hci_dev *hdev);
>> 
>> 	int oob_wake_irq;   /* irq for out-of-band wake-on-bt */
>> +	bool suspended;
>> };
>> 
>> static inline void btusb_free_frags(struct btusb_data *data)
>> @@ -3316,12 +3317,18 @@ static void btusb_disconnect(struct usb_interface *intf)
>> static int btusb_suspend(struct usb_interface *intf, pm_message_t message)
>> {
>> 	struct btusb_data *data = usb_get_intfdata(intf);
>> +	struct hci_dev *hdev = data->hdev;
>> 
>> 	BT_DBG("intf %p", intf);
>> 
>> 	if (data->suspend_count++)
>> 		return 0;
>> 
>> +	if (!PMSG_IS_AUTO(message)) {
>> +		hci_disable_le_advertising(hdev);
>> +		data->suspended = true;
>> +	}
>> +
>> 	spin_lock_irq(&data->txlock);
>> 	if (!(PMSG_IS_AUTO(message) && data->tx_in_flight)) {
>> 		set_bit(BTUSB_SUSPENDING, &data->flags);
>> @@ -3427,6 +3434,11 @@ static int btusb_resume(struct usb_interface *intf)
>> 	spin_unlock_irq(&data->txlock);
>> 	schedule_work(&data->work);
>> 
>> +	if (data->suspended) {
>> +		hci_enable_le_advertising(hdev);
>> +		data->suspended = false;
>> +	}
>> +
>> 	return 0;
> 
> this is a clear NAK. Please stop hacking things.
> 
> Lets use hci_suspend_dev and hci_resume_dev and make it actually do something to disable the events for advertising.

Do you mean hci_disable_le_advertising() should be called by hci_suspend_dev(), which should be called by btusb_suspend()?

I’ve tried calling hci_suspend_dev() without disabling advertising, the issue still presents.

Kai-Heng 

> 
> Regards
> 
> Marcel


  reply	other threads:[~2019-04-25 16:26 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-22  9:20 [PATCH 1/2] Bluetooth: Add helpers to enable or disable LE Advertising Kai-Heng Feng
2019-04-22  9:20 ` [PATCH 2/2] Bluetooth: btusb: Disable LE Advertising on system suspend Kai-Heng Feng
2019-04-23 16:28   ` Marcel Holtmann
2019-04-25 16:27     ` Kai Heng Feng [this message]
2019-04-25 16:35       ` Marcel Holtmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0AA2825C-2286-4A72-AA88-5E57BC55DFE8@canonical.com \
    --to=kai.heng.feng@canonical.com \
    --cc=johan.hedberg@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marcel@holtmann.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).