Skip to content

Commit 0f48f92

Browse files
granquetSasha Levin
authored andcommitted
dmaengine: mediatek: do not issue a new desc if one is still current
[ Upstream commit 2537b40 ] Avoid issuing a new desc if one is still being processed as this can lead to some desc never being marked as completed. Signed-off-by: Guillaume Ranquet <granquet@baylibre.com> Link: https://lore.kernel.org/r/20210513192642.29446-3-granquet@baylibre.com Signed-off-by: Vinod Koul <vkoul@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 63fa5b2 commit 0f48f92

1 file changed

Lines changed: 12 additions & 8 deletions

File tree

‎drivers/dma/mediatek/mtk-uart-apdma.c‎

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -204,14 +204,9 @@ static void mtk_uart_apdma_start_rx(struct mtk_chan *c)
204204

205205
static void mtk_uart_apdma_tx_handler(struct mtk_chan *c)
206206
{
207-
struct mtk_uart_apdma_desc *d = c->desc;
208-
209207
mtk_uart_apdma_write(c, VFF_INT_FLAG, VFF_TX_INT_CLR_B);
210208
mtk_uart_apdma_write(c, VFF_INT_EN, VFF_INT_EN_CLR_B);
211209
mtk_uart_apdma_write(c, VFF_EN, VFF_EN_CLR_B);
212-
213-
list_del(&d->vd.node);
214-
vchan_cookie_complete(&d->vd);
215210
}
216211

217212
static void mtk_uart_apdma_rx_handler(struct mtk_chan *c)
@@ -242,9 +237,17 @@ static void mtk_uart_apdma_rx_handler(struct mtk_chan *c)
242237

243238
c->rx_status = d->avail_len - cnt;
244239
mtk_uart_apdma_write(c, VFF_RPT, wg);
240+
}
245241

246-
list_del(&d->vd.node);
247-
vchan_cookie_complete(&d->vd);
242+
static void mtk_uart_apdma_chan_complete_handler(struct mtk_chan *c)
243+
{
244+
struct mtk_uart_apdma_desc *d = c->desc;
245+
246+
if (d) {
247+
list_del(&d->vd.node);
248+
vchan_cookie_complete(&d->vd);
249+
c->desc = NULL;
250+
}
248251
}
249252

250253
static irqreturn_t mtk_uart_apdma_irq_handler(int irq, void *dev_id)
@@ -258,6 +261,7 @@ static irqreturn_t mtk_uart_apdma_irq_handler(int irq, void *dev_id)
258261
mtk_uart_apdma_rx_handler(c);
259262
else if (c->dir == DMA_MEM_TO_DEV)
260263
mtk_uart_apdma_tx_handler(c);
264+
mtk_uart_apdma_chan_complete_handler(c);
261265
spin_unlock_irqrestore(&c->vc.lock, flags);
262266

263267
return IRQ_HANDLED;
@@ -363,7 +367,7 @@ static void mtk_uart_apdma_issue_pending(struct dma_chan *chan)
363367
unsigned long flags;
364368

365369
spin_lock_irqsave(&c->vc.lock, flags);
366-
if (vchan_issue_pending(&c->vc)) {
370+
if (vchan_issue_pending(&c->vc) && !c->desc) {
367371
vd = vchan_next_desc(&c->vc);
368372
c->desc = to_mtk_uart_apdma_desc(&vd->tx);
369373

0 commit comments

Comments
 (0)