Re: Resetting USB modems and USB to serial converters increases ttyUSBXX counter

2015-10-23 Thread Erwin Van de Velde
Hi all,

Thanks a lot for all your advice, I can confirm that modemmanager
1.4.2 fixes the issue. You saved my week! :-)

Kind regards,
Erwin


On Thu, Oct 22, 2015 at 9:13 PM, Bjørn Mork <bj...@mork.no> wrote:
> Dan Williams <d...@redhat.com> writes:
>> On Thu, 2015-10-22 at 10:39 +0200, Erwin Van de Velde wrote:
>>> Hi all,
>>>
>>> Thank you for your helpful answers! I have investigated it further,
>>> stopping potential culprits in userspace and I have found the issue:
>>> it is modemmanager that seems to keep the devices open somewhere and
>>> thus causes the ttyUSB numbers to go up. So now I will redirect the
>>> issue to their developers :-)
>>
>> There was a bug between ModemManager 1.2 and 1.4.2 that could have
>> triggered this, which was fixed in commit
>> 009af02f6d06d5020e397455354b9ccc56557b02.  So make sure you have 1.4.2
>> (released on 13-Jan-2015) or later.
>
> Yes, unfortunately that includes the current Debian stable version:
>
> nemi:/home/bjorn# apt-cache policy modemmanager
> modemmanager:
>   Installed: 1.4.0-1
>   Candidate: 1.4.0-1
>   Version table:
>  1.4.12-1 0
> 600 http://ftp.no.debian.org/debian/ sid/main amd64 Packages
>  *** 1.4.0-1 0
> 700 http://ftp.no.debian.org/debian/ jessie/main amd64 Packages
> 100 /var/lib/dpkg/status
>
>
> nemi:/home/bjorn# lsof -p8191|grep /dev
> ModemMana 8191 root0u  CHR 136,14  0t0   17 
> /dev/pts/14
> ModemMana 8191 root1u  CHR 136,14  0t0   17 
> /dev/pts/14
> ModemMana 8191 root2u  CHR 136,14  0t0   17 
> /dev/pts/14
> ModemMana 8191 root9u  CHR  180,0  0t0  1091872 
> /dev/cdc-wdm0
> ModemMana 8191 root   10u  CHR  166,0  0t0 9804 
> /dev/ttyACM0 (deleted)
> ModemMana 8191 root   11u  CHR  166,1  0t0   397155 
> /dev/ttyACM1 (deleted)
> ModemMana 8191 root   12u  CHR  166,2  0t0   448536 
> /dev/ttyACM2 (deleted)
> ModemMana 8191 root   13u  CHR  166,3  0t0   507569 
> /dev/ttyACM3 (deleted)
> ModemMana 8191 root   14u  CHR  166,4  0t0   673258 
> /dev/ttyACM4 (deleted)
> ModemMana 8191 root   15u  CHR  166,5  0t0   922024 
> /dev/ttyACM5 (deleted)
>
>
> I must admit that I have known about this, but have been too lazy to
> report it against the Debian package.  It doesn't cause any real
> problems for me, even if I sometimes do large numbers of modem
> plug/unplug cycles. I just restart ModemManager if I find the device
> numbers too high :)
>
>
>
> Bjørn
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Resetting USB modems and USB to serial converters increases ttyUSBXX counter

2015-10-22 Thread Erwin Van de Velde
Hi all,

Thank you for your helpful answers! I have investigated it further,
stopping potential culprits in userspace and I have found the issue:
it is modemmanager that seems to keep the devices open somewhere and
thus causes the ttyUSB numbers to go up. So now I will redirect the
issue to their developers :-)

I do not care about the device node name per se, I use symlinks anyway
to have consistent naming, but since there is a limit of max. 512
ttyUSB devices and each modem consists of 3 of those, the system hits
the limit rather quickly.

Thanks a lot!
Erwin


