sriemer / fix-linux-mouse

Hints how to fix USB mouse issues on Linux
44 stars 5 forks source link

Fix the same mouse disconnect/reconnect issues on FreeBSD? #27

Closed sriemer closed 2 years ago

sriemer commented 2 years ago

I've seen in the traffic graph of this repository that there was traffic from twitter. So I searched for it and found the tweet https://twitter.com/vmisev/status/1502246729344823303.

Vladimir Mišev asks how to do the same mouse disconnect/reconnect fixes on FreeBSD. I see from the picture in his tweet that the driver there is ums. So I looked at the latest FreeBSD kernel source of the ums driver: https://cgit.freebsd.org/src/tree/sys/dev/usb/input/ums.c?id=5c6935a645604b1e39b2cf6dbc23f66ec58f3e54#n1055 https://cgit.freebsd.org/src/tree/sys/dev/usb/input/ums.c?id=5c6935a645604b1e39b2cf6dbc23f66ec58f3e54#n817

FreeBSD has no USB HID quirks. What it has, is an ioctl MOUSE_SETMODE which can set the mouse polling interval in Hz sc->sc_pollrate or mode.rate. The maximum there is 1000. The default is -1 (no polling). A good value should be 1 for one poll per second.

The commands for this should be

killall moused
moused -p /dev/ums0 -t auto -F 1

Can someone verify please?

sriemer commented 2 years ago

@hselasky Did you come across the PixArt USB mouse firmware issues that the mouse disconnects/reconnects every minute due to buffer overflow if those are not always polled already? How would you fix them on FreeBSD? TIA

hselasky commented 2 years ago

@sriemer : The setting you refer to simply overrides the interval setting for the given USB transfer.

I have a USB headset with some buttons on, and if you press those volume buttons many times and don't poll that HID endpoint regularly, it stops working simply :-(

Maybe a firmware issue with the PixArt USB mouse?

Or an expectation that all HID endpoints should be polled always.

--HPS

hselasky commented 2 years ago

@sriemer : moused just start the interrupt endpoint of the mouse. Maybe an issue there, that the interrupt endpoint must be open always also when no clients are consuming events.

vmisev commented 2 years ago

On FreeBSD 13 (from 13.0-RELEASE install disk to 13.1-STABLE that I'm running) this disconnect/reconnect happens only without moused started.

Default is to load mouesed from /etc/defaults/rc.conf as moused_nondefault_enable="YES" With moused loaded, everything works fine, both in the vt(4) console and in X.

Problem occurs only in single user mode or/and when service moused is not started or stopped. It happens even if in boot loader I choose

3 – escape to loader prompt
disable-module ums
boot -s 

This boots in single user mode and kldstat showing only kernel and zfs loaded, and connect/reconnect msgs are flooding every 50 seconds.

Interesting, old Genius mouse which reports itself as "Genius Optical Mouse" (it doesn't state 'USB Optical', just 'Optical') doesn’t have reconnect problem when moused is not started.

sriemer commented 2 years ago

Thanks for the input here. Yes, the Logitech firmware in all PixArt ICs is faulty and causing buffer overflows if the devices are not always polled. Logitech will never fix their firmware. I would expect that the ums driver gets an option to always poll the mouse like it is done with the usbhid driver of Linux with its HID_QUIRK_ALWAYS_POLL on a per device basis. Even keyboards and joysticks are reported to require that quirk.

sriemer commented 2 years ago

The information that I needed has been collected. The issue on FreeBSD seems to be very rare. So closing for now. Thanks.