现象
板子接部分U盘出现枚举失败,看log像是硬件信号问题,如:
[ 29.186464] usb usb3-port1: Cannot enable. Maybe the USB cable is bad?
[ 30.079624] usb usb3-port1: Cannot enable. Maybe the USB cable is bad?
[ 30.080200] usb usb3-port1: attempt power cycle
[ 31.046287] usb usb3-port1: Cannot enable. Maybe the USB cable is bad?
[ 31.939659] usb usb3-port1: Cannot enable. Maybe the USB cable is bad?
[ 31.940242] usb usb3-port1: unable to enumerate USB device
分析
如果是硬件信号问题,应该是所有U盘都会出现这种现象,为了排查问题,接了usb分析仪抓数据,抓到U盘枚举出错的数据如下:
可以看到,有一个LPM包,并有ERROR。
解决
在USB驱动中,有一个usb_quirk_list列表,它其实就是一个黑名单,描述了某个设备有何种问题,其中就有LPM相关的配置,把出错的U盘的VID/PID配置上去可以解决问题。
相关修改:
460 /* udisk */
461 { USB_DEVICE(0x2ca3, 0x0031), .driver_info = USB_QUIRK_NO_LPM },