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

Commit c939878e 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 3268e501
Loading
Loading
Loading
Loading
+1 −5
Original line number Original line Diff line number Diff line
@@ -1478,13 +1478,10 @@ int mhi_process_bw_scale_ev_ring(struct mhi_controller *mhi_cntrl,
	read_unlock_bh(&mhi_cntrl->pm_lock);
	read_unlock_bh(&mhi_cntrl->pm_lock);
	spin_unlock_bh(&mhi_event->lock);
	spin_unlock_bh(&mhi_event->lock);


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


	mutex_lock(&mhi_cntrl->pm_mutex);
	mutex_lock(&mhi_cntrl->pm_mutex);


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


	mhi_device_put(mhi_cntrl->mhi_dev, MHI_VOTE_DEVICE | MHI_VOTE_BUS);
	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);
	mutex_unlock(&mhi_cntrl->pm_mutex);


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


	if (mhi_cntrl->pm_state == MHI_PM_DISABLE)
	if (mhi_cntrl->pm_state == MHI_PM_DISABLE)
		return -EINVAL;
		return -EINVAL;
@@ -1238,7 +1239,8 @@ int mhi_pm_fast_suspend(struct mhi_controller *mhi_cntrl, bool notify_client)
		return -EIO;
		return -EIO;


	/* do a quick check to see if any pending votes to keep us busy */
	/* 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");
		MHI_VERB("Busy, aborting M3\n");
		return -EBUSY;
		return -EBUSY;
	}
	}
@@ -1257,7 +1259,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
	 * Check the votes once more to see if we should abort
	 * suspend.
	 * 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");
		MHI_VERB("Busy, aborting M3\n");
		ret = -EBUSY;
		ret = -EBUSY;
		goto error_suspend;
		goto error_suspend;