From b5fa8bebe70e562cabc706339b39caf938ad78ba Mon Sep 17 00:00:00 2001 From: Dilip Kota Date: Thu, 6 Dec 2018 19:03:17 +0530 Subject: [PATCH] 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: Akash Asthana --- drivers/spi/spi-geni-qcom.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/spi/spi-geni-qcom.c b/drivers/spi/spi-geni-qcom.c index ec2b56ab3dd5..e53c34a03660 100644 --- a/drivers/spi/spi-geni-qcom.c +++ b/drivers/spi/spi-geni-qcom.c @@ -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; }