On Wed, Oct 21, 2015 at 4:37 PM, Greg K-H <gre...@linuxfoundation.org> wrote:
> On Wed, Oct 21, 2015 at 11:39:04AM +0200, Erwin Van de Velde wrote:
>> Hi all,
>>
>> As advised, I retried with a more recent kernel (4.2.0), but I get a
>> similar result:
>>
>> I tested via 'echo 1 > /sys/bus/pci/ehci-pci/\:00\:1a.0/remove'
>> and 'echo 1 > /sys/bus/pci/rescan'.
>
> Why did you remove the PCI device?  Do you have a PCI hotplug system
> that recan will work for?
>
> You are removing the whole USB host controller here, not just the USB
> device itself, it's a "fake" hotplug, which is odd, and your PCI device
> might not work correctly when you add it back...
>
>> There are two possible results: no
>> errors when removing the device and then the devices are reinserted
>> with the same ttyUSB number or, with an error:
>> 'usb_wwan_indat_callback: resubmit read urb failed. (-19)' (as shown
>> in the dmesg copied below) and then the numbers increase, even though
>> the ttyUSB devices with the previously used numbers have been removed
>> from /dev. On following attempts the numbers only remain the same or
>> increase, never reusing the freed ttyUSB numbers. Can someone please
>> tell me how I can prevent the error or circumvent the issue otherwise?
>> Sometimes the devices get stuck and resetting them via removal seems
>> to be the only option.
>>
>> Thanks in advance!
>> Erwin
>>
>> [  623.366025] ehci-pci :00:1a.0: remove, state 1
>> [  623.366042] usb usb1: USB disconnect, device number 1
>> [  623.366047] usb 1-1: USB disconnect, device number 2
>> [  623.366051] usb 1-1.1: USB disconnect, device number 4
>> [  623.366270] option1 ttyUSB6: GSM modem (1-port) converter now
>> disconnected from ttyUSB6
>> [  623.366294] option 1-1.1:1.0: device disconnected
>> [  623.368715] option1 ttyUSB9: usb_wwan_indat_callback: resubmit read
>> urb failed. (-19)
>> [  623.369327] option1 ttyUSB9: usb_wwan_indat_callback: resubmit read
>> urb failed. (-19)
>> [  623.369863] option1 ttyUSB9: usb_wwan_indat_callback: resubmit read
>> urb failed. (-19)
>> [  623.370398] option1 ttyUSB9: usb_wwan_indat_callback: resubmit read
>> urb failed. (-19)
>
> Those are normal, the device is being removed.
>
>> [  623.371083] option1 ttyUSB9: GSM modem (1-port) converter now
>> disconnected from ttyUSB9
>> [  623.371097] option 1-1.1:1.2: device disconnected
>> [  623.371315] option1 ttyUSB14: GSM modem (1-port) converter now
>> disconnected from ttyUSB14
>
>
> Have you also shut down the userspace program that had these device
> nodes open?  That's the issue here, what program has the device nodes
> open, if they don't close them, no matter what you do, the device nodes
> will not be recycled within the kernel.  This isn't a kernel issue, it's
> a userspace issue to properly shut them down in order for the numbers to
> be reused.
>
> But even if they aren't reused, it's not a big deal, userspace should
> not care about the device node names at all, this isn't a problem, they
> will be recycled once userspace closes the device node, eventually.
>
> So focus on your userspace programs if you are really worried about the
> device numbers here.
>
> hope this helps,
>
> greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Resetting USB modems and USB to serial converters increases ttyUSBXX counter

2015-10-21 Thread Erwin Van de Velde
Hi all,

As advised, I retried with a more recent kernel (4.2.0), but I get a
similar result:

I tested via 'echo 1 > /sys/bus/pci/ehci-pci/\:00\:1a.0/remove'
and 'echo 1 > /sys/bus/pci/rescan'. There are two possible results: no
errors when removing the device and then the devices are reinserted
with the same ttyUSB number or, with an error:
'usb_wwan_indat_callback: resubmit read urb failed. (-19)' (as shown
in the dmesg copied below) and then the numbers increase, even though
the ttyUSB devices with the previously used numbers have been removed
from /dev. On following attempts the numbers only remain the same or
increase, never reusing the freed ttyUSB numbers. Can someone please
tell me how I can prevent the error or circumvent the issue otherwise?
Sometimes the devices get stuck and resetting them via removal seems
to be the only option.

Thanks in advance!
Erwin

