[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openbsd-bugs
Subject:    Re: Touchpad emitting keyboard events
From:       Adam Van Ymeren <adam () vany ! ca>
Date:       2017-01-24 3:55:54
Message-ID: 87r33tf6wl.fsf () adam-laptop ! vany ! ca
[Download RAW message or body]

Gregor Best <gbe@unobtanium.de> writes:

> Hi Adam,
>
> I've seen a similar problem on my laptop. Does the following patch help?
> It's not pretty, but it does work on my box and it looks like always
> doing a write to the AUX port doesn't hurt amd64 (at least it hasn't on
> the boxes I've tried it on).

Hey Gregor,

This patch fixed it for me as well, thanks!

Clearly such a patch can't be submitted so I did some digging into the
difference between Linux vs OpenBSD in this area to see if there's a
different strategy worth adopting.


Linux code here
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/drivers/input/serio/i8042.c#n777.

The general flow of the linux code appears to be.

1) Issue an AUXECHO command to see if aux port is there.
2) If the AUXECHO fails try the AUXTEST command.
3) If the AUXTEST command fails, give up.
4) Attempt to toggle the aux port off and then back on with
AUXDISABLE/AUXENABLE
5) If it fails to turn back on, give up.
6) If the AUXECHO in 2 failed but the AUXTEST in 3 succeeded, then
assume the port works and return success.
7) Attempt to register an IRQ for the AUX port ?, if this fails give up
8) Attempt to enable interrupts for the AUX port.
9) Use AUXECHO again to test if the interrupts are successfully
delivered.
10) If no interrupt is triggered in an acceptable time give up.
11) Disable the AUX port interrupts and return.

OpenBSD also starts out by probing the port with an AUXECHO command, but
the first major difference I see appears if the initial echo fails and
you're on sparc64 then we write the byte to be echo'd again using the
AUXWRITE comman this time.  (sparc64 is the only case I can see in the
code where "NEED_AUXWRITE" is true).

Linx on the other hand doesn't use AUXWRITE at all when checking the
port, and instead uses AUXTEST if the initial echo fails, which OpenBSD
explicily avoids based upon this comment.

	/*
	 * Check aux port ok.
	 * Avoid KBC_AUXTEST because it hangs some older controllers
	 * (eg UMC880?).
	 */


Not sure what approach is better here, and obviously this is hairy code
to change which could go breaking a pretty fundamental thing for lots of
people.

Anyways, those are my findings in case they're useful to anyone.

-Adam

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic