Skip to content

Commit e680b67

Browse files
Alexandre Bouninetorvalds
authored andcommitted
rapidio/tsi721_dma: fix synchronization issues
Fix synchronization issues found during testing using multiple DMA transfer requests to the same channel: - lost MSI-X interrupt notifications - non-synchronized attempts to start DMA channel HW resulting in error message from the driver - cookie tracking/update race conditions resulting in incorrect DMA transfer status report Signed-off-by: Alexandre Bounine <[email protected]> Reported-by: Barry Wood <[email protected]> Tested-by: Barry Wood <[email protected]> Cc: Matt Porter <[email protected]> Cc: Aurelien Jacquiot <[email protected]> Cc: Andre van Herk <[email protected]> Cc: Barry Wood <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 8347245 commit e680b67

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

drivers/rapidio/devices/tsi721_dma.c

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ static int tsi721_bdma_ch_init(struct tsi721_bdma_chan *bdma_chan, int bd_num)
8484
*/
8585
bd_ptr = dma_zalloc_coherent(dev,
8686
(bd_num + 1) * sizeof(struct tsi721_dma_desc),
87-
&bd_phys, GFP_KERNEL);
87+
&bd_phys, GFP_ATOMIC);
8888
if (!bd_ptr)
8989
return -ENOMEM;
9090

@@ -102,7 +102,7 @@ static int tsi721_bdma_ch_init(struct tsi721_bdma_chan *bdma_chan, int bd_num)
102102
sts_size = roundup_pow_of_two(sts_size);
103103
sts_ptr = dma_zalloc_coherent(dev,
104104
sts_size * sizeof(struct tsi721_dma_sts),
105-
&sts_phys, GFP_KERNEL);
105+
&sts_phys, GFP_ATOMIC);
106106
if (!sts_ptr) {
107107
/* Free space allocated for DMA descriptors */
108108
dma_free_coherent(dev,
@@ -297,7 +297,8 @@ static irqreturn_t tsi721_bdma_msix(int irq, void *ptr)
297297
{
298298
struct tsi721_bdma_chan *bdma_chan = ptr;
299299

300-
tsi721_bdma_handler(bdma_chan);
300+
if (bdma_chan->active)
301+
tasklet_schedule(&bdma_chan->tasklet);
301302
return IRQ_HANDLED;
302303
}
303304
#endif /* CONFIG_PCI_MSI */
@@ -618,14 +619,14 @@ static void tsi721_dma_tasklet(unsigned long data)
618619
}
619620
list_add(&desc->desc_node, &bdma_chan->free_list);
620621
bdma_chan->active_tx = NULL;
622+
tsi721_advance_work(bdma_chan, NULL);
621623
spin_unlock(&bdma_chan->lock);
622624
if (callback)
623625
callback(param);
624-
spin_lock(&bdma_chan->lock);
626+
} else {
627+
tsi721_advance_work(bdma_chan, bdma_chan->active_tx);
628+
spin_unlock(&bdma_chan->lock);
625629
}
626-
627-
tsi721_advance_work(bdma_chan, bdma_chan->active_tx);
628-
spin_unlock(&bdma_chan->lock);
629630
}
630631

631632
/* Re-Enable BDMA channel interrupts */
@@ -681,7 +682,7 @@ static int tsi721_alloc_chan_resources(struct dma_chan *dchan)
681682

682683
/* Allocate queue of transaction descriptors */
683684
desc = kcalloc(TSI721_DMA_TX_QUEUE_SZ, sizeof(struct tsi721_tx_desc),
684-
GFP_KERNEL);
685+
GFP_ATOMIC);
685686
if (!desc) {
686687
tsi_err(&dchan->dev->device,
687688
"DMAC%d Failed to allocate logical descriptors",
@@ -744,7 +745,13 @@ static
744745
enum dma_status tsi721_tx_status(struct dma_chan *dchan, dma_cookie_t cookie,
745746
struct dma_tx_state *txstate)
746747
{
747-
return dma_cookie_status(dchan, cookie, txstate);
748+
struct tsi721_bdma_chan *bdma_chan = to_tsi721_chan(dchan);
749+
enum dma_status status;
750+
751+
spin_lock_bh(&bdma_chan->lock);
752+
status = dma_cookie_status(dchan, cookie, txstate);
753+
spin_unlock_bh(&bdma_chan->lock);
754+
return status;
748755
}
749756

750757
static void tsi721_issue_pending(struct dma_chan *dchan)

0 commit comments

Comments
 (0)