Skip to content

Commit afe94fb

Browse files
committed
Merge branches 'pm-core' and 'pm-sleep'
* pm-core: PM: runtime: Clarify documentation when callbacks are unassigned PM: runtime: Allow unassigned ->runtime_suspend|resume callbacks PM: runtime: Improve path in rpm_idle() when no callback PM: runtime: document common mistake with pm_runtime_get_sync() * pm-sleep: PM: hibernate: remove leading spaces before tabs PM: sleep: remove trailing spaces and tabs PM: hibernate: fix spelling mistakes PM: wakeirq: Set IRQF_NO_AUTOEN when requesting the IRQ
3 parents fff3df4 + 4ec4f05 + 480f0de commit afe94fb

File tree

8 files changed

+40
-26
lines changed

8 files changed

+40
-26
lines changed

Documentation/power/runtime_pm.rst

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,11 @@ drivers/base/power/runtime.c and include/linux/pm_runtime.h:
378378

379379
`int pm_runtime_get_sync(struct device *dev);`
380380
- increment the device's usage counter, run pm_runtime_resume(dev) and
381-
return its result
381+
return its result;
382+
note that it does not drop the device's usage counter on errors, so
383+
consider using pm_runtime_resume_and_get() instead of it, especially
384+
if its return value is checked by the caller, as this is likely to
385+
result in cleaner code.
382386

383387
`int pm_runtime_get_if_in_use(struct device *dev);`
384388
- return -EINVAL if 'power.disable_depth' is nonzero; otherwise, if the
@@ -827,6 +831,15 @@ or driver about runtime power changes. Instead, the driver for the device's
827831
parent must take responsibility for telling the device's driver when the
828832
parent's power state changes.
829833

834+
Note that, in some cases it may not be desirable for subsystems/drivers to call
835+
pm_runtime_no_callbacks() for their devices. This could be because a subset of
836+
the runtime PM callbacks needs to be implemented, a platform dependent PM
837+
domain could get attached to the device or that the device is power managed
838+
through a supplier device link. For these reasons and to avoid boilerplate code
839+
in subsystems/drivers, the PM core allows runtime PM callbacks to be
840+
unassigned. More precisely, if a callback pointer is NULL, the PM core will act
841+
as though there was a callback and it returned 0.
842+
830843
9. Autosuspend, or automatically-delayed suspends
831844
=================================================
832845

drivers/base/power/runtime.c

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ static void rpm_suspend_suppliers(struct device *dev)
345345
static int __rpm_callback(int (*cb)(struct device *), struct device *dev)
346346
__releases(&dev->power.lock) __acquires(&dev->power.lock)
347347
{
348-
int retval, idx;
348+
int retval = 0, idx;
349349
bool use_links = dev->power.links_count > 0;
350350

351351
if (dev->power.irq_safe) {
@@ -373,7 +373,8 @@ static int __rpm_callback(int (*cb)(struct device *), struct device *dev)
373373
}
374374
}
375375

376-
retval = cb(dev);
376+
if (cb)
377+
retval = cb(dev);
377378

