Skip to content

Commit 905563f

Browse files
committed
Merge back earlier 'pm-sleep' material for v3.18.
2 parents fe82dce + 0cadc70 commit 905563f

4 files changed

Lines changed: 50 additions & 18 deletions

File tree

‎Documentation/kernel-parameters.txt‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3303,11 +3303,13 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
33033303

33043304
tdfx= [HW,DRM]
33053305

3306-
test_suspend= [SUSPEND]
3306+
test_suspend= [SUSPEND][,N]
33073307
Specify "mem" (for Suspend-to-RAM) or "standby" (for
3308-
standby suspend) as the system sleep state to briefly
3309-
enter during system startup. The system is woken from
3310-
this state using a wakeup-capable RTC alarm.
3308+
standby suspend) or "freeze" (for suspend type freeze)
3309+
as the system sleep state during system startup with
3310+
the optional capability to repeat N number of times.
3311+
The system is woken from this state using a
3312+
wakeup-capable RTC alarm.
33113313

33123314
thash_entries= [KNL,NET]
33133315
Set number of hash buckets for TCP connection

‎drivers/base/power/sysfs.c‎

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,6 @@
9292
* wakeup_count - Report the number of wakeup events related to the device
9393
*/
9494

95-
static const char enabled[] = "enabled";
96-
static const char disabled[] = "disabled";
97-
9895
const char power_group_name[] = "power";
9996
EXPORT_SYMBOL_GPL(power_group_name);
10097

@@ -336,11 +333,14 @@ static DEVICE_ATTR(pm_qos_remote_wakeup, 0644,
336333
#endif /* CONFIG_PM_RUNTIME */
337334

338335
#ifdef CONFIG_PM_SLEEP
336+
static const char _enabled[] = "enabled";
337+
static const char _disabled[] = "disabled";
338+
339339
static ssize_t
340340
wake_show(struct device * dev, struct device_attribute *attr, char * buf)
341341
{
342342
return sprintf(buf, "%s\n", device_can_wakeup(dev)
343-
? (device_may_wakeup(dev) ? enabled : disabled)
343+
? (device_may_wakeup(dev) ? _enabled : _disabled)
344344
: "");
345345
}
346346

@@ -357,11 +357,11 @@ wake_store(struct device * dev, struct device_attribute *attr,
357357
cp = memchr(buf, '\n', n);
358358
if (cp)
359359
len = cp - buf;
360-
if (len == sizeof enabled - 1
361-
&& strncmp(buf, enabled, sizeof enabled - 1) == 0)
360+
if (len == sizeof _enabled - 1
361+
&& strncmp(buf, _enabled, sizeof _enabled - 1) == 0)
362362
device_set_wakeup_enable(dev, 1);
363-
else if (len == sizeof disabled - 1
364-
&& strncmp(buf, disabled, sizeof disabled - 1) == 0)
363+
else if (len == sizeof _disabled - 1
364+
&& strncmp(buf, _disabled, sizeof _disabled - 1) == 0)
365365
device_set_wakeup_enable(dev, 0);
366366
else
367367
return -EINVAL;
@@ -570,7 +570,8 @@ static ssize_t async_show(struct device *dev, struct device_attribute *attr,
570570
char *buf)
571571
{
572572
return sprintf(buf, "%s\n",
573-
device_async_suspend_enabled(dev) ? enabled : disabled);
573+
device_async_suspend_enabled(dev) ?
574+
_enabled : _disabled);
574575
}
575576

576577
static ssize_t async_store(struct device *dev, struct device_attribute *attr,
@@ -582,9 +583,10 @@ static ssize_t async_store(struct device *dev, struct device_attribute *attr,
582583
cp = memchr(buf, '\n', n);
583584
if (cp)
584585
len = cp - buf;
585-
if (len == sizeof enabled - 1 && strncmp(buf, enabled, len) == 0)
586+
if (len == sizeof _enabled - 1 && strncmp(buf, _enabled, len) == 0)
586587
device_enable_async_suspend(dev);
587-
else if (len == sizeof disabled - 1 && strncmp(buf, disabled, len) == 0)
588+
else if (len == sizeof _disabled - 1 &&
589+
strncmp(buf, _disabled, len) == 0)
588590
device_disable_async_suspend(dev);
589591
else
590592
return -EINVAL;

‎kernel/power/suspend.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,9 @@ int suspend_devices_and_enter(suspend_state_t state)
361361
suspend_test_start();
362362
dpm_resume_end(PMSG_RESUME);
363363
suspend_test_finish("resume devices");
364+
trace_suspend_resume(TPS("resume_console"), state, true);
364365
resume_console();
366+
trace_suspend_resume(TPS("resume_console"), state, false);
365367

366368
Close:
367369
platform_suspend_end(state);

‎kernel/power/suspend_test.c‎

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
#define TEST_SUSPEND_SECONDS 10
2323

2424
static unsigned long suspend_test_start_time;
25+
static u32 test_repeat_count_max = 1;
26+
static u32 test_repeat_count_current;
2527

2628
void suspend_test_start(void)
2729
{
@@ -74,6 +76,7 @@ static void __init test_wakealarm(struct rtc_device *rtc, suspend_state_t state)
7476
int status;
7577

7678
/* this may fail if the RTC hasn't been initialized */
79+
repeat:
7780
status = rtc_read_time(rtc, &alm.time);
7881
if (status < 0) {
7982
printk(err_readtime, dev_name(&rtc->dev), status);
@@ -100,10 +103,21 @@ static void __init test_wakealarm(struct rtc_device *rtc, suspend_state_t state)
100103
if (state == PM_SUSPEND_STANDBY) {
101104
printk(info_test, pm_states[state]);
102105
status = pm_suspend(state);
106+
if (status < 0)
107+
state = PM_SUSPEND_FREEZE;
103108
}
109+
if (state == PM_SUSPEND_FREEZE) {
110+
printk(info_test, pm_states[state]);
111+
status = pm_suspend(state);
112+
}
113+
104114
if (status < 0)
105115
printk(err_suspend, status);
106116

117+
test_repeat_count_current++;
118+
if (test_repeat_count_current < test_repeat_count_max)
119+
goto repeat;
120+
107121
/* Some platforms can't detect that the alarm triggered the
108122
* wakeup, or (accordingly) disable it after it afterwards.
109123
* It's supposed to give oneshot behavior; cope.
@@ -137,16 +151,28 @@ static char warn_bad_state[] __initdata =
137151
static int __init setup_test_suspend(char *value)
138152
{
139153
int i;
154+
char *repeat;
155+
char *suspend_type;
140156

141-
/* "=mem" ==> "mem" */
157+
/* example : "=mem[,N]" ==> "mem[,N]" */
142158
value++;
159+
suspend_type = strsep(&value, ",");
160+
if (!suspend_type)
161+
return 0;
162+
163+
repeat = strsep(&value, ",");
164+
if (repeat) {
165+
if (kstrtou32(repeat, 0, &test_repeat_count_max))
166+
return 0;
167+
}
168+
143169
for (i = 0; pm_labels[i]; i++)
144-
if (!strcmp(pm_labels[i], value)) {
170+
if (!strcmp(pm_labels[i], suspend_type)) {
145171
test_state_label = pm_labels[i];
146172
return 0;
147173
}
148174

149-
printk(warn_bad_state, value);
175+
printk(warn_bad_state, suspend_type);
150176
return 0;
151177
}
152178
__setup("test_suspend", setup_test_suspend);

0 commit comments

Comments
 (0)