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

Commit 3618ff6c authored by Bhaumik Bhatt's avatar Bhaumik Bhatt
Browse files

mhi: core: handle vote APIs cleanly during power on/off transitions



When a client votes at a time of powering on or off the device,
it is possible the counts can go mismatched and host may assert.
Avoid these issues by clearing the votes at power on and do not
assert if client unvotes when device is inactive.

Change-Id: Iee7b51f11b6beaa11e7f0f5fcde416f8537f355c
Signed-off-by: default avatarBhaumik Bhatt <bbhatt@codeaurora.org>
parent 30d171ac
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -221,7 +221,8 @@ void mhi_deassert_dev_wake(struct mhi_controller *mhi_cntrl, bool override)
{
	unsigned long flags;

	MHI_ASSERT(atomic_read(&mhi_cntrl->dev_wake) == 0, "dev_wake == 0");
	MHI_ASSERT((mhi_is_active(mhi_cntrl->mhi_dev) &&
		   atomic_read(&mhi_cntrl->dev_wake) == 0), "dev_wake == 0");

	/* resources not dropping to 0, decrement and exit */
	if (likely(atomic_add_unless(&mhi_cntrl->dev_wake, -1, 1)))
@@ -842,6 +843,7 @@ int mhi_async_power_up(struct mhi_controller *mhi_cntrl)
	u32 val;
	enum mhi_ee current_ee;
	enum MHI_ST_TRANSITION next_state;
	struct mhi_device *mhi_dev = mhi_cntrl->mhi_dev;

	MHI_LOG("Requested to power on\n");

@@ -857,6 +859,10 @@ int mhi_async_power_up(struct mhi_controller *mhi_cntrl)
			mhi_toggle_dev_wake_nop : mhi_toggle_dev_wake;
	}

	/* clear votes before proceeding for power up */
	atomic_set(&mhi_dev->dev_vote, 0);
	atomic_set(&mhi_dev->bus_vote, 0);

	mutex_lock(&mhi_cntrl->pm_mutex);
	mhi_cntrl->pm_state = MHI_PM_DISABLE;