pm: device_runtime: get rid of the spinlock

Protect critical sections using the mutex.
The mutex is required to use the conditional variable and since we
need to atomically check the pm state and the workqueue before wait
the condition, it is necessary to protect them using the same mutex.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
This commit is contained in:
Flavio Ceolin 2021-05-20 14:47:04 -07:00 committed by Anas Nashif
commit 97281b3862
3 changed files with 14 additions and 23 deletions

View file

@ -105,7 +105,7 @@ struct pm_device {
/** Pointer to the device */
const struct device *dev;
/** Lock to synchronize the get/put operations */
struct k_spinlock lock;
struct k_mutex lock;
/* Following are packed fields protected by #lock. */
/** Device pm enable flag */
bool enable : 1;
@ -119,8 +119,6 @@ struct pm_device {
struct k_work_delayable work;
/** Event conditional var to listen to the sync request events */
struct k_condvar condvar;
/** Condvar mutex */
struct k_mutex condvar_lock;
};
/** Bit position in device_pm::atomic_flags that records whether the