Skip to content

Commit f5b6f14

Browse files
drivers: dai: sai: don't crash on underrun/overrun
TX/RX FIFO underrun shouldn't crash the RTOS when it occurs. Also, since this can also happen under "normal" conditions (i.e: DMA doesn't copy data fast enough from/to SAI's FIFOs) the software should be able to recover from it. As such: 1) Remove `z_irq_spurious()` call. 2) Clear error flag 3) De-escalate error message to warning message Signed-off-by: Laurentiu Mihalcea <[email protected]>
1 parent f29377a commit f5b6f14

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

drivers/dai/nxp/sai/sai.c

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -95,20 +95,14 @@ void sai_isr(const void *parameter)
9595

9696
/* check for TX FIFO error */
9797
if (SAI_TX_RX_STATUS_IS_SET(DAI_DIR_TX, data->regmap, kSAI_FIFOErrorFlag)) {
98-
LOG_ERR("FIFO underrun detected");
99-
/* TODO: this will crash the program and should be addressed as
100-
* mentioned in TODO list's 2).
101-
*/
102-
z_irq_spurious(NULL);
98+
LOG_WRN("FIFO underrun detected");
99+
SAI_TX_RX_STATUS_CLEAR(DAI_DIR_TX, data->regmap, kSAI_FIFOErrorFlag);
103100
}
104101

105102
/* check for RX FIFO error */
106103
if (SAI_TX_RX_STATUS_IS_SET(DAI_DIR_RX, data->regmap, kSAI_FIFOErrorFlag)) {
107-
LOG_ERR("FIFO overrun detected");
108-
/* TODO: this will crash the program and should be addressed as
109-
* mentioned in TODO list's 2).
110-
*/
111-
z_irq_spurious(NULL);
104+
LOG_WRN("FIFO overrun detected");
105+
SAI_TX_RX_STATUS_CLEAR(DAI_DIR_RX, data->regmap, kSAI_FIFOErrorFlag);
112106
}
113107
}
114108

drivers/dai/nxp/sai/sai.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,11 @@ LOG_MODULE_REGISTER(nxp_dai_sai);
210210
((dir) == DAI_DIR_RX ? ((UINT_TO_I2S(regmap))->RCSR & (which)) : \
211211
((UINT_TO_I2S(regmap))->TCSR & (which)))
212212

213+
/* used to clear status flags */
214+
#define SAI_TX_RX_STATUS_CLEAR(dir, regmap, which) \
215+
((dir) == DAI_DIR_RX ? SAI_RxClearStatusFlags(UINT_TO_I2S(regmap), which) \
216+
: SAI_TxClearStatusFlags(UINT_TO_I2S(regmap), which))
217+
213218
/* used to retrieve the SYNC direction. Use this macro when you know for sure
214219
* you have 1 SYNC direction with 1 ASYNC direction.
215220
*/

0 commit comments

Comments
 (0)