summaryrefslogtreecommitdiff
path: root/drivers/crypto/fsl/jr.c
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2025-05-22 08:41:25 -0600
committerTom Rini <trini@konsulko.com>2025-05-22 08:41:25 -0600
commitdf5dcf7b7eb66f74262c5e501f813aac759557f2 (patch)
tree671da9049e216362e75b517ce1460fe3ebeb91c3 /drivers/crypto/fsl/jr.c
parent8f85a7345ed5df70a155f0630da72970eb01d87a (diff)
parent159b6f0e119962ce5da645f548cefe9196c8778e (diff)
Merge tag 'u-boot-imx-master-20250522' of https://gitlab.denx.de/u-boot/custodians/u-boot-imx
CI: https://source.denx.de/u-boot/custodians/u-boot-imx/-/pipelines/26275 - Fix boot regression on imx8mn_bsh_smm_s2/s2pro. - Fix reset on imx6ulz_smm_m2. - Adjust DDR initialization on imx6ulz_smm_m2. - Fix CAAM startup error.
Diffstat (limited to 'drivers/crypto/fsl/jr.c')
-rw-r--r--drivers/crypto/fsl/jr.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/drivers/crypto/fsl/jr.c b/drivers/crypto/fsl/jr.c
index 8f7a821ebf3..1d95d2bff27 100644
--- a/drivers/crypto/fsl/jr.c
+++ b/drivers/crypto/fsl/jr.c
@@ -217,13 +217,6 @@ static int jr_enqueue(uint32_t *desc_addr,
jr->head = (head + 1) & (jr->size - 1);
- /* Invalidate output ring */
- start = (unsigned long)jr->output_ring &
- ~(ARCH_DMA_MINALIGN - 1);
- end = ALIGN((unsigned long)jr->output_ring + jr->op_size,
- ARCH_DMA_MINALIGN);
- invalidate_dcache_range(start, end);
-
sec_out32(&regs->irja, 1);
return 0;
@@ -243,6 +236,7 @@ static int jr_dequeue(int sec_idx, struct caam_regs *caam)
#else
uint32_t *addr;
#endif
+ unsigned long start, end;
while (sec_in32(&regs->orsf) && CIRC_CNT(jr->head, jr->tail,
jr->size)) {
@@ -250,6 +244,11 @@ static int jr_dequeue(int sec_idx, struct caam_regs *caam)
found = 0;
caam_dma_addr_t op_desc;
+
+ /* Invalidate output ring */
+ start = (unsigned long)jr->output_ring & ~(ARCH_DMA_MINALIGN - 1);
+ end = ALIGN((unsigned long)jr->output_ring + jr->op_size, ARCH_DMA_MINALIGN);
+ invalidate_dcache_range(start, end);
#ifdef CONFIG_CAAM_64BIT
/* Read the 64 bit Descriptor address from Output Ring.
* The 32 bit hign and low part of the address will
@@ -283,8 +282,13 @@ static int jr_dequeue(int sec_idx, struct caam_regs *caam)
}
/* Error condition if match not found */
- if (!found)
+ if (!found) {
+ int slots_full = sec_in32(&regs->orsf);
+
+ jr->tail = (jr->tail + slots_full) & (jr->size - 1);
+ sec_out32(&regs->orjr, slots_full);
return -1;
+ }
jr->info[idx].op_done = 1;
callback = (void *)jr->info[idx].callback;
@@ -296,14 +300,14 @@ static int jr_dequeue(int sec_idx, struct caam_regs *caam)
*/
if (idx == tail)
do {
+ jr->info[tail].op_done = 0;
tail = (tail + 1) & (jr->size - 1);
} while (jr->info[tail].op_done);
jr->tail = tail;
- jr->read_idx = (jr->read_idx + 1) & (jr->size - 1);
+
sec_out32(&regs->orjr, 1);
- jr->info[idx].op_done = 0;
callback(status, arg);
}
@@ -378,7 +382,6 @@ static int jr_sw_cleanup(uint8_t sec_idx, struct caam_regs *caam)
jr->head = 0;
jr->tail = 0;
- jr->read_idx = 0;
jr->write_idx = 0;
memset(jr->info, 0, sizeof(jr->info));
memset(jr->input_ring, 0, jr->size * sizeof(caam_dma_addr_t));