Bug 221305

Summary: Mouse cursor loss when moving cursor while loading Dtrace modules
Product: Base System Reporter: Fabian Keil <fk>
Component: kernAssignee: freebsd-bugs (Nobody) <bugs>
Status: Open ---    
Severity: Affects Some People CC: emaste
Priority: --- Keywords: patch
Version: CURRENTFlags: fk: mfc-stable11?
Hardware: Any   
OS: Any   
Attachments:
Description Flags
atkbdc: Work around (apparently) broken mouse reinitialization none

Description Fabian Keil 2017-08-07 10:11:29 UTC
Created attachment 185123 [details]
atkbdc: Work around (apparently) broken mouse reinitialization

Moving the mouse while loading DTrace modules, for example by running
a DTrace script without having loaded the modules manually first, reliably
disables the mouse (track point) until reboot (on a ThinkPad R500).

With debug.psm.loglevel=5 the logs shows:

Nov 25 13:38:06 r500 kernel: [132] psmintr: 28 03 fe 01 ff 00
Nov 25 13:38:06 r500 kernel: [132] psmintr: 28 02 ff 01 ff 00
Nov 25 13:38:06 r500 kernel: [132] psmintr: 28 03 fe 02 ff 00
Nov 25 13:38:06 r500 kernel: [132] psmintr: 08 02 00 03 fe 00
Nov 25 13:38:06 r500 kernel: [132] psmintr: 28 01 ff 03 fe 00
Nov 25 13:38:07 r500 kernel: [132] psmintr: 18 fe 00 03 ff 00

Nov 25 13:38:08 r500 sudo:       fk : TTY=ttyv0 ; PWD=/home/fk ; USER=root ; COMMAND=/usr/share/dtrace/toolkit/execsnoop

