Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp7883324rdb; Thu, 4 Jan 2024 10:31:42 -0800 (PST) X-Google-Smtp-Source: AGHT+IET80GnY2QKVpU5d5sk0XeANZJ3yyBhd0OYTC91Zb08qwqkbsmpyUf4LbtDV7QDxuw5uy9y X-Received: by 2002:a2e:9c09:0:b0:2cc:7692:ff9 with SMTP id s9-20020a2e9c09000000b002cc76920ff9mr571605lji.4.1704393102777; Thu, 04 Jan 2024 10:31:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704393102; cv=none; d=google.com; s=arc-20160816; b=nim+7asihxURYWOLrvwV6CsJcFkX+RngEb2Xcc+tw2ryYNMaDbkRRBiqqQHb+QFrZJ UyNgxdQXr0mLMUONUUaL5Za/jJQ1RJk5FIEW/axvYuj8cR1cnCYu3/vJVrUhn9ft9c+C SAUN8BbCvCmiPqdSEyebBZIUXZJsdUYwkJFj0lRihBuCq0p6TO49Qc3Oiyzts3zh+4iu vdN7JYC+MrnexgSfKXBMWl3X08h0TqllDZtFmCh6MXTp6a6efEvFnOrH4HSIGbnDsDVl 7zr6WobwgIrQxCG0wmp6aDKYEySHoMCFIKFAK4SeZTUPrvgxGzXXtJo948Ks1McPLynA KjBg== 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=ml77MZQyhC872BeHXW+OAuK9F5Hsv/7vM+7dWauzEF0=; fh=itq0ZeunbYFiXOnaVa1O57eXkjTYZFUeglAJDx/4AlQ=; b=mkrX0TAUkn1JTjx8blGVoG00tG32fF14kCqW+ovCa6HueqEcNEIY1B1fSdpqGZMLTi azc8uiL/Ikore1lhwYU5YRNZVgeyfhTN2P7VGWRid+rsve9ZF2oYdwwypUz0SjL/pTav GOdgiGa+sIW/sLDwypyWtwmzaIXVgHPIEu2BDX8d6ynCjgh8GYt0ZPZgOn9/6FiMSQey JyAY9dIhkl3bPhAjJJMS/Oa/pckz6yUJbPQl0tJ8cw2fP7YFw5ECm65yjx4j1sGsm3on cO2HkhIMVG1S4DIWh2sITqI+irO41jvHnZmTAhadWp/o7DKbk6e6FYncjd8fb+jWYC/O Baxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tuxedocomputers.com header.s=default header.b=sKeoONRN; spf=pass (google.com: domain of linux-kernel+bounces-17095-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-17095-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=tuxedocomputers.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id l16-20020a056402231000b0055472810fe5si2333eda.124.2024.01.04.10.31.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jan 2024 10:31:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-17095-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@tuxedocomputers.com header.s=default header.b=sKeoONRN; spf=pass (google.com: domain of linux-kernel+bounces-17095-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-17095-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=tuxedocomputers.com 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 4B6AE1F23D45 for ; Thu, 4 Jan 2024 18:31:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 27D7A28E39; Thu, 4 Jan 2024 18:31:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=tuxedocomputers.com header.i=@tuxedocomputers.com header.b="sKeoONRN" X-Original-To: linux-kernel@vger.kernel.org Received: from mail.tuxedocomputers.com (mail.tuxedocomputers.com [157.90.84.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F05E128E02; Thu, 4 Jan 2024 18:31:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=tuxedocomputers.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tuxedocomputers.com Received: from wse.fritz.box (p5de453e7.dip0.t-ipconnect.de [93.228.83.231]) (Authenticated sender: wse@tuxedocomputers.com) by mail.tuxedocomputers.com (Postfix) with ESMTPA id 5ED372FC006E; Thu, 4 Jan 2024 19:31:23 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxedocomputers.com; s=default; t=1704393083; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ml77MZQyhC872BeHXW+OAuK9F5Hsv/7vM+7dWauzEF0=; b=sKeoONRNCV8FDhxMAeGywwvB/deM5yHXyWFND99x46xGb+z8G2gPAIEJyfrjx+8DVoROwU iZmR0JI4pxdL5A55vwwOpl/srV514mGAzj1O/efdhHb+kbSA+dfP7xIgXumrh0vBRtLhvX ufzan6Hy9j3rsf1clGXWL+XGsJHfZa0= Authentication-Results: mail.tuxedocomputers.com; auth=pass smtp.auth=wse@tuxedocomputers.com smtp.mailfrom=wse@tuxedocomputers.com From: Werner Sembach To: dmitry.torokhov@gmail.com Cc: hdegoede@redhat.com, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, wse@tuxedocomputers.com Subject: [PATCH v4 1/2] i8042: Add forcenorestore quirk to leave controller untouched even on s3 Date: Thu, 4 Jan 2024 19:31:17 +0100 Message-Id: <20240104183118.779778-2-wse@tuxedocomputers.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240104183118.779778-1-wse@tuxedocomputers.com> References: <20240104183118.779778-1-wse@tuxedocomputers.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit On s3 resume the i8042 driver tries to restore the controller to a known state by reinitializing things, however this can confuse the controller with different effects. Mostly occasionally unresponsive keyboards after resume. These issues do not rise on s0ix resume as here the controller is assumed to preserved its state from before suspend. This patch adds a quirk for devices where the reinitialization on s3 resume is not needed and might be harmful as described above. It does this by using the s0ix resume code path at selected locations. This new quirk goes beyond what the preexisting reset=never quirk does, which only skips some reinitialization steps. Signed-off-by: Werner Sembach Cc: stable@vger.kernel.org --- drivers/input/serio/i8042-acpipnpio.h | 10 +++++++--- drivers/input/serio/i8042.c | 10 +++++++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/drivers/input/serio/i8042-acpipnpio.h b/drivers/input/serio/i8042-acpipnpio.h index b585b1dab870e..10ec4534e5e14 100644 --- a/drivers/input/serio/i8042-acpipnpio.h +++ b/drivers/input/serio/i8042-acpipnpio.h @@ -83,6 +83,7 @@ static inline void i8042_write_command(int val) #define SERIO_QUIRK_KBDRESET BIT(12) #define SERIO_QUIRK_DRITEK BIT(13) #define SERIO_QUIRK_NOPNP BIT(14) +#define SERIO_QUIRK_FORCENORESTORE BIT(15) /* Quirk table for different mainboards. Options similar or identical to i8042 * module parameters. @@ -1657,6 +1658,8 @@ static void __init i8042_check_quirks(void) if (quirks & SERIO_QUIRK_NOPNP) i8042_nopnp = true; #endif + if (quirks & SERIO_QUIRK_FORCENORESTORE) + i8042_forcenorestore = true; } #else static inline void i8042_check_quirks(void) {} @@ -1690,7 +1693,7 @@ static int __init i8042_platform_init(void) i8042_check_quirks(); - pr_debug("Active quirks (empty means none):%s%s%s%s%s%s%s%s%s%s%s%s%s\n", + pr_debug("Active quirks (empty means none):%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n", i8042_nokbd ? " nokbd" : "", i8042_noaux ? " noaux" : "", i8042_nomux ? " nomux" : "", @@ -1710,10 +1713,11 @@ static int __init i8042_platform_init(void) "", #endif #ifdef CONFIG_PNP - i8042_nopnp ? " nopnp" : ""); + i8042_nopnp ? " nopnp" : "", #else - ""); + "", #endif + i8042_forcenorestore ? " forcenorestore" : ""); retval = i8042_pnp_init(); if (retval) diff --git a/drivers/input/serio/i8042.c b/drivers/input/serio/i8042.c index 9fbb8d31575ae..2233d93f90e81 100644 --- a/drivers/input/serio/i8042.c +++ b/drivers/input/serio/i8042.c @@ -115,6 +115,10 @@ module_param_named(nopnp, i8042_nopnp, bool, 0); MODULE_PARM_DESC(nopnp, "Do not use PNP to detect controller settings"); #endif +static bool i8042_forcenorestore; +module_param_named(forcenorestore, i8042_forcenorestore, bool, 0); +MODULE_PARM_DESC(forcenorestore, "Force no restore on s3 resume, copying s2idle behaviour"); + #define DEBUG #ifdef DEBUG static bool i8042_debug; @@ -1232,7 +1236,7 @@ static int i8042_pm_suspend(struct device *dev) { int i; - if (pm_suspend_via_firmware()) + if (!i8042_forcenorestore && pm_suspend_via_firmware()) i8042_controller_reset(true); /* Set up serio interrupts for system wakeup. */ @@ -1248,7 +1252,7 @@ static int i8042_pm_suspend(struct device *dev) static int i8042_pm_resume_noirq(struct device *dev) { - if (!pm_resume_via_firmware()) + if (i8042_forcenorestore || !pm_resume_via_firmware()) i8042_interrupt(0, NULL); return 0; @@ -1271,7 +1275,7 @@ static int i8042_pm_resume(struct device *dev) * not restore the controller state to whatever it had been at boot * time, so we do not need to do anything. */ - if (!pm_suspend_via_firmware()) + if (i8042_forcenorestore || !pm_suspend_via_firmware()) return 0; /* -- 2.34.1