Automatic Activation, Hotplug and UDEV, Configuration
Post Reply
skoehler
Posts: 3
Joined: 04 Nov 2014, 13:53

How to avoid race condition?

Post by skoehler » 04 Nov 2014, 14:00

I followed the instructions here:
http://www.draisberghof.de/usb_modeswit ... f=2&t=1904

It does occasionally switch my Samsung S4 mini into modem mode. But it occasionally doesn't. Then I find the following messages in dmesg:

Code: Select all

Nov  3 21:49:39 bernd kernel: [1490747.593728] usb 3-2: usbfs: interface 0 claimed by usbfs while 'usb_modeswitch' sets config #2
Nov  3 21:49:39 bernd kernel: [1490747.593743] usb 3-2: usbfs: interface 0 claimed by usbfs while 'usb_modeswitch' sets config #2
Nov  3 21:49:39 bernd kernel: [1490747.593752] usb 3-2: usbfs: interface 0 claimed by usbfs while 'usb_modeswitch' sets config #2
Nov  3 21:49:39 bernd kernel: [1490747.593759] usb 3-2: usbfs: interface 0 claimed by usbfs while 'usb_modeswitch' sets config #2
Nov  3 21:49:39 bernd kernel: [1490747.593766] usb 3-2: usbfs: interface 0 claimed by usbfs while 'usb_modeswitch' sets config #2
I suspect, that my desktop environment (MATE desktop) or gvfs manages to access my phone (it supports MTP) before the udev has finished execution usb_modeswitch. My question is, who is to blame here?

Josh
Site Admin
Posts: 6570
Joined: 03 Nov 2007, 00:30

Re: How to avoid race condition?

Post by Josh » 04 Nov 2014, 20:17

I would like to see the full log of usb_modeswitch.

See paragraph "Troubleshooting" in the main doc page for usb_modeswitch (link in the top nav bar) about how to enable logging.

skoehler
Posts: 3
Joined: 04 Nov 2014, 13:53

Re: How to avoid race condition?

Post by skoehler » 14 Nov 2014, 22:24

The full log:

Code: Select all

# cat /var/log/usb_modeswitch_3-1\:1.0 

USB_ModeSwitch log from Fri Nov 14 22:22:51 IST 2014

Use global config file: /etc/usb_modeswitch.conf
Raw args from udev: /3-1:1.0

Use top device dir /sys/bus/usb/devices/3-1

----------------
USB values from sysfs:
  manufacturer	SAMSUNG
  product	SAMSUNG_Android
  serial	05eb0e86
----------------
ConfigList: /etc/usb_modeswitch.d/04e8:6860
SCSI attributes not needed, move on
Check config: /etc/usb_modeswitch.d/04e8:6860
! matched. Read config data
Use config file from override folder /etc/usb_modeswitch.d
Logger is /usr/bin/logger
config: TargetVendor set to 04e8
config: TargetProduct set to 6860
config: Configuration (target) set to 2
Driver module is "option", ID path is /sys/bus/usb-serial/drivers/option1

Device may have an MBIM configuration, check driver ...
 driver for MBIM devices is available
Find MBIM configuration number ...
 No MBIM configuration found, switch to legacy modem mode
Command to be run:
usb_modeswitch -W -D -s 20  -b 3 -g 12 -v 04e8 -p 6860 -f $configBuffer

Verbose debug output of usb_modeswitch and libusb follows
(Note that some USB errors are to be expected in the process)
--------------------------------

Read long config from command line

 * usb_modeswitch: handle USB devices with multiple modes
 * Version 2.2.0 (C) Josua Dietze 2014
 * Based on libusb1/libusbx

 ! PLEASE REPORT NEW CONFIGURATIONS !

DefaultVendor=  0x04e8
DefaultProduct= 0x6860
TargetVendor=   0x04e8
TargetProduct=  0x6860
NeedResponse=0
Configuration=0x02
Success check enabled, max. wait time 20 seconds
System integration mode enabled

Use given bus/device number: 003/012 ...
Look for default devices ...
 bus/device number matched
  found USB ID 04e8:6860
   vendor ID matched
   product ID matched
Get the current device configuration ...
   device configuration 1 not matching target
   count device
 Found devices in default mode (1)
Current configuration number is 1
Use interface number 0

USB description data (for identification)
-------------------------
Manufacturer: SAMSUNG
     Product: SAMSUNG_Android
  Serial No.: 05eb0e86
-------------------------
Change configuration to 2 ...
 Device is busy, try to detach kernel driver
Looking for active driver ...
 No active driver found. Detached before or never attached
 Device is busy, try to detach kernel driver
Looking for active driver ...
 No active driver found. Detached before or never attached
 Device is busy, try to detach kernel driver
Looking for active driver ...
 No active driver found. Detached before or never attached
 Device is busy, try to detach kernel driver
Looking for active driver ...
 No active driver found. Detached before or never attached
 Changing the configuration failed (error -6). Try to continue
Bus/dev search active, refer success check to wrapper. Bye!

ok:busdev
--------------------------------
(end of usb_modeswitch output)

Check success of mode switch for max. 20 seconds ...
 Read attributes ...
 Read attributes ...
 Read attributes ...
 Read attributes ...
 Read attributes ...
 Read attributes ...
 Read attributes ...
 Read attributes ...
 Read attributes ...
 Read attributes ...
 Read attributes ...
 Read attributes ...
 Read attributes ...
 Read attributes ...
 Read attributes ...
 Read attributes ...
 Read attributes ...
 Read attributes ...
 Read attributes ...
 Read attributes ...

Target config not matching - current values are
    3-1:1.0/bInterfaceClass:   06
    bConfigurationValue:       1
    bNumConfigurations:        2
    busnum:                    3
    devnum:                    12
    idProduct:                 6860
    idVendor:                  04e8
    manufacturer:              SAMSUNG
    product:                   SAMSUNG_Android
    serial:                    05eb0e86

Mode switching may have failed. Exit

Josh
Site Admin
Posts: 6570
Joined: 03 Nov 2007, 00:30

Re: How to avoid race condition?

Post by Josh » 19 Nov 2014, 23:33

Hmm, I have not seen a loop like this before.

Can you check if there is in fact no driver for the first interface, as reported by usb_modeswitch?

See /sys/bus/usb/devices, identify the phone and its first interface, and look for a "driver" subfolder there.

Post Reply