Skip to content

Commit dc3f595

Browse files
codrin989vinodkoul
authored andcommitted
dmaengine: at_xdmac: Fix wrongfull report of a channel as in use
atchan->status variable is used to store two different information: - pass channel interrupts status from interrupt handler to tasklet; - channel information like whether it is cyclic or paused; This causes a bug when device_terminate_all() is called, (AT_XDMAC_CHAN_IS_CYCLIC cleared on atchan->status) and then a late End of Block interrupt arrives (AT_XDMAC_CIS_BIS), which sets bit 0 of atchan->status. Bit 0 is also used for AT_XDMAC_CHAN_IS_CYCLIC, so when a new descriptor for a cyclic transfer is created, the driver reports the channel as in use: if (test_and_set_bit(AT_XDMAC_CHAN_IS_CYCLIC, &atchan->status)) { dev_err(chan2dev(chan), "channel currently used\n"); return NULL; } This patch fixes the bug by adding a different struct member to keep the interrupts status separated from the channel status bits. Fixes: e1f7c9e ("dmaengine: at_xdmac: creation of the atmel eXtended DMA Controller driver") Signed-off-by: Codrin Ciubotariu <codrin.ciubotariu@microchip.com> Acked-by: Ludovic Desroches <ludovic.desroches@microchip.com> Signed-off-by: Vinod Koul <vkoul@kernel.org>
1 parent bfeffd1 commit dc3f595

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

drivers/dma/at_xdmac.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ struct at_xdmac_chan {
203203
u32 save_cim;
204204
u32 save_cnda;
205205
u32 save_cndc;
206+
u32 irq_status;
206207
unsigned long status;
207208
struct tasklet_struct tasklet;
208209
struct dma_slave_config sconfig;
@@ -1580,24 +1581,24 @@ static void at_xdmac_tasklet(unsigned long data)
15801581
struct at_xdmac_desc *desc;
15811582
u32 error_mask;
15821583

1583-
dev_dbg(chan2dev(&atchan->chan), "%s: status=0x%08lx\n",
1584-
__func__, atchan->status);
1584+
dev_dbg(chan2dev(&atchan->chan), "%s: status=0x%08x\n",
1585+
__func__, atchan->irq_status);
15851586

15861587
error_mask = AT_XDMAC_CIS_RBEIS
15871588
| AT_XDMAC_CIS_WBEIS
15881589
| AT_XDMAC_CIS_ROIS;
15891590

15901591
if (at_xdmac_chan_is_cyclic(atchan)) {
15911592
at_xdmac_handle_cyclic(atchan);
1592-
} else if ((atchan->status & AT_XDMAC_CIS_LIS)
1593-
|| (atchan->status & error_mask)) {
1593+
} else if ((atchan->irq_status & AT_XDMAC_CIS_LIS)
1594+
|| (atchan->irq_status & error_mask)) {
15941595
struct dma_async_tx_descriptor *txd;
15951596

1596-
if (atchan->status & AT_XDMAC_CIS_RBEIS)
1597+
if (atchan->irq_status & AT_XDMAC_CIS_RBEIS)
15971598
dev_err(chan2dev(&atchan->chan), "read bus error!!!");
1598-
if (atchan->status & AT_XDMAC_CIS_WBEIS)
1599+
if (atchan->irq_status & AT_XDMAC_CIS_WBEIS)
15991600
dev_err(chan2dev(&atchan->chan), "write bus error!!!");
1600-
if (atchan->status & AT_XDMAC_CIS_ROIS)
1601+
if (atchan->irq_status & AT_XDMAC_CIS_ROIS)
16011602
dev_err(chan2dev(&atchan->chan), "request overflow error!!!");
16021603

16031604
spin_lock(&atchan->lock);
@@ -1652,7 +1653,7 @@ static irqreturn_t at_xdmac_interrupt(int irq, void *dev_id)
16521653
atchan = &atxdmac->chan[i];
16531654
chan_imr = at_xdmac_chan_read(atchan, AT_XDMAC_CIM);
16541655
chan_status = at_xdmac_chan_read(atchan, AT_XDMAC_CIS);
1655-
atchan->status = chan_status & chan_imr;
1656+
atchan->irq_status = chan_status & chan_imr;
16561657
dev_vdbg(atxdmac->dma.dev,
16571658
"%s: chan%d: imr=0x%x, status=0x%x\n",
16581659
__func__, i, chan_imr, chan_status);
@@ -1666,7 +1667,7 @@ static irqreturn_t at_xdmac_interrupt(int irq, void *dev_id)
16661667
at_xdmac_chan_read(atchan, AT_XDMAC_CDA),
16671668
at_xdmac_chan_read(atchan, AT_XDMAC_CUBC));
16681669

1669-
if (atchan->status & (AT_XDMAC_CIS_RBEIS | AT_XDMAC_CIS_WBEIS))
1670+
if (atchan->irq_status & (AT_XDMAC_CIS_RBEIS | AT_XDMAC_CIS_WBEIS))
16701671
at_xdmac_write(atxdmac, AT_XDMAC_GD, atchan->mask);
16711672

16721673
tasklet_schedule(&atchan->tasklet);

0 commit comments

Comments
 (0)