2017-12-20 11:00:19

by Kai-Heng Feng

[permalink] [raw]
Subject: [PATCH 1/2] Revert "Bluetooth: btusb: fix QCA Rome suspend/resume"

This reverts commit fd865802c66bc451dc515ed89360f84376ce1a56.

This commit causes a regression on some QCA ROME chips. The USB device
reset happens in btusb_open(), hence firmware loading gets interrupted.

Furthermore, this commit stops working after commit
("a0085f2510e8976614ad8f766b209448b385492f Bluetooth: btusb: driver to
enable the usb-wakeup feature"). Reset-resume quirk only gets enabled in
btusb_suspend() when it's not a wakeup source.

If we really want to reset the USB device, we need to do it before
btusb_open(). Let's handle it in drivers/usb/core/quirks.c.

Cc: [email protected]
Cc: Leif Liddy <[email protected]>
Cc: Matthias Kaehlcke <[email protected]>
Cc: Brian Norris <[email protected]>
Cc: Daniel Drake <[email protected]>
Signed-off-by: Kai-Heng Feng <[email protected]>

---

Daniel, Cc you because this also affects your original quirk patch for
Realtek btusb.

drivers/bluetooth/btusb.c | 6 ------
1 file changed, 6 deletions(-)

diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index f7120c9eb9bd..da353c4acdc7 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -3117,12 +3117,6 @@ 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.
- */
- set_bit(BTUSB_RESET_RESUME, &data->flags);
}

#ifdef CONFIG_BT_HCIBTUSB_RTL
--
2.14.1


2017-12-20 11:00:30

by Kai-Heng Feng

[permalink] [raw]
Subject: [PATCH 2/2] usb: quirks: Add reset-resume quirk for Dell DW1820 QCA Rome Bluetooth

