Skip to content

Commit 0a06811

Browse files
committed
Merge branches 'pm-sleep', 'pm-opp' and 'pm-tools'
Merge updates related to system sleep, operating performance points (OPP) updates, and PM tooling updates for 6.12-rc1: - Remove unused stub for saveable_highmem_page() and remove deprecated macros from power management documentation (Andy Shevchenko). - Use ysfs_emit() and sysfs_emit_at() in "show" functions in the PM sysfs interface (Xueqin Luo). - Update the maintainers information for the operating-points-v2-ti-cpu DT binding (Dhruva Gole). - Drop unnecessary of_match_ptr() from ti-opp-supply (Rob Herring). - Update directory handling and installation process in the pm-graph Makefile and add .gitignore to ignore sleepgraph.py artifacts to pm-graph (Amit Vadhavana, Yo-Jung Lin). - Make cpupower display residency value in idle-info (Aboorva Devarajan). - Add missing powercap_set_enabled() stub function to cpupower (John B. Wyatt IV). - Add SWIG support to cpupower (John B. Wyatt IV). * pm-sleep: PM: hibernate: Remove unused stub for saveable_highmem_page() Documentation: PM: Discourage use of deprecated macros PM: sleep: Use sysfs_emit() and sysfs_emit_at() in "show" functions PM: hibernate: Use sysfs_emit() and sysfs_emit_at() in "show" functions * pm-opp: dt-bindings: opp: operating-points-v2-ti-cpu: Update maintainers opp: ti: Drop unnecessary of_match_ptr() * pm-tools: pm:cpupower: Add error warning when SWIG is not installed MAINTAINERS: Add Maintainers for SWIG Python bindings pm:cpupower: Include test_raw_pylibcpupower.py pm:cpupower: Add SWIG bindings files for libcpupower pm:cpupower: Add missing powercap_set_enabled() stub function pm-graph: Update directory handling and installation process in Makefile pm-graph: Make git ignore sleepgraph.py artifacts tools/cpupower: display residency value in idle-info
4 parents 52f1192 + c3565a3 + 339d9d8 + ffa1f26 commit 0a06811

File tree

19 files changed

+553
-101
lines changed

19 files changed

+553
-101
lines changed

Documentation/devicetree/bindings/opp/operating-points-v2-ti-cpu.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ description:
1919
the hardware description for the scheme mentioned above.
2020

2121
maintainers:
22-
- Nishanth Menon <nm@ti.com>
22+
- Dhruva Gole <d-gole@ti.com>
2323

2424
allOf:
2525
- $ref: opp-v2-base.yaml#

Documentation/power/pci.rst

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -979,18 +979,17 @@ subsections can be defined as a separate function, it often is convenient to
979979
point two or more members of struct dev_pm_ops to the same routine. There are
980980
a few convenience macros that can be used for this purpose.
981981

982-
The SIMPLE_DEV_PM_OPS macro declares a struct dev_pm_ops object with one
982+
The DEFINE_SIMPLE_DEV_PM_OPS() declares a struct dev_pm_ops object with one
983983
suspend routine pointed to by the .suspend(), .freeze(), and .poweroff()
984984
members and one resume routine pointed to by the .resume(), .thaw(), and
985985
.restore() members. The other function pointers in this struct dev_pm_ops are
986986
unset.
987987

988-
The UNIVERSAL_DEV_PM_OPS macro is similar to SIMPLE_DEV_PM_OPS, but it
989-
additionally sets the .runtime_resume() pointer to the same value as
990-
.resume() (and .thaw(), and .restore()) and the .runtime_suspend() pointer to
991-
the same value as .suspend() (and .freeze() and .poweroff()).
988+
The DEFINE_RUNTIME_DEV_PM_OPS() is similar to DEFINE_SIMPLE_DEV_PM_OPS(), but it
989+
additionally sets the .runtime_resume() pointer to pm_runtime_force_resume()
990+
and the .runtime_suspend() pointer to pm_runtime_force_suspend().
992991

993-
The SET_SYSTEM_SLEEP_PM_OPS can be used inside of a declaration of struct
992+
The SYSTEM_SLEEP_PM_OPS() can be used inside of a declaration of struct
994993
dev_pm_ops to indicate that one suspend routine is to be pointed to by the
995994
.suspend(), .freeze(), and .poweroff() members and one resume routine is to
996995
be pointed to by the .resume(), .thaw(), and .restore() members.