[  623.366025] ehci-pci :00:1a.0: remove, state 1
[  623.366042] usb usb1: USB disconnect, device number 1
[  623.366047] usb 1-1: USB disconnect, device number 2
[  623.366051] usb 1-1.1: USB disconnect, device number 4
[  623.366270] option1 ttyUSB6: GSM modem (1-port) converter now
disconnected from ttyUSB6
[  623.366294] option 1-1.1:1.0: device disconnected
[  623.368715] option1 ttyUSB9: usb_wwan_indat_callback: resubmit read
urb failed. (-19)
[  623.369327] option1 ttyUSB9: usb_wwan_indat_callback: resubmit read
urb failed. (-19)
[  623.369863] option1 ttyUSB9: usb_wwan_indat_callback: resubmit read
urb failed. (-19)
[  623.370398] option1 ttyUSB9: usb_wwan_indat_callback: resubmit read
urb failed. (-19)
[  623.371083] option1 ttyUSB9: GSM modem (1-port) converter now
disconnected from ttyUSB9
[  623.371097] option 1-1.1:1.2: device disconnected
[  623.371315] option1 ttyUSB14: GSM modem (1-port) converter now
disconnected from ttyUSB14
[  623.371330] option 1-1.1:1.3: device disconnected
[  623.371427] qmi_wwan 1-1.1:1.8 ce3p0: unregister 'qmi_wwan'
usb-:00:1a.0-1.1, WWAN/QMI device
[  623.375567] qmi_wwan 1-1.1:1.8: Error submitting int urb - -19
[  623.390897] qmi_wwan 1-1.1:1.10 ce3p1: unregister 'qmi_wwan'
usb-:00:1a.0-1.1, WWAN/QMI device
[  623.411043] usb 1-1.2: USB disconnect, device number 6
[  623.411240] option1 ttyUSB15: GSM modem (1-port) converter now
disconnected from ttyUSB15
[  623.411260] option 1-1.2:1.0: device disconnected
[  623.413403] option1 ttyUSB17: usb_wwan_indat_callback: resubmit
read urb failed. (-19)
[  623.414139] option1 ttyUSB17: usb_wwan_indat_callback: resubmit
read urb failed. (-19)
[  623.414905] option1 ttyUSB17: usb_wwan_indat_callback: resubmit
read urb failed. (-19)
[  623.415621] option1 ttyUSB17: usb_wwan_indat_callback: resubmit
read urb failed. (-19)
[  623.416496] option1 ttyUSB17: GSM modem (1-port) converter now
disconnected from ttyUSB17
[  623.416509] option 1-1.2:1.2: device disconnected
[  623.416706] option1 ttyUSB18: GSM modem (1-port) converter now
disconnected from ttyUSB18
[  623.416719] option 1-1.2:1.3: device disconnected
[  623.416833] qmi_wwan 1-1.2:1.8 ce2p0: unregister 'qmi_wwan'
usb-:00:1a.0-1.2, WWAN/QMI device
[  623.443063] qmi_wwan 1-1.2:1.10 ce2p1: unregister 'qmi_wwan'
usb-:00:1a.0-1.2, WWAN/QMI device
[  623.463620] usb 1-1.3: USB disconnect, device number 7
[  623.575090] ehci-pci :00:1a.0: USB bus 1 deregistered
[  632.292943] pci :00:1a.0: [8086:1e2d] type 00 class 0x0c0320
[  632.293002] pci :00:1a.0: reg 0x10: [mem 0xafa01000-0xafa013ff]
[  632.293149] pci :00:1a.0: PME# supported from D0 D3hot D3cold
[  632.293368] pci :00:1a.0: System wakeup disabled by ACPI
[  632.293581] pci :00:02.0: BAR 6: [??? 0x flags 0x2] has
bogus alignment
[  632.293599] pci :00:1a.0: BAR 0: assigned [mem 0xafa01000-0xafa013ff]
[  632.294363] ehci-pci :00:1a.0: EHCI Host Controller
[  632.294383] ehci-pci :00:1a.0: new USB bus registered, assigned
bus number 1
[  632.294408] ehci-pci :00:1a.0: debug port 2
[  632.298333] ehci-pci :00:1a.0: cache line size of 64 is not supported
[  632.30] ehci-pci :00:1a.0: irq 16, io mem 0xafa01000
[  632.312131] ehci-pci :00:1a.0: USB 2.0 started, EHCI 1.00
[  632.312244] usb usb1: New USB device found, idVendor=1d6b, idProduct=0002
[  632.312251] usb usb1: New USB device strings: Mfr=3, Product=2,
SerialNumber=1
[  632.312255] usb usb1: Product: EHCI Host Controller
[  632.312260] usb usb1: Manufacturer: Linux 4.2.0-0.bpo.1-amd64 ehci_hcd
[  632.312265] usb usb1: SerialNumber: :00:1a.0
[  632.312665] hub 1-0:1.0: USB hub found
[  632.312689] hub 1-0:1.0: 3 ports detected
[  632.624313] usb 1-1: new high-speed USB device number 2 using ehci-pci
[  632.757186] usb 1-1: New USB device found, idVendor=8087, idProduct=0024
[  632.757196] usb 1-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
[  632.757838] hub 1-1:1.0: USB hub found
[  632.758023] hub 1-1:1.0: 6 ports detected
[  633.028778] usb 1-1.1: new full-speed USB device number 3 using 

Resetting USB modems and USB to serial converters increases ttyUSBXX counter

2015-10-20 Thread Erwin Van de Velde
Hi all,

Due to some hardware issues, I have to reset USB modems and a USB to
serial converter on some of my servers. What I noticed is that
/dev/ttyUSBXX devices are never reused: ttyUSB1 becomes ttyUSB3 e.g.
and so on. This looks fine, but we have to do it rather often, so
after a while we reach ttyUSB511 after which the system refuses to
create new ttyUSB devices (I guess this is a hard limit in the kernel
code).

This issue seems unsolvable with anything less than a reboot. Is there
a better way? Why are ttyUSB device numbers of devices that have
already disappeared not reused?

Tested on Debian 8 with 3.16 kernel.

Kind regards,
Erwin
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html