pm: Remove state lock/unlock API

This API is not widely used and it is actually broken since device
runtime power management is not checking it when suspending and
resuming.

On top of that, this API is very close to pm_device_busy* API,
close enough to consolidate in only one API.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
This commit is contained in:
Flavio Ceolin 2024-03-12 12:19:06 -07:00 committed by Carles Cufí
parent e85226fd1a
commit 3b895064af
6 changed files with 0 additions and 119 deletions

View File

@ -44,8 +44,6 @@ enum pm_device_flag {
PM_DEVICE_FLAG_WS_ENABLED,
/** Indicates if device runtime is enabled */
PM_DEVICE_FLAG_RUNTIME_ENABLED,
/** Indicates if the device pm is locked. */
PM_DEVICE_FLAG_STATE_LOCKED,
/** Indicates if the device is used as a power domain */
PM_DEVICE_FLAG_PD,
/** Indicates if device runtime PM should be automatically enabled */
@ -569,43 +567,6 @@ bool pm_device_wakeup_is_enabled(const struct device *dev);
*/
bool pm_device_wakeup_is_capable(const struct device *dev);
/**
* @brief Lock current device state.
*
* This function locks the current device power state. Once
* locked the device power state will not be changed by
* system power management or device runtime power
* management until unlocked.
*
* @note The given device should not have device runtime enabled.
*
* @see pm_device_state_unlock
*
* @param dev Device instance.
*/
void pm_device_state_lock(const struct device *dev);
/**
* @brief Unlock the current device state.
*
* Unlocks a previously locked device pm.
*
* @see pm_device_state_lock
*
* @param dev Device instance.
*/
void pm_device_state_unlock(const struct device *dev);
/**
* @brief Check if the device pm is locked.
*
* @param dev Device instance.
*
* @retval true If device is locked.
* @retval false If device is not locked.
*/
bool pm_device_state_is_locked(const struct device *dev);
/**
* @brief Check if the device is on a switchable power domain.
*
@ -723,19 +684,6 @@ static inline bool pm_device_wakeup_is_capable(const struct device *dev)
ARG_UNUSED(dev);
return false;
}
static inline void pm_device_state_lock(const struct device *dev)
{
ARG_UNUSED(dev);
}
static inline void pm_device_state_unlock(const struct device *dev)
{
ARG_UNUSED(dev);
}
static inline bool pm_device_state_is_locked(const struct device *dev)
{
ARG_UNUSED(dev);
return false;
}
static inline bool pm_device_on_power_domain(const struct device *dev)
{
ARG_UNUSED(dev);

View File

@ -49,10 +49,6 @@ int pm_device_action_run(const struct device *dev,
return -ENOSYS;
}
if (pm_device_state_is_locked(dev)) {
return -EPERM;
}
/* Validate action against current state */
if (pm->state == action_target_state[action]) {
return -EALREADY;
@ -327,36 +323,6 @@ bool pm_device_wakeup_is_capable(const struct device *dev)
PM_DEVICE_FLAG_WS_CAPABLE);
}
void pm_device_state_lock(const struct device *dev)
{
struct pm_device_base *pm = dev->pm_base;
if ((pm != NULL) && !pm_device_runtime_is_enabled(dev)) {
atomic_set_bit(&pm->flags, PM_DEVICE_FLAG_STATE_LOCKED);
}
}
void pm_device_state_unlock(const struct device *dev)
{
struct pm_device_base *pm = dev->pm_base;
if (pm != NULL) {
atomic_clear_bit(&pm->flags, PM_DEVICE_FLAG_STATE_LOCKED);
}
}
bool pm_device_state_is_locked(const struct device *dev)
{
struct pm_device_base *pm = dev->pm_base;
if (pm == NULL) {
return false;
}
return atomic_test_bit(&pm->flags,
PM_DEVICE_FLAG_STATE_LOCKED);
}
bool pm_device_on_power_domain(const struct device *dev)
{
#ifdef CONFIG_PM_DEVICE_POWER_DOMAIN

View File

@ -422,11 +422,6 @@ int pm_device_runtime_enable(const struct device *dev)
goto end;
}
if (pm_device_state_is_locked(dev)) {
ret = -EPERM;
goto end;
}
if (atomic_test_bit(&dev->pm_base->flags, PM_DEVICE_FLAG_ISR_SAFE)) {
ret = runtime_enable_sync(dev);
goto end;

View File

@ -66,7 +66,6 @@ static int pm_suspend_devices(void)
* devices with runtime PM enabled.
*/
if (!device_is_ready(dev) || pm_device_is_busy(dev) ||
pm_device_state_is_locked(dev) ||
pm_device_wakeup_is_enabled(dev) ||
pm_device_runtime_is_enabled(dev)) {
continue;

View File

@ -250,18 +250,6 @@ ZTEST(device_runtime_api, test_api)
/* Put operation should fail due the state be locked. */
ret = pm_device_runtime_disable(test_dev);
zassert_equal(ret, 0);
pm_device_state_lock(test_dev);
/* This operation should not succeed. */
ret = pm_device_runtime_enable(test_dev);
zassert_equal(ret, -EPERM);
/* After unlock the state, enable runtime should work. */
pm_device_state_unlock(test_dev);
ret = pm_device_runtime_enable(test_dev);
zassert_equal(ret, 0);
}
DEVICE_DEFINE(pm_unsupported_device, "PM Unsupported", NULL, NULL, NULL, NULL,

View File

@ -437,21 +437,6 @@ ZTEST(power_management_1cpu, test_busy)
zassert_false(busy);
}
ZTEST(power_management_1cpu, test_device_state_lock)
{
pm_device_state_lock(device_a);
zassert_true(pm_device_state_is_locked(device_a));
testing_device_lock = true;
enter_low_power = true;
k_sleep(SLEEP_TIMEOUT);
pm_device_state_unlock(device_a);
testing_device_lock = false;
}
ZTEST(power_management_1cpu, test_empty_states)
{
const struct pm_state_info *cpu_states;