Skip to content

Commit d5204c7

Browse files
Alexandre Bouninehnaz
authored andcommitted
rapidio/tsi721: add shutdown notification callback
Add device driver specific shutdown notification callback. Signed-off-by: Alexandre Bounine <alexandre.bounine@idt.com> Cc: Matt Porter <mporter@kernel.crashing.org> Cc: Aurelien Jacquiot <a-jacquiot@ti.com> Cc: Andre van Herk <andre.van.herk@prodrive-technologies.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent 0670726 commit d5204c7

File tree

3 files changed

+48
-0
lines changed

3 files changed

+48
-0
lines changed

drivers/rapidio/devices/tsi721.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2638,6 +2638,8 @@ static int tsi721_probe(struct pci_dev *pdev,
26382638
if (err)
26392639
goto err_free_consistent;
26402640

2641+
pci_set_drvdata(pdev, priv);
2642+
26412643
return 0;
26422644

26432645
err_free_consistent:
@@ -2660,6 +2662,18 @@ static int tsi721_probe(struct pci_dev *pdev,
26602662
return err;
26612663
}
26622664

2665+
static void tsi721_shutdown(struct pci_dev *pdev)
2666+
{
2667+
struct tsi721_device *priv = pci_get_drvdata(pdev);
2668+
2669+
dev_dbg(&pdev->dev, "RIO: %s\n", __func__);
2670+
2671+
tsi721_disable_ints(priv);
2672+
tsi721_dma_stop_all(priv);
2673+
pci_clear_master(pdev);
2674+
pci_disable_device(pdev);
2675+
}
2676+
26632677
static const struct pci_device_id tsi721_pci_tbl[] = {
26642678
{ PCI_DEVICE(PCI_VENDOR_ID_IDT, PCI_DEVICE_ID_TSI721) },
26652679
{ 0, } /* terminate list */
@@ -2671,6 +2685,7 @@ static struct pci_driver tsi721_driver = {
26712685
.name = "tsi721",
26722686
.id_table = tsi721_pci_tbl,
26732687
.probe = tsi721_probe,
2688+
.shutdown = tsi721_shutdown,
26742689
};
26752690

26762691
static int __init tsi721_init(void)

drivers/rapidio/devices/tsi721.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -866,6 +866,9 @@ struct tsi721_device {
866866
#ifdef CONFIG_RAPIDIO_DMA_ENGINE
867867
extern void tsi721_bdma_handler(struct tsi721_bdma_chan *bdma_chan);
868868
extern int tsi721_register_dma(struct tsi721_device *priv);
869+
extern void tsi721_dma_stop_all(struct tsi721_device *priv);
870+
#else
871+
#define tsi721_dma_stop_all(priv) do {} while (0)
869872
#endif
870873

871874
#endif

drivers/rapidio/devices/tsi721_dma.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -852,6 +852,36 @@ static int tsi721_terminate_all(struct dma_chan *dchan)
852852
return 0;
853853
}
854854

855+
static void tsi721_dma_stop(struct tsi721_bdma_chan *bdma_chan)
856+
{
857+
if (!bdma_chan->active)
858+
return;
859+
spin_lock_bh(&bdma_chan->lock);
860+
if (!tsi721_dma_is_idle(bdma_chan)) {
861+
int timeout = 100000;
862+
863+
/* stop the transfer in progress */
864+
iowrite32(TSI721_DMAC_CTL_SUSP,
865+
bdma_chan->regs + TSI721_DMAC_CTL);
866+
867+
/* Wait until DMA channel stops */
868+
while (!tsi721_dma_is_idle(bdma_chan) && --timeout)
869+
udelay(1);
870+
}
871+
872+
spin_unlock_bh(&bdma_chan->lock);
873+
}
874+
875+
void tsi721_dma_stop_all(struct tsi721_device *priv)
876+
{
877+
int i;
878+
879+
for (i = 0; i < TSI721_DMA_MAXCH; i++) {
880+
if (i != TSI721_DMACH_MAINT)
881+
tsi721_dma_stop(&priv->bdma[i]);
882+
}
883+
}
884+
855885
int tsi721_register_dma(struct tsi721_device *priv)
856886
{
857887
int i;

0 commit comments

Comments
 (0)