Merge "mhi: core: fix error handling in time synchronization function"

This commit is contained in:
qctecmdr 2020-04-24 15:45:25 -07:00 committed by Gerrit - the friendly Code Review server
commit 3f5605dd39
2 changed files with 12 additions and 9 deletions

View File

@ -2540,13 +2540,13 @@ int mhi_get_remote_time_sync(struct mhi_device *mhi_dev,
/* not all devices support time feature */
if (!mhi_tsync) {
ret = -EIO;
goto err_unlock;
goto error_unlock;
}
/* bring to M0 state */
ret = __mhi_device_get_sync(mhi_cntrl);
if (ret)
goto err_unlock;
goto error_unlock;
read_lock_bh(&mhi_cntrl->pm_lock);
if (unlikely(MHI_PM_IN_ERROR_STATE(mhi_cntrl->pm_state))) {
@ -2559,8 +2559,10 @@ int mhi_get_remote_time_sync(struct mhi_device *mhi_dev,
/* disable link level low power modes */
ret = mhi_cntrl->lpm_disable(mhi_cntrl, mhi_cntrl->priv_data);
if (ret)
if (ret) {
read_lock_bh(&mhi_cntrl->pm_lock);
goto error_invalid_state;
}
/*
* time critical code to fetch device times,
@ -2582,7 +2584,7 @@ int mhi_get_remote_time_sync(struct mhi_device *mhi_dev,
error_invalid_state:
mhi_cntrl->wake_put(mhi_cntrl, false);
read_unlock_bh(&mhi_cntrl->pm_lock);
err_unlock:
error_unlock:
mutex_unlock(&mhi_cntrl->tsync_mutex);
return ret;
}

View File

@ -1518,10 +1518,11 @@ int __mhi_device_get_sync(struct mhi_controller *mhi_cntrl)
read_lock_bh(&mhi_cntrl->pm_lock);
mhi_cntrl->wake_get(mhi_cntrl, true);
if (MHI_PM_IN_SUSPEND_STATE(mhi_cntrl->pm_state))
mhi_trigger_resume(mhi_cntrl);
read_unlock_bh(&mhi_cntrl->pm_lock);
pm_wakeup_hard_event(&mhi_cntrl->mhi_dev->dev);
mhi_cntrl->runtime_get(mhi_cntrl, mhi_cntrl->priv_data);
mhi_force_reg_write(mhi_cntrl);
ret = wait_event_timeout(mhi_cntrl->state_event,
@ -1536,9 +1537,11 @@ int __mhi_device_get_sync(struct mhi_controller *mhi_cntrl)
read_lock_bh(&mhi_cntrl->pm_lock);
mhi_cntrl->wake_put(mhi_cntrl, false);
read_unlock_bh(&mhi_cntrl->pm_lock);
mhi_cntrl->runtime_put(mhi_cntrl, mhi_cntrl->priv_data);
return -EIO;
}
mhi_cntrl->runtime_put(mhi_cntrl, mhi_cntrl->priv_data);
return 0;
}
@ -1599,9 +1602,7 @@ void mhi_device_put(struct mhi_device *mhi_dev, int vote)
if (vote & MHI_VOTE_DEVICE) {
atomic_dec(&mhi_dev->dev_vote);
read_lock_bh(&mhi_cntrl->pm_lock);
if (MHI_PM_IN_SUSPEND_STATE(mhi_cntrl->pm_state))
mhi_trigger_resume(mhi_cntrl);
mhi_trigger_resume(mhi_cntrl);
mhi_cntrl->wake_put(mhi_cntrl, false);
MHI_LOG("dev_wake %d\n", atomic_read(&mhi_cntrl->dev_wake));
read_unlock_bh(&mhi_cntrl->pm_lock);