From: Steve Cornelius Date: Tue, 20 Nov 2012 23:21:26 +0000 (-0700) Subject: ENGR00234401: CAAM: Fix incorrect invalidate call for output ring X-Git-Tag: v3.0.35-fsl~227 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=81b4a0ec01f98ede900998363860bb66dfc6d2b5;p=karo-tx-linux.git ENGR00234401: CAAM: Fix incorrect invalidate call for output ring 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 Signed-off-by: Steve Cornelius Signed-off-by: Terry Lv --- diff --git a/drivers/crypto/caam/jr.c b/drivers/crypto/caam/jr.c index 280aaaa3d4d4..d7394ea58cd6 100644 --- a/drivers/crypto/caam/jr.c +++ b/drivers/crypto/caam/jr.c @@ -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);