power: device_pm: Fix concurrence issues

The sync API was using k_poll_signal and in certain conditions is
possible multiple threads waiting on a signal leading to an undefined
behavior.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
This commit is contained in:
Flavio Ceolin 2021-04-26 22:37:42 -07:00 committed by Anas Nashif
commit 8705c688e2
4 changed files with 36 additions and 46 deletions

View file

@ -98,11 +98,9 @@ struct pm_device {
/** Device idle internal power state */
atomic_t fsm_state;
/** Work object for asynchronous calls */
struct k_work work;
/** Event object to listen to the sync request events */
struct k_poll_event event;
/** Signal to notify the Async API callers */
struct k_poll_signal signal;
struct k_work_delayable work;
/** Event conditional var to listen to the sync request events */
struct k_condvar condvar;
};
/** Bit position in device_pm::atomic_flags that records whether the