kernel: bump 5.4 to 5.4.109
[openwrt/openwrt.git] / target / linux / layerscape / patches-5.4 / 806-dma-0014-MLK-18248-dma-fsl-edma-v3-avoid-touch-unused-edma-ch.patch
1 From 13d8031dd480b23620923c39400831f7edc68276 Mon Sep 17 00:00:00 2001
2 From: Robin Gong <yibin.gong@nxp.com>
3 Date: Thu, 10 May 2018 01:02:01 +0800
4 Subject: [PATCH] MLK-18248: dma: fsl-edma-v3: avoid touch unused edma channel
5
6 Avoid touch unused edma channel register in susped/resume, otherwise,
7 kernel crash if XRDC enabled in scfw.
8
9 Signed-off-by: Robin Gong <yibin.gong@nxp.com>
10 Acked-by: Fugang Duan <fugang.duan@nxp.com>
11 (cherry picked from commit aa221c4aba34c6ce1ce5f561fa073bb8297cc0ff)
12 ---
13 drivers/dma/fsl-edma-v3.c | 11 +++++++++++
14 1 file changed, 11 insertions(+)
15
16 --- a/drivers/dma/fsl-edma-v3.c
17 +++ b/drivers/dma/fsl-edma-v3.c
18 @@ -149,6 +149,7 @@ struct fsl_edma3_chan {
19 enum dma_status status;
20 enum fsl_edma3_pm_state pm_state;
21 bool idle;
22 + bool used;
23 struct fsl_edma3_engine *edma3;
24 struct fsl_edma3_desc *edesc;
25 struct fsl_edma3_slave_config fsc;
26 @@ -226,6 +227,8 @@ static void fsl_edma3_enable_request(str
27
28 val |= EDMA_CH_CSR_ERQ;
29 writel(val, addr + EDMA_CH_CSR);
30 +
31 + fsl_chan->used = true;
32 }
33
34 static void fsl_edma3_disable_request(struct fsl_edma3_chan *fsl_chan)
35 @@ -281,6 +284,7 @@ static int fsl_edma3_terminate_all(struc
36 fsl_edma3_disable_request(fsl_chan);
37 fsl_chan->edesc = NULL;
38 fsl_chan->idle = true;
39 + fsl_chan->used = false;
40 vchan_get_all_descriptors(&fsl_chan->vchan, &head);
41 spin_unlock_irqrestore(&fsl_chan->vchan.lock, flags);
42 vchan_dma_desc_free_list(&fsl_chan->vchan, &head);
43 @@ -805,6 +809,7 @@ static void fsl_edma3_free_chan_resource
44 vchan_dma_desc_free_list(&fsl_chan->vchan, &head);
45 dma_pool_destroy(fsl_chan->tcd_pool);
46 fsl_chan->tcd_pool = NULL;
47 + fsl_chan->used = false;
48 }
49
50 static int fsl_edma3_probe(struct platform_device *pdev)
51 @@ -900,6 +905,7 @@ static int fsl_edma3_probe(struct platfo
52
53 fsl_chan->vchan.desc_free = fsl_edma3_free_desc;
54 vchan_init(&fsl_chan->vchan, &fsl_edma3->dma_dev);
55 + fsl_chan->used = false;
56 }
57
58 mutex_init(&fsl_edma3->fsl_edma3_mutex);
59 @@ -969,6 +975,8 @@ static int fsl_edma3_suspend_late(struct
60 fsl_chan = &fsl_edma->chans[i];
61 addr = fsl_chan->membase;
62
63 + if (!fsl_chan->used)
64 + continue;
65 spin_lock_irqsave(&fsl_chan->vchan.lock, flags);
66 fsl_edma->edma_regs[i].csr = readl(addr + EDMA_CH_CSR);
67 fsl_edma->edma_regs[i].sbr = readl(addr + EDMA_CH_SBR);
68 @@ -996,6 +1004,9 @@ static int fsl_edma3_resume_early(struct
69 fsl_chan = &fsl_edma->chans[i];
70 addr = fsl_chan->membase;
71
72 + if (!fsl_chan->used)
73 + continue;
74 +
75 spin_lock_irqsave(&fsl_chan->vchan.lock, flags);
76 writel(fsl_edma->edma_regs[i].csr, addr + EDMA_CH_CSR);
77 writel(fsl_edma->edma_regs[i].sbr, addr + EDMA_CH_SBR);