From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Hans de Goede <hdegoede@redhat.com>,
Shang Ye <yesh25@mail2.sysu.edu.cn>, gurevitch <mail@gurevit.ch>,
Egor Ignatov <egori@altlinux.org>, Anton Zhilyaev <anton@cpp.in>,
Dmitry Torokhov <dmitry.torokhov@gmail.com>,
Sasha Levin <sashal@kernel.org>,
rrangel@chromium.org, linux-input@vger.kernel.org
Subject: [PATCH AUTOSEL 6.1 03/24] Input: atkbd - skip ATKBD_CMD_GETID in translated mode
Date: Mon, 25 Dec 2023 19:21:56 -0500 [thread overview]
Message-ID: <20231226002255.5730-3-sashal@kernel.org> (raw)
In-Reply-To: <20231226002255.5730-1-sashal@kernel.org>
From: Hans de Goede <hdegoede@redhat.com>
[ Upstream commit 936e4d49ecbc8c404790504386e1422b599dec39 ]
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, just skip ATKBD_CMD_GETID alltogether on laptops 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/yescallop/atkbd-nogetid
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 Lenovo ThinkPad X1 Yoga gen 8 (always has a translated set 2 keyboard)
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/yescallop/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>
Link: https://lore.kernel.org/r/20231115174625.7462-1-hdegoede@redhat.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/input/keyboard/atkbd.c | 46 +++++++++++++++++++++++++++++++---
1 file changed, 42 insertions(+), 4 deletions(-)
diff --git a/drivers/input/keyboard/atkbd.c b/drivers/input/keyboard/atkbd.c
index 246958795f606..e1e4f1133296a 100644
--- a/drivers/input/keyboard/atkbd.c
+++ b/drivers/input/keyboard/atkbd.c
@@ -746,6 +746,44 @@ static void atkbd_deactivate(struct atkbd *atkbd)
ps2dev->serio->phys);
}
+#ifdef CONFIG_X86
+static bool atkbd_is_portable_device(void)
+{
+ static const char * const chassis_types[] = {
+ "8", /* Portable */
+ "9", /* Laptop */
+ "10", /* Notebook */
+ "14", /* Sub-Notebook */
+ "31", /* Convertible */
+ "32", /* Detachable */
+ };
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(chassis_types); i++)
+ if (dmi_match(DMI_CHASSIS_TYPE, chassis_types[i]))
+ return true;
+
+ return false;
+}
+
+/*
+ * 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.
+ *
+ * Skipping ATKBD_CMD_GETID ends up using a fake keyboard id. Using a fake id is
+ * ok in translated mode, only atkbd_select_set() checks atkbd->id and in
+ * translated mode that is a no-op.
+ */
+static bool atkbd_skip_getid(struct atkbd *atkbd)
+{
+ return atkbd->translated && atkbd_is_portable_device();
+}
+#else
+static inline bool atkbd_skip_getid(struct atkbd *atkbd) { return false; }
+#endif
+
/*
* atkbd_probe() probes for an AT keyboard on a serio port.
*/
@@ -775,12 +813,12 @@ static int atkbd_probe(struct atkbd *atkbd)
*/
param[0] = param[1] = 0xa5; /* initialize with invalid values */
- if (ps2_command(ps2dev, param, ATKBD_CMD_GETID)) {
+ if (atkbd_skip_getid(atkbd) || ps2_command(ps2dev, param, ATKBD_CMD_GETID)) {
/*
- * If the get ID command failed, we check if we can at least set the LEDs on
- * the keyboard. This should work on every keyboard out there. It also turns
- * the LEDs off, which we want anyway.
+ * If the get ID command was skipped or failed, we check if we can at least set
+ * the LEDs on the keyboard. This should work on every keyboard out there.
+ * It also turns the LEDs off, which we want anyway.
*/
param[0] = 0;
if (ps2_command(ps2dev, param, ATKBD_CMD_SETLEDS))
--
2.43.0
next prev parent reply other threads:[~2023-12-26 0:23 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-26 0:21 [PATCH AUTOSEL 6.1 01/24] Input: psmouse - enable Synaptics InterTouch for ThinkPad L14 G1 Sasha Levin
2023-12-26 0:21 ` [PATCH AUTOSEL 6.1 02/24] reset: hisilicon: hi6220: fix Wvoid-pointer-to-enum-cast warning Sasha Levin
2023-12-26 0:21 ` Sasha Levin [this message]
2023-12-26 0:21 ` [PATCH AUTOSEL 6.1 04/24] Input: i8042 - add nomux quirk for Acer P459-G2-M Sasha Levin
2023-12-26 0:21 ` [PATCH AUTOSEL 6.1 05/24] Input: amimouse - convert to platform remove callback returning void Sasha Levin
2023-12-26 0:21 ` [PATCH AUTOSEL 6.1 06/24] s390/scm: fix virtual vs physical address confusion Sasha Levin
2023-12-26 0:22 ` [PATCH AUTOSEL 6.1 07/24] ARC: fix spare error Sasha Levin
2023-12-26 0:22 ` [PATCH AUTOSEL 6.1 08/24] wifi: iwlwifi: pcie: avoid a NULL pointer dereference Sasha Levin
2023-12-26 0:22 ` [PATCH AUTOSEL 6.1 09/24] Input: xpad - add Razer Wolverine V2 support Sasha Levin
2023-12-26 0:22 ` [PATCH AUTOSEL 6.1 10/24] kselftest: alsa: fixed a print formatting warning Sasha Levin
2023-12-26 0:22 ` [PATCH AUTOSEL 6.1 11/24] HID: nintendo: fix initializer element is not constant error Sasha Levin
2023-12-26 0:22 ` [PATCH AUTOSEL 6.1 12/24] platform/x86: thinkpad_acpi: fix for incorrect fan reporting on some ThinkPad systems Sasha Levin
2024-01-09 11:46 ` Pavel Machek
2023-12-26 0:22 ` [PATCH AUTOSEL 6.1 13/24] ASoC: Intel: bytcr_rt5640: Add quirk for the Medion Lifetab S10346 Sasha Levin
2023-12-26 0:22 ` [PATCH AUTOSEL 6.1 14/24] ASoC: Intel: bytcr_rt5640: Add new swapped-speakers quirk Sasha Levin
2023-12-26 0:22 ` [PATCH AUTOSEL 6.1 15/24] ALSA: hda/realtek: Add quirks for ASUS Zenbook 2022 Models Sasha Levin
2023-12-26 0:22 ` [PATCH AUTOSEL 6.1 16/24] dm audit: fix Kconfig so DM_AUDIT depends on BLK_DEV_DM Sasha Levin
2023-12-26 0:22 ` [PATCH AUTOSEL 6.1 17/24] HID: nintendo: Prevent divide-by-zero on code Sasha Levin
2023-12-26 0:22 ` [PATCH AUTOSEL 6.1 18/24] smb: client: fix potential OOB in smb2_dump_detail() Sasha Levin
2023-12-26 0:22 ` [PATCH AUTOSEL 6.1 19/24] i2c: rk3x: fix potential spinlock recursion on poll Sasha Levin
2023-12-26 0:22 ` [PATCH AUTOSEL 6.1 20/24] drm/amd/display: get dprefclk ss info from integration info table Sasha Levin
2023-12-26 0:22 ` [PATCH AUTOSEL 6.1 21/24] pinctrl: cy8c95x0: Fix typo Sasha Levin
2023-12-26 0:22 ` [PATCH AUTOSEL 6.1 22/24] pinctrl: cy8c95x0: Fix regression Sasha Levin
2023-12-26 0:22 ` [PATCH AUTOSEL 6.1 23/24] pinctrl: cy8c95x0: Fix get_pincfg Sasha Levin
2023-12-26 0:22 ` [PATCH AUTOSEL 6.1 24/24] ida: Fix crash in ida_free when the bitmap is empty Sasha Levin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231226002255.5730-3-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=anton@cpp.in \
--cc=dmitry.torokhov@gmail.com \
--cc=egori@altlinux.org \
--cc=hdegoede@redhat.com \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mail@gurevit.ch \
--cc=rrangel@chromium.org \
--cc=stable@vger.kernel.org \
--cc=yesh25@mail2.sysu.edu.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox