USB DWC3 中断上报ERRATIC ERROR,主机端无法识别

/xu海啸/baiy 2023-08-02 19:05:30 编辑

最近在搞一个音箱设备,系统是linux的,配置DWC3作为从机,在大部分电脑上都能正常识别,但出现一台电脑无法识别,经过初步分析DWC3 gadget中断处理函数dwc3_process_event_buf 会在速率协商完后收到DWC3_DEVICE_EVENT_ERRATIC_ERROR的事件
后又发现只要在设备和电脑中间再接一个USB HUB又能正常。
DWC3的中断事件log如下,这是USB硬件不稳定导致的么?应该如何确认问题的根本原因?

[  481.478022] dwc3_process_event_buf-3624 left:4
[  481.478112] dwc3_process_event_buf-3629
[  481.478138] dwc3_process_event_entry-3607
[  481.478162] dwc3_gadget_interrupt-3553 eventtype:6    这个是DWC3_DEVICE_EVENT_EOPF事件
[  481.478210] dwc3 fcc00000.dwc3: device suspend
[  481.478236] dwc3_process_event_buf-3650
[  481.581696] dwc3_process_event_buf-3624 left:4
[  481.581740] dwc3_process_event_buf-3629
[  481.581758] dwc3_process_event_entry-3607
[  481.581774] dwc3_gadget_interrupt-3553 eventtype:1    这个是DWC3_DEVICE_EVENT_RESET事件
[  481.581798] dwc3 fcc00000.dwc3: device reset
[  481.581834] dwc3_process_event_buf-3650
[  481.638807] dwc3_process_event_buf-3624 left:4
[  481.638838] dwc3_process_event_buf-3629
[  481.638854] dwc3_process_event_entry-3607
[  481.638870] dwc3_gadget_interrupt-3553 eventtype:2    这个是DWC3_DEVICE_EVENT_CONNECT_DONE事件
[  481.638904] dwc3_process_event_buf-3650
[  481.661822] dwc3_process_event_buf-3624 left:4
[  481.661885] dwc3_process_event_buf-3629
[  481.661926] dwc3_process_event_entry-3607
[  481.661971] dwc3_gadget_interrupt-3553 eventtype:9    这个9的就是DWC3_DEVICE_EVENT_ERRATIC_ERROR事件
[  481.661993] dwc3_process_event_buf-3650
[  481.691185] dwc3_process_event_buf-3624 left:4
[  481.691246] dwc3_process_event_buf-3629
[  481.691293] dwc3_process_event_entry-3607
[  481.691334] dwc3_gadget_interrupt-3553 eventtype:9
[  481.691371] dwc3_process_event_buf-3650
[  481.703413] dwc3_process_event_buf-3624 left:4
[  481.703474] dwc3_process_event_buf-3629
[  481.703504] dwc3_process_event_entry-3607
[  481.703544] dwc3_gadget_interrupt-3553 eventtype:9
USB中文网 2023-08-02 19:07:17 编辑

感觉可能是信号质量问题

/xu海啸/baiy 2023-08-03 08:24:35 编辑

哈,第一感觉是。看代码 USB还有个metastability workaround的东西,似乎跟这个ERRATIC ERROR也有关系。
但没找到相关资料,只有一个相关问题的补丁:
补丁的描述如下:
Some platforms (e.g. TI’s DRA7 USB2 instance) have more trouble
with the metastability workaround as it supports only
a High-Speed PHY and the PHY can enter into an Erratic state [1]
when the controller is set in SuperSpeed mode as part of
the metastability workaround.

    This causes upto 2 seconds delay in enumeration on DRA7's USB2
    instance in gadget mode.

    If these platforms can be better off without the workaround,
    provide a device tree property to suggest that so the workaround
    is avoided.
    [1] Device mode enumeration trace showing PHY Erratic Error.
    irq/90-dwc3-969 [000] d... 52.323145: dwc3_event: event (00000901): Erratic Error [U0]
    irq/90-dwc3-969 [000] d... 52.560646: dwc3_event: event (00000901): Erratic Error [U0]
    irq/90-dwc3-969 [000] d... 52.798144: dwc3_event: event (00000901): Erratic Error [U0]

不知道哪里有metastability workaround的详细描述。

USB中文网 2023-08-17 15:14:44 编辑

亚稳定性状态,看来像是芯片的坑。估计是PHY设计或者制造工艺上的坑,或者说某些从规范上的角度讲,其电气性能设计高于了规范要求。导致某些电气相关信息如信号质量,驱动能力之类介于亚稳定性态。所以解决方案大部分是增加驱动能力,调整信号状态等。增加一级HUB,也许就有如此功效。