Nov 25 13:38:08 r500 kernel: [134] psm0: lost interrupt?
Nov 25 13:38:09 r500 kernel: [134] psmintr: 08 00 01 03 ff 00
Nov 25 13:38:09 r500 kernel: [134] psmintr: 08 00 01 04 ff 00
Nov 25 13:38:09 r500 kernel: [134] psmintr: 18 ff 01 04 ff 00
Nov 25 13:38:09 r500 kernel: [134] psmintr: 18 ff 02 05 ff 00
Nov 25 13:38:09 r500 kernel: [134] psmintr: 18 ff 02 06 ff 00
Nov 25 13:38:09 r500 kernel: [134] psmintr: 18 fe 03 05 ff 00
Nov 25 13:38:09 r500 kernel: [134] psmintr: 18 fe 04 06 ff 00
Nov 25 13:38:09 r500 kernel: [134] psmintr: 18 fd 05 06 ff 00
Nov 25 13:38:09 r500 kernel: [134] psmintr: 18 fd 05 03 ff 00
Nov 25 13:38:09 r500 kernel: [134] psmintr: 18 fe 03 05 ff 00
Nov 25 13:38:09 r500 kernel: [134] psmintr: 18 fd 03 06 ff 00
Nov 25 13:38:09 r500 kernel: [134] psmintr: 18 fa 06 05 00 00
Nov 25 13:38:09 r500 kernel: [134] psmintr: 18 fc 04 06 ff 00
Nov 25 13:38:09 r500 kernel: [134] psmintr: 18 fa 03 04 00 00
Nov 25 13:38:09 r500 kernel: [134] psmintr: 18 f9 05 07 00 00
Nov 25 13:38:09 r500 kernel: [134] psmintr: 18 f7 03 05 00 00
Nov 25 13:38:09 r500 kernel: [134] psmintr: 18 f9 04 06 00 00
Nov 25 13:38:09 r500 kernel: [134] psmintr: 18 f8 02 04 00 00
Nov 25 13:38:09 r500 kernel: [134] psmintr: 18 fb 01 04 00 00
Nov 25 13:38:09 r500 kernel: [134] psmintr: 18 fb 01 02 00 00
Nov 25 13:38:09 r500 kernel: [134] psmintr: 18 ff 00 03 00 00
Nov 25 13:38:11 r500 kernel: [136] psmintr: 18 ff 00 02 00 00
Nov 25 13:38:11 r500 kernel: [136] psmintr: c8 d3 0b 03 00 00
Nov 25 13:38:11 r500 kernel: [136] psmintr: out of sync (00c0 != 0000) 881 cmds since last error.
Nov 25 13:38:11 r500 kernel: [136] psmintr: discard a byte (1)
Nov 25 13:38:11 r500 kernel: [136] psmintr: d3 0b 08 03 00 00
Nov 25 13:38:11 r500 kernel: [136] psmintr: out of sync (00c0 != 0000) 0 cmds since last error.
Nov 25 13:38:11 r500 kernel: [136] psmintr: discard a byte (2)
Nov 25 13:38:11 r500 kernel: [136] psmintr: 0b 08 4b 03 00 00
Nov 25 13:38:11 r500 kernel: [136] psmintr: 3c 08 0c 03 00 00
Nov 25 13:38:11 r500 kernel: [136] psmintr: 0f 08 0c 03 00 00
Nov 25 13:38:11 r500 kernel: [136] psmintr: 10 08 0b 03 00 00
Nov 25 13:38:11 r500 kernel: [136] psmintr: 10 08 0a 03 00 00
Nov 25 13:38:11 r500 kernel: [136] psmintr: 12 08 08 03 00 00
Nov 25 13:38:11 r500 kernel: [136] psmintr: 10 08 08 03 00 00
Nov 25 13:38:11 r500 kernel: [136] psmintr: 12 08 08 03 00 00
Nov 25 13:38:11 r500 kernel: [136] psmintr: 13 08 05 03 00 00
Nov 25 13:38:11 r500 kernel: [136] psmintr: 0f 08 05 03 00 00
Nov 25 13:38:11 r500 kernel: [136] psmintr: 13 08 04 03 00 00
Nov 25 13:38:11 r500 kernel: [136] psmintr: 13 08 01 03 00 00
Nov 25 13:38:11 r500 kernel: [136] psmintr: 0b 08 00 03 00 00
Nov 25 13:38:11 r500 kernel: [136] psmintr: 0a 18 ff 03 00 00
Nov 25 13:38:11 r500 kernel: [136] psmintr: 0f 18 fd 03 00 00
Nov 25 13:38:11 r500 kernel: [136] psmintr: 0e 18 fc 03 00 00
Nov 25 13:38:11 r500 kernel: [136] psmintr: 08 18 fc 03 00 00
Nov 25 13:38:11 r500 kernel: [136] psmintr: 0a 18 fc 03 00 00
Nov 25 13:38:11 r500 kernel: [136] psmintr: 05 18 fb 03 00 00
Nov 25 13:38:11 r500 kernel: [136] psmintr: 05 18 fa 03 00 00
Nov 25 13:38:11 r500 kernel: [136] psmintr: 05 18 f5 03 00 00
Nov 25 13:38:11 r500 kernel: [136] psmintr: 09 18 f2 03 00 00
Nov 25 13:38:11 r500 kernel: [136] psmintr: 08 18 f2 03 00 00
Nov 25 13:38:11 r500 kernel: [136] psmintr: 05 18 f0 03 00 00
Nov 25 13:38:11 r500 kernel: [136] psmintr: 06 18 f2 03 00 00
Nov 25 13:38:11 r500 kernel: [136] psmintr: 03 18 ee 03 00 00
Nov 25 13:38:11 r500 kernel: [136] psmintr: 02 18 f3 03 00 00
Nov 25 13:38:11 r500 kernel: [136] psmintr: 01 18 ef 03 00 00
Nov 25 13:38:11 r500 kernel: [136] psmintr: 00 38 ed 03 00 00
Nov 25 13:38:11 r500 kernel: [136] psmintr: ff 38 ee 03 00 00
Nov 25 13:38:11 r500 kernel: [136] psmintr: out of sync (00c0 != 0000) 0 cmds since last error.
Nov 25 13:38:11 r500 kernel: [136] psmintr: reset the mouse.
Nov 25 13:38:12 r500 kernel: [137] psm0: current command byte: 0047 (reinitialize).
Nov 25 13:38:12 r500 kernel: [137] psm: DISABLE_DEV return code:00fa
Nov 25 13:38:12 r500 kernel: [137] psm: ENABLE_DEV return code:00fa
Nov 25 13:38:12 r500 kernel: [137] psm: DISABLE_DEV return code:00fa
Nov 25 13:38:12 r500 kernel: [137] psm: SET_SAMPLING_RATE (100) 00fa
Nov 25 13:38:12 r500 kernel: [137] psm: SET_RESOLUTION (2) 00fa
Nov 25 13:38:12 r500 kernel: [137] psm: SET_SCALING11 return code:00fa
Nov 25 13:38:12 r500 kernel: [137] psm: SET_STREAM_MODE return code:00fa
Nov 25 13:38:12 r500 kernel: [137] psm: SEND_AUX_DEV_STATUS return code:00fa
Nov 25 13:38:12 r500 kernel: [137] psm: status 00 02 64
Nov 25 13:38:12 r500 kernel: [137] psm: ENABLE_DEV return code:00fa
Nov 25 13:38:12 r500 kernel: [137] psm: SEND_AUX_DEV_STATUS return code:00fa
Nov 25 13:38:12 r500 kernel: [137] psm: status 20 02 64
Nov 25 13:38:15 r500 kernel: [140] psm0: lost interrupt?
Nov 25 13:38:16 r500 kernel: [141] psm0: lost interrupt?
Nov 25 13:38:17 r500 kernel: [142] psm0: lost interrupt?
Nov 25 13:38:18 r500 kernel: [143] psm0: lost interrupt?
Nov 25 13:38:19 r500 kernel: [144] psm0: lost interrupt?
Nov 25 13:38:20 r500 kernel: [145] psm0: lost interrupt?
Nov 25 13:38:21 r500 kernel: [147] psm0: lost interrupt?
Nov 25 13:38:22 r500 kernel: [148] psm0: lost interrupt?
Nov 25 13:38:23 r500 kernel: [149] psm0: lost interrupt?
Nov 25 13:38:24 r500 kernel: [150] psm0: lost interrupt?
Nov 25 13:38:25 r500 kernel: [151] psm0: lost interrupt?
Nov 25 13:38:26 r500 kernel: [152] psm0: lost interrupt?
Nov 25 13:38:27 r500 kernel: [153] psm0: lost interrupt?
Nov 25 13:38:29 r500 kernel: [154] psm0: lost interrupt?
Nov 25 13:38:30 r500 kernel: [155] psm0: lost interrupt?
Nov 25 13:38:31 r500 kernel: [156] psm0: lost interrupt?
Nov 25 13:38:32 r500 kernel: [157] psm0: lost interrupt?
Nov 25 13:38:33 r500 kernel: [158] psm0: lost interrupt?
Nov 25 13:38:34 r500 kernel: [159] psm0: lost interrupt?
Nov 25 13:38:35 r500 kernel: [160] psm0: lost interrupt?
Nov 25 13:38:36 r500 kernel: [161] psm0: lost interrupt?
Nov 25 13:38:37 r500 kernel: [162] psm0: lost interrupt?
Nov 25 13:38:38 r500 kernel: [163] psm0: lost interrupt?
Nov 25 13:38:39 r500 kernel: [164] psm0: lost interrupt?
Nov 25 13:38:40 r500 kernel: [165] psm0: lost interrupt?

After the "reset" the mouse cursor no longer moves and rebooting
seems to be the only "cure". Restarting moused doesn't help.

The attached patch works around the issue by increasing
debug.psm.pkterrthresh=10.

Obtained from: ElectroBSD

My impression is that (at least on my systems) the psm
reinitialization doesn't work in general .

Without the patch other events occasionally rendered the mouse
useless as well, but loading DTrace modules while moving the cursor
is the only reliable way to reproduce the issue I've found so far.

As the workaround doesn't seem to have any negative effects and
works reliable I haven't looked into the psm reinitialization issue (yet).