USB 设备消息淹没 dmesg(和控制台)

USB 设备消息淹没 dmesg(和控制台)

当 USB 鼠标插入我的笔记本电脑时,dmesg 中充斥着以下消息:

usb 3-1: USB disconnect, device number 28
usb 3-1: new low-speed USB device number 29 using xhci_hcd
usb 3-1: New USB device found, idVendor=045e, idProduct=00cb
usb 3-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
usb 3-1: Product: Microsoft USB Optical Mouse
usb 3-1: Manufacturer: PixArt
usb 3-1: ep 0x81 - rounding interval to 64 microframes, ep desc says 80 microframes
input: PixArt Microsoft USB Optical Mouse as /devices/pci0000:00/0000:00:14.0/usb3/3-1/3-1:1.0/input/input39
hid-generic 0003:045E:00CB.001C: input: USB HID v1.11 Mouse [PixArt Microsoft USB Optical Mouse] on usb-0000:00:14.0-1/input0
usb 3-1: USB disconnect, device number 29
usb 3-1: new low-speed USB device number 30 using xhci_hcd
usb 3-1: New USB device found, idVendor=045e, idProduct=00cb
usb 3-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
usb 3-1: Product: Microsoft USB Optical Mouse
usb 3-1: Manufacturer: PixArt
usb 3-1: ep 0x81 - rounding interval to 64 microframes, ep desc says 80 microframes
input: PixArt Microsoft USB Optical Mouse as /devices/pci0000:00/0000:00:14.0/usb3/3-1/3-1:1.0/input/input40
hid-generic 0003:045E:00CB.001D: input: USB HID v1.11 Mouse [PixArt Microsoft USB Optical Mouse] on usb-0000:00:14.0-1/input0

看起来这只老鼠似乎不断地被移走,然后又被重新发现。

当我登录控制台(即 CTRL+ALT+F1)时,这些消息也会充斥我的控制台。有没有办法解决这个问题,这样这些消息就不会打扰我?

答案1

原相 OEM 鼠标是已知的在运行级别 1 或 3 中每分钟断开/重新连接(如果是)并不总是进行轮询在 Linux 上。一个内部缓冲区溢出,FW崩溃,然后重新连接。驱动程序的默认行为usbhid只是等待中断。

基本: https://github.com/sriemer/fix-linux-mouse

我已经提交了修补对于此鼠标linux-usb现在的邮件列表:

https://marc.info/?l=linux-usb&m=154159427814212&w=2

内核启动选项 usbhid.quirks=0x045e:0x00cb:0x00000400HID_QUIRK_ALWAYS_POLL将为您启用。

另一种选择是激活该gpm服务。然后gpm轮询鼠标,您就可以在虚拟终端上实际使用它了。

答案2

临时解决方案(重启后会重置):

(作为根)

sysctl -w kernel.printk="3 4 1 7"

上述的永久版本:

  • 在 中创建一个文件/etc/sysctl.d/,也许no_msgs.conf(必须以 .conf 结尾)
  • 文件内容:

    kernel.printk = 3 4 1 7
    
  • 作为 root,执行:(使用上面使用的任何文件名)这将立即生效,并将在每次重新启动时再次设置。

    sysctl -p /etc/sysctl.d/no_msgs.conf
    

参数为kernel.printk:(按从左到右的顺序)

  • console_loglevel:具有更高优先级的消息(降低number!),这将被打印到控制台
  • default_message_loglevel:没有明确优先级的消息将以此优先级打印
  • minimum_console_loglevel:console_loglevel 可以设置的最小(最高)值
  • default_console_loglevel:console_loglevel的默认值

这些值会影响打印或记录错误消息时 printk() 的行为。有关不同日志级别的更多信息,请参阅“man 2”syslog”。

本质上,我们正在降低默认值4, 到3,从而拒绝打印 '警告4)' 类型消息,仅更差类型消息将被允许打印到控制台。 (3=错误,2=暴击,1=警报,0=紧急(呃哦!))

如果你发现3不会停止消息,请尝试2 4 1 7,但实际上,您应该调查是什么使您的鼠标不断重新连接。也许它没有获得足够的力量?尝试将其插入计算机上的其他端口,或者更好地将其插入自供电集线器。设备不应该那样振荡。

相关内容