Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

PM: runtime: Unify error handling during suspend and resume

There is a confusing difference in error handling between rpm_suspend()
and rpm_resume() related to the special way in which -EAGAIN and -EBUSY
error values are treated by the former. Also, converting -EACCES coming
from the callback to I/O error, which it quite likely is not, may
confuse runtime PM users.

To address the above, modify rpm_callback() to convert -EACCES coming
from the driver to -EAGAIN and to set power.runtime_error only if the
return value is not -EAGAIN or -EBUSY.

This will cause the error handling in rpm_resume() and rpm_suspend() to
work consistently, so drop the no longer needed -EAGAIN or -EBUSY
special case from the latter and make it retry autosuspend if
power.runtime_error is unset.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>
Link: https://patch.msgid.link/12620037.O9o76ZdvQC@rjwysocki.net

+24 -16
+24 -16
drivers/base/power/runtime.c
··· 448 448 retval = __rpm_callback(cb, dev); 449 449 } 450 450 451 - dev->power.runtime_error = retval; 452 - return retval != -EACCES ? retval : -EIO; 451 + /* 452 + * Since -EACCES means that runtime PM is disabled for the given device, 453 + * it should not be returned by runtime PM callbacks. If it is returned 454 + * nevertheless, assume it to be a transient error and convert it to 455 + * -EAGAIN. 456 + */ 457 + if (retval == -EACCES) 458 + retval = -EAGAIN; 459 + 460 + if (retval != -EAGAIN && retval != -EBUSY) 461 + dev->power.runtime_error = retval; 462 + 463 + return retval; 453 464 } 454 465 455 466 /** ··· 736 725 dev->power.deferred_resume = false; 737 726 wake_up_all(&dev->power.wait_queue); 738 727 739 - if (retval == -EAGAIN || retval == -EBUSY) { 740 - dev->power.runtime_error = 0; 728 + /* 729 + * On transient errors, if the callback routine failed an autosuspend, 730 + * and if the last_busy time has been updated so that there is a new 731 + * autosuspend expiration time, automatically reschedule another 732 + * autosuspend. 733 + */ 734 + if (!dev->power.runtime_error && (rpmflags & RPM_AUTO) && 735 + pm_runtime_autosuspend_expiration(dev) != 0) 736 + goto repeat; 741 737 742 - /* 743 - * If the callback routine failed an autosuspend, and 744 - * if the last_busy time has been updated so that there 745 - * is a new autosuspend expiration time, automatically 746 - * reschedule another autosuspend. 747 - */ 748 - if ((rpmflags & RPM_AUTO) && 749 - pm_runtime_autosuspend_expiration(dev) != 0) 750 - goto repeat; 751 - } else { 752 - pm_runtime_cancel_pending(dev); 753 - } 738 + pm_runtime_cancel_pending(dev); 739 + 754 740 goto out; 755 741 } 756 742