diff mbox series

Input: atkbd - Skip ATKBD_CMD_GETID in translated mode

Message ID 20231106155429.5377-1-hdegoede@redhat.com (mailing list archive)
State Superseded
Headers show
Series Input: atkbd - Skip ATKBD_CMD_GETID in translated mode | expand

Commit Message

Hans de Goede Nov. 6, 2023, 3:54 p.m. UTC
There have been multiple reports of keyboard issues on recent laptop models
which can be worked around by setting i8042.dumbkbd, with the downside
being this breaks the capslock LED.

It seems that these issues are caused by recent laptops getting confused by
ATKBD_CMD_GETID. Rather then adding and endless growing list of quirks for
this, lets just skip ATKBD_CMD_GETID alltogether when in translated mode.

The main goal of sending ATKBD_CMD_GETID is to skip binding to ps/2
mice/touchpads and those are never used in translated mode.

Examples of laptop models which benefit from skipping ATKBD_CMD_GETID:

* "HP Laptop 15s-fq2xxx", "HP laptop 15s-fq4xxx" and "HP Laptop 15-dy2xxx"
  models the kbd stops working for the first 2 - 5 minutes after boot
  (waiting for EC watchdog reset?)

* On "HP Spectre x360 13-aw2xxx" atkbd fails to probe the keyboard

* At least 9 different Lenovo models have issues with ATKBD_CMD_GETID, see:
  https://github.com/yaescallop/atkbd-nogetid

Note this also removes the "NCD terminal keyboards are only supported on
non-translating controllers." warning since that code is now unreachable.

This has been tested on:

1. A MSI B550M PRO-VDH WIFI desktop, where the i8042 controller is not
   in translated mode when no keyboard is plugged in and with a ps/2 kbd
   a "AT Translated Set 2 keyboard" /dev/input/event# node shows up

2. A Dell Latitude 9420 (always has a "AT Translated Set 2 keyboard")

3. A Lenovo ThinkPad X1 Yoga gen 8 (idem)

Reported-by: Shang Ye <yesh25@mail2.sysu.edu.cn>
Closes: https://lore.kernel.org/linux-input/886D6167733841AE+20231017135318.11142-1-yesh25@mail2.sysu.edu.cn/
Closes: https://github.com/yaescallop/atkbd-nogetid
Reported-by: gurevitch <mail@gurevit.ch>
Closes: https://lore.kernel.org/linux-input/2iAJTwqZV6lQs26cTb38RNYqxvsink6SRmrZ5h0cBUSuf9NT0tZTsf9fEAbbto2maavHJEOP8GA1evlKa6xjKOsaskDhtJWxjcnrgPigzVo=@gurevit.ch/
Reported-by: Egor Ignatov <egori@altlinux.org>
Closes: https://lore.kernel.org/all/20210609073333.8425-1-egori@altlinux.org/
Reported-by: Anton Zhilyaev <anton@cpp.in>
Closes: https://lore.kernel.org/linux-input/20210201160336.16008-1-anton@cpp.in/
Closes: https://bugzilla.redhat.com/show_bug.cgi?id=2086156
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
Note this supersedes my previous atkbd series:
https://lore.kernel.org/linux-input/20231005201544.26983-1-hdegoede@redhat.com/
---
 drivers/input/keyboard/atkbd.c | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)

Comments

Dmitry Torokhov Nov. 14, 2023, 3:59 p.m. UTC | #1
Hi Hans,

On Mon, Nov 06, 2023 at 04:54:29PM +0100, Hans de Goede wrote:
> There have been multiple reports of keyboard issues on recent laptop models
> which can be worked around by setting i8042.dumbkbd, with the downside
> being this breaks the capslock LED.
> 
> It seems that these issues are caused by recent laptops getting confused by
> ATKBD_CMD_GETID. Rather then adding and endless growing list of quirks for
> this, lets just skip ATKBD_CMD_GETID alltogether when in translated mode.
> 
> The main goal of sending ATKBD_CMD_GETID is to skip binding to ps/2
> mice/touchpads and those are never used in translated mode.
> 
> Examples of laptop models which benefit from skipping ATKBD_CMD_GETID:
> 
> * "HP Laptop 15s-fq2xxx", "HP laptop 15s-fq4xxx" and "HP Laptop 15-dy2xxx"
>   models the kbd stops working for the first 2 - 5 minutes after boot
>   (waiting for EC watchdog reset?)
> 
> * On "HP Spectre x360 13-aw2xxx" atkbd fails to probe the keyboard
> 
> * At least 9 different Lenovo models have issues with ATKBD_CMD_GETID, see:
>   https://github.com/yaescallop/atkbd-nogetid
> 
> Note this also removes the "NCD terminal keyboards are only supported on
> non-translating controllers." warning since that code is now unreachable.
> 
> This has been tested on:
> 
> 1. A MSI B550M PRO-VDH WIFI desktop, where the i8042 controller is not
>    in translated mode when no keyboard is plugged in and with a ps/2 kbd
>    a "AT Translated Set 2 keyboard" /dev/input/event# node shows up
> 
> 2. A Dell Latitude 9420 (always has a "AT Translated Set 2 keyboard")
> 
> 3. A Lenovo ThinkPad X1 Yoga gen 8 (idem)

