aboutsummaryrefslogtreecommitdiff
path: root/SOURCES/0001-NOT-FOR-UPSTREAM-PM-suspend-Disable-s2idle-on-Steam-.patch
blob: 349a6a6232b8ae10558a6e43fa26d6524c02bf26 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
From d6935e6d62b35ec14d2187c2cfdc19934d66db6d Mon Sep 17 00:00:00 2001
From: "Guilherme G. Piccoli" <gpiccoli@igalia.com>
Date: Thu, 2 Nov 2023 16:28:35 -0300
Subject: [PATCH] (NOT-FOR-UPSTREAM) PM: suspend: Disable s2idle on Steam Deck

Jupiter platform doesn't support s2idle - system appears to
sleep and never wakeup again. So, disable it based on DMI
checking for platforms named "Valve Jupiter".

Signed-off-by: Guilherme G. Piccoli <gpiccoli@igalia.com>
(cherry picked from commit 3956de585667cfd9f91a3ee8af34f6c0d44f4381)
Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
Signed-off-by: Jan200101 <sentrycraft123@gmail.com>
---
 kernel/power/suspend.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c
index fa3bf161d13f..e614b865a099 100644
--- a/kernel/power/suspend.c
+++ b/kernel/power/suspend.c
@@ -30,6 +30,7 @@
 #include <trace/events/power.h>
 #include <linux/compiler.h>
 #include <linux/moduleparam.h>
+#include <linux/dmi.h>
 
 #include "power.h"
 
@@ -60,6 +61,7 @@ static DECLARE_SWAIT_QUEUE_HEAD(s2idle_wait_head);
 
 enum s2idle_states __read_mostly s2idle_state;
 static DEFINE_RAW_SPINLOCK(s2idle_lock);
+static bool s2idle_unsupported;
 
 /**
  * pm_suspend_default_s2idle - Check if suspend-to-idle is the default suspend.
@@ -174,6 +176,8 @@ static bool valid_state(suspend_state_t state)
 
 void __init pm_states_init(void)
 {
+	const char *sys_vendor, *product_name;
+
 	/* "mem" and "freeze" are always present in /sys/power/state. */
 	pm_states[PM_SUSPEND_MEM] = pm_labels[PM_SUSPEND_MEM];
 	pm_states[PM_SUSPEND_TO_IDLE] = pm_labels[PM_SUSPEND_TO_IDLE];
@@ -182,6 +186,20 @@ void __init pm_states_init(void)
 	 * initialize mem_sleep_states[] accordingly here.
 	 */
 	mem_sleep_states[PM_SUSPEND_TO_IDLE] = mem_sleep_labels[PM_SUSPEND_TO_IDLE];
+
+	/*
+	 * Identify here if we're running on Steam Deck - if so, we shouldn't
+	 * support s2idle mem_sleep mode, since this mode doesn't work on Deck.
+	 */
+
+	sys_vendor = dmi_get_system_info(DMI_SYS_VENDOR);
+	product_name = dmi_get_system_info(DMI_PRODUCT_NAME);
+
+	if (sys_vendor && (!strncmp("Valve", sys_vendor, 5)) &&
+	    product_name && (!strncmp("Jupiter", product_name, 7))) {
+		s2idle_unsupported = true;
+		pr_info("Steam Deck quirk - no s2idle allowed!\n");
+	}
 }
 
 static int __init mem_sleep_default_setup(char *str)
@@ -562,6 +580,10 @@ static int enter_state(suspend_state_t state)
 			return -EAGAIN;
 		}
 #endif
+		if (s2idle_unsupported) {
+			pr_info("s2idle sleep is not supported\n");
+			return -EINVAL;
+		}
 	} else if (!valid_state(state)) {
 		return -EINVAL;
 	}
-- 
2.43.0