dma: Fix error_callback enable/disable confusion

Previously the logic was inverted for error_callback_en where 0 was
enablement and 1 was disable. This was likely done so that the default,
sensibly so, was to enable the error callback if possible. A variety of
in tree users had confused the enable/disable value.

Change the name of the flag to error_callback_dis where the default
remains 0 (do not disable the callback!) and correct in tree uses of the
flag where it seemed incorrect.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
This commit is contained in:
Tom Burdick 2024-04-09 14:06:25 -05:00 committed by Anas Nashif
parent 85b3e458ce
commit 4180d70439
20 changed files with 32 additions and 34 deletions

View file

@ -273,7 +273,7 @@ static int dma_atcdmac300_config(const struct device *dev, uint32_t channel,
ch_ctrl |= DMA_CH_CTRL_INTABT; ch_ctrl |= DMA_CH_CTRL_INTABT;
/* Disable the error callback */ /* Disable the error callback */
if (!cfg->error_callback_en) { if (!cfg->error_callback_dis) {
ch_ctrl |= DMA_CH_CTRL_INTERR; ch_ctrl |= DMA_CH_CTRL_INTERR;
} }

View file

@ -129,7 +129,7 @@ static const char *dma_emul_xfer_config_to_string(const struct dma_config *cfg)
"\n\tslot: %u" "\n\tslot: %u"
"\n\tchannel_direction: %u" "\n\tchannel_direction: %u"
"\n\tcomplete_callback_en: %u" "\n\tcomplete_callback_en: %u"
"\n\terror_callback_en: %u" "\n\terror_callback_dis: %u"
"\n\tsource_handshake: %u" "\n\tsource_handshake: %u"
"\n\tdest_handshake: %u" "\n\tdest_handshake: %u"
"\n\tchannel_priority: %u" "\n\tchannel_priority: %u"
@ -148,7 +148,7 @@ static const char *dma_emul_xfer_config_to_string(const struct dma_config *cfg)
"\n\tdma_callback: %p" "\n\tdma_callback: %p"
"\n}", "\n}",
cfg->dma_slot, cfg->channel_direction, cfg->complete_callback_en, cfg->dma_slot, cfg->channel_direction, cfg->complete_callback_en,
cfg->error_callback_en, cfg->source_handshake, cfg->dest_handshake, cfg->error_callback_dis, cfg->source_handshake, cfg->dest_handshake,
cfg->channel_priority, cfg->source_chaining_en, cfg->dest_chaining_en, cfg->channel_priority, cfg->source_chaining_en, cfg->dest_chaining_en,
cfg->linked_channel, cfg->cyclic, cfg->_reserved, cfg->source_data_size, cfg->linked_channel, cfg->cyclic, cfg->_reserved, cfg->source_data_size,
cfg->dest_data_size, cfg->source_burst_length, cfg->dest_burst_length, cfg->dest_data_size, cfg->source_burst_length, cfg->dest_burst_length,
@ -248,11 +248,11 @@ static void dma_emul_work_handler(struct k_work *work)
if (state == DMA_EMUL_CHANNEL_STOPPED) { if (state == DMA_EMUL_CHANNEL_STOPPED) {
LOG_DBG("asynchronously canceled"); LOG_DBG("asynchronously canceled");
if (xfer_config.error_callback_en) { if (!xfer_config.error_callback_dis) {
xfer_config.dma_callback(dev, xfer_config.user_data, xfer_config.dma_callback(dev, xfer_config.user_data,
channel, -ECANCELED); channel, -ECANCELED);
} else { } else {
LOG_DBG("error_callback_en is not set (async " LOG_DBG("error_callback_dis is not set (async "
"cancel)"); "cancel)");
} }
goto out; goto out;

View file

@ -272,7 +272,7 @@ static int check_blocks(struct dma_xec_channel *chdata, struct dma_block_config
* dma_slot - peripheral source/target ID. Not used for Mem2Mem * dma_slot - peripheral source/target ID. Not used for Mem2Mem
* channel_direction - HW supports Mem2Mem, Mem2Periph, and Periph2Mem * channel_direction - HW supports Mem2Mem, Mem2Periph, and Periph2Mem
* complete_callback_en - if true invoke callback on completion (no error) * complete_callback_en - if true invoke callback on completion (no error)
* error_callback_en - if true invoke callback on error * error_callback_dis - if true disable callback on error
* source_handshake - 0=HW, 1=SW * source_handshake - 0=HW, 1=SW
* dest_handshake - 0=HW, 1=SW * dest_handshake - 0=HW, 1=SW
* channel_priority - 4-bit field. HW implements round-robin only. * channel_priority - 4-bit field. HW implements round-robin only.
@ -384,7 +384,7 @@ static int dma_xec_configure(const struct device *dev, uint32_t channel,
if (config->complete_callback_en) { if (config->complete_callback_en) {
chdata->flags |= BIT(DMA_XEC_CHAN_FLAGS_CB_EOB_POS); chdata->flags |= BIT(DMA_XEC_CHAN_FLAGS_CB_EOB_POS);
} }
if (config->error_callback_en) { /* disable callback on errors ? */ if (config->error_callback_dis) { /* disable callback on errors ? */
chdata->flags |= BIT(DMA_XEC_CHAN_FLAGS_CB_ERR_DIS_POS); chdata->flags |= BIT(DMA_XEC_CHAN_FLAGS_CB_ERR_DIS_POS);
} }
@ -690,7 +690,7 @@ static int dmac_xec_pm_action(const struct device *dev,
* completion_callback_en * completion_callback_en
* 0 = invoke at completion of all blocks * 0 = invoke at completion of all blocks
* 1 = invoke at completin of each block * 1 = invoke at completin of each block
* error_callback_en * error_callback_dis
* 0 = invoke on all errors * 0 = invoke on all errors
* 1 = disabled, do not invoke on errors * 1 = disabled, do not invoke on errors
*/ */

View file

@ -125,7 +125,7 @@ static int dma_sam0_config(const struct device *dev, uint32_t channel,
/* Enable the interrupts */ /* Enable the interrupts */
DMA_REGS->CHINTENSET.reg = DMAC_CHINTENSET_TCMPL; DMA_REGS->CHINTENSET.reg = DMAC_CHINTENSET_TCMPL;
if (!config->error_callback_en) { if (!config->error_callback_dis) {
DMA_REGS->CHINTENSET.reg = DMAC_CHINTENSET_TERR; DMA_REGS->CHINTENSET.reg = DMAC_CHINTENSET_TERR;
} else { } else {
DMA_REGS->CHINTENCLR.reg = DMAC_CHINTENSET_TERR; DMA_REGS->CHINTENCLR.reg = DMAC_CHINTENSET_TERR;
@ -179,7 +179,7 @@ static int dma_sam0_config(const struct device *dev, uint32_t channel,
/* Enable the interrupts */ /* Enable the interrupts */
chcfg->CHINTENSET.reg = DMAC_CHINTENSET_TCMPL; chcfg->CHINTENSET.reg = DMAC_CHINTENSET_TCMPL;
if (!config->error_callback_en) { if (!config->error_callback_dis) {
chcfg->CHINTENSET.reg = DMAC_CHINTENSET_TERR; chcfg->CHINTENSET.reg = DMAC_CHINTENSET_TERR;
} else { } else {
chcfg->CHINTENCLR.reg = DMAC_CHINTENSET_TERR; chcfg->CHINTENCLR.reg = DMAC_CHINTENSET_TERR;

View file

@ -264,7 +264,7 @@ static int sam_xdmac_config(const struct device *dev, uint32_t channel,
channel_cfg.dus = 0U; channel_cfg.dus = 0U;
channel_cfg.cie = channel_cfg.cie =
(cfg->complete_callback_en ? XDMAC_CIE_BIE : XDMAC_CIE_LIE) (cfg->complete_callback_en ? XDMAC_CIE_BIE : XDMAC_CIE_LIE)
| (cfg->error_callback_en ? XDMAC_INT_ERR : 0); | (cfg->error_callback_dis ? 0 : XDMAC_INT_ERR);
ret = sam_xdmac_channel_configure(dev, channel, &channel_cfg); ret = sam_xdmac_channel_configure(dev, channel, &channel_cfg);
if (ret < 0) { if (ret < 0) {

View file

@ -57,7 +57,7 @@ static void dma_handler(sedi_dma_t dma_device, int channel, int event_id,
(config->complete_callback_en)) { (config->complete_callback_en)) {
config->dma_callback(dev, config->user_data, config->dma_callback(dev, config->user_data,
channel, 0); channel, 0);
} else if (config->error_callback_en) { } else if (!config->error_callback_dis) {
config->dma_callback(dev, config->user_data, config->dma_callback(dev, config->user_data,
channel, event_id); channel, event_id);
} }

View file

@ -483,7 +483,7 @@ static int dma_smartbond_config(const struct device *dev, uint32_t channel, stru
} }
/* Error handling is not supported; just warn user. */ /* Error handling is not supported; just warn user. */
if (cfg->error_callback_en) { if (!cfg->error_callback_dis) {
LOG_WRN("Error handling is not supported"); LOG_WRN("Error handling is not supported");
} }

View file

@ -294,7 +294,7 @@ static int dma_xmc4xxx_config(const struct device *dev, uint32_t channel, struct
XMC_DMA_CH_EnableEvent(dma, channel, XMC_DMA_CH_EVENT_BLOCK_TRANSFER_COMPLETE); XMC_DMA_CH_EnableEvent(dma, channel, XMC_DMA_CH_EVENT_BLOCK_TRANSFER_COMPLETE);
} }
if (config->error_callback_en) { if (!config->error_callback_dis) {
XMC_DMA_CH_EnableEvent(dma, channel, XMC_DMA_CH_EVENT_ERROR); XMC_DMA_CH_EnableEvent(dma, channel, XMC_DMA_CH_EVENT_ERROR);
} }

View file

@ -124,7 +124,7 @@ int32_t i2c_dw_idma_rx_transfer(const struct device *dev)
dma_cfg.dma_callback = cb_i2c_idma_transfer; dma_cfg.dma_callback = cb_i2c_idma_transfer;
dma_cfg.user_data = (void *)dev; dma_cfg.user_data = (void *)dev;
dma_cfg.complete_callback_en = 0U; dma_cfg.complete_callback_en = 0U;
dma_cfg.error_callback_en = 1U; dma_cfg.error_callback_dis = 0U;
dma_cfg.block_count = 1U; dma_cfg.block_count = 1U;
dma_cfg.head_block = &dma_block_cfg; dma_cfg.head_block = &dma_block_cfg;
@ -172,7 +172,7 @@ int32_t i2c_dw_idma_tx_transfer(const struct device *dev,
dma_cfg.dma_callback = cb_i2c_idma_transfer; dma_cfg.dma_callback = cb_i2c_idma_transfer;
dma_cfg.user_data = (void *)dev; dma_cfg.user_data = (void *)dev;
dma_cfg.complete_callback_en = 0U; dma_cfg.complete_callback_en = 0U;
dma_cfg.error_callback_en = 1U; dma_cfg.error_callback_dis = 0U;
dma_cfg.block_count = 1U; dma_cfg.block_count = 1U;
dma_cfg.head_block = &dma_block_cfg; dma_cfg.head_block = &dma_block_cfg;

View file

@ -449,7 +449,7 @@ static void i2s_mcux_config_dma_blocks(const struct device *dev,
LOG_DBG("channel_direction is %d", stream->dma_cfg.channel_direction); LOG_DBG("channel_direction is %d", stream->dma_cfg.channel_direction);
LOG_DBG("complete_callback_en is %d", LOG_DBG("complete_callback_en is %d",
stream->dma_cfg.complete_callback_en); stream->dma_cfg.complete_callback_en);
LOG_DBG("error_callback_en is %d", stream->dma_cfg.error_callback_en); LOG_DBG("error_callback_dis is %d", stream->dma_cfg.error_callback_dis);
LOG_DBG("source_handshake is %d", stream->dma_cfg.source_handshake); LOG_DBG("source_handshake is %d", stream->dma_cfg.source_handshake);
LOG_DBG("dest_handshake is %d", stream->dma_cfg.dest_handshake); LOG_DBG("dest_handshake is %d", stream->dma_cfg.dest_handshake);
LOG_DBG("channel_priority is %d", stream->dma_cfg.channel_priority); LOG_DBG("channel_priority is %d", stream->dma_cfg.channel_priority);

View file

@ -1303,7 +1303,7 @@ static const struct i2s_driver_api i2s_mcux_driver_api = {
CONFIG_I2S_EDMA_BURST_SIZE, \ CONFIG_I2S_EDMA_BURST_SIZE, \
.dma_callback = i2s_dma_tx_callback, \ .dma_callback = i2s_dma_tx_callback, \
.complete_callback_en = 1, \ .complete_callback_en = 1, \
.error_callback_en = 1, \ .error_callback_dis = 1, \
.block_count = 1, \ .block_count = 1, \
.head_block = \ .head_block = \
&i2s_##i2s_id##_data.tx.dma_block, \ &i2s_##i2s_id##_data.tx.dma_block, \
@ -1323,7 +1323,7 @@ static const struct i2s_driver_api i2s_mcux_driver_api = {
CONFIG_I2S_EDMA_BURST_SIZE, \ CONFIG_I2S_EDMA_BURST_SIZE, \
.dma_callback = i2s_dma_rx_callback, \ .dma_callback = i2s_dma_rx_callback, \
.complete_callback_en = 1, \ .complete_callback_en = 1, \
.error_callback_en = 1, \ .error_callback_dis = 1, \
.block_count = 1, \ .block_count = 1, \
.head_block = \ .head_block = \
&i2s_##i2s_id##_data.rx.dma_block, \ &i2s_##i2s_id##_data.rx.dma_block, \

View file

@ -1144,7 +1144,7 @@ DT_INST_FOREACH_STATUS_OKAY(UART_MCUX_FLEXCOMM_RX_TIMEOUT_FUNC);
.source_data_size = 1, \ .source_data_size = 1, \
.dest_data_size = 1, \ .dest_data_size = 1, \
.complete_callback_en = 1, \ .complete_callback_en = 1, \
.error_callback_en = 1, \ .error_callback_dis = 1, \
.block_count = 1, \ .block_count = 1, \
.head_block = \ .head_block = \
&mcux_flexcomm_##n##_data.tx_data.active_block, \ &mcux_flexcomm_##n##_data.tx_data.active_block, \
@ -1165,7 +1165,7 @@ DT_INST_FOREACH_STATUS_OKAY(UART_MCUX_FLEXCOMM_RX_TIMEOUT_FUNC);
.source_data_size = 1, \ .source_data_size = 1, \
.dest_data_size = 1, \ .dest_data_size = 1, \
.complete_callback_en = 1, \ .complete_callback_en = 1, \
.error_callback_en = 1, \ .error_callback_dis = 1, \
.block_count = 1, \ .block_count = 1, \
.head_block = \ .head_block = \
&mcux_flexcomm_##n##_data.rx_data.active_block, \ &mcux_flexcomm_##n##_data.rx_data.active_block, \

View file

@ -1176,7 +1176,7 @@ static const struct uart_driver_api mcux_lpuart_driver_api = {
.source_data_size = 1, \ .source_data_size = 1, \
.dest_data_size = 1, \ .dest_data_size = 1, \
.complete_callback_en = 1, \ .complete_callback_en = 1, \
.error_callback_en = 1, \ .error_callback_dis = 0, \
.block_count = 1, \ .block_count = 1, \
.head_block = \ .head_block = \
&mcux_lpuart_##id##_data.async.tx_dma_params.active_dma_block, \ &mcux_lpuart_##id##_data.async.tx_dma_params.active_dma_block, \
@ -1199,7 +1199,7 @@ static const struct uart_driver_api mcux_lpuart_driver_api = {
.source_data_size = 1, \ .source_data_size = 1, \
.dest_data_size = 1, \ .dest_data_size = 1, \
.complete_callback_en = 1, \ .complete_callback_en = 1, \
.error_callback_en = 1, \ .error_callback_dis = 0, \
.block_count = 1, \ .block_count = 1, \
.head_block = \ .head_block = \
&mcux_lpuart_##id##_data.async.rx_dma_params.active_dma_block, \ &mcux_lpuart_##id##_data.async.rx_dma_params.active_dma_block, \

View file

@ -1862,7 +1862,7 @@ static const struct uart_driver_api uart_ns16550_driver_api = {
.source_data_size = 1, \ .source_data_size = 1, \
.dest_data_size = 1, \ .dest_data_size = 1, \
.complete_callback_en = 0, \ .complete_callback_en = 0, \
.error_callback_en = 1, \ .error_callback_dis = 1, \
.block_count = 1, \ .block_count = 1, \
.channel_direction = MEMORY_TO_PERIPHERAL, \ .channel_direction = MEMORY_TO_PERIPHERAL, \
.dma_slot = DT_INST_DMAS_CELL_BY_NAME(n, tx, channel), \ .dma_slot = DT_INST_DMAS_CELL_BY_NAME(n, tx, channel), \
@ -1881,7 +1881,7 @@ static const struct uart_driver_api uart_ns16550_driver_api = {
.source_data_size = 1, \ .source_data_size = 1, \
.dest_data_size = 1, \ .dest_data_size = 1, \
.complete_callback_en = 0, \ .complete_callback_en = 0, \
.error_callback_en = 1, \ .error_callback_dis = 1, \
.block_count = 1, \ .block_count = 1, \
.channel_direction = PERIPHERAL_TO_MEMORY, \ .channel_direction = PERIPHERAL_TO_MEMORY, \
.dma_slot = DT_INST_DMAS_CELL_BY_NAME(n, rx, channel), \ .dma_slot = DT_INST_DMAS_CELL_BY_NAME(n, rx, channel), \

View file

@ -887,7 +887,7 @@ static void spi_atcspi200_irq_handler(void *arg)
.channel_direction = ANDES_DMA_CONFIG_DIRECTION( \ .channel_direction = ANDES_DMA_CONFIG_DIRECTION( \
DMA_CHANNEL_CONFIG(index, dir)), \ DMA_CHANNEL_CONFIG(index, dir)), \
.complete_callback_en = 0, \ .complete_callback_en = 0, \
.error_callback_en = 0, \ .error_callback_dis = 0, \
.source_data_size = \ .source_data_size = \
ANDES_DMA_CONFIG_##src_dev##_DATA_SIZE( \ ANDES_DMA_CONFIG_##src_dev##_DATA_SIZE( \
DMA_CHANNEL_CONFIG(index, dir) \ DMA_CHANNEL_CONFIG(index, dir) \

View file

@ -836,7 +836,7 @@ static const struct spi_driver_api spi_mcux_driver_api = {
.dest_data_size = 4, \ .dest_data_size = 4, \
.dma_callback = dma_callback, \ .dma_callback = dma_callback, \
.complete_callback_en = 1, \ .complete_callback_en = 1, \
.error_callback_en = 1, \ .error_callback_dis = 0, \
.block_count = 1, \ .block_count = 1, \
.head_block = &spi_mcux_data_##id.tx_dma_block, \ .head_block = &spi_mcux_data_##id.tx_dma_block, \
.channel_direction = MEMORY_TO_PERIPHERAL, \ .channel_direction = MEMORY_TO_PERIPHERAL, \
@ -857,7 +857,7 @@ static const struct spi_driver_api spi_mcux_driver_api = {
.dest_data_size = 2, \ .dest_data_size = 2, \
.dma_callback = dma_callback, \ .dma_callback = dma_callback, \
.complete_callback_en = 1, \ .complete_callback_en = 1, \
.error_callback_en = 1, \ .error_callback_dis = 0, \
.block_count = \ .block_count = \
_UTIL_AND2(DT_INST_NODE_HAS_PROP( \ _UTIL_AND2(DT_INST_NODE_HAS_PROP( \
id, nxp_rx_tx_chn_share), 2), \ id, nxp_rx_tx_chn_share), 2), \

View file

@ -340,7 +340,6 @@ static int spi_sam_dma_txrx(const struct device *dev,
.source_burst_length = 1, .source_burst_length = 1,
.dest_burst_length = 1, .dest_burst_length = 1,
.complete_callback_en = true, .complete_callback_en = true,
.error_callback_en = true,
.dma_callback = NULL, .dma_callback = NULL,
.user_data = (void *)dev, .user_data = (void *)dev,
}; };
@ -373,7 +372,6 @@ static int spi_sam_dma_txrx(const struct device *dev,
.source_burst_length = 1, .source_burst_length = 1,
.dest_burst_length = 1, .dest_burst_length = 1,
.complete_callback_en = true, .complete_callback_en = true,
.error_callback_en = true,
.dma_callback = dma_callback, .dma_callback = dma_callback,
.user_data = (void *)dev, .user_data = (void *)dev,
}; };

View file

@ -217,12 +217,12 @@ struct dma_config {
*/ */
uint32_t complete_callback_en : 1; uint32_t complete_callback_en : 1;
/** /**
* Error callback enable * Error callback disable
* *
* - 0b0 error callback enabled * - 0b0 error callback enabled
* - 0b1 error callback disabled * - 0b1 error callback disabled
*/ */
uint32_t error_callback_en : 1; uint32_t error_callback_dis : 1;
/** /**
* Source handshake, HW specific * Source handshake, HW specific
* *

View file

@ -52,7 +52,7 @@ static int test_task(const struct device *dma, uint32_t chan_id, uint32_t blen)
dma_cfg.dest_burst_length = blen; dma_cfg.dest_burst_length = blen;
dma_cfg.dma_callback = test_done; dma_cfg.dma_callback = test_done;
dma_cfg.complete_callback_en = 0U; dma_cfg.complete_callback_en = 0U;
dma_cfg.error_callback_en = 1U; dma_cfg.error_callback_dis = 0U;
dma_cfg.block_count = 1U; dma_cfg.block_count = 1U;
dma_cfg.head_block = &dma_block_cfg; dma_cfg.head_block = &dma_block_cfg;
#ifdef CONFIG_DMA_MCUX_TEST_SLOT_START #ifdef CONFIG_DMA_MCUX_TEST_SLOT_START

View file

@ -71,7 +71,7 @@ static int test_task(int minor, int major)
dma_cfg.dest_burst_length = 16; dma_cfg.dest_burst_length = 16;
dma_cfg.dma_callback = test_done; dma_cfg.dma_callback = test_done;
dma_cfg.complete_callback_en = 0U; dma_cfg.complete_callback_en = 0U;
dma_cfg.error_callback_en = 1U; dma_cfg.error_callback_dis = 0U;
dma_cfg.block_count = 1U; dma_cfg.block_count = 1U;
dma_cfg.head_block = &dma_block_cfg; dma_cfg.head_block = &dma_block_cfg;
#ifdef CONFIG_DMA_MCUX_TEST_SLOT_START #ifdef CONFIG_DMA_MCUX_TEST_SLOT_START