Re: 3.7.3, ttyUSB0 serial problem - devices stop working and onlyreboot helps (Inappropriate ioctl for device)

From: Woody Suwalski
Date: Sat Jan 19 2013 - 21:19:35 EST


Arkadiusz Miskiewicz wrote:
On Saturday 19 of January 2013, Arkadiusz Miskiewicz wrote:
On Saturday 19 of January 2013, Greg Kroah-Hartman wrote:
On Fri, Jan 18, 2013 at 11:28:43PM +0100, Arkadiusz Miskiewicz wrote:
Hi.

Using 3.7.3 kernel and connecting two rs232 usb adapters, CP2102 and
FT232RL, one after disconnecting another.

After few cycles of reconnecting and using socat (below) I'm getting
problems accessing ttyUSB0:
ioctl(3, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or
TCGETS, 0x7fffb70c6ae0) = -1 ENOTTY (Inappropriate ioctl for device)

Unloading and reloading (by udev) modules ftdio_sio, cp210x, usbserial
doesn't help. I have to reboot to get ttyUSB0 working (regardless of
which driver, ftdio_sio or cp210x is handling ttyUSB0 - both stop
working).

Any clues?
The kernel log shows the device getting removed a bunch and then coming
back, which implies electrical issues (flaky connection, low power,
etc.) Are you really removing it and plugging it back in? Or is it
doing it all by itself?
I was doing plug in CP2102, remove it, plug in FT232RL after few seconds,
remove it, plug in CP... (and various variations, several times) and
testing with socat before removing devices. After some iteration the
problem appears and only reboot helps.
The issue is really weird. Machine is Thinkpad T400 2764CTO (latest bios).
When the problem happened on 3.7.3 today I rebooted into 3.8rc4 and ...
freshly after reboot and plugging in PL2303 adapter the problem was already
there. Didn't have to do unplug/plug cycle to make it happen.

Looks like sometimes reboot cures the problem, sometimes it doesn't. Now
powered off laptop and powered it on - problem gone.

Connected PL2303, ran socat, disconnected PL2303 (while socat was running) ->
problem happened again. Looks like it doesn't depend on adapter chip type.

So to reproduce here:
- boot fresh 3.8rc4
- plug in some adapter (PL2303 for example)
- run "socat -ddd -s -u /dev/ttyUSB0,raw,echo=0,b115200,crnl,noctty,nonblock -
| logger" - it should run fine, without any error
- disconnect adapter; socat should exit with error "W cannot restore terminal
settings on fd 3: Input/output error"
- plug in adapter again
- run socat again -> this time error "E tcgetattr(3, 0x7fff21411780):
Inappropriate ioctl for device" immediately always; regardless which adapter
is used and if kernel module drivers for these adapters were reloaded

dmesg:
http://pastebin.com/r1Q5mmgt

config:
http://pastebin.com/8dpFFzuU

lspci:
http://pastebin.com/TBtUg1tW

lsusb:
http://pastebin.com/SueVw9CD

[ 53.776047] usb 4-1: new full-speed USB device number 2 using uhci_hcd
[ 53.938053] usb 4-1: New USB device found, idVendor=067b, idProduct=2303
[ 53.938060] usb 4-1: New USB device strings: Mfr=1, Product=2,
SerialNumber=0
[ 53.938065] usb 4-1: Product: USB-Serial Controller
[ 53.938068] usb 4-1: Manufacturer: Prolific Technology Inc.
[ 53.949924] usbcore: registered new interface driver usbserial
[ 53.950364] usbcore: registered new interface driver usbserial_generic
[ 53.951147] usbserial: USB Serial support registered for generic
[ 53.954268] usbcore: registered new interface driver pl2303
[ 53.955009] usbserial: USB Serial support registered for pl2303
[ 53.955039] pl2303 4-1:1.0: pl2303 converter detected
[ 53.967394] usb 4-1: pl2303 converter now attached to ttyUSB0
[ 64.492122] usb 4-1: USB disconnect, device number 2
[ 64.501748] pl2303 ttyUSB0: pl2303 converter now disconnected from ttyUSB0
[ 64.502343] pl2303 4-1:1.0: device disconnected
[ 66.494930] usb 4-1: new full-speed USB device number 3 using uhci_hcd
[ 66.654247] usb 4-1: New USB device found, idVendor=067b, idProduct=2303
[ 66.654261] usb 4-1: New USB device strings: Mfr=1, Product=2,
SerialNumber=0
[ 66.654269] usb 4-1: Product: USB-Serial Controller
[ 66.654276] usb 4-1: Manufacturer: Prolific Technology Inc.
[ 66.659661] pl2303 4-1:1.0: pl2303 converter detected
[ 66.671587] usb 4-1: pl2303 converter now attached to ttyUSB0

5722 munmap(0x7f1bfc0d7000, 4096) = 0
5722 write(2, "2013/01/19 09:36:38 socat[5722] E tcgetattr(3,
0x7fffeff64020): Inappropriate ioctl for device\n", 95) = 95
5722 ioctl(3, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or TCGETS,
0x7fffeff63e50) = -1 ENOTTY (Inappropriate ioctl for device)
5722 write(2, "2013/01/19 09:36:38 socat[5722] E tcgetattr(3,
0x7fffeff63f90): Inappropriate ioctl for device\n", 95) = 95
5722 ioctl(3, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or TCGETS,
0x7fffeff63ec0) = -1 ENOTTY (Inappropriate ioctl for device)
5722 write(2, "2013/01/19 09:36:38 socat[5722] E tcgetattr(3,
0x7fffeff64160): Inappropriate ioctl for device\n", 95) = 95
5722 fcntl(3, F_SETFD, FD_CLOEXEC) = 0
5722 ioctl(1, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or TCGETS,
0x7fffeff64330) = -1 ENOTTY (Inappropriate ioctl for device)
5722 select(4, [3], [1], [], NULL) = 2 (in [3], out [1])

If I unplug the USB device while tty session is running, I will get on next plugin a new devnode ttyUSB1. It seems that you are trying to reuse an old "dead" connection? Could it be rather a udev problem?

Woody

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/