d6949b617b793fa91f5da94bf389d895d40347bb
[openwrt/staging/dangole.git] /
1 From 659c52fe8a86264c5119c0592654898d09fe8f28 Mon Sep 17 00:00:00 2001
2 From: Eric Anholt <eric@anholt.net>
3 Date: Fri, 13 Oct 2017 17:12:55 -0700
4 Subject: [PATCH 176/454] drm/vc4: Fix sleeps during the IRQ handler for DSI
5 transactions.
6
7 VC4's DSI1 has a bug where the AXI connection is broken for 32-bit
8 writes from the CPU, so we use the DMA engine to DMA 32-bit values
9 into registers instead. That sleeps, so we can't do it from the top
10 half.
11
12 As a solution, use an interrupt thread so that all our writes happen
13 when sleeping is is allowed.
14
15 v2: Use IRQF_ONESHOT (suggested by Boris)
16 v3: Style nitpicks.
17
18 Signed-off-by: Eric Anholt <eric@anholt.net>
19 Link: https://patchwork.freedesktop.org/patch/msgid/20171014001255.32005-1-eric@anholt.net
20 Reviewed-by: Boris Brezillon <boris.brezillon@free-electrons.com> (v2)
21 (cherry picked from commit af0c8c10564aac5b6d67308129ec09c4ad5db476)
22 ---
23 drivers/gpu/drm/vc4/vc4_dsi.c | 32 ++++++++++++++++++++++++++++++--
24 1 file changed, 30 insertions(+), 2 deletions(-)
25
26 --- a/drivers/gpu/drm/vc4/vc4_dsi.c
27 +++ b/drivers/gpu/drm/vc4/vc4_dsi.c
28 @@ -1383,6 +1383,27 @@ static void dsi_handle_error(struct vc4_
29 *ret = IRQ_HANDLED;
30 }
31
32 +/*
33 + * Initial handler for port 1 where we need the reg_dma workaround.
34 + * The register DMA writes sleep, so we can't do it in the top half.
35 + * Instead we use IRQF_ONESHOT so that the IRQ gets disabled in the
36 + * parent interrupt contrller until our interrupt thread is done.
37 + */
38 +static irqreturn_t vc4_dsi_irq_defer_to_thread_handler(int irq, void *data)
39 +{
40 + struct vc4_dsi *dsi = data;
41 + u32 stat = DSI_PORT_READ(INT_STAT);
42 +
43 + if (!stat)
44 + return IRQ_NONE;
45 +
46 + return IRQ_WAKE_THREAD;
47 +}
48 +
49 +/*
50 + * Normal IRQ handler for port 0, or the threaded IRQ handler for port
51 + * 1 where we need the reg_dma workaround.
52 + */
53 static irqreturn_t vc4_dsi_irq_handler(int irq, void *data)
54 {
55 struct vc4_dsi *dsi = data;
56 @@ -1566,8 +1587,15 @@ static int vc4_dsi_bind(struct device *d
57 /* Clear any existing interrupt state. */
58 DSI_PORT_WRITE(INT_STAT, DSI_PORT_READ(INT_STAT));
59
60 - ret = devm_request_irq(dev, platform_get_irq(pdev, 0),
61 - vc4_dsi_irq_handler, 0, "vc4 dsi", dsi);
62 + if (dsi->reg_dma_mem)
63 + ret = devm_request_threaded_irq(dev, platform_get_irq(pdev, 0),
64 + vc4_dsi_irq_defer_to_thread_handler,
65 + vc4_dsi_irq_handler,
66 + IRQF_ONESHOT,
67 + "vc4 dsi", dsi);
68 + else
69 + ret = devm_request_irq(dev, platform_get_irq(pdev, 0),
70 + vc4_dsi_irq_handler, 0, "vc4 dsi", dsi);
71 if (ret) {
72 if (ret != -EPROBE_DEFER)
73 dev_err(dev, "Failed to get interrupt: %d\n", ret);