Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp2537650rdb; Mon, 25 Dec 2023 16:31:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IGyBsNSEvS3FjahNrnX/xgxXZBZ3ce72jo/cr6EEeIIBO61CV0HmjmobA3lszRRqM7xVmNC X-Received: by 2002:a05:622a:148e:b0:425:4043:50f0 with SMTP id t14-20020a05622a148e00b00425404350f0mr9364189qtx.127.1703550686701; Mon, 25 Dec 2023 16:31:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703550686; cv=none; d=google.com; s=arc-20160816; b=k7CJKqjqwh2SM0NZX14+JY9Hpspt3R0hZYyjeWI1rRRXFU3aLKdncl6y11l9/IRQ4c jPjqdVBIpzI7W/03wemWORXMwYDbsgJp0TbWkuk8XYp6diZJi1r9/i91oqOPTNGhT3uT n/aRb4SphQBsKWtl6wlPPkLKlV7M5xBF1Q7vuHQvOiCXI74f72RomYlUYHgwK9ySyZNz 7n6q6ZZ5eYQD07Rz9hd68wyghksmhNBY8ns12CTSdW1A+6JyHNAQts7EnPq8Px6BKnYL nzDF6A0yRo22D+0QqE9+//WM7Ma4f5TQj+M9BMU4kdLe5KGTIaKo4hanWGD5FcDoefHT +4eA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=uG6OSWrEV19E0V5hMIUEXb4+po4SfszrRVaqWKYtOJ4=; fh=KikKy0EnRxQRTEB8wqbk5XRjKoVPGZPOjqukozGsD1k=; b=kNh1gokqrf6O1liuk1x27qaESm+lWAw3wenr1QwRLCbAS5/Dd8sgGOV5D5lG1I547a lYAtilssO8OfcAFkl2KA9+StjCmqvYC/eAWTMvzkHK7v+fxoTXhw2A8QQbZX7GM++jmV CDqDcNLe8sinjR0gsY1PmivYKXDtUwSsnhOpvwyguKZYsWEfmphDR0mTp0nZ003R17D3 aaW+WfwcPspGQjOnH9JpYiLH5kSOf/WYoTpJlupxTTcgQUoLX4tKfCSl8wIpiVkdzwyA 7jJ6I/+fpDmaXZMXYulbHoV/uEflXPP/mxlr4qnUHu/vGo/SC8+wfcoyrTc/sFiFIfsu ciVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=L7Gum8iN; spf=pass (google.com: domain of linux-kernel+bounces-11235-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-11235-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id d15-20020ac85acf000000b0042395bfaa25si11449043qtd.221.2023.12.25.16.31.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Dec 2023 16:31:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-11235-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=L7Gum8iN; spf=pass (google.com: domain of linux-kernel+bounces-11235-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-11235-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 6B3D31C218E3 for ; Tue, 26 Dec 2023 00:31:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 889F01DFD4; Tue, 26 Dec 2023 00:23:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="L7Gum8iN" X-Original-To: linux-kernel@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B8DFC1D69F; Tue, 26 Dec 2023 00:23:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D9167C433C8; Tue, 26 Dec 2023 00:23:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1703550185; bh=tSWAgRJQ9irJcPibgrni7CB/EUHDb4LZ8Hiobn8pZ+8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=L7Gum8iNuMbWgX07wAGBrEPj27hfxQPN8k/jICCa4qdYi02SPuHluY9+FubAuabcS cWnniJxip740zIjmWn1/j7X/flKMkV5KPcisfq19AE+pbM0OOmxKIyi3Tb3PL3CCxm ISWVMpWwP54Qd1vtly2hdJh9ucz+PWu+5vuwJkYgMio6/GeRjv+wK1GiErrQnXBdBu 7IvPLT9E0T0jU1/cRztNrCiAlRKl3TURiDGMDOhW8CiSXNKAJYZ0f9KwTlTkORa3vl VSyXwgL43CNLko3Bo3NBxBu+YTa3k4noBG9KGVjr/Q8yo6Ak5VtIpbFMHAjAJbT+TB nC7rCihSTNltQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Hans de Goede , Shang Ye , gurevitch , Egor Ignatov , Anton Zhilyaev , Dmitry Torokhov , Sasha Levin , 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 Message-ID: <20231226002255.5730-3-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231226002255.5730-1-sashal@kernel.org> References: <20231226002255.5730-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.1.69 Content-Transfer-Encoding: 8bit From: Hans de Goede [ 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 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 Closes: https://lore.kernel.org/linux-input/2iAJTwqZV6lQs26cTb38RNYqxvsink6SRmrZ5h0cBUSuf9NT0tZTsf9fEAbbto2maavHJEOP8GA1evlKa6xjKOsaskDhtJWxjcnrgPigzVo=@gurevit.ch/ Reported-by: Egor Ignatov Closes: https://lore.kernel.org/all/20210609073333.8425-1-egori@altlinux.org/ Reported-by: Anton Zhilyaev 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 Link: https://lore.kernel.org/r/20231115174625.7462-1-hdegoede@redhat.com Signed-off-by: Dmitry Torokhov Signed-off-by: Sasha Levin --- 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