From patchwork Thu Sep 19 17:19:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antheas Kapenekakis X-Patchwork-Id: 13807904 Received: from linux1587.grserver.gr (linux1587.grserver.gr [185.138.42.100]) (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 D01DF1A2848; Thu, 19 Sep 2024 17:26:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.138.42.100 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726766798; cv=none; b=FBHS34nAa9yga9jHUBmMxl0gtCIc5aZ8bwbdzvqMBY3JLj2t9gO2VRPtbb2fUgM+3dMX55oeugzhV5vaSaMRQwADgLrXVAqPELk7lQ52yqam4DBTeBhmhaGLSVX4jFMqKzxblAECFYYSlMhurS1yo5fVLRaB8/FgeaUwaQdzdJY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726766798; c=relaxed/simple; bh=hmWlx/cLlSaH/IO1ZEjQxJG2EKpp2wLIxmnZmp/VHc4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kyMcyRA/yCSuLTe6c+f5Xeqf8GIfwYSzAlly40FzSJrWIFUJDyaM3XftnqkZy4Q9TzxwUidJYly8vB88+yANmKuQ7+4Mcjly0djHmR4vebHMH34RBU3ve+/cun9KabMjvg5V8zaxKzzWIwCOEI5TV6AE5AeGMSu/e+ZJp2A3z5M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=antheas.dev; spf=pass smtp.mailfrom=antheas.dev; dkim=pass (1024-bit key) header.d=antheas.dev header.i=@antheas.dev header.b=Y4ppS1IY; arc=none smtp.client-ip=185.138.42.100 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=antheas.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=antheas.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=antheas.dev header.i=@antheas.dev header.b="Y4ppS1IY" Received: from localhost.localdomain (unknown [IPv6:2a05:f6c2:511b:0:6813:1156:549c:fa23]) by linux1587.grserver.gr (Postfix) with ESMTPSA id 3F9182E09C25; Thu, 19 Sep 2024 20:20:15 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=antheas.dev; s=default; t=1726766416; bh=1GPf111nh2bHLIm8C+lfqX5qYHAJo/tpPpPbFuwPGDc=; h=From:To:Subject; b=Y4ppS1IYbpR2QeC6vLTuhXnKKoODmHSVduzUqJ0Cj7FoXzrGKhYHjoUdHM66U48Ch gOIBItPcmH7VmTUQZQThoX4hbZExCqGvfWEUpePXQz10XzJ4MEh0t9vdXYeVn/jNpT EC0FDlWrWxEA+UgH8hbpodls4WUyDjGOJjn1ANqU= Authentication-Results: linux1587.grserver.gr; spf=pass (sender IP is 2a05:f6c2:511b:0:6813:1156:549c:fa23) smtp.mailfrom=lkml@antheas.dev smtp.helo=localhost.localdomain Received-SPF: pass (linux1587.grserver.gr: connection is authenticated) From: Antheas Kapenekakis To: linux-pm@vger.kernel.org Cc: platform-driver-x86@vger.kernel.org, Mario.Limonciello@amd.com, luke@ljones.dev, me@kylegospodneti.ch Subject: [PATCH v1 1/4] acpi/x86: s2idle: add support for screen off and screen on callbacks Date: Thu, 19 Sep 2024 19:19:49 +0200 Message-ID: <20240919171952.403745-2-lkml@antheas.dev> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240919171952.403745-1-lkml@antheas.dev> References: <20240919171952.403745-1-lkml@antheas.dev> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-PPP-Message-ID: <172676641622.26464.13999305177901794476@linux1587.grserver.gr> X-PPP-Vhost: antheas.dev X-Virus-Scanned: clamav-milter 0.103.11 at linux1587.grserver.gr X-Virus-Status: Clean The screen off and screen on firmware functions are meant to signify the system entering a state where the user is not actively interacting with it (i.e., in Windows this state is called "Screen Off" and the system enters it once it turns the screen off e.g., due to inactivity). In this state, the kernel and userspace are fully active, and the user might still be interacting with the system somehow (such as with listening to music or having a hotspot). Userspace is supposed to minimize non-essential activities, but this is not required. In addition, there is no requirement of suspending post the screen off call. If the user interacts with the system, the kernel should call screen on and resume normal operation. This patch adds a set of callbacks to allow calling the screen on/off callbacks outside of the suspend/resume path. It is based on Mario Limonciello's patch on the superm1/dsm-screen-on-off branch. However, the intent here is completely different. Signed-off-by: Antheas Kapenekakis --- include/linux/suspend.h | 5 +++++ kernel/power/suspend.c | 12 ++++++++++++ 2 files changed, 17 insertions(+) diff --git a/include/linux/suspend.h b/include/linux/suspend.h index da6ebca3ff77..96ceaad07839 100644 --- a/include/linux/suspend.h +++ b/include/linux/suspend.h @@ -132,6 +132,7 @@ struct platform_suspend_ops { }; struct platform_s2idle_ops { + int (*screen_off)(void); int (*begin)(void); int (*prepare)(void); int (*prepare_late)(void); @@ -140,6 +141,7 @@ struct platform_s2idle_ops { void (*restore_early)(void); void (*restore)(void); void (*end)(void); + int (*screen_on)(void); }; #ifdef CONFIG_SUSPEND @@ -160,6 +162,9 @@ extern unsigned int pm_suspend_global_flags; #define PM_SUSPEND_FLAG_FW_RESUME BIT(1) #define PM_SUSPEND_FLAG_NO_PLATFORM BIT(2) +int platform_suspend_screen_off(void); +int platform_suspend_screen_on(void); + static inline void pm_suspend_clear_flags(void) { pm_suspend_global_flags = 0; diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c index 09f8397bae15..19734b297527 100644 --- a/kernel/power/suspend.c +++ b/kernel/power/suspend.c @@ -254,6 +254,18 @@ static bool sleep_state_supported(suspend_state_t state) (valid_state(state) && !cxl_mem_active()); } +int platform_suspend_screen_off(void) +{ + return s2idle_ops && s2idle_ops->screen_off ? s2idle_ops->screen_off() : 0; +} +EXPORT_SYMBOL_GPL(platform_suspend_screen_off); + +int platform_suspend_screen_on(void) +{ + return s2idle_ops && s2idle_ops->screen_on ? s2idle_ops->screen_on() : 0; +} +EXPORT_SYMBOL_GPL(platform_suspend_screen_on); + static int platform_suspend_prepare(suspend_state_t state) { return state != PM_SUSPEND_TO_IDLE && suspend_ops->prepare ? From patchwork Thu Sep 19 17:19:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antheas Kapenekakis X-Patchwork-Id: 13807902 Received: from linux1587.grserver.gr (linux1587.grserver.gr [185.138.42.100]) (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 2FC831A2863; Thu, 19 Sep 2024 17:26:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.138.42.100 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726766797; cv=none; b=KpvNsknVyx3cPIAS/5739ssk+QZeF6rvFCresXBCgONnfIZNGAzAY1vpgnmz2D3dSs8SL4wjbUhhpJGJXQf6cqCEXAhDOSUApx/BXz9u1ddx1jbeNVnZyWl/W3wqs5lh1JJQNp+rjdo9dCXMVDAvN2bTyC73HdMdoPSuQI27edg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726766797; c=relaxed/simple; bh=c1Ki3+zG7/5wotWeiw2IG0TgqkK2cVncFVi63km7PEo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HMc3vxWpL4iPFlJJGCDIR2wlZXlAPut9n4DGOCzaExGpThMCiTIXs3X1EoqKUuwWTgKUfwaz7REYG5o/cgEuF0xl9rjI2OS9Ike5D+a1DWwQCQOUQYrEWWSca+XdXMOk1HuqueUjg1FzroAz5k1pcCyftV9s3Qwy3aOKxh8ciuU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=antheas.dev; spf=pass smtp.mailfrom=antheas.dev; dkim=pass (1024-bit key) header.d=antheas.dev header.i=@antheas.dev header.b=oluZlcDi; arc=none smtp.client-ip=185.138.42.100 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=antheas.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=antheas.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=antheas.dev header.i=@antheas.dev header.b="oluZlcDi" Received: from localhost.localdomain (unknown [IPv6:2a05:f6c2:511b:0:6813:1156:549c:fa23]) by linux1587.grserver.gr (Postfix) with ESMTPSA id BABCD2E09C24; Thu, 19 Sep 2024 20:20:16 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=antheas.dev; s=default; t=1726766420; bh=95gmiwyDCGwbw7Fjy10AvGErlGkNmq4ZiD1FeYxAWMA=; h=From:To:Subject; b=oluZlcDiiSMuS08jZRhYod6Y6+h3NDQSUCMV1XNur++/x9zUIUCuqiGq6P/7NOoN+ v49x1ThJLeFgtaQkwiKzHaxZOi57oavHbIzQ5Xmh5/5d+umiz5t1m3xsfSKvEXjevU YPJtqn5ieBGVQBexrLTJTcroewzE0OQc316SpfsY= Authentication-Results: linux1587.grserver.gr; spf=pass (sender IP is 2a05:f6c2:511b:0:6813:1156:549c:fa23) smtp.mailfrom=lkml@antheas.dev smtp.helo=localhost.localdomain Received-SPF: pass (linux1587.grserver.gr: connection is authenticated) From: Antheas Kapenekakis To: linux-pm@vger.kernel.org Cc: platform-driver-x86@vger.kernel.org, Mario.Limonciello@amd.com, luke@ljones.dev, me@kylegospodneti.ch Subject: [PATCH v1 2/4] acpi/x86: s2idle: handle screen off/on calls outside of suspend sequence Date: Thu, 19 Sep 2024 19:19:50 +0200 Message-ID: <20240919171952.403745-3-lkml@antheas.dev> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240919171952.403745-1-lkml@antheas.dev> References: <20240919171952.403745-1-lkml@antheas.dev> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-PPP-Message-ID: <172676641764.26701.13590723372717455783@linux1587.grserver.gr> X-PPP-Vhost: antheas.dev X-Virus-Scanned: clamav-milter 0.103.11 at linux1587.grserver.gr X-Virus-Status: Clean Currently, the screen off/on calls are handled within the suspend sequence, which is a deviation from Windows. This causes issues with certain devices, such as the ROG Ally, which expects this call to be executed with the kernel fully awake. The subsequent half-suspended state makes the controller of the device to fail to suspend properly. This patch calls the screen off/on callbacks before entering the suspend sequence, which fixes this issue. In addition, it opens the possibility of modelling a state such as "Screen Off" that mirrors Windows, as the callbacks will be accessible and validated to work outside of the suspend sequence. Signed-off-by: Antheas Kapenekakis --- kernel/power/suspend.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c index 19734b297527..afa95271ef00 100644 --- a/kernel/power/suspend.c +++ b/kernel/power/suspend.c @@ -507,6 +507,19 @@ int suspend_devices_and_enter(suspend_state_t state) pm_suspend_target_state = state; + /* + * Linux does not have the concept of a "Screen Off" state, so call + * the platform functions for screen off prior to beginning the suspend + * sequence, mirroring Windows which calls them outside of it as well. + * + * If Linux ever gains a "Screen Off" state, the following callbacks can + * be replaced with a call that checks if we are in "Screen Off", in which + * case they will NOOP and if not call them as a fallback. + */ + error = platform_suspend_screen_off(); + if (error) + goto Screen_on; + if (state == PM_SUSPEND_TO_IDLE) pm_set_suspend_no_platform(); @@ -540,6 +553,9 @@ int suspend_devices_and_enter(suspend_state_t state) Close: platform_resume_end(state); pm_suspend_target_state = PM_SUSPEND_ON; + + Screen_on: + platform_suspend_screen_on(); return error; Recover_platform: From patchwork Thu Sep 19 17:19:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antheas Kapenekakis X-Patchwork-Id: 13807897 Received: from linux1587.grserver.gr (linux1587.grserver.gr [185.138.42.100]) (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 D9ACE1EB56; Thu, 19 Sep 2024 17:20:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.138.42.100 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726766431; cv=none; b=m5Vw0lj3pMX7xbI0s2yPJCLJT6ndZSMGA/orXcVHJ3+AL3zbD58O7gHgd88u9UuWviS8VxnDF4UMsAmZaoKLbLRbDKR6GkcTpOL77IDL0NKeVdg6giShyqEAZCyijSybzWj9IzqxARrev8y0YMB8NimoAj+8aev7qX81yoaTs8s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726766431; c=relaxed/simple; bh=gkjVQ81/OGWaa+G/4QS8wPf4pkOCPqgYyM08k9Kjz1Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YRbWkXpAZQBubwrpfs0wSnENd+P6XhSmLjQ+UEdKrA9aarW6LMKOeQjtA48Gk7mfW5xEJVhdWp5FYmfkauqiSlxPpvCekR1ph2QmJexXkTNttBFQ+mOVgi3qHnbKRGIlWBlSGVPAUjfTg2Hc/BqcQHpbZ6A/ibuvKptDFvbYZcw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=antheas.dev; spf=pass smtp.mailfrom=antheas.dev; dkim=pass (1024-bit key) header.d=antheas.dev header.i=@antheas.dev header.b=rm/XBKOQ; arc=none smtp.client-ip=185.138.42.100 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=antheas.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=antheas.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=antheas.dev header.i=@antheas.dev header.b="rm/XBKOQ" Received: from localhost.localdomain (unknown [IPv6:2a05:f6c2:511b:0:6813:1156:549c:fa23]) by linux1587.grserver.gr (Postfix) with ESMTPSA id 13E0E2E09C11; Thu, 19 Sep 2024 20:20:22 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=antheas.dev; s=default; t=1726766424; bh=sTJcvD3ghjMAZI0q0CaO0A3NL6Fe4Q6twf2MptYvw7k=; h=From:To:Subject; b=rm/XBKOQzXjZSjHc53q4iBIVPrJEKlSjCkuIKERdmq2ESyh9pFv/gRMAl0MSZ7OSE tsOtfWuCS3LlZihN/Uci8xG13HN7/MlXAasAyAKyLTmMWPSH1cWa5ylkYjffLWufJG YYrV+pQwScM5kwOD3G9QsdbAWGRRo+nW4OYByrag= Authentication-Results: linux1587.grserver.gr; spf=pass (sender IP is 2a05:f6c2:511b:0:6813:1156:549c:fa23) smtp.mailfrom=lkml@antheas.dev smtp.helo=localhost.localdomain Received-SPF: pass (linux1587.grserver.gr: connection is authenticated) From: Antheas Kapenekakis To: linux-pm@vger.kernel.org Cc: platform-driver-x86@vger.kernel.org, Mario.Limonciello@amd.com, luke@ljones.dev, me@kylegospodneti.ch Subject: [PATCH v1 3/4] acpi/x86: s2idle: call screen on and off as part of callbacks Date: Thu, 19 Sep 2024 19:19:51 +0200 Message-ID: <20240919171952.403745-4-lkml@antheas.dev> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240919171952.403745-1-lkml@antheas.dev> References: <20240919171952.403745-1-lkml@antheas.dev> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-PPP-Message-ID: <172676642290.26992.10738575555388669892@linux1587.grserver.gr> X-PPP-Vhost: antheas.dev X-Virus-Scanned: clamav-milter 0.103.11 at linux1587.grserver.gr X-Virus-Status: Clean Move the screen on and off calls into dedicated callbacks that gate the ACPI mutex, so they can be called outside of the suspend path. This fixes issues on certain devices that expect kernel drivers to be fully active during the calls, and allows for the flexibility of calling them as part of a more elaborate userspace suspend sequence (such as with "Screen Off" in Windows Modern Standby). Signed-off-by: Antheas Kapenekakis --- drivers/acpi/x86/s2idle.c | 72 +++++++++++++++++++++++++++++++-------- 1 file changed, 57 insertions(+), 15 deletions(-) diff --git a/drivers/acpi/x86/s2idle.c b/drivers/acpi/x86/s2idle.c index dd0b40b9bbe8..aa448ed58077 100644 --- a/drivers/acpi/x86/s2idle.c +++ b/drivers/acpi/x86/s2idle.c @@ -60,6 +60,7 @@ static int lps0_dsm_func_mask; static guid_t lps0_dsm_guid_microsoft; static int lps0_dsm_func_mask_microsoft; static int lps0_dsm_state; +static bool lsp0_dsm_in_screen_off; /* Device constraint entry structure */ struct lpi_device_info { @@ -539,15 +540,19 @@ static struct acpi_scan_handler lps0_handler = { .attach = lps0_device_attach, }; -int acpi_s2idle_prepare_late(void) +static int acpi_s2idle_screen_off(void) { - struct acpi_s2idle_dev_ops *handler; - if (!lps0_device_handle || sleep_no_lps0) return 0; - if (pm_debug_messages_on) - lpi_check_constraints(); + if (lsp0_dsm_in_screen_off) { + acpi_handle_info(lps0_device_handle, + "called screen off call twice before calling screen on.\n"); + // fallthrough for debugging, calling twice should be gated by the caller + } + + lsp0_dsm_in_screen_off = true; + acpi_scan_lock_acquire(); /* Screen off */ if (lps0_dsm_func_mask > 0) @@ -560,6 +565,50 @@ int acpi_s2idle_prepare_late(void) acpi_sleep_run_lps0_dsm(ACPI_LPS0_SCREEN_OFF, lps0_dsm_func_mask_microsoft, lps0_dsm_guid_microsoft); + acpi_scan_lock_release(); + + return 0; +} + +static int acpi_s2idle_screen_on(void) +{ + if (!lps0_device_handle || sleep_no_lps0) + return 0; + + if (!lsp0_dsm_in_screen_off) { + acpi_handle_info(lps0_device_handle, + "called screen on before calling screen off.\n"); + // fallthrough for debugging, calling twice should be gated by the caller + } + + lsp0_dsm_in_screen_off = false; + acpi_scan_lock_acquire(); + + /* Screen on */ + if (lps0_dsm_func_mask_microsoft > 0) + acpi_sleep_run_lps0_dsm(ACPI_LPS0_SCREEN_ON, + lps0_dsm_func_mask_microsoft, lps0_dsm_guid_microsoft); + if (lps0_dsm_func_mask > 0) + acpi_sleep_run_lps0_dsm(acpi_s2idle_vendor_amd() ? + ACPI_LPS0_SCREEN_ON_AMD : + ACPI_LPS0_SCREEN_ON, + lps0_dsm_func_mask, lps0_dsm_guid); + + acpi_scan_lock_release(); + + return 0; +} + +int acpi_s2idle_prepare_late(void) +{ + struct acpi_s2idle_dev_ops *handler; + + if (!lps0_device_handle || sleep_no_lps0) + return 0; + + if (pm_debug_messages_on) + lpi_check_constraints(); + /* LPS0 entry */ if (lps0_dsm_func_mask > 0 && acpi_s2idle_vendor_amd()) acpi_sleep_run_lps0_dsm(ACPI_LPS0_ENTRY_AMD, @@ -623,19 +672,10 @@ void acpi_s2idle_restore_early(void) acpi_sleep_run_lps0_dsm(ACPI_LPS0_MS_EXIT, lps0_dsm_func_mask_microsoft, lps0_dsm_guid_microsoft); } - - /* Screen on */ - if (lps0_dsm_func_mask_microsoft > 0) - acpi_sleep_run_lps0_dsm(ACPI_LPS0_SCREEN_ON, - lps0_dsm_func_mask_microsoft, lps0_dsm_guid_microsoft); - if (lps0_dsm_func_mask > 0) - acpi_sleep_run_lps0_dsm(acpi_s2idle_vendor_amd() ? - ACPI_LPS0_SCREEN_ON_AMD : - ACPI_LPS0_SCREEN_ON, - lps0_dsm_func_mask, lps0_dsm_guid); } static const struct platform_s2idle_ops acpi_s2idle_ops_lps0 = { + .screen_off = acpi_s2idle_screen_off, .begin = acpi_s2idle_begin, .prepare = acpi_s2idle_prepare, .prepare_late = acpi_s2idle_prepare_late, @@ -644,10 +684,12 @@ static const struct platform_s2idle_ops acpi_s2idle_ops_lps0 = { .restore_early = acpi_s2idle_restore_early, .restore = acpi_s2idle_restore, .end = acpi_s2idle_end, + .screen_on = acpi_s2idle_screen_on, }; void __init acpi_s2idle_setup(void) { + lsp0_dsm_in_screen_off = false; acpi_scan_add_handler(&lps0_handler); s2idle_set_ops(&acpi_s2idle_ops_lps0); } From patchwork Thu Sep 19 17:19:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antheas Kapenekakis X-Patchwork-Id: 13807898 Received: from linux1587.grserver.gr (linux1587.grserver.gr [185.138.42.100]) (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 B0145191F74; Thu, 19 Sep 2024 17:20:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.138.42.100 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726766432; cv=none; b=kVhwQs4E8zxNWpv5MkzrDcEYD+o4eeRUPWbRbQ5xP3Pd27KB8uBvui+MlfeRcI32sZGGsp7BVEs0inJ2VXKvJN1ng8nhK6hlrKtQSR1kN+p39r4xEjGN1aJObhLyqJL/lhPDXzsNdRXCbqRiprdBjXuONl7rbTUVup11jpWzaCE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726766432; c=relaxed/simple; bh=WDe/894nXLWPbl0OsXmviqdGw3HVdOZGv8ikt38PbBo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mfvRvxy7EOjb4SXScroxtW4xxsSurAQMgZoPYRNllYdycDW7rM07k5RSWq9h4IDvC4lFO4PRE/6+o7OfwRnZWmzOEiXty7Nea/akyxblTNjcIvzzaIWvgpUHjq5kut4hDezJeG7rmtAp38IsLUWaz12FWIPFehKJUj/ChzbkJeg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=antheas.dev; spf=pass smtp.mailfrom=antheas.dev; dkim=pass (1024-bit key) header.d=antheas.dev header.i=@antheas.dev header.b=UN2i3Kn8; arc=none smtp.client-ip=185.138.42.100 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=antheas.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=antheas.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=antheas.dev header.i=@antheas.dev header.b="UN2i3Kn8" Received: from localhost.localdomain (unknown [IPv6:2a05:f6c2:511b:0:6813:1156:549c:fa23]) by linux1587.grserver.gr (Postfix) with ESMTPSA id 6FBE02E09C21; Thu, 19 Sep 2024 20:20:25 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=antheas.dev; s=default; t=1726766426; bh=2A2rAgoAhMY4S+LBirNVsSlPtMJXO/HWDrAVx+jjdvk=; h=From:To:Subject; b=UN2i3Kn8osXzxkLZtU9dix+u0qv86XsVcVqUeFyGwtjoN1jyR1xY6DbVc3l0RYQSI IiokavFx03JkiliepM1qFMYpWBEzZbYiNttVchqJZfrhPqARu5TwuwlG9Le4NrBAM9 SA15pPVgdUss5UVv6LxqCy1DNXR90g6U1NGFv7l0= Authentication-Results: linux1587.grserver.gr; spf=pass (sender IP is 2a05:f6c2:511b:0:6813:1156:549c:fa23) smtp.mailfrom=lkml@antheas.dev smtp.helo=localhost.localdomain Received-SPF: pass (linux1587.grserver.gr: connection is authenticated) From: Antheas Kapenekakis To: linux-pm@vger.kernel.org Cc: platform-driver-x86@vger.kernel.org, Mario.Limonciello@amd.com, luke@ljones.dev, me@kylegospodneti.ch Subject: [PATCH v1 4/4] platform/x86: asus-wmi: remove Ally (1st gen) and Ally X suspend quirk Date: Thu, 19 Sep 2024 19:19:52 +0200 Message-ID: <20240919171952.403745-5-lkml@antheas.dev> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240919171952.403745-1-lkml@antheas.dev> References: <20240919171952.403745-1-lkml@antheas.dev> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-PPP-Message-ID: <172676642625.27078.12809531855910783380@linux1587.grserver.gr> X-PPP-Vhost: antheas.dev X-Virus-Scanned: clamav-milter 0.103.11 at linux1587.grserver.gr X-Virus-Status: Clean By moving the Display On/Off calls outside of the suspend sequence, the racing conditions that made the Ally controller suspend unreliable are completely fixed. This includes both when mcu_powersave is enabled and disabled. Therefore, remove the quirk that fixes them only when mcu_powersave is disabled. Signed-off-by: Antheas Kapenekakis Reviewed-by: Mario Limonciello --- drivers/platform/x86/asus-wmi.c | 54 --------------------------------- 1 file changed, 54 deletions(-) diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c index 37636e5a38e3..2c9656e0afda 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c @@ -137,29 +137,10 @@ module_param(fnlock_default, bool, 0444); #define ASUS_MINI_LED_2024_STRONG 0x01 #define ASUS_MINI_LED_2024_OFF 0x02 -/* Controls the power state of the USB0 hub on ROG Ally which input is on */ -#define ASUS_USB0_PWR_EC0_CSEE "\\_SB.PCI0.SBRG.EC0.CSEE" -/* 300ms so far seems to produce a reliable result on AC and battery */ -#define ASUS_USB0_PWR_EC0_CSEE_WAIT 1500 - static const char * const ashs_ids[] = { "ATK4001", "ATK4002", NULL }; static int throttle_thermal_policy_write(struct asus_wmi *); -static const struct dmi_system_id asus_ally_mcu_quirk[] = { - { - .matches = { - DMI_MATCH(DMI_BOARD_NAME, "RC71L"), - }, - }, - { - .matches = { - DMI_MATCH(DMI_BOARD_NAME, "RC72L"), - }, - }, - { }, -}; - static bool ashs_present(void) { int i = 0; @@ -269,9 +250,6 @@ struct asus_wmi { u32 tablet_switch_dev_id; bool tablet_switch_inverted; - /* The ROG Ally device requires the MCU USB device be disconnected before suspend */ - bool ally_mcu_usb_switch; - enum fan_type fan_type; enum fan_type gpu_fan_type; enum fan_type mid_fan_type; @@ -4698,8 +4676,6 @@ static int asus_wmi_add(struct platform_device *pdev) asus->egpu_enable_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_EGPU); asus->dgpu_disable_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_DGPU); asus->kbd_rgb_state_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_TUF_RGB_STATE); - asus->ally_mcu_usb_switch = acpi_has_method(NULL, ASUS_USB0_PWR_EC0_CSEE) - && dmi_check_system(asus_ally_mcu_quirk); if (asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_MINI_LED_MODE)) asus->mini_led_dev_id = ASUS_WMI_DEVID_MINI_LED_MODE; @@ -4892,34 +4868,6 @@ static int asus_hotk_resume(struct device *device) return 0; } -static int asus_hotk_resume_early(struct device *device) -{ - struct asus_wmi *asus = dev_get_drvdata(device); - - if (asus->ally_mcu_usb_switch) { - /* sleep required to prevent USB0 being yanked then reappearing rapidly */ - if (ACPI_FAILURE(acpi_execute_simple_method(NULL, ASUS_USB0_PWR_EC0_CSEE, 0xB8))) - dev_err(device, "ROG Ally MCU failed to connect USB dev\n"); - else - msleep(ASUS_USB0_PWR_EC0_CSEE_WAIT); - } - return 0; -} - -static int asus_hotk_prepare(struct device *device) -{ - struct asus_wmi *asus = dev_get_drvdata(device); - - if (asus->ally_mcu_usb_switch) { - /* sleep required to ensure USB0 is disabled before sleep continues */ - if (ACPI_FAILURE(acpi_execute_simple_method(NULL, ASUS_USB0_PWR_EC0_CSEE, 0xB7))) - dev_err(device, "ROG Ally MCU failed to disconnect USB dev\n"); - else - msleep(ASUS_USB0_PWR_EC0_CSEE_WAIT); - } - return 0; -} - static int asus_hotk_restore(struct device *device) { struct asus_wmi *asus = dev_get_drvdata(device); @@ -4964,8 +4912,6 @@ static const struct dev_pm_ops asus_pm_ops = { .thaw = asus_hotk_thaw, .restore = asus_hotk_restore, .resume = asus_hotk_resume, - .resume_early = asus_hotk_resume_early, - .prepare = asus_hotk_prepare, }; /* Registration ***************************************************************/