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

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

Merge "mhi: core: Force PM state to M0 while processing BW scaling event"

parents 34813ff0 4d1342a2
Loading
Loading
Loading
Loading
+17 −14
Original line number Diff line number Diff line
@@ -1392,29 +1392,28 @@ int mhi_process_bw_scale_ev_ring(struct mhi_controller *mhi_cntrl,
	struct mhi_link_info link_info, *cur_info = &mhi_cntrl->mhi_link_info;
	int result, ret = 0;

	mutex_lock(&mhi_cntrl->pm_mutex);

	if (unlikely(MHI_EVENT_ACCESS_INVALID(mhi_cntrl->pm_state))) {
		MHI_LOG("No EV access, PM_STATE:%s\n",
			to_mhi_pm_state_str(mhi_cntrl->pm_state));
		ret = -EIO;
		goto exit_bw_process;
		goto exit_no_lock;
	}

	/*
	 * BW change is not process during suspend since we're suspending link,
	 * host will process it during resume
	 */
	if (MHI_PM_IN_SUSPEND_STATE(mhi_cntrl->pm_state)) {
		ret = -EACCES;
		goto exit_bw_process;
	}
	ret = __mhi_device_get_sync(mhi_cntrl);
	if (ret)
		goto exit_no_lock;

	mutex_lock(&mhi_cntrl->pm_mutex);

	spin_lock_bh(&mhi_event->lock);
	dev_rp = mhi_to_virtual(ev_ring, er_ctxt->rp);

	if (ev_ring->rp == dev_rp) {
		spin_unlock_bh(&mhi_event->lock);
		read_lock_bh(&mhi_cntrl->pm_lock);
		mhi_cntrl->wake_put(mhi_cntrl, false);
		read_unlock_bh(&mhi_cntrl->pm_lock);
		MHI_VERB("no pending event found\n");
		goto exit_bw_process;
	}

@@ -1459,13 +1458,16 @@ int mhi_process_bw_scale_ev_ring(struct mhi_controller *mhi_cntrl,
		mhi_write_reg(mhi_cntrl, mhi_cntrl->bw_scale_db, 0,
			      MHI_BW_SCALE_RESULT(result,
						  link_info.sequence_num));

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

exit_bw_process:
	MHI_VERB("exit er_index:%u\n", mhi_event->er_index);

	mutex_unlock(&mhi_cntrl->pm_mutex);

exit_no_lock:
	MHI_VERB("exit er_index:%u\n", mhi_event->er_index);

	return ret;
}

@@ -1625,6 +1627,7 @@ irqreturn_t mhi_intvec_handlr(int irq_number, void *dev)
	wake_up_all(&mhi_cntrl->state_event);
	MHI_VERB("Exit\n");

	if (MHI_IN_MISSION_MODE(mhi_cntrl->ee))
		schedule_work(&mhi_cntrl->low_priority_worker);

	return IRQ_WAKE_THREAD;
+11 −11
Original line number Diff line number Diff line
@@ -154,9 +154,6 @@ enum MHI_PM_STATE __must_check mhi_tryset_pm_state(
	MHI_VERB("Transition to pm state from:%s to:%s\n",
		 to_mhi_pm_state_str(cur_state), to_mhi_pm_state_str(state));

	if (MHI_REG_ACCESS_VALID(cur_state) && MHI_REG_ACCESS_VALID(state))
		mhi_timesync_log(mhi_cntrl);

	mhi_cntrl->pm_state = state;
	return mhi_cntrl->pm_state;
}
@@ -451,22 +448,24 @@ int mhi_pm_m3_transition(struct mhi_controller *mhi_cntrl)
static int mhi_pm_mission_mode_transition(struct mhi_controller *mhi_cntrl)
{
	int i, ret;
	enum mhi_ee ee = 0;
	struct mhi_event *mhi_event;

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

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

	if (!MHI_IN_MISSION_MODE(mhi_cntrl->ee))
	if (!MHI_IN_MISSION_MODE(ee))
		return -EIO;

	wake_up_all(&mhi_cntrl->state_event);

	mhi_cntrl->status_cb(mhi_cntrl, mhi_cntrl->priv_data,
			     MHI_CB_EE_MISSION_MODE);
	mhi_cntrl->ee = ee;

	wake_up_all(&mhi_cntrl->state_event);

	/* force MHI to be in M0 state before continuing */
	ret = __mhi_device_get_sync(mhi_cntrl);
@@ -505,6 +504,9 @@ static int mhi_pm_mission_mode_transition(struct mhi_controller *mhi_cntrl)
	/* setup support for time sync */
	mhi_init_timesync(mhi_cntrl);

	if (MHI_REG_ACCESS_VALID(mhi_cntrl->pm_state))
		mhi_timesync_log(mhi_cntrl);

	MHI_LOG("Adding new devices\n");

	/* add supported devices */
@@ -772,11 +774,9 @@ void mhi_low_priority_worker(struct work_struct *work)
		 TO_MHI_EXEC_STR(mhi_cntrl->ee));

	/* check low priority event rings and process events */
	list_for_each_entry(mhi_event, &mhi_cntrl->lp_ev_rings, node) {
		if (MHI_IN_MISSION_MODE(mhi_cntrl->ee))
	list_for_each_entry(mhi_event, &mhi_cntrl->lp_ev_rings, node)
		mhi_event->process_event(mhi_cntrl, mhi_event, U32_MAX);
}
}

void mhi_pm_sys_err_worker(struct work_struct *work)
{