Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1328158

[PATCH 10/30] rapidio/tsi721: add shutdown notification callback

From Alexandre Bounine <alexandre.bounine@idt.com>
Newsgroups linux.kernel
Subject [PATCH 10/30] rapidio/tsi721: add shutdown notification callback
Date 2016-02-06 00:40 +0100
Message-ID <qYY8P-75F-39@gated-at.bofh.it> (permalink)
References <qYXZ7-6YG-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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>
Cc: linux-kernel@vger.kernel.org
---
 drivers/rapidio/devices/tsi721.c     |   15 +++++++++++++++
 drivers/rapidio/devices/tsi721.h     |    3 +++
 drivers/rapidio/devices/tsi721_dma.c |   30 ++++++++++++++++++++++++++++++
 3 files changed, 48 insertions(+), 0 deletions(-)

diff --git a/drivers/rapidio/devices/tsi721.c b/drivers/rapidio/devices/tsi721.c
index cd40f0f..1fc9663 100644
--- a/drivers/rapidio/devices/tsi721.c
+++ b/drivers/rapidio/devices/tsi721.c
@@ -2638,6 +2638,8 @@ static int tsi721_probe(struct pci_dev *pdev,
 	if (err)
 		goto err_free_consistent;
 
+	pci_set_drvdata(pdev, priv);
+
 	return 0;
 
 err_free_consistent:
@@ -2660,6 +2662,18 @@ err_exit:
 	return err;
 }
 
+static void tsi721_shutdown(struct pci_dev *pdev)
+{
+	struct tsi721_device *priv = pci_get_drvdata(pdev);
+
+	dev_dbg(&pdev->dev, "RIO: %s\n", __func__);
+
+	tsi721_disable_ints(priv);
+	tsi721_dma_stop_all(priv);
+	pci_clear_master(pdev);
+	pci_disable_device(pdev);
+}
+
 static const struct pci_device_id tsi721_pci_tbl[] = {
 	{ PCI_DEVICE(PCI_VENDOR_ID_IDT, PCI_DEVICE_ID_TSI721) },
 	{ 0, }	/* terminate list */
@@ -2671,6 +2685,7 @@ static struct pci_driver tsi721_driver = {
 	.name		= "tsi721",
 	.id_table	= tsi721_pci_tbl,
 	.probe		= tsi721_probe,
+	.shutdown	= tsi721_shutdown,
 };
 
 static int __init tsi721_init(void)
diff --git a/drivers/rapidio/devices/tsi721.h b/drivers/rapidio/devices/tsi721.h
index d675a44..ce2fb11 100644
--- a/drivers/rapidio/devices/tsi721.h
+++ b/drivers/rapidio/devices/tsi721.h
@@ -866,6 +866,9 @@ struct tsi721_device {
 #ifdef CONFIG_RAPIDIO_DMA_ENGINE
 extern void tsi721_bdma_handler(struct tsi721_bdma_chan *bdma_chan);
 extern int tsi721_register_dma(struct tsi721_device *priv);
+extern void tsi721_dma_stop_all(struct tsi721_device *priv);
+#else
+#define tsi721_dma_stop_all(priv) do {} while (0)
 #endif
 
 #endif
diff --git a/drivers/rapidio/devices/tsi721_dma.c b/drivers/rapidio/devices/tsi721_dma.c
index 500e1e0..b490ec3 100644
--- a/drivers/rapidio/devices/tsi721_dma.c
+++ b/drivers/rapidio/devices/tsi721_dma.c
@@ -852,6 +852,36 @@ static int tsi721_terminate_all(struct dma_chan *dchan)
 	return 0;
 }
 
+static void tsi721_dma_stop(struct tsi721_bdma_chan *bdma_chan)
+{
+	if (!bdma_chan->active)
+		return;
+	spin_lock_bh(&bdma_chan->lock);
+	if (!tsi721_dma_is_idle(bdma_chan)) {
+		int timeout = 100000;
+
+		/* stop the transfer in progress */
+		iowrite32(TSI721_DMAC_CTL_SUSP,
+			  bdma_chan->regs + TSI721_DMAC_CTL);
+
+		/* Wait until DMA channel stops */
+		while (!tsi721_dma_is_idle(bdma_chan) && --timeout)
+			udelay(1);
+	}
+
+	spin_unlock_bh(&bdma_chan->lock);
+}
+
+void tsi721_dma_stop_all(struct tsi721_device *priv)
+{
+	int i;
+
+	for (i = 0; i < TSI721_DMA_MAXCH; i++) {
+		if (i != TSI721_DMACH_MAINT)
+			tsi721_dma_stop(&priv->bdma[i]);
+	}
+}
+
 int tsi721_register_dma(struct tsi721_device *priv)
 {
 	int i;
-- 
1.7.8.4

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 00/30] rapidio: mport character driver and subsystem updates Alexandre Bounine <alexandre.bounine@idt.com> - 2016-02-06 00:40 +0100
  [PATCH 23/30] rapidio/tsi721: fix locking in OB_MSG processing Alexandre Bounine <alexandre.bounine@idt.com> - 2016-02-06 00:40 +0100
  [PATCH 12/30] rapidio: rework common RIO device add/delete routines Alexandre Bounine <alexandre.bounine@idt.com> - 2016-02-06 00:40 +0100
  [PATCH 03/30] rapidio/tsi721: fix hardcoded MRRS setting Alexandre Bounine <alexandre.bounine@idt.com> - 2016-02-06 00:40 +0100
  [PATCH 17/30] rapidio/rionet: add locking into add/remove device Alexandre Bounine <alexandre.bounine@idt.com> - 2016-02-06 00:40 +0100
  [PATCH 08/30] rapidio/tsi721: add query_mport callback Alexandre Bounine <alexandre.bounine@idt.com> - 2016-02-06 00:40 +0100
  [PATCH 06/30] rapidio/tsi721_dma: fix pending transaction queue handling Alexandre Bounine <alexandre.bounine@idt.com> - 2016-02-06 00:40 +0100
  [PATCH 11/30] rapidio/rionet: add shutdown event handling Alexandre Bounine <alexandre.bounine@idt.com> - 2016-02-06 00:40 +0100
  [PATCH 02/30] rapidio/rionet: add capability to change MTU Alexandre Bounine <alexandre.bounine@idt.com> - 2016-02-06 00:40 +0100
  [PATCH 10/30] rapidio/tsi721: add shutdown notification callback Alexandre Bounine <alexandre.bounine@idt.com> - 2016-02-06 00:40 +0100
  [PATCH 04/30] rapidio/tsi721: add check for overlapped IB window mappings Alexandre Bounine <alexandre.bounine@idt.com> - 2016-02-06 00:40 +0100
  [PATCH 19/30] rapidio: add lock protection for doorbell list Alexandre Bounine <alexandre.bounine@idt.com> - 2016-02-06 00:40 +0100
  [PATCH 25/30] rapidio/tsi721: add outbound windows mapping support Alexandre Bounine <alexandre.bounine@idt.com> - 2016-02-06 00:40 +0100
  [PATCH 24/30] rapidio: add outbound window support Alexandre Bounine <alexandre.bounine@idt.com> - 2016-02-06 00:40 +0100

csiph-web