Skip to content

Commit dabdb40

Browse files
Alexandre Bouninegregkh
authored andcommitted
rapidio/tsi721: fix tasklet termination in dma channel release
commit 04379df upstream. This patch is a modification of the patch originally proposed by Xiaotian Feng <xtfeng@gmail.com>: https://lkml.org/lkml/2012/11/5/413 This new version disables DMA channel interrupts and ensures that the tasklet wil not be scheduled again before calling tasklet_kill(). Unfortunately the updated patch was not released at that time due to planned rework of Tsi721 mport driver to use threaded interrupts (which has yet to happen). Recently the issue was reported again: https://lkml.org/lkml/2014/2/19/762. Description from the original Xiaotian's patch: "Some drivers use tasklet_disable in device remove/release process, tasklet_disable will inc tasklet->count and return. If the tasklet is not handled yet under some softirq pressure, the tasklet will be placed on the tasklet_vec, never have a chance to be excuted. This might lead to a heavy loaded ksoftirqd, wakeup with pending_softirq, but tasklet is disabled. tasklet_kill should be used in this case." This patch is applicable to kernel versions starting from v3.5. Signed-off-by: Alexandre Bounine <alexandre.bounine@idt.com> Cc: Matt Porter <mporter@kernel.crashing.org> Cc: Xiaotian Feng <xtfeng@gmail.com> Reviewed-by: Thomas Gleixner <tglx@linutronix.de> Cc: Mike Galbraith <bitbucket@online.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 84bb5b6 commit dabdb40

2 files changed

Lines changed: 19 additions & 9 deletions

File tree

‎drivers/rapidio/devices/tsi721.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -678,6 +678,7 @@ struct tsi721_bdma_chan {
678678
struct list_head free_list;
679679
dma_cookie_t completed_cookie;
680680
struct tasklet_struct tasklet;
681+
bool active;
681682
};
682683

683684
#endif /* CONFIG_RAPIDIO_DMA_ENGINE */

‎drivers/rapidio/devices/tsi721_dma.c‎

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,8 @@ void tsi721_bdma_handler(struct tsi721_bdma_chan *bdma_chan)
206206
{
207207
/* Disable BDMA channel interrupts */
208208
iowrite32(0, bdma_chan->regs + TSI721_DMAC_INTE);
209-
210-
tasklet_schedule(&bdma_chan->tasklet);
209+
if (bdma_chan->active)
210+
tasklet_schedule(&bdma_chan->tasklet);
211211
}
212212

213213
#ifdef CONFIG_PCI_MSI
@@ -562,7 +562,7 @@ static int tsi721_alloc_chan_resources(struct dma_chan *dchan)
562562
}
563563
#endif /* CONFIG_PCI_MSI */
564564

565-
tasklet_enable(&bdma_chan->tasklet);
565+
bdma_chan->active = true;
566566
tsi721_bdma_interrupt_enable(bdma_chan, 1);
567567

568568
return bdma_chan->bd_num - 1;
@@ -576,9 +576,7 @@ static int tsi721_alloc_chan_resources(struct dma_chan *dchan)
576576
static void tsi721_free_chan_resources(struct dma_chan *dchan)
577577
{
578578
struct tsi721_bdma_chan *bdma_chan = to_tsi721_chan(dchan);
579-
#ifdef CONFIG_PCI_MSI
580579
struct tsi721_device *priv = to_tsi721(dchan->device);
581-
#endif
582580
LIST_HEAD(list);
583581

584582
dev_dbg(dchan->device->dev, "%s: Entry\n", __func__);
@@ -589,14 +587,25 @@ static void tsi721_free_chan_resources(struct dma_chan *dchan)
589587
BUG_ON(!list_empty(&bdma_chan->active_list));
590588
BUG_ON(!list_empty(&bdma_chan->queue));
591589

592-
tasklet_disable(&bdma_chan->tasklet);
590+
tsi721_bdma_interrupt_enable(bdma_chan, 0);
591+
bdma_chan->active = false;
592+
593+
#ifdef CONFIG_PCI_MSI
594+
if (priv->flags & TSI721_USING_MSIX) {
595+
synchronize_irq(priv->msix[TSI721_VECT_DMA0_DONE +
596+
bdma_chan->id].vector);
597+
synchronize_irq(priv->msix[TSI721_VECT_DMA0_INT +
598+
bdma_chan->id].vector);
599+
} else
600+
#endif
601+
synchronize_irq(priv->pdev->irq);
602+
603+
tasklet_kill(&bdma_chan->tasklet);
593604

594605
spin_lock_bh(&bdma_chan->lock);
595606
list_splice_init(&bdma_chan->free_list, &list);
596607
spin_unlock_bh(&bdma_chan->lock);
597608

598-
tsi721_bdma_interrupt_enable(bdma_chan, 0);
599-
600609
#ifdef CONFIG_PCI_MSI
601610
if (priv->flags & TSI721_USING_MSIX) {
602611
free_irq(priv->msix[TSI721_VECT_DMA0_DONE +
@@ -790,6 +799,7 @@ int tsi721_register_dma(struct tsi721_device *priv)
790799
bdma_chan->dchan.cookie = 1;
791800
bdma_chan->dchan.chan_id = i;
792801
bdma_chan->id = i;
802+
bdma_chan->active = false;
793803

794804
spin_lock_init(&bdma_chan->lock);
795805

@@ -799,7 +809,6 @@ int tsi721_register_dma(struct tsi721_device *priv)
799809

800810
tasklet_init(&bdma_chan->tasklet, tsi721_dma_tasklet,
801811
(unsigned long)bdma_chan);
802-
tasklet_disable(&bdma_chan->tasklet);
803812
list_add_tail(&bdma_chan->dchan.device_node,
804813
&mport->dma.channels);
805814
}

0 commit comments

Comments
 (0)