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

Commit b5fa8beb authored by Dilip Kota's avatar Dilip Kota Committed by Gerrit - the friendly Code Review server
Browse files

spi-geni: Synchronize SPI transfer and ISR



In ISR, set the complete variable at the end of the ISR
so that the transfer function which is waiting for the
complete variable will initiate next transfer only after
the ISR is done.

Change-Id: I38bb1a6f063e1553a13ceeb405fdb74f3ced84b4
Signed-off-by: default avatarAkash Asthana <akashast@codeaurora.org>
parent 6d0b2be2
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -156,6 +156,7 @@ struct spi_geni_master {
	void *ipc;
	bool shared_se;
	bool dis_autosuspend;
	bool cmd_done;
};

static struct spi_master *get_spi_master(struct device *dev)
@@ -1279,7 +1280,7 @@ static irqreturn_t geni_spi_irq(int irq, void *data)

		if ((m_irq & M_CMD_DONE_EN) || (m_irq & M_CMD_CANCEL_EN) ||
			(m_irq & M_CMD_ABORT_EN)) {
			complete(&mas->xfer_done);
			mas->cmd_done = true;
			/*
			 * If this happens, then a CMD_DONE came before all the
			 * buffer bytes were sent out. This is unusual, log this
@@ -1319,12 +1320,16 @@ static irqreturn_t geni_spi_irq(int irq, void *data)
		if (dma_rx_status & RX_DMA_DONE)
			mas->rx_rem_bytes = 0;
		if (!mas->tx_rem_bytes && !mas->rx_rem_bytes)
			complete(&mas->xfer_done);
			mas->cmd_done = true;
		if ((m_irq & M_CMD_CANCEL_EN) || (m_irq & M_CMD_ABORT_EN))
			complete(&mas->xfer_done);
			mas->cmd_done = true;
	}
exit_geni_spi_irq:
	geni_write_reg(m_irq, mas->base, SE_GENI_M_IRQ_CLEAR);
	if (mas->cmd_done) {
		mas->cmd_done = false;
		complete(&mas->xfer_done);
	}
	return IRQ_HANDLED;
}