Bug 242542 - [psm] trackpoint not working, touchpad only sometimes after upgrade to 12.1-RELEASE
Summary: [psm] trackpoint not working, touchpad only sometimes after upgrade to 12.1-R...
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 12.1-RELEASE
Hardware: amd64 Any
: --- Affects Only Me
Assignee: Vladimir Kondratyev
URL:
Keywords: regression
Depends on:
Blocks:
 
Reported: 2019-12-10 12:44 UTC by Felix Palmen
Modified: 2020-06-15 22:45 UTC (History)
1 user (show)

See Also:


Attachments
dmesg on first boot (complete failure) (13.70 KB, text/plain)
2020-05-28 08:22 UTC, Felix Palmen
no flags Details
dmesg on reboot (partial failure) (79.29 KB, text/plain)
2020-05-28 08:23 UTC, Felix Palmen
no flags Details
psm.patch (543 bytes, patch)
2020-05-29 12:33 UTC, Vladimir Kondratyev
no flags Details | Diff
dmesg with patch on reboot (all working) (78.88 KB, text/plain)
2020-05-29 13:25 UTC, Felix Palmen
no flags Details
psm.patch (652 bytes, patch)
2020-05-29 14:24 UTC, Vladimir Kondratyev
no flags Details | Diff
psm.patch (940 bytes, patch)
2020-05-29 15:39 UTC, Vladimir Kondratyev
no flags Details | Diff
psm.patch (2.28 KB, patch)
2020-05-31 13:25 UTC, Vladimir Kondratyev
no flags Details | Diff
psm.patch (2.28 KB, patch)
2020-05-31 13:28 UTC, Vladimir Kondratyev
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Felix Palmen 2019-12-10 12:44:17 UTC
I'm using a Lenovo X121e which has a touchpad and a trackpoint, both worked fine on 12.0-RELEASE. After upgrading to 12.1-RELEASE (currently patchlevel p1), the trackpoint stopped working completely, and the touchpad only works on every second boot.

I have the following in /boot/loader.conf:

hw.psm.trackpoint_support="1"
hw.psm.synaptics_support="1"
hw.psm.synaptics.vscroll_hor_area="1300"

scrolling on the touchpad never worked, but everything else was fine. Now on 12.1-RELEASE, I get either the following messages, with nothing working at all:

Dec 10 13:26:11 photon kernel: psm0: failed to get status.
Dec 10 13:26:11 photon kernel: psm0: <PS/2 Mouse> irq 12 on atkbdc0
Dec 10 13:26:11 photon kernel: psm0: [GIANT-LOCKED]
Dec 10 13:26:11 photon kernel: psm0: model Generic PS/2 mouse, device ID 0
[...]
Dec 10 13:26:14 photon kernel: psm0: failed to enable the device (doopen).

... or the following, with the touchpad working, but the trackpoint not:

