Bug 202275 - USB SX lock hang involving sound devices
Summary: USB SX lock hang involving sound devices
Status: Closed DUPLICATE of bug 194727
Alias: None
Product: Base System
Classification: Unclassified
Component: usb (show other bugs)
Version: 10.2-BETA1
Hardware: amd64 Any
: --- Affects Only Me
Assignee: freebsd-usb (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-08-12 20:17 UTC by John Hood
Modified: 2024-11-12 14:17 UTC (History)
8 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description John Hood 2015-08-12 20:17:14 UTC
FreeBSD 10.2-RC2

I think something in the USB or audio stack has a USB locking issue.  I think this duplicates Bug 194727.

I had a strange USB hang this afternoon.  I took a little nap, and my display went to sleep (this is important, see below).  On waking and returning to my computer, my two USB mice were hung, but a USB keyboard and a Bluetooth keyboard connected via a USB host controller continued to work.

Investigation found this appearing in /var/log/messages every 2-3 seconds:

Aug 12 15:38:54 lister kernel: pcm6: unregister: mixer busy
Aug 12 15:38:54 lister kernel: pcm6: Waiting for sound application to exit!

I ran 'usbconfig -l', it hung.  ^T revealed it was waiting on [USB config SX lock].

I finally discovered a couple of instances of kdeinit4 that had /dev/mixer6 open.  Killing them caused the messages to stop, the USB stack to recover, and my mice started working again.

I have a Dell P2815Q monitor with USB3 hub attached to my system.  Plugged into that is an old Microsoft USB webcam.  This webcam's uaudio0 device was attached to pcm6.  The monitor is set to an energy save mode where it powers down the hub when it goes to sleep, and my system log shows the hub and webcam disconnecting and reconnecting frequently.  It also has some firmware issues that sometimes require you to do a hard power cycle by holding the power button down for 4s, I don't remember if I had to do that this time.

I do not know what is going on exactly, but this all suggests that something may be inappropriately holding that USB lock while waiting for a process during device teardown and causing other non-sound-related devices to hang.  Fortunately, my keyboards continued to work in this case.
Comment 1 John Hood 2015-08-12 20:34:04 UTC
ugen2.1: <OHCI root HUB ATI> at usbus2, cfg=0 md=HOST spd=FULL (12Mbps) pwr=SAVE (0mA)
ugen1.1: <XHCI root HUB 0x1b21> at usbus1, cfg=0 md=HOST spd=SUPER (5.0Gbps) pwr=SAVE (0mA)
ugen0.1: <XHCI root HUB 0x1b21> at usbus0, cfg=0 md=HOST spd=SUPER (5.0Gbps) pwr=SAVE (0mA)
ugen5.1: <EHCI root HUB ATI> at usbus5, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=SAVE (0mA)
ugen4.1: <OHCI root HUB ATI> at usbus4, cfg=0 md=HOST spd=FULL (12Mbps) pwr=SAVE (0mA)
ugen3.1: <EHCI root HUB ATI> at usbus3, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=SAVE (0mA)
ugen7.1: <OHCI root HUB ATI> at usbus7, cfg=0 md=HOST spd=FULL (12Mbps) pwr=SAVE (0mA)
ugen6.1: <OHCI root HUB ATI> at usbus6, cfg=0 md=HOST spd=FULL (12Mbps) pwr=SAVE (0mA)
ugen8.1: <EHCI root HUB ATI> at usbus8, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=SAVE (0mA)
ugen3.2: <product 0x0234 vendor 0x050d> at usbus3, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=SAVE (100mA)
ugen2.2: <Comfort Curve Keyboard 2000 Microsoft> at usbus2, cfg=0 md=HOST spd=LOW (1.5Mbps) pwr=ON (100mA)
ugen2.3: <BELKIN BLUETOOTH USB ADAPTER CL. 2 Broadcom Corp> at usbus2, cfg=0 md=HOST spd=FULL (12Mbps) pwr=ON (100mA)
ugen8.2: <Pioneer external optical drive Pioneer Corporation> at usbus8, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=ON (2mA)
ugen4.2: <product 0x2046 vendor 0x0451> at usbus4, cfg=0 md=HOST spd=FULL (12Mbps) pwr=SAVE (0mA)
ugen4.3: <Razer DeathAdder Razer> at usbus4, cfg=0 md=HOST spd=FULL (12Mbps) pwr=ON (100mA)
ugen4.4: <USB Gaming Mouse Logitech> at usbus4, cfg=0 md=HOST spd=FULL (12Mbps) pwr=ON (98mA)
ugen1.3: <product 0x8044 vendor 0x0451> at usbus1, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=SAVE (0mA)
ugen1.2: <product 0x8046 vendor 0x0451> at usbus1, cfg=0 md=HOST spd=SUPER (5.0Gbps) pwr=SAVE (0mA)
ugen1.4: <Microsoft LifeCam-VX700  v2.0 Microsoft> at usbus1, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=ON (168mA)
Comment 2 Mark Linimon freebsd_committer freebsd_triage 2021-06-11 23:29:33 UTC
^Triage: to submitter: this PR never got assigned to the appropriate mailing list.

As it is now quite old, is it still valid?
Comment 3 Graham Perrin freebsd_committer freebsd_triage 2021-06-12 04:36:26 UTC
Incidentally, 

(In reply to John Hood from comment #0)

> … I ran 'usbconfig -l', it hung. …

For usbconfig(8), I see no option -l

----

More generally, for myself I'm following this bug in the context of 
<https://forums.freebsd.org/threads/80412/>

> forcing off the computer – endlessly waiting for sound application 
> to exit at sleep/suspend time
Comment 4 cgull 2021-07-10 02:12:20 UTC
It's supposedly fixed by now, see bug 194727.  There's also several other bugs for this issue.

Everything has changed since I reported that bug:  I no longer have the sleepy monitor, the machine is a server now, I can't find the webcam, my office is at home, etc.  I tried to reproduce the problem on that machine with 12.2-RELEASE and a USB audio dongle-- the logging still happens but no hung USB devices.

As to comment #3, I must have meant to type `usbconfig list`, of course.
Comment 5 commit-hook freebsd_committer freebsd_triage 2024-03-31 14:16:56 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=9eff58c6d52b66eb8abe7f724dabcd804a566df4

commit 9eff58c6d52b66eb8abe7f724dabcd804a566df4
Author:     Christos Margiolis <christos@FreeBSD.org>
AuthorDate: 2024-03-31 14:13:43 +0000
Commit:     Christos Margiolis <christos@FreeBSD.org>
CommitDate: 2024-03-31 14:13:43 +0000

    sound: Implement asynchronous device detach

    Hot-unplugging a sound device, such as a USB sound card, whilst being
    consumed by an application, results in an infinite loop until either the
    application closes the device's file descriptor, or the channel
    automatically times out after hw.snd.timeout seconds. In the case of a
    detach however, the timeout approach is still not ideal, since we want
    all resources to be released immediatelly, without waiting for N seconds
    until we can use the bus again.

    The timeout mechanism works by calling chn_sleep() in chn_read() and
    chn_write() (see pcm/channel.c) in order to send the thread to sleep,
    using cv_timedwait_sig(). Since chn_sleep() sets the CHN_F_SLEEPING flag
    while waiting for cv_timedwait_sig() to return, we can test this flag in
    pcm_unregister() (called during detach) and wakeup the sleeping
    thread(s) to immediately kill the channel(s) being consumed.

    Sponsored by:   The FreeBSD Foundation
    MFC after:      2 months
    PR:             194727, 278055, 202275, 220949, 272286
    Reviewed by:    dev_submerge.ch, markj
    Differential Revision:  https://reviews.freebsd.org/D43545

 share/man/man4/snd_uaudio.4 | 11 +----------
 sys/dev/sound/pcm/dsp.c     |  2 +-
 sys/dev/sound/pcm/mixer.c   | 11 -----------
 sys/dev/sound/pcm/sound.c   | 24 ++++++++++--------------
 sys/dev/sound/usb/uaudio.c  | 13 +++----------
 5 files changed, 15 insertions(+), 46 deletions(-)
Comment 6 Christos Margiolis freebsd_committer freebsd_triage 2024-04-14 21:05:52 UTC
Fixed as of 44e128fe9d92c1a544b801cb56e907a66ef34691
Comment 7 Christos Margiolis freebsd_committer freebsd_triage 2024-04-15 00:18:20 UTC
*** This bug has been marked as a duplicate of bug 194727 ***
Comment 8 64GBRAMbutWINCRASH 2024-10-13 05:18:35 UTC
Hi I tried GhostBSD recent version based on FreeBSD 14.1 stable, it seems I have the same or similar problem of this report. Details can be seen here
https://forums.ghostbsd.org/viewtopic.php?f=63&t=2818

USB devices lost response/locks up randomly (every few minuts on the exernal usb docker/hub(has display link, sound devices on it), less often on the one connected on the motherboard);
onboard usb 3.0 drive stick sometimes run at usb 2 speed;
manually disconnect and replug in usb hub or usb drive, can not be connected back to the system, dmesg shows error "getting device descriptor at addr 8 failed, USB_ERR_TIMEOUT" etc. 

The same hardware works flawlessly in linux or windows 10.

If you want to have a look of this problem, or I can help with the testing, just send me message. 

also those seems to be interested:
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=211895
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=202275
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=194727


some of the log below:

ugen0.2: <VIA Labs, Inc. USB3.0 Hub> at usbus0
uhub2 on uhub1
uhub2: <VIA Labs, Inc. USB3.0 Hub, class 9/0, rev 3.00/90.84, addr 1> on usbus0
ums0 on uhub0
ums0: <vendor 0x2b89 UGREEN Mouse, class 0/0, rev 1.10/2.00, addr 1> on usbus1
ums0: 8 buttons and [XYZT] coordinates ID=2
uhub2: 4 ports with 2 removable, self powered
ugen0.3: <DisplayLink USB3.0 Dual Video Dock> at usbus0
uaudio0 on uhub2
uaudio0: <DisplayLink USB3.0 Dual Video Dock, class 239/2, rev 3.20/35.06, addr 2> on usbus0
uaudio0: Play[0]: 48000 Hz, 6 ch, 16-bit S-LE PCM format, 2x4ms buffer. (selected)
uaudio0: Record[0]: 48000 Hz, 2 ch, 16-bit S-LE PCM format, 2x4ms buffer. (selected)
uaudio0: No MIDI sequencer.
pcm9 on uaudio0
uaudio0: No HID volume keys found.
cdce0 on uhub2
cdce0: <DisplayLink USB3.0 Dual Video Dock, class 239/2, rev 3.20/35.06, addr 2> on usbus0
ue0: <USB Ethernet> on cdce0
ue0: Ethernet address: 00:50:b6:e0:34:2b
ugen0.4: <VIA Labs, Inc. USB2.0 Hub> at usbus0
uhub3 on uhub1
uhub3: <VIA Labs, Inc. USB2.0 Hub, class 9/0, rev 2.10/90.80, addr 3> on usbus0
uhub3: 4 ports with 2 removable, self powered
ugen0.5: <vendor 0x1a40 USB 2.0 Hub> at usbus0
uhub4 on uhub3
uhub4: <vendor 0x1a40 USB 2.0 Hub, class 9/0, rev 2.00/1.11, addr 4> on usbus0
igb0: link state changed to UP
uhub4: 4 ports with 4 removable, self powered
ugen0.6: <Broadcom Remote Download Wireless Adapter> at usbus0
ipfw2 (+ipv6) initialized, divert loadable, nat loadable, default to accept, logging disabled
Security policy loaded: MAC/ntpd (mac_ntpd)
usb_dev_suspend_peer: Setting device remote wakeup failed
usb_dev_suspend_peer: Suspending port failed
uhub4: at uhub3, port 4, addr 4 (disconnected)
uhub4: detached
usbd_req_re_enumerate: addr=4, port reset failed, USB_ERR_TIMEOUT
usbd_req_re_enumerate: addr=4, port reset failed, USB_ERR_TIMEOUT
usb_dev_suspend_peer: Setting device remote wakeup failed
usb_dev_resume_peer: Clearing device remote wakeup failed: USB_ERR_TIMEOUT
uhub3: at uhub1, port 6, addr 3 (disconnected)
ugen0.5: <vendor 0x1a40 USB 2.0 Hub> at usbus0 (disconnected)
uhub3: detached
usbd_req_re_enumerate: addr=3, set address failed! (USB_ERR_IOERROR, ignored)
usbd_setup_device_desc: getting device descriptor at addr 3 failed, USB_ERR_TIMEOUT
usbd_req_re_enumerate: addr=3, set address failed! (USB_ERR_IOERROR, ignored)
usbd_setup_device_desc: getting device descriptor at addr 3 failed, USB_ERR_TIMEOUT
ugen0.2: <VIA Labs, Inc. USB3.0 Hub> at usbus0 (disconnected)
uhub2: at uhub1, port 2, addr 1 (disconnected)
ugen0.3: <DisplayLink USB3.0 Dual Video Dock> at usbus0 (disconnected)
uaudio0: at uhub2, port 1, addr 2 (disconnected)
pcm9: detached
uaudio0: detached
cdce0: at uhub2, port 1, addr 2 (disconnected)
cdce0: detached
uhub2: detached

[b][here I tried to disconnect and replug in the USB HUB][/b]
usbd_setup_device_desc: getting device descriptor at addr 6 failed, USB_ERR_TIMEOUT
usbd_setup_device_desc: getting device descriptor at addr 6 failed, USB_ERR_TIMEOUT
usbd_setup_device_desc: getting device descriptor at addr 6 failed, USB_ERR_TIMEOUT
usbd_setup_device_desc: getting device descriptor at addr 6 failed, USB_ERR_TIMEOUT
usbd_setup_device_desc: getting device descriptor at addr 6 failed, USB_ERR_TIMEOUT
ugen0.2: <Unknown > at usbus0 (disconnected)
uhub_reattach_port: could not allocate new device
ugen0.4: <VIA Labs, Inc. USB2.0 Hub> at usbus0 (disconnected)

[here I tried to disconnect and replug in the USB HUB]

usbd_setup_device_desc: getting device descriptor at addr 7 failed, USB_ERR_TIMEOUT
usbd_setup_device_desc: getting device descriptor at addr 7 failed, USB_ERR_TIMEOUT
usbd_setup_device_desc: getting device descriptor at addr 7 failed, USB_ERR_TIMEOUT
usbd_setup_device_desc: getting device descriptor at addr 7 failed, USB_ERR_TIMEOUT
usbd_setup_device_desc: getting device descriptor at addr 7 failed, USB_ERR_TIMEOUT
ugen0.2: <Unknown > at usbus0 (disconnected)
uhub_reattach_port: could not allocate new device
ugen0.4: <VIA Labs, Inc. USB2.0 Hub> at usbus0 (disconnected)

[here I tried to disconnect and replug in the USB HUB]

usbd_setup_device_desc: getting device descriptor at addr 7 failed, USB_ERR_TIMEOUT
usbd_setup_device_desc: getting device descriptor at addr 7 failed, USB_ERR_TIMEOUT
usbd_setup_device_desc: getting device descriptor at addr 7 failed, USB_ERR_TIMEOUT
usbd_setup_device_desc: getting device descriptor at addr 7 failed, USB_ERR_TIMEOUT
usbd_setup_device_desc: getting device descriptor at addr 7 failed, USB_ERR_TIMEOUT
ugen0.2: <Unknown > at usbus0 (disconnected)
uhub_reattach_port: could not allocate new device

[here I tried to disconnect and replug my USB 3.0 pen drive directly onto the motherboard USB port and its same error ]

usbd_setup_device_desc: getting device descriptor at addr 8 failed, USB_ERR_TIMEOUT
usbd_setup_device_desc: getting device descriptor at addr 8 failed, USB_ERR_TIMEOUT
usbd_setup_device_desc: getting device descriptor at addr 8 failed, USB_ERR_TIMEOUT
usbd_setup_device_desc: getting device descriptor at addr 8 failed, USB_ERR_TIMEOUT
usbd_setup_device_desc: getting device descriptor at addr 8 failed, USB_ERR_TIMEOUT
ugen0.2: <Unknown > at usbus0 (disconnected)
uhub_reattach_port: could not allocate new device
Comment 9 Christos Margiolis freebsd_committer freebsd_triage 2024-10-13 17:06:57 UTC
(In reply to 64GBRAMbutWINCRASH from comment #8)

I am not sure this is related to the sound driver bug mentioned here, which has been fixed in 44e128fe9d92. These errors are coming from the USB driver, not the sound one.

It's better to open a new bug report and CC freebsd-usb@.