7cc8c5f244c2864152b10c4436bd599d2df09446
[openwrt/staging/mkresin.git] /
1 From ada13fea4dcc8419e0523614b108635d8f689000 Mon Sep 17 00:00:00 2001
2 From: Iuliana Prodan <iuliana.prodan@nxp.com>
3 Date: Mon, 17 Feb 2020 03:05:10 +0200
4 Subject: [PATCH] LF-838: crypto: caam - increase the domain of write memory
5 barrier to full system
6 MIME-Version: 1.0
7 Content-Type: text/plain; charset=UTF-8
8 Content-Transfer-Encoding: 8bit
9
10 In caam_jr_enqueue, under heavy DDR load, smp_wmb() or dma_wmb()
11 fail to make the input ring be updated before the CAAM starts
12 reading it. So, CAAM will process, again, an old descriptor address
13 and will put it in the output ring. This will make caam_jr_dequeue()
14 to fail, since this old descriptor is not in the software ring.
15 To fix this, use wmb() which works on the full system instead of
16 inner/outer shareable domains.
17
18 Signed-off-by: Iuliana Prodan <iuliana.prodan@nxp.com>
19 Reviewed-by: Horia Geantă <horia.geanta@nxp.com>
20 Signed-off-by: Leonard Crestez <leonard.crestez@nxp.com>
21 ---
22 drivers/crypto/caam/jr.c | 10 +++++++++-
23 1 file changed, 9 insertions(+), 1 deletion(-)
24
25 --- a/drivers/crypto/caam/jr.c
26 +++ b/drivers/crypto/caam/jr.c
27 @@ -434,8 +434,16 @@ int caam_jr_enqueue(struct device *dev,
28 * Guarantee that the descriptor's DMA address has been written to
29 * the next slot in the ring before the write index is updated, since
30 * other cores may update this index independently.
31 + *
32 + * Under heavy DDR load, smp_wmb() or dma_wmb() fail to make the input
33 + * ring be updated before the CAAM starts reading it. So, CAAM will
34 + * process, again, an old descriptor address and will put it in the
35 + * output ring. This will make caam_jr_dequeue() to fail, since this
36 + * old descriptor is not in the software ring.
37 + * To fix this, use wmb() which works on the full system instead of
38 + * inner/outer shareable domains.
39 */
40 - smp_wmb();
41 + wmb();
42
43 jrp->head = (head + 1) & (JOBR_DEPTH - 1);
44