Dec 10 13:29:03 photon kernel: psm0: <PS/2 Mouse> irq 12 on atkbdc0
Dec 10 13:29:03 photon kernel: psm0: [GIANT-LOCKED]
Dec 10 13:29:03 photon kernel: psm0: model Synaptics Touchpad, device ID 0
Comment 1 Felix Palmen 2020-05-24 08:10:32 UTC
Recently, I had both the touchpad and trackpoint work on that notebook once. Could someone give hints what I should analyze to track down the root cause of this issue?
Comment 2 Vladimir Kondratyev freebsd_committer 2020-05-27 10:16:12 UTC
(In reply to Felix Palmen from comment #1)
> Could someone give hints what I should analyze to track down
> the root cause of this issue?

add debug.psm.loglevel=5 to /boot/loader.conf and place dmesg output here after reboot.
Comment 3 Felix Palmen 2020-05-28 08:22:03 UTC
Created attachment 214954 [details]
dmesg on first boot (complete failure)

Ok thanks! I can't reproduce a case where everything works. Here's the dmesg output with psm debugging from the first boot, neither touchpad nor trackpoint working.
Comment 4 Felix Palmen 2020-05-28 08:23:17 UTC
Created attachment 214955 [details]
dmesg on reboot (partial failure)

And this is the dmesg output I get on reboot, result is a working touchpad, but the trackpoint is still "dead".
Comment 5 Vladimir Kondratyev freebsd_committer 2020-05-29 12:33:22 UTC
Created attachment 215015 [details]
psm.patch

AUX port becomes dead after switching MUX back to legacy mode.

Try attached patch. It will show us who is guilty: mode transition or PS/2 commands executed in multiplexed mode

P.S. Does your laptop have external PS/2 port or dock station with PS/2 port?
Comment 6 Felix Palmen 2020-05-29 13:25:45 UTC
Created attachment 215020 [details]
dmesg with patch on reboot (all working)

(In reply to Vladimir Kondratyev from comment #5)

Thanks!

> Try attached patch.

Applied it to releng/12.1 and the observable behavior is *almost* the same: touchpad and trackpoint dead on cold start, but this time, both worked fine on reboot. This could however be coincidence as I had them both working once a few weeks ago as well. I'm attaching a dmesg log from the reboot. Please let me know if you also need the log from cold start case when nothing worked.

> P.S. Does your laptop have external PS/2 port or dock station with PS/2 port?

No, it's a small netbook that doesn't even have a docking station connector, and there are no PS/2 ports, so it's just wired internally.
Comment 7 Vladimir Kondratyev freebsd_committer 2020-05-29 14:24:43 UTC
Created attachment 215024 [details]
psm.patch

> Applied it to releng/12.1 and the observable behavior is *almost* the same: touchpad and trackpoint dead on cold start, but this time, both worked fine on reboot.

Is it always broken on cold start and restores after reboot?

> Please let me know if you also need the log from cold start case when nothing worked.

I need about 30-40 lines starting from:
psm0: current command byte:0067

Try:

1. Attached patch.
2. enable_synaptics_mux() body replaced with return(FALSE);
Comment 8 Felix Palmen 2020-05-29 14:40:23 UTC
(In reply to Vladimir Kondratyev from comment #7)

> Is it always broken on cold start and restores after reboot?
From my observations so far, yes. But normally, only the touchpad works after reboot, a working trackpoint is rare.

> I need about 30-40 lines starting from:
> psm0: current command byte:0067

psm0: current command byte:0067
psm: ENABLE_DEV return code:00fa
psm: DISABLE_DEV return code:00fa
psm: SEND_AUX_DEV_STATUS return code:00fa
psm: status 00 02 64
psm: SEND_DEV_ID return code:00fa
psm: device ID: 0000
psm: SET_RESOLUTION (0) 00fa
psm: SET_SCALING11 return code:00fa
psm: SET_SCALING11 return code:00fa
psm: SET_SCALING11 return code:00fa
psm: SEND_AUX_DEV_STATUS return code:00fa
psm: status 00 00 64
aux_mux: ping port 0
aux_mux: ping port 1
aux_mux: ping port 2
aux_mux: ping port 3
Active Multiplexing PS/2 controller v1.1 with 0 active port(s)
psm: SET_RESOLUTION (3) 00fe
psm: SET_RESOLUTION (3) 00fe
psm: SET_SCALING11 return code:00fe
psm: SET_SAMPLING_RATE (200) 00fe
psm: SET_SAMPLING_RATE (200) 00fe
psm: SET_SAMPLING_RATE (200) 00fe
psm: SEND_DEV_ID return code:00fe
synaptics: BEGIN init
psm: SET_SCALING11 return code:00fe
psm: SET_RESOLUTION (0) 00fe
elantech: BEGIN init
psm: SET_SCALING11 return code:00fe
psm: SET_SCALING11 return code:00fe
psm: SET_SCALING11 return code:00fe
psm: SEND_AUX_DEV_STATUS return code:00fe
psm: SET_SAMPLING_RATE (200) 00fe
psm: SET_SAMPLING_RATE (100) 00fe
psm: SEND_DEV_ID return code:00fe
psm: SET_SAMPLING_RATE (10) 00fe
psm: SET_RESOLUTION (2) 00fe
psm: SET_SAMPLING_RATE (100) 00fe
psm: SET_SCALING11 return code:00fe
psm: SET_SCALING11 return code:00fe
psm: SET_SCALING11 return code:00fe
psm: SET_SCALING11 return code:00fe
psm: SEND_AUX_DEV_STATUS return code:00fe
psm: SET_RESOLUTION (2) 00fe
psm: SET_SAMPLING_RATE (100) 00fe
psm: SET_SCALING11 return code:00fe
psm: SEND_AUX_DEV_STATUS return code:00fe
psm0: failed to get status.
psm0: <PS/2 Mouse> irq 12 on atkbdc0
psm0: [GIANT-LOCKED]
psm0: model Generic PS/2 mouse, device ID 0-00, 2 buttons
psm0: config:00000000, flags:00000008, packet size:3
psm0: syncmask:c0, syncbits:00

> Try:
> 1. Attached patch.
> 2. enable_synaptics_mux() body replaced with return(FALSE);

Thanks again! Will test both soon and report back. Why are there lines added, but commented? Should I also try *with* these lines?
Comment 9 Vladimir Kondratyev freebsd_committer 2020-05-29 14:50:42 UTC
(In reply to Felix Palmen from comment #8)
> Why are there lines added, but commented? Should I also try *with* these lines?

This is a quirk related to coreboot devices. It is commented out as it requires some additional lines to be added to compile.
Comment 10 Felix Palmen 2020-05-29 14:56:08 UTC
With the new patch, the following changes:

psm: status 00 00 64
aux_mux: ping port 0
psm: ENABLE_DEV return code:00fe
aux_mux: ping port 1
psm: ENABLE_DEV return code:00fe
aux_mux: ping port 2
psm: ENABLE_DEV return code:00fe
aux_mux: ping port 3
psm: ENABLE_DEV return code:00fa
psm: DISABLE_DEV return code:00fa
Active Multiplexing PS/2 controller v1.1 with 1 active port(s)
psm: ENABLE_DEV return code:00fe
psm0: failed to enable the aux device.

Now trying the "short-circuit" :)
Comment 11 Vladimir Kondratyev freebsd_committer 2020-05-29 14:59:30 UTC
(In reply to Felix Palmen from comment #10)
Did you try touchpad after "psm0: failed to enable the aux device."?
Comment 12 Vladimir Kondratyev freebsd_committer 2020-05-29 15:01:39 UTC
(In reply to Vladimir Kondratyev from comment #11)
And what is on the next lines after "psm0: failed to enable the aux device."?
Comment 13 Felix Palmen 2020-05-29 15:08:59 UTC
(In reply to Vladimir Kondratyev from comment #12)
Yes, nothing was working, and the following lines were exactly the same as in the previous log from comment #8.

> 2. enable_synaptics_mux() body replaced with return(FALSE);
This however fixes the problem! Both touchpad and trackpoint are working after cold start.
Comment 14 Vladimir Kondratyev freebsd_committer 2020-05-29 15:39:17 UTC
Created attachment 215027 [details]
psm.patch

Could you try this patch?

It contains several commands which can change controller or mouse state.

If it helps exact one should be found with commenting out of others.
Comment 15 Felix Palmen 2020-05-29 16:08:23 UTC
(In reply to Vladimir Kondratyev from comment #14)

> Could you try this patch?

> It contains several commands which can change controller or mouse state.
Yes! This seems to get the recovery done, I'm getting this (I guess 00fa is good) and both touchpad and trackpoint are working:

aux_mux: ping port 0
psm: ENABLE_DEV return code:00fe
aux_mux: ping port 1
psm: ENABLE_DEV return code:00fe
aux_mux: ping port 2
psm: ENABLE_DEV return code:00fe
aux_mux: ping port 3
psm: ENABLE_DEV return code:00fa
psm: DISABLE_DEV return code:00fa
Active Multiplexing PS/2 controller v1.1 with 1 active port(s)
psm: ENABLE_DEV return code:00fe
psm0: failed to enable the aux device.
psm: SET_RESOLUTION (3) 00fa
psm: SET_SCALING11 return code:00fa
psm: SET_SCALING11 return code:00fa
psm: SET_SCALING11 return code:00fa
psm: SEND_AUX_DEV_STATUS return code:00fa
psm: status 00 03 64

So, have to leave now, thanks a lot so far. I will test tomorrow which line exactly recovers successfully and post an update.
Comment 16 Felix Palmen 2020-05-29 19:51:27 UTC
Ok, I tried only this one:

reset_kbd(kbdc);

First ran into -Werror for unused local variables :o

Well, it works! Did two cold starts with this code just to be sure, both touchpad and trackpoint working flawlessly :)

Do you still need me to test the alternative reset/restore functions in isolation as well?
Comment 17 Vladimir Kondratyev freebsd_committer 2020-05-30 12:46:27 UTC
(In reply to Felix Palmen from comment #16)

> reset_kbd(kbdc);

Reset keyboard to unstuck mouse... It is funny.

> Do you still need me to test the alternative reset/restore functions in isolation as well?

Yes, test them all, please! Keyboard reset is rather radical solution, but acceptable as a last resort.

There are 2 more command used in keyboard driver to bring hung kbd controller back which can be tested:

test_controller(kbdc);
test_kbd_port(kbdc);
Comment 18 Felix Palmen 2020-05-30 15:35:30 UTC
Ok, I don't get how the keyboard is related here (it always worked fine), but as long as it solves the problem…


Testing:


reset_aux_dev(kbdc);                     // broken


restore_controller(kbdc, command_byte);  // broken


restore_controller(kbdc, command_byte);
reset_aux_dev(kbdc);                     // broken


test_controller(kbdc);                   // broken


test_kbd_port(kbdc);                     // broken


reset_kbd(kbdc);                         // works


I re-tested this last one to be sure it is really reproducible.
Comment 19 Vladimir Kondratyev freebsd_committer 2020-05-31 13:25:51 UTC
Created attachment 215104 [details]
psm.patch

Here is, hopefully, a final version. It adds loader tunable, manpage changes and extra checks. Only "reset_kbd(kbdc);" command is used to do a recovery.
Comment 20 Vladimir Kondratyev freebsd_committer 2020-05-31 13:28:18 UTC
Created attachment 215105 [details]
psm.patch

Fix typo.
Comment 21 Felix Palmen 2020-06-01 08:23:09 UTC
(In reply to Vladimir Kondratyev from comment #20)
Great, thanks :)

Applied to releng/12.1 and installed, and as expected, works fine with and without the new setting (so I never see the warning message you added). But verified from debug dmesg output that the mux code is skipped entirely when setting "mux_disabled".
Comment 22 commit-hook freebsd_committer 2020-06-02 01:05:40 UTC
A commit references this bug:

Author: wulf
Date: Tue Jun  2 01:04:49 UTC 2020
New revision: 361718
URL: https://svnweb.freebsd.org/changeset/base/361718

Log:
  [psm] Workaround active PS/2 multiplexor hang

  which happens on some laptops after returning to legacy multiplexing mode
  at initialization stage.

  PR:		242542
  Reported by:	Felix Palmen <felix@palmen-it.de>
  MFC after:	1 week

Changes:
  head/share/man/man4/psm.4
  head/sys/dev/atkbdc/psm.c
Comment 23 commit-hook freebsd_committer 2020-06-15 22:42:30 UTC
A commit references this bug:

Author: wulf
Date: Mon Jun 15 22:41:28 UTC 2020
New revision: 362208
URL: https://svnweb.freebsd.org/changeset/base/362208

Log:
  MFC r361715:

  [psm] Do not disable trackpoint when hw.psm.elantech.touchpad_off is enabled

  PR:		246117
  Reported by:	Alexander Sieg <ports@xanderio.de>

  MFC r361718:

  [psm] Workaround active PS/2 multiplexor hang

  which happens on some laptops after returning to legacy multiplexing mode
  at initialization stage.

  PR:		242542
  Reported by:	Felix Palmen <felix@palmen-it.de>

Changes:
_U  stable/12/
  stable/12/share/man/man4/psm.4
  stable/12/sys/dev/atkbdc/psm.c
Comment 24 commit-hook freebsd_committer 2020-06-15 22:44:33 UTC
A commit references this bug:

Author: wulf
Date: Mon Jun 15 22:43:46 UTC 2020
New revision: 362209
URL: https://svnweb.freebsd.org/changeset/base/362209

Log:
  MFC r361715:

  [psm] Do not disable trackpoint when hw.psm.elantech.touchpad_off is enabled

  PR:		246117
  Reported by:	Alexander Sieg <ports@xanderio.de>

  MFC r361718:

  [psm] Workaround active PS/2 multiplexor hang

  which happens on some laptops after returning to legacy multiplexing mode
  at initialization stage.

  PR:		242542
  Reported by:	Felix Palmen <felix@palmen-it.de>

Changes:
_U  stable/11/
  stable/11/share/man/man4/psm.4
  stable/11/sys/dev/atkbdc/psm.c