From 1da00a482fe91e4e4af2324202439a799cc02f89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Th=C3=A9baudeau?= Date: Thu, 23 Jun 2016 22:25:27 +0200 Subject: [PATCH] cc2538: aes: Fix possibly missing result available status MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Depending on the use case and on the timings, aes_auth_crypt_check_status() sometimes never reported an available result, leading to a deadlock of any protothread waiting for this event, and to a WDT reset if a protothread was polling it. This was caused by aes_auth_crypt_start() clearing the result available interrupt after operations that may rightfully trigger it, leading to a missed interrupt. Signed-off-by: Benoît Thébaudeau --- cpu/cc2538/dev/aes.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/cpu/cc2538/dev/aes.c b/cpu/cc2538/dev/aes.c index 429def67b..2b9e11a17 100644 --- a/cpu/cc2538/dev/aes.c +++ b/cpu/cc2538/dev/aes.c @@ -226,12 +226,14 @@ aes_auth_crypt_start(uint32_t ctrl, uint8_t key_area, const void *iv, REG(AES_CTRL_ALG_SEL) = 0x00000000; return CRYPTO_DMA_BUS_ERROR; } + + /* Clear interrupt status */ + REG(AES_CTRL_INT_CLR) = AES_CTRL_INT_CLR_DMA_IN_DONE; } } - /* Clear interrupt status */ - REG(AES_CTRL_INT_CLR) = AES_CTRL_INT_CLR_DMA_IN_DONE | - AES_CTRL_INT_CLR_RESULT_AV; + /* Enable result available bit in interrupt enable */ + REG(AES_CTRL_INT_EN) = AES_CTRL_INT_EN_RESULT_AV; if(process != NULL) { crypto_register_process_notification(process); @@ -239,9 +241,6 @@ aes_auth_crypt_start(uint32_t ctrl, uint8_t key_area, const void *iv, nvic_interrupt_enable(NVIC_INT_AES); } - /* Enable result available bit in interrupt enable */ - REG(AES_CTRL_INT_EN) = AES_CTRL_INT_EN_RESULT_AV; - if(data_len != 0) { /* Configure DMAC * Enable DMA channel 0 */