Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a5c36deb authored by qctecmdr Service's avatar qctecmdr Service Committed by Gerrit - the friendly Code Review server
Browse files

Merge "mhi: core: fix returning incorrect code when entering rddm mode"

parents 3ec19b2f ceaaa4c8
Loading
Loading
Loading
Loading
+23 −10
Original line number Original line Diff line number Diff line
@@ -422,27 +422,32 @@ int mhi_pm_m3_transition(struct mhi_controller *mhi_cntrl)


static int mhi_pm_mission_mode_transition(struct mhi_controller *mhi_cntrl)
static int mhi_pm_mission_mode_transition(struct mhi_controller *mhi_cntrl)
{
{
	int i;
	int i, ret;
	struct mhi_event *mhi_event;
	struct mhi_event *mhi_event;


	MHI_LOG("Processing Mission Mode Transition\n");
	MHI_LOG("Processing Mission Mode Transition\n");


	/* force MHI to be in M0 state before continuing */
	ret = __mhi_device_get_sync(mhi_cntrl);
	if (ret)
		return ret;

	ret = -EIO;

	write_lock_irq(&mhi_cntrl->pm_lock);
	write_lock_irq(&mhi_cntrl->pm_lock);
	if (MHI_REG_ACCESS_VALID(mhi_cntrl->pm_state))
	if (MHI_REG_ACCESS_VALID(mhi_cntrl->pm_state))
		mhi_cntrl->ee = mhi_get_exec_env(mhi_cntrl);
		mhi_cntrl->ee = mhi_get_exec_env(mhi_cntrl);
	write_unlock_irq(&mhi_cntrl->pm_lock);
	write_unlock_irq(&mhi_cntrl->pm_lock);


	read_lock_bh(&mhi_cntrl->pm_lock);
	if (!MHI_IN_MISSION_MODE(mhi_cntrl->ee))
	if (!MHI_IN_MISSION_MODE(mhi_cntrl->ee))
		return -EIO;
		goto error_mission_mode;


	wake_up_all(&mhi_cntrl->state_event);
	wake_up_all(&mhi_cntrl->state_event);


	/* add elements to all HW event rings */
	/* add elements to all HW event rings */
	read_lock_bh(&mhi_cntrl->pm_lock);
	if (MHI_PM_IN_ERROR_STATE(mhi_cntrl->pm_state))
	if (MHI_PM_IN_ERROR_STATE(mhi_cntrl->pm_state)) {
		goto error_mission_mode;
		read_unlock_bh(&mhi_cntrl->pm_lock);
		return -EIO;
	}


	mhi_event = mhi_cntrl->mhi_event;
	mhi_event = mhi_cntrl->mhi_event;
	for (i = 0; i < mhi_cntrl->total_ev_rings; i++, mhi_event++) {
	for (i = 0; i < mhi_cntrl->total_ev_rings; i++, mhi_event++) {
@@ -474,9 +479,17 @@ static int mhi_pm_mission_mode_transition(struct mhi_controller *mhi_cntrl)
	/* add supported devices */
	/* add supported devices */
	mhi_create_devices(mhi_cntrl);
	mhi_create_devices(mhi_cntrl);


	MHI_LOG("Exited\n");
	ret = 0;


	return 0;
	read_lock_bh(&mhi_cntrl->pm_lock);

error_mission_mode:
	mhi_cntrl->wake_put(mhi_cntrl, false);
	read_unlock_bh(&mhi_cntrl->pm_lock);

	MHI_LOG("Exit with ret:%d\n", ret);

	return ret;
}
}


/* handles both sys_err and shutdown transitions */
/* handles both sys_err and shutdown transitions */
@@ -1124,7 +1137,7 @@ int mhi_force_rddm_mode(struct mhi_controller *mhi_cntrl)
	ret = wait_event_timeout(mhi_cntrl->state_event,
	ret = wait_event_timeout(mhi_cntrl->state_event,
				 mhi_cntrl->ee == MHI_EE_RDDM,
				 mhi_cntrl->ee == MHI_EE_RDDM,
				 msecs_to_jiffies(mhi_cntrl->timeout_ms));
				 msecs_to_jiffies(mhi_cntrl->timeout_ms));
	ret = !ret ? 0 : -EIO;
	ret = ret ? 0 : -EIO;


	MHI_LOG("Exiting with pm_state:%s ee:%s ret:%d\n",
	MHI_LOG("Exiting with pm_state:%s ee:%s ret:%d\n",
		to_mhi_pm_state_str(mhi_cntrl->pm_state),
		to_mhi_pm_state_str(mhi_cntrl->pm_state),