2015-12-22 10:57:24

by John Ernberg

[permalink] [raw]
Subject: [PATCH] usb: option.c: Fix Cinterion AHxx enumeration.

From: John Ernberg <[email protected]>

This resolves a race condition that may occur with Cinterion AH3 modem modules
if both the option and cdc_ether drivers are compiled as modules.

Note:
Since I have no other AHxx modem modules to test with, I cannot guarantee that
this is the correct way to solve this issue globally.
This might break support for other AHxx modules.
Please consider this during the review of the patch.

Please explicitly keep me on CC as I did not register.

John Ernberg (1):
usb: option.c: Fix Cinterion AHxx enumeration.

drivers/usb/serial/option.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

--
1.9.1


2015-12-22 10:57:08

by John Ernberg

[permalink] [raw]
Subject: [PATCH] usb: option.c: Fix Cinterion AHxx enumeration.

From: John Ernberg <[email protected]>

In certain kernel configurations where the cdc_ether and option drivers
are compiled as modules there can occur a race condition in enumeration.
This causes the option driver to enumerate the ethernet(wwan) interface
as usb-serial interfaces.

In dmesg it may look like this:
[ 18.380585] usb 1-1: new high-speed USB device number 2 using ci_hdrc
[ 18.592290] usbcore: registered new interface driver usbserial
[ 18.606636] usbcore: registered new interface driver usbserial_generic
[ 18.614815] usbserial: USB Serial support registered for generic
[ 18.652111] usbcore: registered new interface driver option
[ 18.659745] usbserial: USB Serial support registered for GSM modem (1-port)
[ 18.667600] option 1-1:1.0: GSM modem (1-port) converter detected
[ 18.676906] usb 1-1: GSM modem (1-port) converter now attached to ttyUSB0
[ 18.686725] cdc_ether 1-1:1.4 wwan0: register 'cdc_ether' at usb-ci_hdrc.1-1, Mobile Broadband Network Device
[ 18.705587] option 1-1:1.1: GSM modem (1-port) converter detected
[ 18.713468] usbcore: registered new interface driver cdc_ether
[ 18.719930] usb 1-1: GSM modem (1-port) converter now attached to ttyUSB1
[ 18.729770] option 1-1:1.2: GSM modem (1-port) converter detected
[ 18.737421] usb 1-1: GSM modem (1-port) converter now attached to ttyUSB2
[ 18.745232] option 1-1:1.3: GSM modem (1-port) converter detected
[ 18.752838] usb 1-1: GSM modem (1-port) converter now attached to ttyUSB3
[ 43.422579] option1 ttyUSB3: option_instat_callback: error -71
[ 43.622575] option1 ttyUSB3: option_instat_callback: error -71
[ 43.822579] option1 ttyUSB3: option_instat_callback: error -71
[ 44.022575] option1 ttyUSB3: option_instat_callback: error -71
[ 44.222569] option1 ttyUSB3: option_instat_callback: error -71
[ 44.398490] usb 1-1: USB disconnect, device number 2
[ 44.405414] option1 ttyUSB0: GSM modem (1-port) converter now disconnected from ttyUSB0
[ 44.417200] option 1-1:1.0: device disconnected
[ 44.424903] option1 ttyUSB1: GSM modem (1-port) converter now disconnected from ttyUSB1
[ 44.434249] option 1-1:1.1: device disconnected
[ 44.438824] option1 ttyUSB3: option_instat_callback: error -71
[ 44.448436] option1 ttyUSB2: GSM modem (1-port) converter now disconnected from ttyUSB2
[ 44.457736] option 1-1:1.2: device disconnected
[ 44.465204] option1 ttyUSB3: GSM modem (1-port) converter now disconnected from ttyUSB3
[ 44.474480] option 1-1:1.3: device disconnected
[ 44.479754] cdc_ether 1-1:1.4 wwan0: unregister 'cdc_ether' usb-ci_hdrc.1-1, Mobile Broadband Network Device
[ 48.960593] usb 1-1: new high-speed USB device number 3 using ci_hdrc
[ 49.116118] option 1-1:1.0: GSM modem (1-port) converter detected
[ 49.123853] usb 1-1: GSM modem (1-port) converter now attached to ttyUSB0
[ 49.132029] option 1-1:1.1: GSM modem (1-port) converter detected
[ 49.138778] usb 1-1: GSM modem (1-port) converter now attached to ttyUSB1
[ 49.147432] option 1-1:1.2: GSM modem (1-port) converter detected
[ 49.154924] usb 1-1: GSM modem (1-port) converter now attached to ttyUSB2
[ 49.162940] option 1-1:1.3: GSM modem (1-port) converter detected
[ 49.169724] usb 1-1: GSM modem (1-port) converter now attached to ttyUSB3
[ 49.178440] option 1-1:1.4: GSM modem (1-port) converter detected
[ 49.185979] usb 1-1: GSM modem (1-port) converter now attached to ttyUSB4
[ 49.193985] option 1-1:1.5: GSM modem (1-port) converter detected
[ 49.201458] usb 1-1: GSM modem (1-port) converter now attached to ttyUSB5
---
drivers/usb/serial/option.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
index f228060..4e483f2 100644
--- a/drivers/usb/serial/option.c
+++ b/drivers/usb/serial/option.c
@@ -1679,7 +1679,7 @@ static const struct usb_device_id option_ids[] = {
{ USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_EU3_P) },
{ USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_PH8),
.driver_info = (kernel_ulong_t)&net_intf4_blacklist },
- { USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_AHXX) },
+ { USB_DEVICE_INTERFACE_CLASS(CINTERION_VENDOR_ID, CINTERION_PRODUCT_AHXX, 0xff) },
{ USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_PLXX),
.driver_info = (kernel_ulong_t)&net_intf4_blacklist },
{ USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_HC28_MDM) },
--
1.9.1

