Skip to content

Commit e9fd49f

Browse files
talih0nashif
authored andcommitted
drivers: dma_xmc4xxx: Clear request before callback when overrun happens
If an overrun happens the user may decide to stop the dma which unsets the DMA line. Currently, the line is always re-enabled after the callback. Switch the order around to fix the problem. Also, always reset the line even if the user doesn't provide a callback. Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
1 parent 30c96a9 commit e9fd49f

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

drivers/dma/dma_xmc4xxx.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,19 +101,21 @@ static void dma_xmc4xxx_isr(const struct device *dev)
101101
struct dma_xmc4xxx_channel *dma_channel;
102102

103103
dma_channel = &dev_data->channels[i];
104-
if (dma_channel->cb && dma_channel->dlr_line != DLR_LINE_UNSET &&
104+
if (dma_channel->dlr_line != DLR_LINE_UNSET &&
105105
sr_overruns & BIT(dma_channel->dlr_line)) {
106106

107-
LOG_ERR("Overruns detected on channel %d", i);
108-
dma_channel->cb(dev, dma_channel->user_data, i, -EIO);
109-
110107
/* From XMC4700/4800 reference documentation - Section 4.4.1 */
111108
/* Once the overrun condition is entered the user can clear the */
112109
/* overrun status bits by writing to the DLR_OVRCLR register. */
113110
/* Additionally the pending request must be reset by successively */
114111
/* disabling and enabling the respective line. */
115112
DLR->LNEN &= ~BIT(dma_channel->dlr_line);
116113
DLR->LNEN |= BIT(dma_channel->dlr_line);
114+
115+
LOG_ERR("Overruns detected on channel %d", i);
116+
if (dma_channel->cb != NULL) {
117+
dma_channel->cb(dev, dma_channel->user_data, i, -EIO);
118+
}
117119
}
118120
}
119121
}

0 commit comments

Comments
 (0)