Bluetooth: btusb: CSR chip hangs when unbound
PATCH 1/1 Bluetooth: btusb: CSR chip hangs when unbound
Bluetooth Dongles with CSR chip (i.e. USB Bluetooth V4.0 Dongle by Trust) hang when they are unbound from 'unbind' sysfs entry and can not be bound again.
The reason is CSR chip hangs when usb configuration command with index 0 (used to unconfigure) is sent during disconnection.
To avoid this unwanted result, it is necessary not to send this command for CSR chip when usb device is unbound, so a new quirk has been created for this device.
Athough device is not unconfigured, it is better to avoid device hanging to be able to operate. Even bluetooth can be previously turned off.
On the other hand, this is not important if usb device is going to be bound again (normal behavior), i.e. with usbip.
--- drivers/usb/core/generic.c | 3 ++- drivers/usb/core/quirks.c | 3 +++ include/linux/usb/quirks.h | 3 +++ 3 files changed, 8 insertions(+), 1 deletion(-)
drivers/usb/core/generic.c +2 -1
@@ -22,6 +22,7 @@#include <linux/usb.h> #include <linux/usb/hcd.h> #include <uapi/linux/usb/audio.h> +#include <linux/usb/quirks.h> #include "usb.h" static inline const char *plural (int n)
@@ -256,7 +257,7 @@ void usb_generic_driver_disconnect(struct usb_device *udev)/* if this is only an unbind, not a physical disconnect, then * unconfigure the device */ -if (udev->actconfig) +if (!(udev->quirks &USB_QUIRK_SKIP_UNCONFIGURE ) && udev->actconfig)usb_set_configuration (udev,-1 ); }
drivers/usb/core/quirks.c +3 -0
@@ -510,6 +510,9 @@ static const struct usb_device_id usb_quirk_list[] = {/* INTEL VALUE SSD */ { USB_DEVICE(0x8086, 0xf1a5), .driver_info = USB_QUIRK_RESET_RESUME }, + /* CSR Bluetooth */ + { USB_DEVICE(0x0a12, 0x0001), .driver_info = USB_QUIRK_SKIP_UNCONFIGURE }, + { }/* terminating entry must be last */ };
include/linux/usb/quirks.h +3 -0
@@ -72,4 +72,7 @@/* device has endpoints that should be ignored */ #define USB_QUIRK_ENDPOINT_IGNORE BIT(15) +/* device doesn't support unconfigure when unbound. */ +#define USB_QUIRK_SKIP_UNCONFIGURE BIT(16) +#endif /* __LINUX_USB_QUIRKS_H */
Signature · 1 line
2.35.1
Greg KH
maintainerQuoted 27 lines · Jose Ignacio Tornos Martinez
Bluetooth Dongles with CSR chip (i.e. USB Bluetooth V4.0 Dongle by Trust) hang when they are unbound from 'unbind' sysfs entry and can not be bound again.
The reason is CSR chip hangs when usb configuration command with index 0 (used to unconfigure) is sent during disconnection.
To avoid this unwanted result, it is necessary not to send this command for CSR chip when usb device is unbound, so a new quirk has been created for this device.
Athough device is not unconfigured, it is better to avoid device hanging to be able to operate. Even bluetooth can be previously turned off.
On the other hand, this is not important if usb device is going to be bound again (normal behavior), i.e. with usbip.--- drivers/usb/core/generic.c | 3 ++- drivers/usb/core/quirks.c | 3 +++ include/linux/usb/quirks.h | 3 +++ 3 files changed, 8 insertions(+), 1 deletion(-)drivers/usb/core/generic.c +0
-0
drivers/usb/core/generic.c line 25
Quoted 4 lines
drivers/usb/core/generic.c +1
-0@@ -22,6 +22,7 @@#include <linux/usb.h> #include <linux/usb/hcd.h> #include <uapi/linux/usb/audio.h> +#include <linux/usb/quirks.h>
Shouldn't that be above the uapi include?
Quoted 17 lines
drivers/usb/core/generic.c +1
-1#include "usb.h" static inline const char *plural (int n)@@ -256,7 +257,7 @@ void usb_generic_driver_disconnect(struct usb_device *udev)/* if this is only an unbind, not a physical disconnect, then * unconfigure the device */ -if (udev->actconfig) +if (!(udev->quirks &USB_QUIRK_SKIP_UNCONFIGURE ) && udev->actconfig)usb_set_configuration (udev,-1 ); }drivers/usb/core/quirks.c +0
-0
drivers/usb/core/quirks.c static const struct usb_device_id usb_quirk_list[] = { · line 514
Quoted 5 lines
drivers/usb/core/quirks.c +2
-0@@ -510,6 +510,9 @@ static const struct usb_device_id usb_quirk_list[] = {/* INTEL VALUE SSD */ { USB_DEVICE(0x8086, 0xf1a5), .driver_info = USB_QUIRK_RESET_RESUME }, + /* CSR Bluetooth */ + { USB_DEVICE(0x0a12, 0x0001), .driver_info = USB_QUIRK_SKIP_UNCONFIGURE },
Please read the big comment at the top of this list of entries. It says it must be in sorder order, which this is not :(
thanks,
greg k-h
Greg KH
maintainerQuoted 72 lines · Jose Ignacio Tornos Martinez
Bluetooth Dongles with CSR chip (i.e. USB Bluetooth V4.0 Dongle by Trust) hang when they are unbound from 'unbind' sysfs entry and can not be bound again.
The reason is CSR chip hangs when usb configuration command with index 0 (used to unconfigure) is sent during disconnection.
To avoid this unwanted result, it is necessary not to send this command for CSR chip when usb device is unbound, so a new quirk has been created for this device.
Athough device is not unconfigured, it is better to avoid device hanging to be able to operate. Even bluetooth can be previously turned off.
On the other hand, this is not important if usb device is going to be bound again (normal behavior), i.e. with usbip.--- drivers/usb/core/generic.c | 3 ++- drivers/usb/core/quirks.c | 3 +++ include/linux/usb/quirks.h | 3 +++ 3 files changed, 8 insertions(+), 1 deletion(-)drivers/usb/core/generic.c +2
-1@@ -22,6 +22,7 @@#include <linux/usb.h> #include <linux/usb/hcd.h> #include <uapi/linux/usb/audio.h> +#include <linux/usb/quirks.h> #include "usb.h" static inline const char *plural (int n)@@ -256,7 +257,7 @@ void usb_generic_driver_disconnect(struct usb_device *udev)/* if this is only an unbind, not a physical disconnect, then * unconfigure the device */ -if (udev->actconfig) +if (!(udev->quirks &USB_QUIRK_SKIP_UNCONFIGURE ) && udev->actconfig)usb_set_configuration (udev,-1 ); }drivers/usb/core/quirks.c +3
-0@@ -510,6 +510,9 @@ static const struct usb_device_id usb_quirk_list[] = {/* INTEL VALUE SSD */ { USB_DEVICE(0x8086, 0xf1a5), .driver_info = USB_QUIRK_RESET_RESUME }, + /* CSR Bluetooth */ + { USB_DEVICE(0x0a12, 0x0001), .driver_info = USB_QUIRK_SKIP_UNCONFIGURE }, + { }/* terminating entry must be last */ };include/linux/usb/quirks.h +3
-0@@ -72,4 +72,7 @@/* device has endpoints that should be ignored */ #define USB_QUIRK_ENDPOINT_IGNORE BIT(15) +/* device doesn't support unconfigure when unbound. */ +#define USB_QUIRK_SKIP_UNCONFIGURE BIT(16) +#endif /* __LINUX_USB_QUIRKS_H */ Signature · 1 line
2.35.1
Hi,
This is the friendly patch-bot of Greg Kroah-Hartman. You have sent him a patch that has triggered this response. He used to manually respond to these common problems, but in order to save his sanity (he kept writing the same thing over and over, yet to different people), I was created. Hopefully you will not take offence and will fix the problem in your patch and resubmit it so that it can be accepted into the Linux kernel tree.
You are receiving this message because of the following common error(s) as indicated below:
- Your patch does not have a Signed-off-by: line. Please read the kernel file, Documentation/SubmittingPatches and resend it after adding that line. Note, the line needs to be in the body of the email, before the patch, not at the bottom of the patch or in the email signature.
If you wish to discuss this problem further, or you have questions about how to resolve this issue, please feel free to respond to this email and Greg will reply once he has dug out from the pending patches received from other developers.
thanks,
greg k-h's patch email bot
Greg KH
maintainerQuoted 11 lines · Jose Ignacio Tornos Martinez
Bluetooth Dongles with CSR chip (i.e. USB Bluetooth V4.0 Dongle by Trust) hang when they are unbound from 'unbind' sysfs entry and can not be bound again.
The reason is CSR chip hangs when usb configuration command with index 0 (used to unconfigure) is sent during disconnection.
To avoid this unwanted result, it is necessary not to send this command for CSR chip when usb device is unbound, so a new quirk has been created for this device.
Quoted 6 lines
Athough device is not unconfigured, it is better to avoid device hanging to be able to operate. Even bluetooth can be previously turned off.
On the other hand, this is not important if usb device is going to be bound again (normal behavior), i.e. with usbip.
---
Also, the subject is totally wrong :(
Quoted 35 lines · Jose Ignacio Tornos Martinez
Bluetooth Dongles with CSR chip (i.e. USB Bluetooth V4.0 Dongle by Trust) hang when they are unbound from 'unbind' sysfs entry and can not be bound again.
The reason is CSR chip hangs when usb configuration command with index 0 (used to unconfigure) is sent during disconnection.
To avoid this unwanted result, it is necessary not to send this command for CSR chip when usb device is unbound, so a new quirk has been created for this device.
Athough device is not unconfigured, it is better to avoid device hanging to be able to operate. Even bluetooth can be previously turned off.
On the other hand, this is not important if usb device is going to be bound again (normal behavior), i.e. with usbip.--- drivers/usb/core/generic.c | 3 ++- drivers/usb/core/quirks.c | 3 +++ include/linux/usb/quirks.h | 3 +++ 3 files changed, 8 insertions(+), 1 deletion(-)drivers/usb/core/generic.c +1
-0@@ -22,6 +22,7 @@#include <linux/usb.h> #include <linux/usb/hcd.h> #include <uapi/linux/usb/audio.h> +#include <linux/usb/quirks.h> #include "usb.h" static inline const char *plural (int n)
drivers/usb/core/generic.c void usb_generic_driver_disconnect(struct usb_device *udev) · line 260
Quoted 5 lines
drivers/usb/core/generic.c +1
-1@@ -256,7 +257,7 @@ void usb_generic_driver_disconnect(struct usb_device *udev)/* if this is only an unbind, not a physical disconnect, then * unconfigure the device */ -if (udev->actconfig) +if (!(udev->quirks &USB_QUIRK_SKIP_UNCONFIGURE ) && udev->actconfig)
The usual programming convention is that when an "if" statement tests more than one condition, the test which is more likely to fail should come first. In this case, it is more likely that udev->actconfig is non-NULL than that the USB_QUIRK_SKIP_UNCONFIGURE flag is set, because the quirk flag affects only one type of device whereas udev->actconfig can be non-NULL on any device. So the test of udev->actconfig should come first.
Quoted 8 lines
drivers/usb/core/generic.c +0
-0usb_set_configuration (udev,-1 ); }drivers/usb/core/quirks.c +0
-0
drivers/usb/core/quirks.c static const struct usb_device_id usb_quirk_list[] = { · line 517
Quoted 8 lines
drivers/usb/core/quirks.c +3
-0@@ -510,6 +510,9 @@ static const struct usb_device_id usb_quirk_list[] = {/* INTEL VALUE SSD */ { USB_DEVICE(0x8086, 0xf1a5), .driver_info = USB_QUIRK_RESET_RESUME }, + /* CSR Bluetooth */ + { USB_DEVICE(0x0a12, 0x0001), .driver_info = USB_QUIRK_SKIP_UNCONFIGURE }, + { }/* terminating entry must be last */ };
Did you want people to be able to test this quirk interactively? If you do, you should add a flag character for this quirk to quirks_param_set() and document it. But if you don't think people will need to test the new quirk then you don't need to add anything else.
include/linux/usb/quirks.h line 76
Quoted 10 lines
include/linux/usb/quirks.h +2
-0@@ -72,4 +72,7 @@/* device has endpoints that should be ignored */ #define USB_QUIRK_ENDPOINT_IGNORE BIT(15) +/* device doesn't support unconfigure when unbound. */ +#define USB_QUIRK_SKIP_UNCONFIGURE BIT(16)
The comment isn't right. In fact, the device doesn't ever support unconfigure. Whether it is bound or not makes no difference.
Alan Stern
Thanks everyone for your help.
I will prepare a new better patch.
Best regards
José Ignacio
Quoted 89 lines · Alan Stern
Quoted 35 lines · Jose Ignacio Tornos Martinez
Bluetooth Dongles with CSR chip (i.e. USB Bluetooth V4.0 Dongle by Trust) hang when they are unbound from 'unbind' sysfs entry and can not be bound again.
The reason is CSR chip hangs when usb configuration command with index 0 (used to unconfigure) is sent during disconnection.
To avoid this unwanted result, it is necessary not to send this command for CSR chip when usb device is unbound, so a new quirk has been created for this device.
Athough device is not unconfigured, it is better to avoid device hanging to be able to operate. Even bluetooth can be previously turned off.
On the other hand, this is not important if usb device is going to be bound again (normal behavior), i.e. with usbip.--- drivers/usb/core/generic.c | 3 ++- drivers/usb/core/quirks.c | 3 +++ include/linux/usb/quirks.h | 3 +++ 3 files changed, 8 insertions(+), 1 deletion(-)drivers/usb/core/generic.c +1
-0@@ -22,6 +22,7 @@#include <linux/usb.h> #include <linux/usb/hcd.h> #include <uapi/linux/usb/audio.h> +#include <linux/usb/quirks.h> #include "usb.h" static inline const char *plural (int n)drivers/usb/core/generic.c void usb_generic_driver_disconnect(struct usb_device *udev) · line 260
Quoted 5 lines
drivers/usb/core/generic.c +1
-1@@ -256,7 +257,7 @@ void usb_generic_driver_disconnect(struct usb_device *udev)/* if this is only an unbind, not a physical disconnect, then * unconfigure the device */ -if (udev->actconfig) +if (!(udev->quirks &USB_QUIRK_SKIP_UNCONFIGURE ) && udev->actconfig)The usual programming convention is that when an "if" statement tests more than one condition, the test which is more likely to fail should come first. In this case, it is more likely that
udev->actconfigis non-NULL than that theUSB_QUIRK_SKIP_UNCONFIGUREflag is set, because the quirk flag affects only one type of device whereasudev->actconfigcan be non-NULL on any device. So the test ofudev->actconfigshould come first.Quoted 8 lines
drivers/usb/core/generic.c +0
-0usb_set_configuration (udev,-1 ); }drivers/usb/core/quirks.c +0
-0drivers/usb/core/quirks.c static const struct usb_device_id usb_quirk_list[] = { · line 517
Quoted 8 lines
drivers/usb/core/quirks.c +3
-0@@ -510,6 +510,9 @@ static const struct usb_device_id usb_quirk_list[] = {/* INTEL VALUE SSD */ { USB_DEVICE(0x8086, 0xf1a5), .driver_info = USB_QUIRK_RESET_RESUME }, + /* CSR Bluetooth */ + { USB_DEVICE(0x0a12, 0x0001), .driver_info = USB_QUIRK_SKIP_UNCONFIGURE }, + { }/* terminating entry must be last */ };Did you want people to be able to test this quirk interactively? If you do, you should add a flag character for this quirk to
quirks_param_set()and document it. But if you don't think people will need to test the new quirk then you don't need to add anything else.include/linux/usb/quirks.h line 76
Quoted 10 lines
include/linux/usb/quirks.h +2
-0@@ -72,4 +72,7 @@/* device has endpoints that should be ignored */ #define USB_QUIRK_ENDPOINT_IGNORE BIT(15) +/* device doesn't support unconfigure when unbound. */ +#define USB_QUIRK_SKIP_UNCONFIGURE BIT(16)The comment isn't right. In fact, the device doesn't ever support unconfigure. Whether it is bound or not makes no difference.
Alan Stern