@@ -96,6 +96,12 @@ struct dev_pm_ops {
96
96
int (*thaw)(struct device *dev);
97
97
int (*poweroff)(struct device *dev);
98
98
int (*restore)(struct device *dev);
99
+ int (*suspend_late)(struct device *dev);
100
+ int (*resume_early)(struct device *dev);
101
+ int (*freeze_late)(struct device *dev);
102
+ int (*thaw_early)(struct device *dev);
103
+ int (*poweroff_late)(struct device *dev);
104
+ int (*restore_early)(struct device *dev);
99
105
int (*suspend_noirq)(struct device *dev);
100
106
int (*resume_noirq)(struct device *dev);
101
107
int (*freeze_noirq)(struct device *dev);
@@ -305,7 +311,7 @@ Entering System Suspend
305
311
-----------------------
306
312
When the system goes into the standby or memory sleep state, the phases are:
307
313
308
- prepare, suspend, suspend_noirq.
314
+ prepare, suspend, suspend_late, suspend_noirq.
309
315
310
316
1. The prepare phase is meant to prevent races by preventing new devices
311
317
from being registered; the PM core would never know that all the
@@ -324,7 +330,12 @@ When the system goes into the standby or memory sleep state, the phases are:
324
330
appropriate low-power state, depending on the bus type the device is on,
325
331
and they may enable wakeup events.
326
332
327
- 3. The suspend_noirq phase occurs after IRQ handlers have been disabled,
333
+ 3 For a number of devices it is convenient to split suspend into the
334
+ "quiesce device" and "save device state" phases, in which cases
335
+ suspend_late is meant to do the latter. It is always executed after
336
+ runtime power management has been disabled for all devices.
337
+
338
+ 4. The suspend_noirq phase occurs after IRQ handlers have been disabled,
328
339
which means that the driver's interrupt handler will not be called while
329
340
the callback method is running. The methods should save the values of
330
341
the device's registers that weren't saved previously and finally put the
@@ -359,7 +370,7 @@ Leaving System Suspend
359
370
----------------------
360
371
When resuming from standby or memory sleep, the phases are:
361
372
362
- resume_noirq, resume, complete.
373
+ resume_noirq, resume_early, resume, complete.
363
374
364
375
1. The resume_noirq callback methods should perform any actions needed
365
376
before the driver's interrupt handlers are invoked. This generally
@@ -375,14 +386,18 @@ When resuming from standby or memory sleep, the phases are:
375
386
device driver's ->pm.resume_noirq() method to perform device-specific
376
387
actions.
377
388
378
- 2. The resume methods should bring the the device back to its operating
389
+ 2. The resume_early methods should prepare devices for the execution of
390
+ the resume methods. This generally involves undoing the actions of the
391
+ preceding suspend_late phase.
392
+
393
+ 3 The resume methods should bring the the device back to its operating
379
394
state, so that it can perform normal I/O. This generally involves
380
395
undoing the actions of the suspend phase.
381
396
382
- 3 . The complete phase uses only a bus callback. The method should undo the
383
- actions of the prepare phase. Note, however, that new children may be
384
- registered below the device as soon as the resume callbacks occur; it's
385
- not necessary to wait until the complete phase.
397
+ 4 . The complete phase should undo the actions of the prepare phase. Note,
398
+ however, that new children may be registered below the device as soon as
399
+ the resume callbacks occur; it's not necessary to wait until the
400
+ complete phase.
386
401
387
402
At the end of these phases, drivers should be as functional as they were before
388
403
suspending: I/O can be performed using DMA and IRQs, and the relevant clocks are
@@ -429,8 +444,8 @@ an image of the system memory while everything is stable, reactivate all
429
444
devices (thaw), write the image to permanent storage, and finally shut down the
430
445
system (poweroff). The phases used to accomplish this are:
431
446
432
- prepare, freeze, freeze_noirq, thaw_noirq, thaw, complete ,
433
- prepare, poweroff, poweroff_noirq
447
+ prepare, freeze, freeze_late, freeze_noirq, thaw_noirq, thaw_early ,
448
+ thaw, complete, prepare, poweroff, poweroff_late , poweroff_noirq
434
449
435
450
1. The prepare phase is discussed in the "Entering System Suspend" section
436
451
above.
@@ -441,40 +456,51 @@ system (poweroff). The phases used to accomplish this are:
441
456
save time it's best not to do so. Also, the device should not be
442
457
prepared to generate wakeup events.
443
458
444
- 3. The freeze_noirq phase is analogous to the suspend_noirq phase discussed
459
+ 3. The freeze_late phase is analogous to the suspend_late phase described
460
+ above, except that the device should not be put in a low-power state and
461
+ should not be allowed to generate wakeup events by it.
462
+
463
+ 4. The freeze_noirq phase is analogous to the suspend_noirq phase discussed
445
464
above, except again that the device should not be put in a low-power
446
465
state and should not be allowed to generate wakeup events.
447
466
448
467
At this point the system image is created. All devices should be inactive and
449
468
the contents of memory should remain undisturbed while this happens, so that the
450
469
image forms an atomic snapshot of the system state.
451
470
452
- 4 . The thaw_noirq phase is analogous to the resume_noirq phase discussed
471
+ 5 . The thaw_noirq phase is analogous to the resume_noirq phase discussed
453
472
above. The main difference is that its methods can assume the device is
454
473
in the same state as at the end of the freeze_noirq phase.
455
474
456
- 5. The thaw phase is analogous to the resume phase discussed above. Its
475
+ 6. The thaw_early phase is analogous to the resume_early phase described
476
+ above. Its methods should undo the actions of the preceding
477
+ freeze_late, if necessary.
478
+
479
+ 7. The thaw phase is analogous to the resume phase discussed above. Its
457
480
methods should bring the device back to an operating state, so that it
458
481
can be used for saving the image if necessary.
459
482
460
- 6 . The complete phase is discussed in the "Leaving System Suspend" section
483
+ 8 . The complete phase is discussed in the "Leaving System Suspend" section
461
484
above.
462
485
463
486
At this point the system image is saved, and the devices then need to be
464
487
prepared for the upcoming system shutdown. This is much like suspending them
465
488
before putting the system into the standby or memory sleep state, and the phases
466
489
are similar.
467
490
468
- 7. The prepare phase is discussed above.
491
+ 9. The prepare phase is discussed above.
492
+
493
+ 10. The poweroff phase is analogous to the suspend phase.
469
494
470
- 8 . The poweroff phase is analogous to the suspend phase.
495
+ 11 . The poweroff_late phase is analogous to the suspend_late phase.
471
496
472
- 9 . The poweroff_noirq phase is analogous to the suspend_noirq phase.
497
+ 12 . The poweroff_noirq phase is analogous to the suspend_noirq phase.
473
498
474
- The poweroff and poweroff_noirq callbacks should do essentially the same things
475
- as the suspend and suspend_noirq callbacks. The only notable difference is that
476
- they need not store the device register values, because the registers should
477
- already have been stored during the freeze or freeze_noirq phases.
499
+ The poweroff, poweroff_late and poweroff_noirq callbacks should do essentially
500
+ the same things as the suspend, suspend_late and suspend_noirq callbacks,
501
+ respectively. The only notable difference is that they need not store the
502
+ device register values, because the registers should already have been stored
503
+ during the freeze, freeze_late or freeze_noirq phases.
478
504
479
505
480
506
Leaving Hibernation
@@ -518,22 +544,25 @@ To achieve this, the image kernel must restore the devices' pre-hibernation
518
544
functionality. The operation is much like waking up from the memory sleep
519
545
state, although it involves different phases:
520
546
521
- restore_noirq, restore, complete
547
+ restore_noirq, restore_early, restore, complete
522
548
523
549
1. The restore_noirq phase is analogous to the resume_noirq phase.
524
550
525
- 2. The restore phase is analogous to the resume phase.
551
+ 2. The restore_early phase is analogous to the resume_early phase.
552
+
553
+ 3. The restore phase is analogous to the resume phase.
526
554
527
- 3 . The complete phase is discussed above.
555
+ 4 . The complete phase is discussed above.
528
556
529
- The main difference from resume[_noirq] is that restore[_noirq] must assume the
530
- device has been accessed and reconfigured by the boot loader or the boot kernel.
531
- Consequently the state of the device may be different from the state remembered
532
- from the freeze and freeze_noirq phases. The device may even need to be reset
533
- and completely re-initialized. In many cases this difference doesn't matter, so
534
- the resume[_noirq] and restore[_norq] method pointers can be set to the same
535
- routines. Nevertheless, different callback pointers are used in case there is a
536
- situation where it actually matters.
557
+ The main difference from resume[_early|_noirq] is that restore[_early|_noirq]
558
+ must assume the device has been accessed and reconfigured by the boot loader or
559
+ the boot kernel. Consequently the state of the device may be different from the
560
+ state remembered from the freeze, freeze_late and freeze_noirq phases. The
561
+ device may even need to be reset and completely re-initialized. In many cases
562
+ this difference doesn't matter, so the resume[_early|_noirq] and
563
+ restore[_early|_norq] method pointers can be set to the same routines.
564
+ Nevertheless, different callback pointers are used in case there is a situation
565
+ where it actually does matter.
537
566
538
567
539
568
Device Power Management Domains
0 commit comments