Skip to content

Commit fed7eaa

Browse files
computersforpeacerafaeljw
authored andcommitted
PM: runtime: Update kerneldoc return codes
APIs based on __pm_runtime_idle() (pm_runtime_idle(), pm_request_idle()) do not return 1 when already suspended. They return -EAGAIN. This is already covered in the docs, so the entry for "1" is redundant and conflicting. (pm_runtime_put() and pm_runtime_put_sync() were previously incorrect, but that's fixed in "PM: runtime: pm_runtime_put{,_sync}() returns 1 when already suspended", to ensure consistency with APIs like pm_runtime_put_autosuspend().) RPM_GET_PUT APIs based on __pm_runtime_suspend() do return 1 when already suspended, but the language is a little unclear -- it's not really an "error", so it seems better to list as a clarification before the 0/success case. Additionally, they only actually return 1 when the refcount makes it to 0; if the usage counter is still non-zero, we return 0. pm_runtime_put(), etc., also don't appear at first like they can ever see "-EAGAIN: Runtime PM usage_count non-zero", because in non-racy conditions, pm_runtime_put() would drop its reference count, see it's non-zero, and return early (in __pm_runtime_idle()). However, it's possible to race with another actor that increments the usage_count afterward, since rpm_idle() is protected by a separate lock; in such a case, we may see -EAGAIN. Because this case is only seen in the presence of concurrent actors, it makes sense to clarify that this is when "usage_count **became** non-zero", by way of some racing actor. Lastly, pm_runtime_put_sync_suspend() duplicated some -EAGAIN language. Fix that. Fixes: 271ff96 ("PM: runtime: Document return values of suspend-related API functions") Link: https://lore.kernel.org/linux-pm/aJ5pkEJuixTaybV4@google.com/ Signed-off-by: Brian Norris <briannorris@chromium.org> Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com> Cc: 6.17+ <stable@vger.kernel.org> # 6.17+ Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent d0b8651 commit fed7eaa

1 file changed

Lines changed: 31 additions & 25 deletions

File tree

include/linux/pm_runtime.h

Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -350,13 +350,12 @@ static inline int pm_runtime_force_resume(struct device *dev) { return -ENXIO; }
350350
* * 0: Success.
351351
* * -EINVAL: Runtime PM error.
352352
* * -EACCES: Runtime PM disabled.
353-
* * -EAGAIN: Runtime PM usage_count non-zero, Runtime PM status change ongoing
354-
* or device not in %RPM_ACTIVE state.
353+
* * -EAGAIN: Runtime PM usage counter non-zero, Runtime PM status change
354+
* ongoing or device not in %RPM_ACTIVE state.
355355
* * -EBUSY: Runtime PM child_count non-zero.
356356
* * -EPERM: Device PM QoS resume latency 0.
357357
* * -EINPROGRESS: Suspend already in progress.
358358
* * -ENOSYS: CONFIG_PM not enabled.
359-
* * 1: Device already suspended.
360359
* Other values and conditions for the above values are possible as returned by
361360
* Runtime PM idle and suspend callbacks.
362361
*/
@@ -370,14 +369,15 @@ static inline int pm_runtime_idle(struct device *dev)
370369
* @dev: Target device.
371370
*
372371
* Return:
372+
* * 1: Success; device was already suspended.
373373
* * 0: Success.
374374
* * -EINVAL: Runtime PM error.
375375
* * -EACCES: Runtime PM disabled.
376-
* * -EAGAIN: Runtime PM usage_count non-zero or Runtime PM status change ongoing.
376+
* * -EAGAIN: Runtime PM usage counter non-zero or Runtime PM status change
377+
* ongoing.
377378
* * -EBUSY: Runtime PM child_count non-zero.
378379
* * -EPERM: Device PM QoS resume latency 0.
379380
* * -ENOSYS: CONFIG_PM not enabled.
380-
* * 1: Device already suspended.
381381
* Other values and conditions for the above values are possible as returned by
382382
* Runtime PM suspend callbacks.
383383
*/
@@ -396,14 +396,15 @@ static inline int pm_runtime_suspend(struct device *dev)
396396
* engaging its "idle check" callback.
397397
*
398398
* Return:
399+
* * 1: Success; device was already suspended.
399400
* * 0: Success.
400401
* * -EINVAL: Runtime PM error.
401402
* * -EACCES: Runtime PM disabled.
402-
* * -EAGAIN: Runtime PM usage_count non-zero or Runtime PM status change ongoing.
403+
* * -EAGAIN: Runtime PM usage counter non-zero or Runtime PM status change
404+
* ongoing.
403405
* * -EBUSY: Runtime PM child_count non-zero.
404406
* * -EPERM: Device PM QoS resume latency 0.
405407
* * -ENOSYS: CONFIG_PM not enabled.
406-
* * 1: Device already suspended.
407408
* Other values and conditions for the above values are possible as returned by
408409
* Runtime PM suspend callbacks.
409410
*/
@@ -433,13 +434,12 @@ static inline int pm_runtime_resume(struct device *dev)
433434
* * 0: Success.
434435
* * -EINVAL: Runtime PM error.
435436
* * -EACCES: Runtime PM disabled.
436-
* * -EAGAIN: Runtime PM usage_count non-zero, Runtime PM status change ongoing
437-
* or device not in %RPM_ACTIVE state.
437+
* * -EAGAIN: Runtime PM usage counter non-zero, Runtime PM status change
438+
* ongoing or device not in %RPM_ACTIVE state.
438439
* * -EBUSY: Runtime PM child_count non-zero.
439440
* * -EPERM: Device PM QoS resume latency 0.
440441
* * -EINPROGRESS: Suspend already in progress.
441442
* * -ENOSYS: CONFIG_PM not enabled.
442-
* * 1: Device already suspended.
443443
*/
444444
static inline int pm_request_idle(struct device *dev)
445445
{
@@ -464,15 +464,16 @@ static inline int pm_request_resume(struct device *dev)
464464
* equivalent pm_runtime_autosuspend() for @dev asynchronously.
465465
*
466466
* Return:
467+
* * 1: Success; device was already suspended.
467468
* * 0: Success.
468469
* * -EINVAL: Runtime PM error.
469470
* * -EACCES: Runtime PM disabled.
470-
* * -EAGAIN: Runtime PM usage_count non-zero or Runtime PM status change ongoing.
471+
* * -EAGAIN: Runtime PM usage counter non-zero or Runtime PM status change
472+
* ongoing.
471473
* * -EBUSY: Runtime PM child_count non-zero.
472474
* * -EPERM: Device PM QoS resume latency 0.
473475
* * -EINPROGRESS: Suspend already in progress.
474476
* * -ENOSYS: CONFIG_PM not enabled.
475-
* * 1: Device already suspended.
476477
*/
477478
static inline int pm_request_autosuspend(struct device *dev)
478479
{
@@ -540,15 +541,16 @@ static inline int pm_runtime_resume_and_get(struct device *dev)
540541
* equal to 0, queue up a work item for @dev like in pm_request_idle().
541542
*
542543
* Return:
544+
* * 1: Success. Usage counter dropped to zero, but device was already suspended.
543545
* * 0: Success.
544546
* * -EINVAL: Runtime PM error.
545547
* * -EACCES: Runtime PM disabled.
546-
* * -EAGAIN: Runtime PM usage_count non-zero or Runtime PM status change ongoing.
548+
* * -EAGAIN: Runtime PM usage counter became non-zero or Runtime PM status
549+
* change ongoing.
547550
* * -EBUSY: Runtime PM child_count non-zero.
548551
* * -EPERM: Device PM QoS resume latency 0.
549552
* * -EINPROGRESS: Suspend already in progress.
550553
* * -ENOSYS: CONFIG_PM not enabled.
551-
* * 1: Device already suspended.
552554
*/
553555
static inline int pm_runtime_put(struct device *dev)
554556
{
@@ -565,15 +567,16 @@ DEFINE_FREE(pm_runtime_put, struct device *, if (_T) pm_runtime_put(_T))
565567
* equal to 0, queue up a work item for @dev like in pm_request_autosuspend().
566568
*
567569
* Return:
570+
* * 1: Success. Usage counter dropped to zero, but device was already suspended.
568571
* * 0: Success.
569572
* * -EINVAL: Runtime PM error.
570573
* * -EACCES: Runtime PM disabled.
571-
* * -EAGAIN: Runtime PM usage_count non-zero or Runtime PM status change ongoing.
574+
* * -EAGAIN: Runtime PM usage counter became non-zero or Runtime PM status
575+
* change ongoing.
572576
* * -EBUSY: Runtime PM child_count non-zero.
573577
* * -EPERM: Device PM QoS resume latency 0.
574578
* * -EINPROGRESS: Suspend already in progress.
575579
* * -ENOSYS: CONFIG_PM not enabled.
576-
* * 1: Device already suspended.
577580
*/
578581
static inline int __pm_runtime_put_autosuspend(struct device *dev)
579582
{
@@ -590,15 +593,16 @@ static inline int __pm_runtime_put_autosuspend(struct device *dev)
590593
* in pm_request_autosuspend().
591594
*
592595
* Return:
596+
* * 1: Success. Usage counter dropped to zero, but device was already suspended.
593597
* * 0: Success.
594598
* * -EINVAL: Runtime PM error.
595599
* * -EACCES: Runtime PM disabled.
596-
* * -EAGAIN: Runtime PM usage_count non-zero or Runtime PM status change ongoing.
600+
* * -EAGAIN: Runtime PM usage counter became non-zero or Runtime PM status
601+
* change ongoing.
597602
* * -EBUSY: Runtime PM child_count non-zero.
598603
* * -EPERM: Device PM QoS resume latency 0.
599604
* * -EINPROGRESS: Suspend already in progress.
600605
* * -ENOSYS: CONFIG_PM not enabled.
601-
* * 1: Device already suspended.
602606
*/
603607
static inline int pm_runtime_put_autosuspend(struct device *dev)
604608
{
@@ -619,14 +623,15 @@ static inline int pm_runtime_put_autosuspend(struct device *dev)
619623
* if it returns an error code.
620624
*
621625
* Return:
626+
* * 1: Success. Usage counter dropped to zero, but device was already suspended.
622627
* * 0: Success.
623628
* * -EINVAL: Runtime PM error.
624629
* * -EACCES: Runtime PM disabled.
625-
* * -EAGAIN: Runtime PM usage_count non-zero or Runtime PM status change ongoing.
630+
* * -EAGAIN: Runtime PM usage counter became non-zero or Runtime PM status
631+
* change ongoing.
626632
* * -EBUSY: Runtime PM child_count non-zero.
627633
* * -EPERM: Device PM QoS resume latency 0.
628634
* * -ENOSYS: CONFIG_PM not enabled.
629-
* * 1: Device already suspended.
630635
* Other values and conditions for the above values are possible as returned by
631636
* Runtime PM suspend callbacks.
632637
*/
@@ -646,15 +651,15 @@ static inline int pm_runtime_put_sync(struct device *dev)
646651
* if it returns an error code.
647652
*
648653
* Return:
654+
* * 1: Success. Usage counter dropped to zero, but device was already suspended.
649655
* * 0: Success.
650656
* * -EINVAL: Runtime PM error.
651657
* * -EACCES: Runtime PM disabled.
652-
* * -EAGAIN: Runtime PM usage_count non-zero or Runtime PM status change ongoing.
653-
* * -EAGAIN: usage_count non-zero or Runtime PM status change ongoing.
658+
* * -EAGAIN: Runtime PM usage counter became non-zero or Runtime PM status
659+
* change ongoing.
654660
* * -EBUSY: Runtime PM child_count non-zero.
655661
* * -EPERM: Device PM QoS resume latency 0.
656662
* * -ENOSYS: CONFIG_PM not enabled.
657-
* * 1: Device already suspended.
658663
* Other values and conditions for the above values are possible as returned by
659664
* Runtime PM suspend callbacks.
660665
*/
@@ -677,15 +682,16 @@ static inline int pm_runtime_put_sync_suspend(struct device *dev)
677682
* if it returns an error code.
678683
*
679684
* Return:
685+
* * 1: Success. Usage counter dropped to zero, but device was already suspended.
680686
* * 0: Success.
681687
* * -EINVAL: Runtime PM error.
682688
* * -EACCES: Runtime PM disabled.
683-
* * -EAGAIN: Runtime PM usage_count non-zero or Runtime PM status change ongoing.
689+
* * -EAGAIN: Runtime PM usage counter became non-zero or Runtime PM status
690+
* change ongoing.
684691
* * -EBUSY: Runtime PM child_count non-zero.
685692
* * -EPERM: Device PM QoS resume latency 0.
686693
* * -EINPROGRESS: Suspend already in progress.
687694
* * -ENOSYS: CONFIG_PM not enabled.
688-
* * 1: Device already suspended.
689695
* Other values and conditions for the above values are possible as returned by
690696
* Runtime PM suspend callbacks.
691697
*/

0 commit comments

Comments
 (0)