Skip to content

Commit a61210c

Browse files
ambarusvinodkoul
authored andcommitted
dmaengine: at_xdmac: Remove a level of indentation in at_xdmac_tasklet()
Apart of making the code easier to read, this patch is a prerequisite for a functional change: 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. atchan->irq_status will be protected in a further patch. Signed-off-by: Tudor Ambarus <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]>
1 parent 912f7c6 commit a61210c

File tree

1 file changed

+34
-36
lines changed

1 file changed

+34
-36
lines changed

drivers/dma/at_xdmac.c

Lines changed: 34 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1667,53 +1667,51 @@ static void at_xdmac_tasklet(struct tasklet_struct *t)
16671667
{
16681668
struct at_xdmac_chan *atchan = from_tasklet(atchan, t, tasklet);
16691669
struct at_xdmac_desc *desc;
1670+
struct dma_async_tx_descriptor *txd;
16701671
u32 error_mask;
16711672

16721673
dev_dbg(chan2dev(&atchan->chan), "%s: status=0x%08x\n",
16731674
__func__, atchan->irq_status);
16741675

1675-
error_mask = AT_XDMAC_CIS_RBEIS
1676-
| AT_XDMAC_CIS_WBEIS
1677-
| AT_XDMAC_CIS_ROIS;
1678-
1679-
if (at_xdmac_chan_is_cyclic(atchan)) {
1680-
at_xdmac_handle_cyclic(atchan);
1681-
} else if ((atchan->irq_status & AT_XDMAC_CIS_LIS)
1682-
|| (atchan->irq_status & error_mask)) {
1683-
struct dma_async_tx_descriptor *txd;
1684-
1685-
if (atchan->irq_status & error_mask)
1686-
at_xdmac_handle_error(atchan);
1687-
1688-
spin_lock_irq(&atchan->lock);
1689-
desc = list_first_entry(&atchan->xfers_list,
1690-
struct at_xdmac_desc,
1691-
xfer_node);
1692-
dev_vdbg(chan2dev(&atchan->chan), "%s: desc 0x%p\n", __func__, desc);
1693-
if (!desc->active_xfer) {
1694-
dev_err(chan2dev(&atchan->chan), "Xfer not active: exiting");
1695-
spin_unlock_irq(&atchan->lock);
1696-
return;
1697-
}
1676+
if (at_xdmac_chan_is_cyclic(atchan))
1677+
return at_xdmac_handle_cyclic(atchan);
16981678

1699-
txd = &desc->tx_dma_desc;
1700-
dma_cookie_complete(txd);
1701-
/* Remove the transfer from the transfer list. */
1702-
list_del(&desc->xfer_node);
1703-
spin_unlock_irq(&atchan->lock);
1679+
error_mask = AT_XDMAC_CIS_RBEIS | AT_XDMAC_CIS_WBEIS |
1680+
AT_XDMAC_CIS_ROIS;
17041681

1705-
if (txd->flags & DMA_PREP_INTERRUPT)
1706-
dmaengine_desc_get_callback_invoke(txd, NULL);
1682+
if (!(atchan->irq_status & AT_XDMAC_CIS_LIS) &&
1683+
!(atchan->irq_status & error_mask))
1684+
return;
17071685

1708-
dma_run_dependencies(txd);
1686+
if (atchan->irq_status & error_mask)
1687+
at_xdmac_handle_error(atchan);
17091688

1710-
spin_lock_irq(&atchan->lock);
1711-
/* Move the xfer descriptors into the free descriptors list. */
1712-
list_splice_tail_init(&desc->descs_list,
1713-
&atchan->free_descs_list);
1714-
at_xdmac_advance_work(atchan);
1689+
spin_lock_irq(&atchan->lock);
1690+
desc = list_first_entry(&atchan->xfers_list, struct at_xdmac_desc,
1691+
xfer_node);
1692+
dev_vdbg(chan2dev(&atchan->chan), "%s: desc 0x%p\n", __func__, desc);
1693+
if (!desc->active_xfer) {
1694+
dev_err(chan2dev(&atchan->chan), "Xfer not active: exiting");
17151695
spin_unlock_irq(&atchan->lock);
1696+
return;
17161697
}
1698+
1699+
txd = &desc->tx_dma_desc;
1700+
dma_cookie_complete(txd);
1701+
/* Remove the transfer from the transfer list. */
1702+
list_del(&desc->xfer_node);
1703+
spin_unlock_irq(&atchan->lock);
1704+
1705+
if (txd->flags & DMA_PREP_INTERRUPT)
1706+
dmaengine_desc_get_callback_invoke(txd, NULL);
1707+
1708+
dma_run_dependencies(txd);
1709+
1710+
spin_lock_irq(&atchan->lock);
1711+
/* Move the xfer descriptors into the free descriptors list. */
1712+
list_splice_tail_init(&desc->descs_list, &atchan->free_descs_list);
1713+
at_xdmac_advance_work(atchan);
1714+
spin_unlock_irq(&atchan->lock);
17171715
}
17181716

17191717
static irqreturn_t at_xdmac_interrupt(int irq, void *dev_id)

0 commit comments

Comments
 (0)