Documentation/power/runtime_pm.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -811,8 +811,8 @@ subsystem-level dev_pm_ops structure.
811811

812812
Device drivers that wish to use the same function as a system suspend, freeze,
813813
poweroff and runtime suspend callback, and similarly for system resume, thaw,
814-
restore, and runtime resume, can achieve this with the help of the
815-
UNIVERSAL_DEV_PM_OPS macro defined in include/linux/pm.h (possibly setting its
814+
restore, and runtime resume, can achieve similar behaviour with the help of the
815+
DEFINE_RUNTIME_DEV_PM_OPS() defined in include/linux/pm_runtime.h (possibly setting its
816816
last argument to NULL).
817817

818818
8. "No-Callback" Devices

MAINTAINERS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5824,6 +5824,9 @@ CPU POWER MONITORING SUBSYSTEM
58245824
M: Thomas Renninger <[email protected]>
58255825
M: Shuah Khan <[email protected]>
58265826
M: Shuah Khan <[email protected]>
5827+
M: John B. Wyatt IV <[email protected]>
5828+
M: John B. Wyatt IV <[email protected]>
5829+
M: John Kacur <[email protected]>
58275830
58285831
S: Maintained
58295832
F: tools/power/cpupower/

drivers/opp/ti-opp-supply.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ static struct platform_driver ti_opp_supply_driver = {
405405
.probe = ti_opp_supply_probe,
406406
.driver = {
407407
.name = "ti_opp_supply",
408-
.of_match_table = of_match_ptr(ti_opp_supply_of_match),
408+
.of_match_table = ti_opp_supply_of_match,
409409
},
410410
};
411411
module_platform_driver(ti_opp_supply_driver);

kernel/power/hibernate.c

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1123,11 +1123,11 @@ static const char * const hibernation_modes[] = {
11231123
static ssize_t disk_show(struct kobject *kobj, struct kobj_attribute *attr,
11241124
char *buf)
11251125
{
1126+
ssize_t count = 0;
11261127
int i;
1127-
char *start = buf;
11281128

11291129
if (!hibernation_available())
1130-
return sprintf(buf, "[disabled]\n");
1130+
return sysfs_emit(buf, "[disabled]\n");
11311131

11321132
for (i = HIBERNATION_FIRST; i <= HIBERNATION_MAX; i++) {
11331133
if (!hibernation_modes[i])
@@ -1147,12 +1147,16 @@ static ssize_t disk_show(struct kobject *kobj, struct kobj_attribute *attr,
11471147
continue;
11481148
}
11491149
if (i == hibernation_mode)
1150-
buf += sprintf(buf, "[%s] ", hibernation_modes[i]);
1150+
count += sysfs_emit_at(buf, count, "[%s] ", hibernation_modes[i]);
11511151
else
1152-
buf += sprintf(buf, "%s ", hibernation_modes[i]);
1152+
count += sysfs_emit_at(buf, count, "%s ", hibernation_modes[i]);
11531153
}
1154-
buf += sprintf(buf, "\n");
1155-
return buf-start;
1154+
1155+
/* Convert the last space to a newline if needed. */
1156+
if (count > 0)
1157+
buf[count - 1] = '\n';
1158+
1159+
return count;
11561160
}
11571161

11581162
static ssize_t disk_store(struct kobject *kobj, struct kobj_attribute *attr,
@@ -1210,8 +1214,8 @@ power_attr(disk);
12101214
static ssize_t resume_show(struct kobject *kobj, struct kobj_attribute *attr,
12111215
char *buf)
12121216
{
1213-
return sprintf(buf, "%d:%d\n", MAJOR(swsusp_resume_device),
1214-
MINOR(swsusp_resume_device));
1217+
return sysfs_emit(buf, "%d:%d\n", MAJOR(swsusp_resume_device),
1218+
MINOR(swsusp_resume_device));
12151219
}
12161220

12171221
static ssize_t resume_store(struct kobject *kobj, struct kobj_attribute *attr,
@@ -1270,7 +1274,7 @@ power_attr(resume);
12701274
static ssize_t resume_offset_show(struct kobject *kobj,
12711275
struct kobj_attribute *attr, char *buf)
12721276
{
1273-
return sprintf(buf, "%llu\n", (unsigned long long)swsusp_resume_block);
1277+
return sysfs_emit(buf, "%llu\n", (unsigned long long)swsusp_resume_block);
12741278
}
12751279

12761280
static ssize_t resume_offset_store(struct kobject *kobj,
@@ -1293,7 +1297,7 @@ power_attr(resume_offset);
12931297
static ssize_t image_size_show(struct kobject *kobj, struct kobj_attribute *attr,
12941298
char *buf)
12951299
{
1296-
return sprintf(buf, "%lu\n", image_size);
1300+
return sysfs_emit(buf, "%lu\n", image_size);
12971301
}
12981302

12991303
static ssize_t image_size_store(struct kobject *kobj, struct kobj_attribute *attr,
@@ -1314,7 +1318,7 @@ power_attr(image_size);
13141318
static ssize_t reserved_size_show(struct kobject *kobj,
13151319
struct kobj_attribute *attr, char *buf)
13161320
{
1317-
return sprintf(buf, "%lu\n", reserved_size);
1321+
return sysfs_emit(buf, "%lu\n", reserved_size);
13181322
}
13191323

13201324
static ssize_t reserved_size_store(struct kobject *kobj,

kernel/power/main.c

Lines changed: 39 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ int pm_async_enabled = 1;
115115
static ssize_t pm_async_show(struct kobject *kobj, struct kobj_attribute *attr,
116116
char *buf)
117117
{
118-
return sprintf(buf, "%d\n", pm_async_enabled);
118+
return sysfs_emit(buf, "%d\n", pm_async_enabled);
119119
}
120120

121121
static ssize_t pm_async_store(struct kobject *kobj, struct kobj_attribute *attr,
@@ -139,7 +139,7 @@ power_attr(pm_async);
139139
static ssize_t mem_sleep_show(struct kobject *kobj, struct kobj_attribute *attr,
140140
char *buf)
141141
{
142-
char *s = buf;
142+
ssize_t count = 0;
143143
suspend_state_t i;
144144

145145
for (i = PM_SUSPEND_MIN; i < PM_SUSPEND_MAX; i++) {
@@ -149,17 +149,17 @@ static ssize_t mem_sleep_show(struct kobject *kobj, struct kobj_attribute *attr,
149149
const char *label = mem_sleep_states[i];
150150

151151
if (mem_sleep_current == i)
152-
s += sprintf(s, "[%s] ", label);
152+
count += sysfs_emit_at(buf, count, "[%s] ", label);
153153
else
154-
s += sprintf(s, "%s ", label);
154+
count += sysfs_emit_at(buf, count, "%s ", label);
155155
}
156156
}
157157

158158
/* Convert the last space to a newline if needed. */
159-
if (s != buf)
160-
*(s-1) = '\n';
159+
if (count > 0)
160+
buf[count - 1] = '\n';
161161

162-
return (s - buf);
162+
return count;
163163
}
164164

165165
static suspend_state_t decode_suspend_state(const char *buf, size_t n)
@@ -220,7 +220,7 @@ bool sync_on_suspend_enabled = !IS_ENABLED(CONFIG_SUSPEND_SKIP_SYNC);
220220
static ssize_t sync_on_suspend_show(struct kobject *kobj,
221221
struct kobj_attribute *attr, char *buf)
222222
{
223-
return sprintf(buf, "%d\n", sync_on_suspend_enabled);
223+
return sysfs_emit(buf, "%d\n", sync_on_suspend_enabled);
224224
}
225225

226226
static ssize_t sync_on_suspend_store(struct kobject *kobj,
@@ -257,22 +257,22 @@ static const char * const pm_tests[__TEST_AFTER_LAST] = {
257257
static ssize_t pm_test_show(struct kobject *kobj, struct kobj_attribute *attr,
258258
char *buf)
259259
{
260-
char *s = buf;
260+
ssize_t count = 0;
261261
int level;
262262

263263
for (level = TEST_FIRST; level <= TEST_MAX; level++)
264264
if (pm_tests[level]) {
265265
if (level == pm_test_level)
266-
s += sprintf(s, "[%s] ", pm_tests[level]);
266+
count += sysfs_emit_at(buf, count, "[%s] ", pm_tests[level]);
267267
else
268-
s += sprintf(s, "%s ", pm_tests[level]);
268+
count += sysfs_emit_at(buf, count, "%s ", pm_tests[level]);
269269
}
270270

271-
if (s != buf)
272-
/* convert the last space to a newline */
273-
*(s-1) = '\n';
271+
/* Convert the last space to a newline if needed. */
272+
if (count > 0)
273+
buf[count - 1] = '\n';
274274

275-
return (s - buf);
275+
return count;
276276
}
277277

278278
static ssize_t pm_test_store(struct kobject *kobj, struct kobj_attribute *attr,
@@ -390,7 +390,7 @@ static const char * const suspend_step_names[] = {
390390
static ssize_t _name##_show(struct kobject *kobj, \
391391
struct kobj_attribute *attr, char *buf) \
392392
{ \
393-
return sprintf(buf, format_str, suspend_stats._name); \
393+
return sysfs_emit(buf, format_str, suspend_stats._name);\
394394
} \
395395
static struct kobj_attribute _name = __ATTR_RO(_name)
396396

@@ -404,7 +404,7 @@ suspend_attr(max_hw_sleep, "%llu\n");
404404
static ssize_t _name##_show(struct kobject *kobj, \
405405
struct kobj_attribute *attr, char *buf) \
406406
{ \
407-
return sprintf(buf, "%u\n", \
407+
return sysfs_emit(buf, "%u\n", \
408408
suspend_stats.step_failures[step-1]); \
409409
} \
410410
static struct kobj_attribute _name = __ATTR_RO(_name)
@@ -428,7 +428,7 @@ static ssize_t last_failed_dev_show(struct kobject *kobj,
428428
index %= REC_FAILED_NUM;
429429
last_failed_dev = suspend_stats.failed_devs[index];
430430

431-
return sprintf(buf, "%s\n", last_failed_dev);
431+
return sysfs_emit(buf, "%s\n", last_failed_dev);
432432
}
433433
static struct kobj_attribute last_failed_dev = __ATTR_RO(last_failed_dev);
434434

@@ -442,7 +442,7 @@ static ssize_t last_failed_errno_show(struct kobject *kobj,
442442
index %= REC_FAILED_NUM;
443443
last_failed_errno = suspend_stats.errno[index];
444444

445-
return sprintf(buf, "%d\n", last_failed_errno);
445+
return sysfs_emit(buf, "%d\n", last_failed_errno);
446446
}
447447
static struct kobj_attribute last_failed_errno = __ATTR_RO(last_failed_errno);
448448

@@ -456,7 +456,7 @@ static ssize_t last_failed_step_show(struct kobject *kobj,
456456
index %= REC_FAILED_NUM;
457457
step = suspend_stats.failed_steps[index];
458458

459-
return sprintf(buf, "%s\n", suspend_step_names[step]);
459+
return sysfs_emit(buf, "%s\n", suspend_step_names[step]);
460460
}
461461
static struct kobj_attribute last_failed_step = __ATTR_RO(last_failed_step);
462462

@@ -571,7 +571,7 @@ bool pm_print_times_enabled;
571571
static ssize_t pm_print_times_show(struct kobject *kobj,
572572
struct kobj_attribute *attr, char *buf)
573573
{
574-
return sprintf(buf, "%d\n", pm_print_times_enabled);
574+
return sysfs_emit(buf, "%d\n", pm_print_times_enabled);
575575
}
576576

577577
static ssize_t pm_print_times_store(struct kobject *kobj,
@@ -604,7 +604,7 @@ static ssize_t pm_wakeup_irq_show(struct kobject *kobj,
604604
if (!pm_wakeup_irq())
605605
return -ENODATA;
606606

607-
return sprintf(buf, "%u\n", pm_wakeup_irq());
607+
return sysfs_emit(buf, "%u\n", pm_wakeup_irq());
608608
}
609609

610610
power_attr_ro(pm_wakeup_irq);
@@ -620,7 +620,7 @@ EXPORT_SYMBOL_GPL(pm_debug_messages_should_print);
620620
static ssize_t pm_debug_messages_show(struct kobject *kobj,
621621
struct kobj_attribute *attr, char *buf)
622622
{
623-
return sprintf(buf, "%d\n", pm_debug_messages_on);
623+
return sysfs_emit(buf, "%d\n", pm_debug_messages_on);
624624
}
625625

626626
static ssize_t pm_debug_messages_store(struct kobject *kobj,
@@ -668,21 +668,23 @@ struct kobject *power_kobj;
668668
static ssize_t state_show(struct kobject *kobj, struct kobj_attribute *attr,
669669
char *buf)
670670
{
671-
char *s = buf;
671+
ssize_t count = 0;
672672
#ifdef CONFIG_SUSPEND
673673
suspend_state_t i;
674674

675675
for (i = PM_SUSPEND_MIN; i < PM_SUSPEND_MAX; i++)
676676
if (pm_states[i])
677-
s += sprintf(s,"%s ", pm_states[i]);
677+
count += sysfs_emit_at(buf, count, "%s ", pm_states[i]);
678678

679679
#endif
680680
if (hibernation_available())
681-
s += sprintf(s, "disk ");
682-
if (s != buf)
683-
/* convert the last space to a newline */
684-
*(s-1) = '\n';
685-
return (s - buf);
681+
count += sysfs_emit_at(buf, count, "disk ");
682+
683+
/* Convert the last space to a newline if needed. */
684+
if (count > 0)
685+
buf[count - 1] = '\n';
686+
687+
return count;
686688
}
687689

688690
static suspend_state_t decode_state(const char *buf, size_t n)
@@ -782,7 +784,7 @@ static ssize_t wakeup_count_show(struct kobject *kobj,
782784
unsigned int val;
783785

784786
return pm_get_wakeup_count(&val, true) ?
785-
sprintf(buf, "%u\n", val) : -EINTR;
787+
sysfs_emit(buf, "%u\n", val) : -EINTR;
786788
}
787789

788790
static ssize_t wakeup_count_store(struct kobject *kobj,
@@ -824,17 +826,17 @@ static ssize_t autosleep_show(struct kobject *kobj,
824826
suspend_state_t state = pm_autosleep_state();
825827

826828
if (state == PM_SUSPEND_ON)
827-
return sprintf(buf, "off\n");
829+
return sysfs_emit(buf, "off\n");
828830

829831
#ifdef CONFIG_SUSPEND
830832
if (state < PM_SUSPEND_MAX)
831-
return sprintf(buf, "%s\n", pm_states[state] ?
833+
return sysfs_emit(buf, "%s\n", pm_states[state] ?
832834
pm_states[state] : "error");
833835
#endif
834836
#ifdef CONFIG_HIBERNATION
835-
return sprintf(buf, "disk\n");
837+
return sysfs_emit(buf, "disk\n");
836838
#else
837-
return sprintf(buf, "error");
839+
return sysfs_emit(buf, "error\n");
838840
#endif
839841
}
840842

@@ -903,7 +905,7 @@ int pm_trace_enabled;
903905
static ssize_t pm_trace_show(struct kobject *kobj, struct kobj_attribute *attr,
904906
char *buf)
905907
{
906-
return sprintf(buf, "%d\n", pm_trace_enabled);
908+
return sysfs_emit(buf, "%d\n", pm_trace_enabled);
907909
}
908910

909911
static ssize_t
@@ -940,7 +942,7 @@ power_attr_ro(pm_trace_dev_match);
940942
static ssize_t pm_freeze_timeout_show(struct kobject *kobj,
941943
struct kobj_attribute *attr, char *buf)
942944
{
943-
return sprintf(buf, "%u\n", freeze_timeout_msecs);
945+
return sysfs_emit(buf, "%u\n", freeze_timeout_msecs);
944946
}
945947

946948
static ssize_t pm_freeze_timeout_store(struct kobject *kobj,

kernel/power/snapshot.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1365,11 +1365,6 @@ static unsigned int count_highmem_pages(void)
13651365
}
13661366
return n;
13671367
}
1368-
#else
1369-
static inline void *saveable_highmem_page(struct zone *z, unsigned long p)
1370-
{
1371-
return NULL;
1372-
}
13731368
#endif /* CONFIG_HIGHMEM */
13741369

13751370
/**
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
__pycache__/
2+
raw_pylibcpupower_wrap.c
3+
*.o
4+
*.so
5+
*.py
6+
!test_raw_pylibcpupower.py
7+
# git keeps ignoring this file, use git add -f raw_libcpupower.i
8+
!raw_pylibcpupower.i

0 commit comments

Comments
 (0)