ipq806x: sync with latest patches sent by QCA
[openwrt/openwrt.git] / target / linux / ipq806x / patches-4.4 / 714-spi-qup-properly-detect-extra-interrupts.patch
1 From b69e5e855aaae2dd9f7fc6f4a40af8e6e0cf98ee Mon Sep 17 00:00:00 2001
2 From: Matthew McClintock <mmcclint@codeaurora.org>
3 Date: Thu, 10 Mar 2016 16:44:55 -0600
4 Subject: [PATCH] spi: qup: properly detect extra interrupts
5
6 It's possible for a SPI transaction to complete and get another
7 interrupt and have it processed on the same spi_transfer before the
8 transfer_one can set it to NULL.
9
10 This masks unexpected interrupts, so let's set the spi_transfer to
11 NULL in the interrupt once the transaction is done. So we can
12 properly detect these bad interrupts and print warning messages.
13
14 Change-Id: I0e70ed59fb50e5c48a72a38f74bd178b17c9f24d
15 Signed-off-by: Matthew McClintock <mmcclint@codeaurora.org>
16 ---
17 drivers/spi/spi-qup.c | 15 +++++++++------
18 1 file changed, 9 insertions(+), 6 deletions(-)
19
20 diff --git a/drivers/spi/spi-qup.c b/drivers/spi/spi-qup.c
21 index e487416..45e30c7 100644
22 --- a/drivers/spi/spi-qup.c
23 +++ b/drivers/spi/spi-qup.c
24 @@ -509,6 +509,7 @@ static irqreturn_t spi_qup_qup_irq(int irq, void *dev_id)
25 u32 opflags, qup_err, spi_err;
26 unsigned long flags;
27 int error = 0;
28 + bool done = 0;
29
30 spin_lock_irqsave(&controller->lock, flags);
31 xfer = controller->xfer;
32 @@ -567,16 +568,19 @@ static irqreturn_t spi_qup_qup_irq(int irq, void *dev_id)
33 spi_qup_write(controller, xfer);
34 }
35
36 - spin_lock_irqsave(&controller->lock, flags);
37 - controller->error = error;
38 - controller->xfer = xfer;
39 - spin_unlock_irqrestore(&controller->lock, flags);
40 -
41 /* re-read opflags as flags may have changed due to actions above */
42 opflags = readl_relaxed(controller->base + QUP_OPERATIONAL);
43
44 if ((controller->rx_bytes == xfer->len &&
45 (opflags & QUP_OP_MAX_INPUT_DONE_FLAG)) || error)
46 + done = true;
47 +
48 + spin_lock_irqsave(&controller->lock, flags);
49 + controller->error = error;
50 + controller->xfer = done ? NULL : xfer;
51 + spin_unlock_irqrestore(&controller->lock, flags);
52 +
53 + if (done)
54 complete(&controller->done);
55
56 return IRQ_HANDLED;
57 @@ -769,7 +773,6 @@ static int spi_qup_transfer_one(struct spi_master *master,
58 exit:
59 spi_qup_set_state(controller, QUP_STATE_RESET);
60 spin_lock_irqsave(&controller->lock, flags);
61 - controller->xfer = NULL;
62 if (!ret)
63 ret = controller->error;
64 spin_unlock_irqrestore(&controller->lock, flags);
65 --
66 2.7.2
67