Commit ("fd865802c66bc451dc515ed89360f84376ce1a56 Bluetooth: btusb: fix
QCA Rome suspend/resume") enables reset_resume in btusb_probe(). This
makes the device resets during btusb_open(), firmware loading gets
interrupted as a result.

We still want to reset the device to solve the original issue, but we
should do it before btusb_open().

Hence, add reset-resume quirk in usb core intead of btusb.

Cc: [email protected]
Cc: Leif Liddy <[email protected]>
Cc: Matthias Kaehlcke <[email protected]>
Cc: Brian Norris <[email protected]>
Cc: Daniel Drake <[email protected]>
Signed-off-by: Kai-Heng Feng <[email protected]>

---
drivers/usb/core/quirks.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c
index a10b346b9777..96951104c45b 100644
--- a/drivers/usb/core/quirks.c
+++ b/drivers/usb/core/quirks.c
@@ -197,6 +197,9 @@ static const struct usb_device_id usb_quirk_list[] = {
{ USB_DEVICE(0x0b05, 0x17e0), .driver_info =
USB_QUIRK_IGNORE_REMOTE_WAKEUP },

+ /* QCA Rome Bluetooth in Dell DW1820 wireless module */
+ { USB_DEVICE(0x0cf3, 0xe007), .driver_info = USB_QUIRK_RESET_RESUME },
+
/* Action Semiconductor flash disk */
{ USB_DEVICE(0x10d6, 0x2200), .driver_info =
USB_QUIRK_STRING_FETCH_255 },
--
2.14.1

2017-12-20 18:53:52

by Brian Norris

[permalink] [raw]
Subject: Re: [PATCH 1/2] Revert "Bluetooth: btusb: fix QCA Rome suspend/resume"

On Wed, Dec 20, 2017 at 07:00:07PM +0800, Kai-Heng Feng wrote:
> This reverts commit fd865802c66bc451dc515ed89360f84376ce1a56.
>
> This commit causes a regression on some QCA ROME chips. The USB device
> reset happens in btusb_open(), hence firmware loading gets interrupted.

Oh, did you really confirm that's the root of the problem? I was only
hypothesizing, with some informed observation and code review; but I
didn't fully convince myself. If so, that's interesting.

> Furthermore, this commit stops working after commit
> ("a0085f2510e8976614ad8f766b209448b385492f Bluetooth: btusb: driver to
> enable the usb-wakeup feature"). Reset-resume quirk only gets enabled in
> btusb_suspend() when it's not a wakeup source.
>
> If we really want to reset the USB device, we need to do it before
> btusb_open(). Let's handle it in drivers/usb/core/quirks.c.
>
> Cc: [email protected]
> Cc: Leif Liddy <[email protected]>
> Cc: Matthias Kaehlcke <[email protected]>
> Cc: Brian Norris <[email protected]>
> Cc: Daniel Drake <[email protected]>
> Signed-off-by: Kai-Heng Feng <[email protected]>

Looks good to me. Definitely a regression and we need to clear that up
in mainline and stable before reintroducing the intended fix:

Reviewed-by: Brian Norris <[email protected]>
Tested-by: Brian Norris <[email protected]>

Thanks!

> ---
>
> Daniel, Cc you because this also affects your original quirk patch for
> Realtek btusb.
>
> drivers/bluetooth/btusb.c | 6 ------
> 1 file changed, 6 deletions(-)
>
> diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
> index f7120c9eb9bd..da353c4acdc7 100644
> --- a/drivers/bluetooth/btusb.c
> +++ b/drivers/bluetooth/btusb.c
> @@ -3117,12 +3117,6 @@ 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.
> - */
> - set_bit(BTUSB_RESET_RESUME, &data->flags);
> }
>
> #ifdef CONFIG_BT_HCIBTUSB_RTL
> --
> 2.14.1
>

2017-12-21 11:44:00

by Daniel Drake

[permalink] [raw]
Subject: Re: [PATCH 1/2] Revert "Bluetooth: btusb: fix QCA Rome suspend/resume"

On Wed, Dec 20, 2017 at 6:53 PM, Brian Norris <[email protected]> wrote:
>
> On Wed, Dec 20, 2017 at 07:00:07PM +0800, Kai-Heng Feng wrote:
> > This commit causes a regression on some QCA ROME chips. The USB device
> > reset happens in btusb_open(), hence firmware loading gets interrupted.
>
> Oh, did you really confirm that's the root of the problem? I was only
> hypothesizing, with some informed observation and code review; but I
> didn't fully convince myself. If so, that's interesting.

I have the same doubt. Can you explain how/why firmware uploading and
btusb_open() overlap, and how this is avoided with your patch?
If they do overlap, is that not a bug in the stack that should be fixed instead?
If the fix belongs in btusb and this BTUSB_RESET_RESUME thing really
is problematic, should it be totally removed instead?

Daniel

2017-12-21 17:31:49

by Brian Norris

[permalink] [raw]
Subject: Re: [PATCH 1/2] Revert "Bluetooth: btusb: fix QCA Rome suspend/resume"

On Thu, Dec 21, 2017 at 3:43 AM, Daniel Drake <[email protected]> wrote:
> On Wed, Dec 20, 2017 at 6:53 PM, Brian Norris <[email protected]> wrote:
>>
>> On Wed, Dec 20, 2017 at 07:00:07PM +0800, Kai-Heng Feng wrote:
>> > This commit causes a regression on some QCA ROME chips. The USB device
>> > reset happens in btusb_open(), hence firmware loading gets interrupted.
>>
>> Oh, did you really confirm that's the root of the problem? I was only
>> hypothesizing, with some informed observation and code review; but I
>> didn't fully convince myself. If so, that's interesting.
>
> I have the same doubt. Can you explain how/why firmware uploading and
> btusb_open() overlap, and how this is avoided with your patch?
> If they do overlap, is that not a bug in the stack that should be fixed instead?
> If the fix belongs in btusb and this BTUSB_RESET_RESUME thing really
> is problematic, should it be totally removed instead?

To be clear: this is a regression in mainline and should definitely be
fixed by reverting it. The path forward for patch 2/2 should be
determined by a better understanding of where the real problem is.

Brian

2017-12-26 21:00:26

by Marcel Holtmann

[permalink] [raw]
Subject: Re: [PATCH 1/2] Revert "Bluetooth: btusb: fix QCA Rome suspend/resume"

Hi Kai-Heng,

> This reverts commit fd865802c66bc451dc515ed89360f84376ce1a56.
>
> This commit causes a regression on some QCA ROME chips. The USB device
> reset happens in btusb_open(), hence firmware loading gets interrupted.
>
> Furthermore, this commit stops working after commit
> ("a0085f2510e8976614ad8f766b209448b385492f Bluetooth: btusb: driver to
> enable the usb-wakeup feature"). Reset-resume quirk only gets enabled in
> btusb_suspend() when it's not a wakeup source.
>
> If we really want to reset the USB device, we need to do it before
> btusb_open(). Let's handle it in drivers/usb/core/quirks.c.
>
> Cc: [email protected]
> Cc: Leif Liddy <[email protected]>
> Cc: Matthias Kaehlcke <[email protected]>
> Cc: Brian Norris <[email protected]>
> Cc: Daniel Drake <[email protected]>
> Signed-off-by: Kai-Heng Feng <[email protected]>
>
> ---
>
> Daniel, Cc you because this also affects your original quirk patch for
> Realtek btusb.
>
> drivers/bluetooth/btusb.c | 6 ------
> 1 file changed, 6 deletions(-)

patch has been applied to bluetooth-next tree.

Regards

Marcel

2017-12-26 21:01:50

by Marcel Holtmann

[permalink] [raw]
Subject: Re: [PATCH 2/2] usb: quirks: Add reset-resume quirk for Dell DW1820 QCA Rome Bluetooth

Hi Greg,

> Commit ("fd865802c66bc451dc515ed89360f84376ce1a56 Bluetooth: btusb: fix
> QCA Rome suspend/resume") enables reset_resume in btusb_probe(). This
> makes the device resets during btusb_open(), firmware loading gets
> interrupted as a result.
>
> We still want to reset the device to solve the original issue, but we
> should do it before btusb_open().
>
> Hence, add reset-resume quirk in usb core intead of btusb.
>
> Cc: [email protected]
> Cc: Leif Liddy <[email protected]>
> Cc: Matthias Kaehlcke <[email protected]>
> Cc: Brian Norris <[email protected]>
> Cc: Daniel Drake <[email protected]>
> Signed-off-by: Kai-Heng Feng <[email protected]>
>
> ---
> drivers/usb/core/quirks.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c
> index a10b346b9777..96951104c45b 100644
> --- a/drivers/usb/core/quirks.c
> +++ b/drivers/usb/core/quirks.c
> @@ -197,6 +197,9 @@ static const struct usb_device_id usb_quirk_list[] = {
> { USB_DEVICE(0x0b05, 0x17e0), .driver_info =
> USB_QUIRK_IGNORE_REMOTE_WAKEUP },
>
> + /* QCA Rome Bluetooth in Dell DW1820 wireless module */
> + { USB_DEVICE(0x0cf3, 0xe007), .driver_info = USB_QUIRK_RESET_RESUME },
> +

can I get an ACK from you to take this patch through bluetooth-next tree? Or are you planning to take it?

Regards

Marcel

2017-12-27 12:57:30

by Greg Kroah-Hartman

[permalink] [raw]
Subject: Re: [PATCH 2/2] usb: quirks: Add reset-resume quirk for Dell DW1820 QCA Rome Bluetooth

On Tue, Dec 26, 2017 at 10:01:46PM +0100, Marcel Holtmann wrote:
> Hi Greg,
>
> > Commit ("fd865802c66bc451dc515ed89360f84376ce1a56 Bluetooth: btusb: fix
> > QCA Rome suspend/resume") enables reset_resume in btusb_probe(). This
> > makes the device resets during btusb_open(), firmware loading gets
> > interrupted as a result.
> >
> > We still want to reset the device to solve the original issue, but we
> > should do it before btusb_open().
> >
> > Hence, add reset-resume quirk in usb core intead of btusb.
> >
> > Cc: [email protected]
> > Cc: Leif Liddy <[email protected]>
> > Cc: Matthias Kaehlcke <[email protected]>
> > Cc: Brian Norris <[email protected]>
> > Cc: Daniel Drake <[email protected]>
> > Signed-off-by: Kai-Heng Feng <[email protected]>
> >
> > ---
> > drivers/usb/core/quirks.c | 3 +++
> > 1 file changed, 3 insertions(+)
> >
> > diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c
> > index a10b346b9777..96951104c45b 100644
> > --- a/drivers/usb/core/quirks.c
> > +++ b/drivers/usb/core/quirks.c
> > @@ -197,6 +197,9 @@ static const struct usb_device_id usb_quirk_list[] = {
> > { USB_DEVICE(0x0b05, 0x17e0), .driver_info =
> > USB_QUIRK_IGNORE_REMOTE_WAKEUP },
> >
> > + /* QCA Rome Bluetooth in Dell DW1820 wireless module */
> > + { USB_DEVICE(0x0cf3, 0xe007), .driver_info = USB_QUIRK_RESET_RESUME },
> > +
>
> can I get an ACK from you to take this patch through bluetooth-next tree? Or are you planning to take it?

It's not in my queue at all, so I didn't even have the chance to take it
:)

Acked-by: Greg Kroah-Hartman <[email protected]>

2017-12-28 11:59:39

by Leif Liddy

[permalink] [raw]
Subject: Re: [PATCH 2/2] usb: quirks: Add reset-resume quirk for Dell DW1820 QCA Rome Bluetooth

Perhaps targeting all QCA Rome chipsets in the original patch was a
bit overkill.
I'll try adding the quirk USB_QUIRK_RESET_RESUME for my device
(0cf3:e300) in usb core and will report back.

-Leif Liddy

https://bugzilla.kernel.org/show_bug.cgi?id=193571

On Wed, Dec 27, 2017 at 1:52 PM, Greg Kroah-Hartman
<[email protected]> wrote:
> On Tue, Dec 26, 2017 at 10:01:46PM +0100, Marcel Holtmann wrote:
>> Hi Greg,
>>
>> > Commit ("fd865802c66bc451dc515ed89360f84376ce1a56 Bluetooth: btusb: fix
>> > QCA Rome suspend/resume") enables reset_resume in btusb_probe(). This
>> > makes the device resets during btusb_open(), firmware loading gets
>> > interrupted as a result.
>> >
>> > We still want to reset the device to solve the original issue, but we
>> > should do it before btusb_open().
>> >
>> > Hence, add reset-resume quirk in usb core intead of btusb.
>> >
>> > Cc: [email protected]
>> > Cc: Leif Liddy <[email protected]>
>> > Cc: Matthias Kaehlcke <[email protected]>
>> > Cc: Brian Norris <[email protected]>
>> > Cc: Daniel Drake <[email protected]>
>> > Signed-off-by: Kai-Heng Feng <[email protected]>
>> >
>> > ---
>> > drivers/usb/core/quirks.c | 3 +++
>> > 1 file changed, 3 insertions(+)
>> >
>> > diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c
>> > index a10b346b9777..96951104c45b 100644
>> > --- a/drivers/usb/core/quirks.c
>> > +++ b/drivers/usb/core/quirks.c
>> > @@ -197,6 +197,9 @@ static const struct usb_device_id usb_quirk_list[] = {
>> > { USB_DEVICE(0x0b05, 0x17e0), .driver_info =
>> > USB_QUIRK_IGNORE_REMOTE_WAKEUP },
>> >
>> > + /* QCA Rome Bluetooth in Dell DW1820 wireless module */
>> > + { USB_DEVICE(0x0cf3, 0xe007), .driver_info = USB_QUIRK_RESET_RESUME },
>> > +
>>
>> can I get an ACK from you to take this patch through bluetooth-next tree? Or are you planning to take it?
>
> It's not in my queue at all, so I didn't even have the chance to take it
> :)
>
> Acked-by: Greg Kroah-Hartman <[email protected]>

2017-12-28 20:15:47

by Marcel Holtmann

[permalink] [raw]
Subject: Re: [PATCH 2/2] usb: quirks: Add reset-resume quirk for Dell DW1820 QCA Rome Bluetooth

Hi Kai-Heng,

> Commit ("fd865802c66bc451dc515ed89360f84376ce1a56 Bluetooth: btusb: fix
> QCA Rome suspend/resume") enables reset_resume in btusb_probe(). This
> makes the device resets during btusb_open(), firmware loading gets
> interrupted as a result.
>
> We still want to reset the device to solve the original issue, but we
> should do it before btusb_open().
>
> Hence, add reset-resume quirk in usb core intead of btusb.
>
> Cc: [email protected]
> Cc: Leif Liddy <[email protected]>
> Cc: Matthias Kaehlcke <[email protected]>
> Cc: Brian Norris <[email protected]>
> Cc: Daniel Drake <[email protected]>
> Signed-off-by: Kai-Heng Feng <[email protected]>
>
> ---
> drivers/usb/core/quirks.c | 3 +++
> 1 file changed, 3 insertions(+)

patch has been applied to bluetooth-next tree.

Regards

Marcel

2018-01-02 10:06:39

by Kai-Heng Feng

[permalink] [raw]
Subject: Re: [PATCH 1/2] Revert "Bluetooth: btusb: fix QCA Rome suspend/resume"



> On 21 Dec 2017, at 7:43 PM, Daniel Drake <[email protected]> wrote:
>
> On Wed, Dec 20, 2017 at 6:53 PM, Brian Norris <[email protected]> wrote:
>>
>> On Wed, Dec 20, 2017 at 07:00:07PM +0800, Kai-Heng Feng wrote:
>>> This commit causes a regression on some QCA ROME chips. The USB device
>>> reset happens in btusb_open(), hence firmware loading gets interrupted.
>>
>> Oh, did you really confirm that's the root of the problem? I was only
>> hypothesizing, with some informed observation and code review; but I
>> didn't fully convince myself. If so, that's interesting.
>
> I have the same doubt. Can you explain how/why firmware uploading and
> btusb_open() overlap, and how this is avoided with your patch?

QCA ROME chip uploads its firmware inside btusb_open().

The behavior is like below:
- btusb_probe()
- btusb_open()
- btusb_suspend(), reset_resume gets set.
- btusb_open() again, hub resets the device, then the issue happens.

I didn’t dig really deep for the issue, I simply tried usb core quirks, it reset
the USB device before btusb_probe().

It might be that using the USB quirk only papers over the real issue.

> If they do overlap, is that not a bug in the stack that should be fixed instead?
> If the fix belongs in btusb and this BTUSB_RESET_RESUME thing really
> is problematic, should it be totally removed instead?

I think so. That’s why I need some insight from the original patch author.

Kai-Heng

>
> Daniel