2023-08-08 16:08:09

by Meenakshi Aggarwal

[permalink] [raw]
Subject: [PATCH] crypto: caam - increase the domain of write memory barrier to full system

From: Iuliana Prodan <[email protected]>

In caam_jr_enqueue, under heavy DDR load, smp_wmb() or dma_wmb()
fail to make the input ring be updated before the CAAM starts
reading it. So, CAAM will process, again, an old descriptor address
and will put it in the output ring. This will make caam_jr_dequeue()
to fail, since this old descriptor is not in the software ring.
To fix this, use wmb() which works on the full system instead of
inner/outer shareable domains.

Signed-off-by: Iuliana Prodan <[email protected]>
Signed-off-by: Meenakshi Aggarwal <[email protected]>
---
drivers/crypto/caam/jr.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/crypto/caam/jr.c b/drivers/crypto/caam/jr.c
index 767fbf052536..5507d5d34a4c 100644
--- a/drivers/crypto/caam/jr.c
+++ b/drivers/crypto/caam/jr.c
@@ -464,8 +464,16 @@ int caam_jr_enqueue(struct device *dev, u32 *desc,
* Guarantee that the descriptor's DMA address has been written to
* the next slot in the ring before the write index is updated, since
* other cores may update this index independently.
+ *
+ * Under heavy DDR load, smp_wmb() or dma_wmb() fail to make the input
+ * ring be updated before the CAAM starts reading it. So, CAAM will
+ * process, again, an old descriptor address and will put it in the
+ * output ring. This will make caam_jr_dequeue() to fail, since this
+ * old descriptor is not in the software ring.
+ * To fix this, use wmb() which works on the full system instead of
+ * inner/outer shareable domains.
*/
- smp_wmb();
+ wmb();

jrp->head = (head + 1) & (JOBR_DEPTH - 1);

--
2.25.1



2023-08-14 07:01:59

by Gaurav Jain

[permalink] [raw]
Subject: RE: [PATCH] crypto: caam - increase the domain of write memory barrier to full system

Reviewed-by: Gaurav Jain <[email protected]>

> -----Original Message-----
> From: Meenakshi Aggarwal <[email protected]>
> Sent: Tuesday, August 8, 2023 4:25 PM
> To: Horia Geanta <[email protected]>; Varun Sethi <[email protected]>;
> Pankaj Gupta <[email protected]>; Gaurav Jain <[email protected]>;
> [email protected]; [email protected]; linux-
> [email protected]; [email protected]
> Cc: Iuliana Prodan <[email protected]>; Meenakshi Aggarwal
> <[email protected]>
> Subject: [PATCH] crypto: caam - increase the domain of write memory barrier to
> full system
>
> From: Iuliana Prodan <[email protected]>
>
> In caam_jr_enqueue, under heavy DDR load, smp_wmb() or dma_wmb() fail to
> make the input ring be updated before the CAAM starts reading it. So, CAAM will
> process, again, an old descriptor address and will put it in the output ring. This
> will make caam_jr_dequeue() to fail, since this old descriptor is not in the
> software ring.
> To fix this, use wmb() which works on the full system instead of inner/outer
> shareable domains.
>
> Signed-off-by: Iuliana Prodan <[email protected]>
> Signed-off-by: Meenakshi Aggarwal <[email protected]>
> ---
> drivers/crypto/caam/jr.c | 10 +++++++++-
> 1 file changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/crypto/caam/jr.c b/drivers/crypto/caam/jr.c index
> 767fbf052536..5507d5d34a4c 100644
> --- a/drivers/crypto/caam/jr.c
> +++ b/drivers/crypto/caam/jr.c
> @@ -464,8 +464,16 @@ int caam_jr_enqueue(struct device *dev, u32 *desc,
> * Guarantee that the descriptor's DMA address has been written to
> * the next slot in the ring before the write index is updated, since
> * other cores may update this index independently.
> + *
> + * Under heavy DDR load, smp_wmb() or dma_wmb() fail to make the
> input
> + * ring be updated before the CAAM starts reading it. So, CAAM will
> + * process, again, an old descriptor address and will put it in the
> + * output ring. This will make caam_jr_dequeue() to fail, since this
> + * old descriptor is not in the software ring.
> + * To fix this, use wmb() which works on the full system instead of
> + * inner/outer shareable domains.
> */
> - smp_wmb();
> + wmb();
>
> jrp->head = (head + 1) & (JOBR_DEPTH - 1);
>
> --
> 2.25.1