2015-12-22 18:49:12

by Johan Hovold

[permalink] [raw]
Subject: Re: [PATCH] usb: option.c: Fix Cinterion AHxx enumeration.

[ +CC: linux-usb ]

On Tue, Dec 22, 2015 at 10:51:32AM +0000, John Ernberg wrote:
> From: John Ernberg <[email protected]>
>
> In certain kernel configurations where the cdc_ether and option drivers
> are compiled as modules there can occur a race condition in enumeration.
> This causes the option driver to enumerate the ethernet(wwan) interface
> as usb-serial interfaces.
>
> In dmesg it may look like this:
> [ 18.380585] usb 1-1: new high-speed USB device number 2 using ci_hdrc
> [ 18.592290] usbcore: registered new interface driver usbserial
> [ 18.606636] usbcore: registered new interface driver usbserial_generic
> [ 18.614815] usbserial: USB Serial support registered for generic
> [ 18.652111] usbcore: registered new interface driver option
> [ 18.659745] usbserial: USB Serial support registered for GSM modem (1-port)
> [ 18.667600] option 1-1:1.0: GSM modem (1-port) converter detected
> [ 18.676906] usb 1-1: GSM modem (1-port) converter now attached to ttyUSB0
> [ 18.686725] cdc_ether 1-1:1.4 wwan0: register 'cdc_ether' at usb-ci_hdrc.1-1, Mobile Broadband Network Device
> [ 18.705587] option 1-1:1.1: GSM modem (1-port) converter detected
> [ 18.713468] usbcore: registered new interface driver cdc_ether
> [ 18.719930] usb 1-1: GSM modem (1-port) converter now attached to ttyUSB1
> [ 18.729770] option 1-1:1.2: GSM modem (1-port) converter detected
> [ 18.737421] usb 1-1: GSM modem (1-port) converter now attached to ttyUSB2
> [ 18.745232] option 1-1:1.3: GSM modem (1-port) converter detected
> [ 18.752838] usb 1-1: GSM modem (1-port) converter now attached to ttyUSB3
> [ 43.422579] option1 ttyUSB3: option_instat_callback: error -71
> [ 43.622575] option1 ttyUSB3: option_instat_callback: error -71
> [ 43.822579] option1 ttyUSB3: option_instat_callback: error -71
> [ 44.022575] option1 ttyUSB3: option_instat_callback: error -71
> [ 44.222569] option1 ttyUSB3: option_instat_callback: error -71
> [ 44.398490] usb 1-1: USB disconnect, device number 2
> [ 44.405414] option1 ttyUSB0: GSM modem (1-port) converter now disconnected from ttyUSB0
> [ 44.417200] option 1-1:1.0: device disconnected
> [ 44.424903] option1 ttyUSB1: GSM modem (1-port) converter now disconnected from ttyUSB1
> [ 44.434249] option 1-1:1.1: device disconnected
> [ 44.438824] option1 ttyUSB3: option_instat_callback: error -71
> [ 44.448436] option1 ttyUSB2: GSM modem (1-port) converter now disconnected from ttyUSB2
> [ 44.457736] option 1-1:1.2: device disconnected
> [ 44.465204] option1 ttyUSB3: GSM modem (1-port) converter now disconnected from ttyUSB3
> [ 44.474480] option 1-1:1.3: device disconnected
> [ 44.479754] cdc_ether 1-1:1.4 wwan0: unregister 'cdc_ether' usb-ci_hdrc.1-1, Mobile Broadband Network Device
> [ 48.960593] usb 1-1: new high-speed USB device number 3 using ci_hdrc
> [ 49.116118] option 1-1:1.0: GSM modem (1-port) converter detected
> [ 49.123853] usb 1-1: GSM modem (1-port) converter now attached to ttyUSB0
> [ 49.132029] option 1-1:1.1: GSM modem (1-port) converter detected
> [ 49.138778] usb 1-1: GSM modem (1-port) converter now attached to ttyUSB1
> [ 49.147432] option 1-1:1.2: GSM modem (1-port) converter detected
> [ 49.154924] usb 1-1: GSM modem (1-port) converter now attached to ttyUSB2
> [ 49.162940] option 1-1:1.3: GSM modem (1-port) converter detected
> [ 49.169724] usb 1-1: GSM modem (1-port) converter now attached to ttyUSB3
> [ 49.178440] option 1-1:1.4: GSM modem (1-port) converter detected
> [ 49.185979] usb 1-1: GSM modem (1-port) converter now attached to ttyUSB4
> [ 49.193985] option 1-1:1.5: GSM modem (1-port) converter detected
> [ 49.201458] usb 1-1: GSM modem (1-port) converter now attached to ttyUSB5
> ---
> drivers/usb/serial/option.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
> index f228060..4e483f2 100644
> --- a/drivers/usb/serial/option.c
> +++ b/drivers/usb/serial/option.c
> @@ -1679,7 +1679,7 @@ static const struct usb_device_id option_ids[] = {
> { USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_EU3_P) },
> { USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_PH8),
> .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
> - { USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_AHXX) },
> + { USB_DEVICE_INTERFACE_CLASS(CINTERION_VENDOR_ID, CINTERION_PRODUCT_AHXX, 0xff) },
> { USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_PLXX),
> .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
> { USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_HC28_MDM) },

Thanks for the patch.

Could you provide the output of lsusb -v for this device?

Thanks,
Johan