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

Commit adc7dca4 authored by Bojun Pan's avatar Bojun Pan Committed by Gerrit - the friendly Code Review server
Browse files

msm: gsi: Avoid unnessary write to ipa



Only write to ipa to reset channel interrupt, when there
is no entry. Do a read of read pointer after write to close
a small window. The sequence is as such in the poll channel:
 If sw needs to update sw read pointer, it does,
  step 1. update read pointer from ipa,
  step 2  if there is no event, write to reset channel
    interrupt.
  step 3, to close window between step 1 and step2 that
    may have new events, do another read of read pointer.
    And if no more entry then, return EMPTY.
    Otherwise proceeed to process entries as before.

Change-Id: I68b983111416b617b835de024a22c47517ea7f3e
Signed-off-by: default avatarBojun Pan <bojunp@codeaurora.org>
parent 99080dfb
Loading
Loading
Loading
Loading
+21 −9
Original line number Diff line number Diff line
@@ -3597,20 +3597,32 @@ int gsi_poll_n_channel(unsigned long chan_hdl,
	spin_lock_irqsave(&ctx->evtr->ring.slock, flags);
	if (ctx->evtr->ring.rp == ctx->evtr->ring.rp_local) {
		/* update rp to see of we have anything new to process */
		gsi_writel(1 << ctx->evtr->id, gsi_ctx->base +
			GSI_EE_n_CNTXT_SRC_IEOB_IRQ_CLR_OFFS(ee));
		rp = gsi_readl(gsi_ctx->base +
			GSI_EE_n_EV_CH_k_CNTXT_4_OFFS(ctx->evtr->id, ee));
		rp |= ctx->ring.rp & 0xFFFFFFFF00000000;
		rp |= ctx->ring.rp & 0xFFFFFFFF00000000ULL;

		ctx->evtr->ring.rp = rp;
	}

	if (ctx->evtr->ring.rp == ctx->evtr->ring.rp_local) {
		spin_unlock_irqrestore(&ctx->evtr->ring.slock, flags);
		/* read gsi event ring rp again if last read is empty */
		if (rp == ctx->evtr->ring.rp_local) {
			/* event ring is empty */
			gsi_writel(1 << ctx->evtr->id, gsi_ctx->base +
				GSI_EE_n_CNTXT_SRC_IEOB_IRQ_CLR_OFFS(ee));
			/* do another read to close a small window */
			__iowmb();
			rp = gsi_readl(gsi_ctx->base +
				GSI_EE_n_EV_CH_k_CNTXT_4_OFFS(
				ctx->evtr->id, ee));
			rp |= ctx->ring.rp & 0xFFFFFFFF00000000ULL;
			ctx->evtr->ring.rp = rp;
			if (rp == ctx->evtr->ring.rp_local) {
				spin_unlock_irqrestore(
					&ctx->evtr->ring.slock,
					flags);
				ctx->stats.poll_empty++;
				return GSI_STATUS_POLL_EMPTY;
			}
		}
	}

	*actual_num = gsi_get_complete_num(&ctx->evtr->ring,
			ctx->evtr->ring.rp_local, ctx->evtr->ring.rp);