378379
if (dev->power.irq_safe) {
379380
spin_lock(&dev->power.lock);
@@ -446,7 +447,10 @@ static int rpm_idle(struct device *dev, int rpmflags)
446447
/* Pending requests need to be canceled. */
447448
dev->power.request = RPM_REQ_NONE;
448449

449-
if (dev->power.no_callbacks)
450+
callback = RPM_GET_CALLBACK(dev, runtime_idle);
451+
452+
/* If no callback assume success. */
453+
if (!callback || dev->power.no_callbacks)
450454
goto out;
451455

452456
/* Carry out an asynchronous or a synchronous idle notification. */
@@ -462,10 +466,7 @@ static int rpm_idle(struct device *dev, int rpmflags)
462466

463467
dev->power.idle_notification = true;
464468

465-
callback = RPM_GET_CALLBACK(dev, runtime_idle);
466-
467-
if (callback)
468-
retval = __rpm_callback(callback, dev);
469+
retval = __rpm_callback(callback, dev);
469470

470471
dev->power.idle_notification = false;
471472
wake_up_all(&dev->power.wait_queue);
@@ -484,9 +485,6 @@ static int rpm_callback(int (*cb)(struct device *), struct device *dev)
484485
{
485486
int retval;
486487

487-
if (!cb)
488-
return -ENOSYS;
489-
490488
if (dev->power.memalloc_noio) {
491489
unsigned int noio_flag;
492490

drivers/base/power/wakeirq.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,6 @@ int dev_pm_set_dedicated_wake_irq(struct device *dev, int irq)
182182

183183
wirq->dev = dev;
184184
wirq->irq = irq;
185-
irq_set_status_flags(irq, IRQ_NOAUTOEN);
186185

187186
/* Prevent deferred spurious wakeirqs with disable_irq_nosync() */
188187
irq_set_status_flags(irq, IRQ_DISABLE_UNLAZY);
@@ -192,7 +191,8 @@ int dev_pm_set_dedicated_wake_irq(struct device *dev, int irq)
192191
* so we use a threaded irq.
193192
*/
194193
err = request_threaded_irq(irq, NULL, handle_threaded_wake_irq,
195-
IRQF_ONESHOT, wirq->name, wirq);
194+
IRQF_ONESHOT | IRQF_NO_AUTOEN,
195+
wirq->name, wirq);
196196
if (err)
197197
goto err_free_name;
198198

include/linux/pm_runtime.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,9 @@ static inline int pm_runtime_get(struct device *dev)
380380
* The possible return values of this function are the same as for
381381
* pm_runtime_resume() and the runtime PM usage counter of @dev remains
382382
* incremented in all cases, even if it returns an error code.
383+
* Consider using pm_runtime_resume_and_get() instead of it, especially
384+
* if its return value is checked by the caller, as this is likely to result
385+
* in cleaner code.
383386
*/
384387
static inline int pm_runtime_get_sync(struct device *dev)
385388
{

kernel/power/Kconfig

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,20 +98,20 @@ config PM_STD_PARTITION
9898
default ""
9999
help
100100
The default resume partition is the partition that the suspend-
101-
to-disk implementation will look for a suspended disk image.
101+
to-disk implementation will look for a suspended disk image.
102102

103-
The partition specified here will be different for almost every user.
103+
The partition specified here will be different for almost every user.
104104
It should be a valid swap partition (at least for now) that is turned
105-
on before suspending.
105+
on before suspending.
106106

107107
The partition specified can be overridden by specifying:
108108

109-
resume=/dev/<other device>
109+
resume=/dev/<other device>
110110

111-
which will set the resume partition to the device specified.
111+
which will set the resume partition to the device specified.
112112

113113
Note there is currently not a way to specify which device to save the
114-
suspended image to. It will simply pick the first available swap
114+
suspended image to. It will simply pick the first available swap
115115
device.
116116

117117
config PM_SLEEP

kernel/power/process.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// SPDX-License-Identifier: GPL-2.0
22
/*
3-
* drivers/power/process.c - Functions for starting/stopping processes on
3+
* drivers/power/process.c - Functions for starting/stopping processes on
44
* suspend transitions.
55
*
66
* Originally from swsusp.

kernel/power/snapshot.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ static void *chain_alloc(struct chain_allocator *ca, unsigned int size)
331331
*
332332
* Memory bitmap is a structure consisting of many linked lists of
333333
* objects. The main list's elements are of type struct zone_bitmap
334-
* and each of them corresonds to one zone. For each zone bitmap
334+
* and each of them corresponds to one zone. For each zone bitmap
335335
* object there is a list of objects of type struct bm_block that
336336
* represent each blocks of bitmap in which information is stored.
337337
*
@@ -1146,7 +1146,7 @@ int create_basic_memory_bitmaps(void)
11461146
Free_second_object:
11471147
kfree(bm2);
11481148
Free_first_bitmap:
1149-
memory_bm_free(bm1, PG_UNSAFE_CLEAR);
1149+
memory_bm_free(bm1, PG_UNSAFE_CLEAR);
11501150
Free_first_object:
11511151
kfree(bm1);
11521152
return -ENOMEM;
@@ -1500,7 +1500,7 @@ static struct memory_bitmap copy_bm;
15001500
/**
15011501
* swsusp_free - Free pages allocated for hibernation image.
15021502
*
1503-
* Image pages are alocated before snapshot creation, so they need to be
1503+
* Image pages are allocated before snapshot creation, so they need to be
15041504
* released after resume.
15051505
*/
15061506
void swsusp_free(void)
@@ -2326,7 +2326,7 @@ static struct memory_bitmap *safe_highmem_bm;
23262326
* (@nr_highmem_p points to the variable containing the number of highmem image
23272327
* pages). The pages that are "safe" (ie. will not be overwritten when the
23282328
* hibernation image is restored entirely) have the corresponding bits set in
2329-
* @bm (it must be unitialized).
2329+
* @bm (it must be uninitialized).
23302330
*
23312331
* NOTE: This function should not be called if there are no highmem image pages.
23322332
*/
@@ -2483,7 +2483,7 @@ static inline void free_highmem_data(void) {}
24832483

24842484
/**
24852485
* prepare_image - Make room for loading hibernation image.
2486-
* @new_bm: Unitialized memory bitmap structure.
2486+
* @new_bm: Uninitialized memory bitmap structure.
24872487
* @bm: Memory bitmap with unsafe pages marked.
24882488
*
24892489
* Use @bm to mark the pages that will be overwritten in the process of

kernel/power/swap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1125,7 +1125,7 @@ struct dec_data {
11251125
};
11261126

11271127
/**
1128-
* Deompression function that runs in its own thread.
1128+
* Decompression function that runs in its own thread.
11291129
*/
11301130
static int lzo_decompress_threadfn(void *data)
11311131
{

0 commit comments

Comments
 (0)