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

Commit 820d9a40 authored by Bhaumik Bhatt's avatar Bhaumik Bhatt
Browse files

mhi: core: block fast suspends on controller device bus vote



Currently only a pending packets check is used to block fast
suspends. Since it does not exactly reflect what the core
driver intends to do, allow a bus vote to the controller device
to block fast suspends as well.

Change-Id: I31266d296e855027f6b49b2dcfe4606bb48ac221
Signed-off-by: default avatarBhaumik Bhatt <bbhatt@codeaurora.org>
parent 1d6a7b7e
Loading
Loading
Loading
Loading
+1 −5
Original line number Diff line number Diff line
@@ -1484,13 +1484,10 @@ int mhi_process_bw_scale_ev_ring(struct mhi_controller *mhi_cntrl,
	read_unlock_bh(&mhi_cntrl->pm_lock);
	spin_unlock_bh(&mhi_event->lock);

	atomic_inc(&mhi_cntrl->pending_pkts);
	ret = mhi_device_get_sync(mhi_cntrl->mhi_dev,
				  MHI_VOTE_DEVICE | MHI_VOTE_BUS);
	if (ret) {
		atomic_dec(&mhi_cntrl->pending_pkts);
	if (ret)
		goto exit_bw_scale_process;
	}

	mutex_lock(&mhi_cntrl->pm_mutex);

@@ -1508,7 +1505,6 @@ int mhi_process_bw_scale_ev_ring(struct mhi_controller *mhi_cntrl,
	read_unlock_bh(&mhi_cntrl->pm_lock);

	mhi_device_put(mhi_cntrl->mhi_dev, MHI_VOTE_DEVICE | MHI_VOTE_BUS);
	atomic_dec(&mhi_cntrl->pending_pkts);

	mutex_unlock(&mhi_cntrl->pm_mutex);

+5 −2
Original line number Diff line number Diff line
@@ -1241,6 +1241,7 @@ int mhi_pm_fast_suspend(struct mhi_controller *mhi_cntrl, bool notify_client)
	int ret;
	enum MHI_PM_STATE new_state;
	struct mhi_chan *itr, *tmp;
	struct mhi_device *mhi_dev = mhi_cntrl->mhi_dev;

	read_lock_bh(&mhi_cntrl->pm_lock);
	if (mhi_cntrl->pm_state == MHI_PM_DISABLE) {
@@ -1255,7 +1256,8 @@ int mhi_pm_fast_suspend(struct mhi_controller *mhi_cntrl, bool notify_client)
	read_unlock_bh(&mhi_cntrl->pm_lock);

	/* do a quick check to see if any pending votes to keep us busy */
	if (atomic_read(&mhi_cntrl->pending_pkts)) {
	if (atomic_read(&mhi_cntrl->pending_pkts) ||
	    atomic_read(&mhi_dev->bus_vote)) {
		MHI_VERB("Busy, aborting M3\n");
		return -EBUSY;
	}
@@ -1274,7 +1276,8 @@ int mhi_pm_fast_suspend(struct mhi_controller *mhi_cntrl, bool notify_client)
	 * Check the votes once more to see if we should abort
	 * suspend.
	 */
	if (atomic_read(&mhi_cntrl->pending_pkts)) {
	if (atomic_read(&mhi_cntrl->pending_pkts) ||
	    atomic_read(&mhi_dev->bus_vote)) {
		MHI_VERB("Busy, aborting M3\n");
		ret = -EBUSY;
		goto error_suspend;