pm: device_runtime: Fix atomic usage

Protect critical sessions using the spinlock available. The atomic
usage was not properly protecting the critical section and was
possible to have a race condition between the usage check and state
set.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
This commit is contained in:
Flavio Ceolin 2021-05-14 16:50:23 -07:00 committed by Anas Nashif
commit ce989e33e6
2 changed files with 44 additions and 24 deletions

View file

@ -112,7 +112,7 @@ struct pm_device {
/* Following are packed fields accessed with atomic bit operations. */
atomic_t atomic_flags;
/** Device usage count */
atomic_t usage;
uint32_t usage;
/** Device idle internal power state */
atomic_t state;
/** Work object for asynchronous calls */