]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
ENGR00234401: CAAM: Fix incorrect invalidate call for output ring
authorSteve Cornelius <steve.cornelius@freescale.com>
Tue, 20 Nov 2012 23:21:26 +0000 (16:21 -0700)
committerLothar Waßmann <LW@KARO-electronics.de>
Fri, 24 May 2013 06:35:45 +0000 (08:35 +0200)
The job ring driver exhibited a hang condition in the top of
caam_jr_dequeue() where a BUG_ON statement looks for a condition
where the output ring is said to have valid entries by the ring logic,
but the ring entries apparently have NULL descriptor pointers.

In the initial ARM port of this driver, the cache flush call
of the output ring content occured before the output ring read index
register read occurred, exposing a condition where the driver sensed valid
output entries, yet the entries written by the ring hardware were not
invalidated, and therefore were not visible to the processor, appearing
as false NULL entries.

This patch relocates the invalidate call to immediately follow the
check of the output read index, where it is required.

Signed-off-by: Vicki Milhoan <vicki.milhoan@freescale.com>
Signed-off-by: Steve Cornelius <steve.cornelius@freescale.com>
Signed-off-by: Terry Lv <r65388@freescale.com>
drivers/crypto/caam/jr.c

index 280aaaa3d4d44cb1b83c8de752b64d80abce06f9..d7394ea58cd608ad83e1648a240d41556e7ceae8 100644 (file)
@@ -62,9 +62,6 @@ static void caam_jr_dequeue(unsigned long devarg)
        unsigned long flags;
 
        outbusaddr = rd_reg64(&jrp->rregs->outring_base);
-       dma_sync_single_for_cpu(dev, outbusaddr,
-                               sizeof(struct jr_outentry) * JOBR_DEPTH,
-                               DMA_FROM_DEVICE);
 
        spin_lock_irqsave(&jrp->outlock, flags);
 
@@ -75,6 +72,10 @@ static void caam_jr_dequeue(unsigned long devarg)
               rd_reg32(&jrp->rregs->outring_used)) {
 
                hw_idx = jrp->out_ring_read_index;
+               dma_sync_single_for_cpu(dev, outbusaddr,
+                                       sizeof(struct jr_outentry) * JOBR_DEPTH,
+                                       DMA_FROM_DEVICE);
+
                for (i = 0; CIRC_CNT(head, tail + i, JOBR_DEPTH) >= 1; i++) {
                        sw_idx = (tail + i) & (JOBR_DEPTH - 1);