I agree that the mice/touchpads are not going to work if the controller
is in translated mode, however I wonder if on a device with external
PS/2 ports we could not end up with a port in translated mode with
"wrong" device plugged in.

Can we consider not skipping the check completely, but rather use DMI to
check the chassis type (we already have a similar check in 8042)
and skip ATKBD_CMD_GETID on mobile devices, but still try
ATKBD_CMD_SETLEDS on them?

Thanks.
Hans de Goede Nov. 15, 2023, 5:45 p.m. UTC | #2
Hi Dmitry,

Thank you for the review.

On 11/14/23 16:59, Dmitry Torokhov wrote:
> Hi Hans,
> 
> On Mon, Nov 06, 2023 at 04:54:29PM +0100, Hans de Goede wrote:
>> There have been multiple reports of keyboard issues on recent laptop models
>> which can be worked around by setting i8042.dumbkbd, with the downside
>> being this breaks the capslock LED.
>>
>> It seems that these issues are caused by recent laptops getting confused by
>> ATKBD_CMD_GETID. Rather then adding and endless growing list of quirks for
>> this, lets just skip ATKBD_CMD_GETID alltogether when in translated mode.
>>
>> The main goal of sending ATKBD_CMD_GETID is to skip binding to ps/2
>> mice/touchpads and those are never used in translated mode.
>>
>> Examples of laptop models which benefit from skipping ATKBD_CMD_GETID:
>>
>> * "HP Laptop 15s-fq2xxx", "HP laptop 15s-fq4xxx" and "HP Laptop 15-dy2xxx"
>>   models the kbd stops working for the first 2 - 5 minutes after boot
>>   (waiting for EC watchdog reset?)
>>
>> * On "HP Spectre x360 13-aw2xxx" atkbd fails to probe the keyboard
>>
>> * At least 9 different Lenovo models have issues with ATKBD_CMD_GETID, see:
>>   https://github.com/yaescallop/atkbd-nogetid
>>
>> Note this also removes the "NCD terminal keyboards are only supported on
>> non-translating controllers." warning since that code is now unreachable.
>>
>> This has been tested on:
>>
>> 1. A MSI B550M PRO-VDH WIFI desktop, where the i8042 controller is not
>>    in translated mode when no keyboard is plugged in and with a ps/2 kbd
>>    a "AT Translated Set 2 keyboard" /dev/input/event# node shows up
>>
>> 2. A Dell Latitude 9420 (always has a "AT Translated Set 2 keyboard")
>>
>> 3. A Lenovo ThinkPad X1 Yoga gen 8 (idem)
> 
> I agree that the mice/touchpads are not going to work if the controller
> is in translated mode, however I wonder if on a device with external
> PS/2 ports we could not end up with a port in translated mode with
> "wrong" device plugged in.
> 
> Can we consider not skipping the check completely, but rather use DMI to
> check the chassis type (we already have a similar check in 8042)
> and skip ATKBD_CMD_GETID on mobile devices, but still try
> ATKBD_CMD_SETLEDS on them?

I think that should work. At least the patches from:

https://github.com/yescallop/atkbd-nogetid

for the affected Lenovo models to exactly that and from my (remote)
debugging of the issue on one of the HP laptops I expect it to work
fine there too.

I've prepared a v2 implementing this and I'll send v2 out
right after this email.

Regards,

Hans
diff mbox series

Patch

diff --git a/drivers/input/keyboard/atkbd.c b/drivers/input/keyboard/atkbd.c
index c92e544c792d..c5ffa79548d5 100644
--- a/drivers/input/keyboard/atkbd.c
+++ b/drivers/input/keyboard/atkbd.c
@@ -786,6 +786,20 @@  static int atkbd_probe(struct atkbd *atkbd)
 				 "keyboard reset failed on %s\n",
 				 ps2dev->serio->phys);
 
+/*
+ * On many modern laptops ATKBD_CMD_GETID may cause problems, on these laptops
+ * the controller is always in translated mode. In this mode mice/touchpads will
+ * not work. So in this case simply assume a keyboard is connected to avoid
+ * confusing some laptop keyboards.
+ *
+ * Using a fake keyboard id is ok in translated mode. Only atkbd_select_set()
+ * checks atkbd->id and in translated mode that is a no-op.
+ */
+	if (atkbd->translated) {
+		atkbd->id = 0xabba;
+		goto deactivate;
+	}
+
 /*
  * Then we check the keyboard ID. We should get 0xab83 under normal conditions.
  * Some keyboards report different values, but the first byte is always 0xab or
@@ -813,13 +827,7 @@  static int atkbd_probe(struct atkbd *atkbd)
 
 	atkbd->id = (param[0] << 8) | param[1];
 
-	if (atkbd->id == 0xaca1 && atkbd->translated) {
-		dev_err(&ps2dev->serio->dev,
-			"NCD terminal keyboards are only supported on non-translating controllers. "
-			"Use i8042.direct=1 to disable translation.\n");
-		return -1;
-	}
-
+deactivate:
 /*
  * Make sure nothing is coming from the keyboard and disturbs our
  * internal state.