FreeBSD 11.0-CURRENT, when running on Raspberry Pi Zero ("bcm283x_dwcotg0: <DWC OTG 2.0 integrated USB controller (bcm283x)> mem 0x980000-0x99ffff irq 10029 on simplebus0"), doesn't seem to "notice" the device got unplugged. In other words, after disconnecting the USB memory stick from the USB cable, "usbconfig" claims the device is still there: root@rpi-b:~ # usbconfig ugen0.1: <OTG Root HUB DWCOTG> at usbus0, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=SAVE (0mA) ugen0.2: <DataTraveler 3.0 Kingston> at usbus0, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=ON (300mA)
Forgot to mention: "usbconfig reset" clears the situation.
Hi, It is likely some OTG interrupt which is not handled by the driver. We need to emulate the port status. Can you enable first: hw.usb.uhub.debug=16 Any disconnect messages when you unplug. Then enabled the debug knob for the dwc otg just before you disconnect for like 1-2 seconds. It produces a lot of messages too. See if there is an OTG interrupt and write down the values. Thank you! --HPS
Created attachment 171946 [details] Debug log
After disconnection: usb_needs_explore: usb_bus_powerd: bus=0xc28e8000 usb_bus_powerd: Recomputing power masks uhub_explore: udev=0xc2b12000 addr=1 uhub_read_port_status: port 1, wPortStatus=0x0500, wPortChange=0x0000, err=USB_ERR_NORMAL_COMPLETION usbd_transfer_power_ref: Adding type 2 to power state usbd_transfer_power_ref: needs power usb_needs_explore: usb_bus_powerd: bus=0xc28e8000 uhub_explore: udev=0xc2b12000 addr=1 uhub_read_port_status: port 1, wPortStatus=0x0500, wPortChange=0x0000, err=USB_ERR_NORMAL_COMPLETION usb_needs_explore: usb_bus_powerd: bus=0xc28e8000 usb_bus_powerd: Recomputing power masks uhub_explore: udev=0xc2b12000 addr=1 uhub_read_port_status: port 1, wPortStatus=0x0500, wPortChange=0x0000, err=USB_ERR_NORMAL_COMPLETION usbd_transfer_power_ref: Adding type 0 to power state usbd_transfer_power_ref: needs power usb_needs_explore: usb_bus_powerd: bus=0xc28e8000 usb_bus_powerd: Recomputing power masks uhub_explore: udev=0xc2b12000 addr=1 uhub_read_port_status: port 1, wPortStatus=0x0500, wPortChange=0x0000, err=USB_ERR_NORMAL_COMPLETION usb_needs_explore: usb_bus_powerd: bus=0xc28e8000 usb_bus_powerd: Recomputing power masks uhub_explore: udev=0xc2b12000 addr=1 uhub_read_port_status: port 1, wPortStatus=0x0500, wPortChange=0x0000, err=USB_ERR_NORMAL_COMPLETION usb_needs_explore: usb_bus_powerd: bus=0xc28e8000 uhub_explore: udev=0xc2b12000 addr=1 uhub_read_port_status: port 1, wPortStatus=0x0500, wPortChange=0x0000, err=USB_ERR_NORMAL_COMPLETION usb_needs_explore: usb_bus_powerd: bus=0xc28e8000 usb_bus_powerd: Recomputing power masks uhub_explore: udev=0xc2b12000 addr=1 Note that the messages seem to came from some sort of one-second timer. The second log, with dwc_otg debug level set to 1000, is attached.
Created attachment 171981 [details] DWC OTG patch Can you test the attached patch?
Created attachment 171982 [details] DWC OTG patch Needed to mask the port change event on plug - but not unplug.
The patch fixes the problem. Thanks :-)
A commit references this bug: Author: hselasky Date: Fri Jul 1 07:27:33 UTC 2016 New revision: 302306 URL: https://svnweb.freebsd.org/changeset/base/302306 Log: Fix detection of USB device disconnects in USB host mode when the USB device is connected directly to the USB port of the DWC OTG, in this case a RPI-zero. PR: 210695 Approved by: re (gjb) MFC after: 1 week Changes: head/sys/dev/usb/controller/dwc_otg.c
A commit references this bug: Author: hselasky Date: Mon Jul 11 12:59:23 UTC 2016 New revision: 302562 URL: https://svnweb.freebsd.org/changeset/base/302562 Log: MFC r302306: Fix detection of USB device disconnects in USB host mode when the USB device is connected directly to the USB port of the DWC OTG, in this case a RPI-zero. PR: 210695 Changes: _U stable/10/ stable/10/sys/dev/usb/controller/dwc_otg.c