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

Commit b09c22c0 authored by Utkarsh Saxena's avatar Utkarsh Saxena Committed by Gerrit - the friendly Code Review server
Browse files

msm: ipa: Fix incorrect wakelock handling



For every __pm_stay_awake call, there must be a
__pm_relax call to ensure there is no stale
wakelock is held. with the current logic
__pm_stay_awake is called whenever wakelock ref
cnt is non-zero and released only when it is 0.
This leads to wakelock being held even when
it is not required. Make a change to acquire
wakelock only when it is not held previously.

Change-Id: I8c61c184506c705fd5866de8a606f642c5de3d5b
Acked-by: default avatarChaitanya Pratapa <cpratapa@qti.qualcomm.com>
Signed-off-by: default avatarUtkarsh Saxena <usaxena@codeaurora.org>
parent 9bf70038
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -3418,11 +3418,14 @@ void ipa_inc_acquire_wakelock(enum ipa_wakelock_ref_client ref_client)
		return;
	spin_lock_irqsave(&ipa_ctx->wakelock_ref_cnt.spinlock, flags);
	if (ipa_ctx->wakelock_ref_cnt.cnt & (1 << ref_client))
		IPAERR("client enum %d mask already set. ref cnt = %d\n",
		IPADBG("client enum %d mask already set. ref cnt = %d\n",
		ref_client, ipa_ctx->wakelock_ref_cnt.cnt);
	ipa_ctx->wakelock_ref_cnt.cnt |= (1 << ref_client);
	if (ipa_ctx->wakelock_ref_cnt.cnt)
	if (ipa_ctx->wakelock_ref_cnt.cnt &&
		!ipa_ctx->wakelock_ref_cnt.wakelock_acquired) {
		__pm_stay_awake(&ipa_ctx->w_lock);
		ipa_ctx->wakelock_ref_cnt.wakelock_acquired = true;
	}
	IPADBG_LOW("active wakelock ref cnt = %d client enum %d\n",
		ipa_ctx->wakelock_ref_cnt.cnt, ref_client);
	spin_unlock_irqrestore(&ipa_ctx->wakelock_ref_cnt.spinlock, flags);
@@ -3446,8 +3449,11 @@ void ipa_dec_release_wakelock(enum ipa_wakelock_ref_client ref_client)
	ipa_ctx->wakelock_ref_cnt.cnt &= ~(1 << ref_client);
	IPADBG_LOW("active wakelock ref cnt = %d client enum %d\n",
		ipa_ctx->wakelock_ref_cnt.cnt, ref_client);
	if (ipa_ctx->wakelock_ref_cnt.cnt == 0)
	if (ipa_ctx->wakelock_ref_cnt.cnt == 0 &&
		ipa_ctx->wakelock_ref_cnt.wakelock_acquired) {
		__pm_relax(&ipa_ctx->w_lock);
		ipa_ctx->wakelock_ref_cnt.wakelock_acquired = false;
	}
	spin_unlock_irqrestore(&ipa_ctx->wakelock_ref_cnt.spinlock, flags);
}

+1 −0
Original line number Diff line number Diff line
@@ -841,6 +841,7 @@ struct ipa_active_clients {
struct ipa_wakelock_ref_cnt {
	spinlock_t spinlock;
	u32 cnt;
	bool wakelock_acquired;
};

struct ipa_tag_completion {