dmaengine: at_xdmac: Fix wrongfull report of a channel as in use
[ Upstream commitdc3f595b66
] 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:e1f7c9eee7
("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> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
4560637bde
commit
86785a1681
@ -203,6 +203,7 @@ struct at_xdmac_chan {
|
|||||||
u32 save_cim;
|
u32 save_cim;
|
||||||
u32 save_cnda;
|
u32 save_cnda;
|
||||||
u32 save_cndc;
|
u32 save_cndc;
|
||||||
|
u32 irq_status;
|
||||||
unsigned long status;
|
unsigned long status;
|
||||||
struct tasklet_struct tasklet;
|
struct tasklet_struct tasklet;
|
||||||
struct dma_slave_config sconfig;
|
struct dma_slave_config sconfig;
|
||||||
@ -1582,8 +1583,8 @@ static void at_xdmac_tasklet(unsigned long data)
|
|||||||
struct at_xdmac_desc *desc;
|
struct at_xdmac_desc *desc;
|
||||||
u32 error_mask;
|
u32 error_mask;
|
||||||
|
|
||||||
dev_dbg(chan2dev(&atchan->chan), "%s: status=0x%08lx\n",
|
dev_dbg(chan2dev(&atchan->chan), "%s: status=0x%08x\n",
|
||||||
__func__, atchan->status);
|
__func__, atchan->irq_status);
|
||||||
|
|
||||||
error_mask = AT_XDMAC_CIS_RBEIS
|
error_mask = AT_XDMAC_CIS_RBEIS
|
||||||
| AT_XDMAC_CIS_WBEIS
|
| AT_XDMAC_CIS_WBEIS
|
||||||
@ -1591,15 +1592,15 @@ static void at_xdmac_tasklet(unsigned long data)
|
|||||||
|
|
||||||
if (at_xdmac_chan_is_cyclic(atchan)) {
|
if (at_xdmac_chan_is_cyclic(atchan)) {
|
||||||
at_xdmac_handle_cyclic(atchan);
|
at_xdmac_handle_cyclic(atchan);
|
||||||
} else if ((atchan->status & AT_XDMAC_CIS_LIS)
|
} else if ((atchan->irq_status & AT_XDMAC_CIS_LIS)
|
||||||
|| (atchan->status & error_mask)) {
|
|| (atchan->irq_status & error_mask)) {
|
||||||
struct dma_async_tx_descriptor *txd;
|
struct dma_async_tx_descriptor *txd;
|
||||||
|
|
||||||
if (atchan->status & AT_XDMAC_CIS_RBEIS)
|
if (atchan->irq_status & AT_XDMAC_CIS_RBEIS)
|
||||||
dev_err(chan2dev(&atchan->chan), "read bus error!!!");
|
dev_err(chan2dev(&atchan->chan), "read bus error!!!");
|
||||||
if (atchan->status & AT_XDMAC_CIS_WBEIS)
|
if (atchan->irq_status & AT_XDMAC_CIS_WBEIS)
|
||||||
dev_err(chan2dev(&atchan->chan), "write bus error!!!");
|
dev_err(chan2dev(&atchan->chan), "write bus error!!!");
|
||||||
if (atchan->status & AT_XDMAC_CIS_ROIS)
|
if (atchan->irq_status & AT_XDMAC_CIS_ROIS)
|
||||||
dev_err(chan2dev(&atchan->chan), "request overflow error!!!");
|
dev_err(chan2dev(&atchan->chan), "request overflow error!!!");
|
||||||
|
|
||||||
spin_lock_bh(&atchan->lock);
|
spin_lock_bh(&atchan->lock);
|
||||||
@ -1654,7 +1655,7 @@ static irqreturn_t at_xdmac_interrupt(int irq, void *dev_id)
|
|||||||
atchan = &atxdmac->chan[i];
|
atchan = &atxdmac->chan[i];
|
||||||
chan_imr = at_xdmac_chan_read(atchan, AT_XDMAC_CIM);
|
chan_imr = at_xdmac_chan_read(atchan, AT_XDMAC_CIM);
|
||||||
chan_status = at_xdmac_chan_read(atchan, AT_XDMAC_CIS);
|
chan_status = at_xdmac_chan_read(atchan, AT_XDMAC_CIS);
|
||||||
atchan->status = chan_status & chan_imr;
|
atchan->irq_status = chan_status & chan_imr;
|
||||||
dev_vdbg(atxdmac->dma.dev,
|
dev_vdbg(atxdmac->dma.dev,
|
||||||
"%s: chan%d: imr=0x%x, status=0x%x\n",
|
"%s: chan%d: imr=0x%x, status=0x%x\n",
|
||||||
__func__, i, chan_imr, chan_status);
|
__func__, i, chan_imr, chan_status);
|
||||||
@ -1668,7 +1669,7 @@ static irqreturn_t at_xdmac_interrupt(int irq, void *dev_id)
|
|||||||
at_xdmac_chan_read(atchan, AT_XDMAC_CDA),
|
at_xdmac_chan_read(atchan, AT_XDMAC_CDA),
|
||||||
at_xdmac_chan_read(atchan, AT_XDMAC_CUBC));
|
at_xdmac_chan_read(atchan, AT_XDMAC_CUBC));
|
||||||
|
|
||||||
if (atchan->status & (AT_XDMAC_CIS_RBEIS | AT_XDMAC_CIS_WBEIS))
|
if (atchan->irq_status & (AT_XDMAC_CIS_RBEIS | AT_XDMAC_CIS_WBEIS))
|
||||||
at_xdmac_write(atxdmac, AT_XDMAC_GD, atchan->mask);
|
at_xdmac_write(atxdmac, AT_XDMAC_GD, atchan->mask);
|
||||||
|
|
||||||
tasklet_schedule(&atchan->tasklet);
|
tasklet_schedule(&atchan->tasklet);
|
||||||
|
Reference in New Issue
Block a user