pm: device_runtime: detect power up failures

Check that the device we are trying to use has successfully powered up
when it is on a power domain. If it has not, release the request for the
power domain to be powered to ensure we do not have dangling requests.

As a result of this, `PM_DEVICE_ACTION_RESUME` will not be run on a
device if `PM_DEVICE_ACTION_TURN_ON` has already failed.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
This commit is contained in:
Jordan Yates 2022-05-10 14:25:23 +10:00 committed by Carles Cufí
commit 962eca65af

View file

@ -142,6 +142,12 @@ int pm_device_runtime_get(const struct device *dev)
if (ret != 0) {
goto unlock;
}
/* Check if powering up this device failed */
if (atomic_test_bit(&pm->flags, PM_DEVICE_FLAG_TURN_ON_FAILED)) {
(void)pm_device_runtime_put(PM_DOMAIN(pm));
ret = -EAGAIN;
goto unlock;
}
}
pm->usage++;