2012-01-23 05:58:01

by Keith Packard

[permalink] [raw]
Subject: [PATCH] Regression: Revert "Bluetooth: use buffer priority to mark URB_ISO_ASAP flag"

This reverts commit b8aabfc92249b239c425da7e4ca85b7e4855e984.

URB_ISO_ASAP may only be used with iso end points, but this patch was
attempting to use it with a bulk endpoint. When DEBUG is defined in
the USB stack, it checks for invalid flags and returns -EINVAL instead
of actually transmitting the data.

Signed-off-by: Keith Packard <[email protected]>
---

Ok, so this is a comedy of errors. The Bluetooth code is trying to use
an iso-specific flag (URB_ISO_ASAP) on a bulk endpoint, which is
invalid, but normally harmless. Unless the USB code is compiled for
debugging, in which case it checks a bunch for incorrect usage and
discards URBs which are wrong.

As far as I'm concerned, #ifdef DEBUG code should never ever change
the behaviour of the code, and so I'd say the USB code is even more
broken than the bluetooth code...

In any case, to reproduce this issue, enable CONFIG_USB_DEBUG and then
try to use bluetooth (sdptool browse). You'll get error messages from
the USB stack:

usb 1-1.1.3: BOGUS urb flags, 2 --> 0

Apply this patch and bluetooth starts working again.

drivers/bluetooth/btusb.c | 3 ---
1 files changed, 0 insertions(+), 3 deletions(-)

diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index f00f596..b7c4f4e 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -726,9 +726,6 @@ static int btusb_send_frame(struct sk_buff *skb)
usb_fill_bulk_urb(urb, data->udev, pipe,
skb->data, skb->len, btusb_tx_complete, skb);

- if (skb->priority >= HCI_PRIO_MAX - 1)
- urb->transfer_flags = URB_ISO_ASAP;
-
hdev->stat.acl_tx++;
break;

--
1.7.8.3



2012-01-23 15:23:14

by Alan Stern

[permalink] [raw]
Subject: Re: [PATCH] Regression: Revert "Bluetooth: use buffer priority to mark URB_ISO_ASAP flag"

On Sun, 22 Jan 2012, Keith Packard wrote:

> Ok, so this is a comedy of errors. The Bluetooth code is trying to use
> an iso-specific flag (URB_ISO_ASAP) on a bulk endpoint, which is
> invalid, but normally harmless. Unless the USB code is compiled for
> debugging, in which case it checks a bunch for incorrect usage and
> discards URBs which are wrong.
>
> As far as I'm concerned, #ifdef DEBUG code should never ever change
> the behaviour of the code, and so I'd say the USB code is even more
> broken than the bluetooth code...

Well, if the DEBUG code never changed any behaviors at all, it would be
pretty useless, wouldn't it?

In this case, the change in behavior involves printing out a kernel
message announcing a bug. Causing the submission to fail also helps
draw people's attention to the bug. Under the circumstances, I think
this is understandable and not truly broken.

Alan Stern


2012-01-23 09:18:33

by Johan Hedberg

[permalink] [raw]
Subject: Re: [PATCH] Regression: Revert "Bluetooth: use buffer priority to mark URB_ISO_ASAP flag"

Hi Marcel,

On Mon, Jan 23, 2012, Marcel Holtmann wrote:
> > URB_ISO_ASAP may only be used with iso end points, but this patch was
> > attempting to use it with a bulk endpoint. When DEBUG is defined in
> > the USB stack, it checks for invalid flags and returns -EINVAL instead
> > of actually transmitting the data.
> >
> > Signed-off-by: Keith Packard <[email protected]>
> > ---
>
> a version of this patch should be already upstream or in stable trees.
> If you are sending this again, then it might slipped through. Johan?

It's here:

http://git.kernel.org/?p=linux/kernel/git/jh/bluetooth-next.git;a=commitdiff;h=e2bcdc65928af5f2b509a8c4d8b4469901f6522f

Johan

2012-01-23 09:03:35

by Marcel Holtmann

[permalink] [raw]
Subject: Re: [PATCH] Regression: Revert "Bluetooth: use buffer priority to mark URB_ISO_ASAP flag"

Hi Keith,

> URB_ISO_ASAP may only be used with iso end points, but this patch was
> attempting to use it with a bulk endpoint. When DEBUG is defined in
> the USB stack, it checks for invalid flags and returns -EINVAL instead
> of actually transmitting the data.
>
> Signed-off-by: Keith Packard <[email protected]>
> ---

a version of this patch should be already upstream or in stable trees.
If you are sending this again, then it might slipped through. Johan?

> Ok, so this is a comedy of errors. The Bluetooth code is trying to use
> an iso-specific flag (URB_ISO_ASAP) on a bulk endpoint, which is
> invalid, but normally harmless. Unless the USB code is compiled for
> debugging, in which case it checks a bunch for incorrect usage and
> discards URBs which are wrong.
>
> As far as I'm concerned, #ifdef DEBUG code should never ever change
> the behaviour of the code, and so I'd say the USB code is even more
> broken than the bluetooth code...

And yes, this one is hilarious.

Regards

Marcel



2012-02-02 10:50:59

by Pavel Machek

[permalink] [raw]
Subject: Re: [PATCH] Regression: Revert "Bluetooth: use buffer priority to mark URB_ISO_ASAP flag"

Hi!

> This reverts commit b8aabfc92249b239c425da7e4ca85b7e4855e984.
>
> URB_ISO_ASAP may only be used with iso end points, but this patch was
> attempting to use it with a bulk endpoint. When DEBUG is defined in
> the USB stack, it checks for invalid flags and returns -EINVAL instead
> of actually transmitting the data.
>
> Signed-off-by: Keith Packard <[email protected]>

This patch fixes a regression, and it is not in 3.3.0-rc2.

(And for the record I also believe that #ifdef debug should not
introduce extra error returns. WARN_ON() should be enough. Don't break
systems for people who try to be nice and enable debugging.)
Pavel
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html