Skip to content

Commit e77e561

Browse files
ambarusvinodkoul
authored andcommitted
dmaengine: at_xdmac: Fix race over irq_status
Tasklets run with interrupts enabled, so we need to protect atchan->irq_status with spin_lock_irq() otherwise the tasklet can be interrupted by the IRQ that modifies irq_status. Move the dev_dbg that prints the irq_status in at_xdmac_handle_cyclic() and lower in at_xdmac_tasklet() where the IRQ is disabled. Signed-off-by: Tudor Ambarus <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]>
1 parent a61210c commit e77e561

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

drivers/dma/at_xdmac.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1611,6 +1611,8 @@ static void at_xdmac_handle_cyclic(struct at_xdmac_chan *atchan)
16111611
struct dma_async_tx_descriptor *txd;
16121612

16131613
spin_lock_irq(&atchan->lock);
1614+
dev_dbg(chan2dev(&atchan->chan), "%s: status=0x%08x\n",
1615+
__func__, atchan->irq_status);
16141616
if (list_empty(&atchan->xfers_list)) {
16151617
spin_unlock_irq(&atchan->lock);
16161618
return;
@@ -1623,6 +1625,7 @@ static void at_xdmac_handle_cyclic(struct at_xdmac_chan *atchan)
16231625
dmaengine_desc_get_callback_invoke(txd, NULL);
16241626
}
16251627

1628+
/* Called with atchan->lock held. */
16261629
static void at_xdmac_handle_error(struct at_xdmac_chan *atchan)
16271630
{
16281631
struct at_xdmac *atxdmac = to_at_xdmac(atchan->chan.device);
@@ -1641,8 +1644,6 @@ static void at_xdmac_handle_error(struct at_xdmac_chan *atchan)
16411644
if (atchan->irq_status & AT_XDMAC_CIS_ROIS)
16421645
dev_err(chan2dev(&atchan->chan), "request overflow error!!!");
16431646

1644-
spin_lock_irq(&atchan->lock);
1645-
16461647
/* Channel must be disabled first as it's not done automatically */
16471648
at_xdmac_write(atxdmac, AT_XDMAC_GD, atchan->mask);
16481649
while (at_xdmac_read(atxdmac, AT_XDMAC_GS) & atchan->mask)
@@ -1652,8 +1653,6 @@ static void at_xdmac_handle_error(struct at_xdmac_chan *atchan)
16521653
struct at_xdmac_desc,
16531654
xfer_node);
16541655

1655-
spin_unlock_irq(&atchan->lock);
1656-
16571656
/* Print bad descriptor's details if needed */
16581657
dev_dbg(chan2dev(&atchan->chan),
16591658
"%s: lld: mbr_sa=%pad, mbr_da=%pad, mbr_ubc=0x%08x\n",
@@ -1670,23 +1669,24 @@ static void at_xdmac_tasklet(struct tasklet_struct *t)
16701669
struct dma_async_tx_descriptor *txd;
16711670
u32 error_mask;
16721671

1673-
dev_dbg(chan2dev(&atchan->chan), "%s: status=0x%08x\n",
1674-
__func__, atchan->irq_status);
1675-
16761672
if (at_xdmac_chan_is_cyclic(atchan))
16771673
return at_xdmac_handle_cyclic(atchan);
16781674

16791675
error_mask = AT_XDMAC_CIS_RBEIS | AT_XDMAC_CIS_WBEIS |
16801676
AT_XDMAC_CIS_ROIS;
16811677

1678+
spin_lock_irq(&atchan->lock);
1679+
1680+
dev_dbg(chan2dev(&atchan->chan), "%s: status=0x%08x\n",
1681+
__func__, atchan->irq_status);
1682+
16821683
if (!(atchan->irq_status & AT_XDMAC_CIS_LIS) &&
16831684
!(atchan->irq_status & error_mask))
16841685
return;
16851686

16861687
if (atchan->irq_status & error_mask)
16871688
at_xdmac_handle_error(atchan);
16881689

1689-
spin_lock_irq(&atchan->lock);
16901690
desc = list_first_entry(&atchan->xfers_list, struct at_xdmac_desc,
16911691
xfer_node);
16921692
dev_vdbg(chan2dev(&atchan->chan), "%s: desc 0x%p\n", __func__, desc);

0 commit comments

Comments
 (0)