[PATCH] crypto: fsl - Add cache flush after job descriptor swap
Pawel Kochanowski
pkochanowski at sii.pl
Sun Apr 13 20:38:09 CEST 2025
On devices with CONFIG_SYS_FSL_SEC_BE an endianess swap is done before
sending descriptor to SEC/CAAM engine. A cache flush needs to be
performed to ensure that the updated descriptor is taken into account.
Signed-off-by: Pawel Kochanowski <pkochanowski at sii.pl>
---
drivers/crypto/fsl/jr.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/drivers/crypto/fsl/jr.c b/drivers/crypto/fsl/jr.c
index 8f7a821ebf3..5a69e1f6bd8 100644
--- a/drivers/crypto/fsl/jr.c
+++ b/drivers/crypto/fsl/jr.c
@@ -162,6 +162,8 @@ static int jr_enqueue(uint32_t *desc_addr,
uint32_t desc_word;
int length = desc_len(desc_addr);
int i;
+ unsigned long start;
+ unsigned long end;
#ifdef CONFIG_CAAM_64BIT
uint32_t *addr_hi, *addr_lo;
#endif
@@ -176,6 +178,11 @@ static int jr_enqueue(uint32_t *desc_addr,
sec_out32((uint32_t *)&desc_addr[i], desc_word);
}
+ start = (unsigned long)desc_addr & ~(ARCH_DMA_MINALIGN - 1);
+ end = ALIGN((unsigned long)desc_addr +
+ length * sizeof(desc_addr[0]), ARCH_DMA_MINALIGN);
+ flush_dcache_range(start, end);
+
caam_dma_addr_t desc_phys_addr = virt_to_phys(desc_addr);
jr->info[head].desc_phys_addr = desc_phys_addr;
@@ -183,9 +190,9 @@ static int jr_enqueue(uint32_t *desc_addr,
jr->info[head].arg = arg;
jr->info[head].op_done = 0;
- unsigned long start = (unsigned long)&jr->info[head] &
+ start = (unsigned long)&jr->info[head] &
~(ARCH_DMA_MINALIGN - 1);
- unsigned long end = ALIGN((unsigned long)&jr->info[head] +
+ end = ALIGN((unsigned long)&jr->info[head] +
sizeof(struct jr_info), ARCH_DMA_MINALIGN);
flush_dcache_range(start, end);
--
2.43.0
More information about the U-Boot
mailing list