fix(dma2d): dma2d_force_end should not crash when rx channel is idle

This commit is contained in:
Song Ruo Jing
2025-02-25 20:22:14 +08:00
parent 9a97296876
commit bf147686a7

View File

@@ -967,12 +967,14 @@ esp_err_t dma2d_force_end(dma2d_trans_t *trans, bool *need_yield)
dma2d_group_t *group = trans->rx_chan->group;
bool in_flight = false;
// We judge whether the transaction is in-flight by checking the RX channel it uses is in-use or free
// We judge whether the transaction is in-flight by checking the RX channel it uses is being occupied or free
portENTER_CRITICAL_SAFE(&group->spinlock);
if (!(group->rx_channel_free_mask & (1 << trans->rx_chan->channel_id))) {
in_flight = true;
dma2d_ll_rx_enable_interrupt(group->hal.dev, trans->rx_chan->channel_id, UINT32_MAX, false);
assert(!dma2d_ll_rx_is_fsm_idle(group->hal.dev, trans->rx_chan->channel_id));
// DMA consumer could generate an error in both cases:
// 1. when TX or RX is transferring data (channel not in idle state)
// 2. TX successfully passed data to the module, but module cannot process the data, so RX has no data to delivery (RX channel in idle state)
}
portEXIT_CRITICAL_SAFE(&group->spinlock);
ESP_RETURN_ON_FALSE_ISR(in_flight, ESP_ERR_INVALID_STATE, TAG, "transaction not in-flight");