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

Commit 1c624689 authored by Bojun Pan's avatar Bojun Pan
Browse files

msm: gsi: gsi channel mode switch spinlock fix



Fix the spin lock issue which will cause the race condition
that gsi_isr will still happen even we are in polling mode.

Change-Id: I940b5e45bbfcdc25bcde943b8a6fb523a7e995bb
Signed-off-by: default avatarBojun Pan <bojunp@codeaurora.org>
parent eddc683b
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -2787,21 +2787,27 @@ int gsi_config_channel_mode(unsigned long chan_hdl, enum gsi_chan_mode mode)
		return -GSI_STATUS_UNSUPPORTED_OP;
	}

	spin_lock_irqsave(&gsi_ctx->slock, flags);
	if (curr == GSI_CHAN_MODE_CALLBACK &&
			mode == GSI_CHAN_MODE_POLL) {
		spin_lock_irqsave(&gsi_ctx->slock, flags);
		__gsi_config_ieob_irq(gsi_ctx->per.ee, 1 << ctx->evtr->id, 0);
		spin_unlock_irqrestore(&gsi_ctx->slock, flags);
		spin_lock_irqsave(&ctx->ring.slock, flags);
		atomic_set(&ctx->poll_mode, mode);
		spin_unlock_irqrestore(&ctx->ring.slock, flags);
		ctx->stats.callback_to_poll++;
	}

	if (curr == GSI_CHAN_MODE_POLL &&
			mode == GSI_CHAN_MODE_CALLBACK) {
		spin_lock_irqsave(&ctx->ring.slock, flags);
		atomic_set(&ctx->poll_mode, mode);
		spin_unlock_irqrestore(&ctx->ring.slock, flags);
		spin_lock_irqsave(&gsi_ctx->slock, flags);
		__gsi_config_ieob_irq(gsi_ctx->per.ee, 1 << ctx->evtr->id, ~0);
		spin_unlock_irqrestore(&gsi_ctx->slock, flags);
		ctx->stats.poll_to_callback++;
	}
	spin_unlock_irqrestore(&gsi_ctx->slock, flags);

	return GSI_STATUS_SUCCESS;
}