All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wey-Yi Guy <wey-yi.w.guy@intel.com>
To: linville@tuxdriver.com
Cc: linux-wireless@vger.kernel.org,
	Emmanuel Grumbach <emmanuel.grumbach@intel.com>,
	Wey-Yi Guy <wey-yi.w.guy@intel.com>
Subject: [PATCH 48/60] iwlagn: stop the device before freeing it
Date: Sat, 13 Aug 2011 10:38:24 -0700	[thread overview]
Message-ID: <1313257116-2697-49-git-send-email-wey-yi.w.guy@intel.com> (raw)
In-Reply-To: <1313257116-2697-1-git-send-email-wey-yi.w.guy@intel.com>

From: Emmanuel Grumbach <emmanuel.grumbach@intel.com>

When we remove the module, we free all the tx and rx resources.
Before doing that, we'd better stop the tx / rx activity. Calling
iwl_trans_stop_device in iwl_remove helps also to remove a few API
functions:
 * rx_free:		happens in iwl_trans_free
 * tx_free:		happens in iwl_trans_free
 * disable_sync_irq:	happens in iwl_trans_stop_device

Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
---
 drivers/net/wireless/iwlwifi/iwl-agn.c   |   11 +------
 drivers/net/wireless/iwlwifi/iwl-trans.c |   42 ++++++++++++++---------------
 drivers/net/wireless/iwlwifi/iwl-trans.h |   23 ----------------
 3 files changed, 22 insertions(+), 54 deletions(-)

diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c
index ce78ace..868770b 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn.c
@@ -3507,20 +3507,13 @@ void __devexit iwl_remove(struct iwl_priv * priv)
 		priv->mac80211_registered = 0;
 	}
 
-	/* Reset to low power before unloading driver. */
-	iwl_apm_stop(priv);
-
 	iwl_tt_exit(priv);
 
-	/* make sure we flush any pending irq or
-	 * tasklet for the driver */
-	iwl_trans_disable_sync_irq(trans(priv));
+	/*This will stop the queues, move the device to low power state */
+	iwl_trans_stop_device(trans(priv));
 
 	iwl_dealloc_ucode(priv);
 
-	iwl_trans_rx_free(trans(priv));
-	iwl_trans_tx_free(trans(priv));
-
 	iwl_eeprom_free(priv);
 
 	/*netif_stop_queue(dev); */
diff --git a/drivers/net/wireless/iwlwifi/iwl-trans.c b/drivers/net/wireless/iwlwifi/iwl-trans.c
index ac401b8..0a3dd6b 100644
--- a/drivers/net/wireless/iwlwifi/iwl-trans.c
+++ b/drivers/net/wireless/iwlwifi/iwl-trans.c
@@ -555,7 +555,7 @@ static int iwl_trans_tx_alloc(struct iwl_trans *trans)
 	return 0;
 
 error:
-	iwl_trans_tx_free(trans);
+	iwl_trans_pcie_tx_free(trans);
 
 	return ret;
 }
@@ -603,7 +603,7 @@ static int iwl_tx_init(struct iwl_trans *trans)
 error:
 	/*Upon error, free only if we allocated something */
 	if (alloc)
-		iwl_trans_tx_free(trans);
+		iwl_trans_pcie_tx_free(trans);
 	return ret;
 }
 
@@ -958,13 +958,28 @@ static int iwl_trans_tx_stop(struct iwl_trans *trans)
 	return 0;
 }
 
+static void iwl_trans_pcie_disable_sync_irq(struct iwl_trans *trans)
+{
+	unsigned long flags;
+	struct iwl_trans_pcie *trans_pcie =
+		IWL_TRANS_GET_PCIE_TRANS(trans);
+
+	spin_lock_irqsave(&trans->shrd->lock, flags);
+	iwl_disable_interrupts(trans);
+	spin_unlock_irqrestore(&trans->shrd->lock, flags);
+
+	/* wait to make sure we flush pending tasklet*/
+	synchronize_irq(bus(trans)->irq);
+	tasklet_kill(&trans_pcie->irq_tasklet);
+}
+
 static void iwl_trans_pcie_stop_device(struct iwl_trans *trans)
 {
 	/* stop and reset the on-board processor */
 	iwl_write32(bus(trans), CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET);
 
 	/* tell the device to stop sending interrupts */
-	iwl_trans_disable_sync_irq(trans);
+	iwl_trans_pcie_disable_sync_irq(trans);
 
 	/* device going down, Stop using ICT table */
 	iwl_disable_ict(trans);
@@ -1208,23 +1223,10 @@ static void iwl_trans_pcie_reclaim(struct iwl_trans *trans, int txq_id,
 	}
 }
 
-static void iwl_trans_pcie_disable_sync_irq(struct iwl_trans *trans)
-{
-	unsigned long flags;
-	struct iwl_trans_pcie *trans_pcie =
-		IWL_TRANS_GET_PCIE_TRANS(trans);
-
-	spin_lock_irqsave(&trans->shrd->lock, flags);
-	iwl_disable_interrupts(trans);
-	spin_unlock_irqrestore(&trans->shrd->lock, flags);
-
-	/* wait to make sure we flush pending tasklet*/
-	synchronize_irq(bus(trans)->irq);
-	tasklet_kill(&trans_pcie->irq_tasklet);
-}
-
 static void iwl_trans_pcie_free(struct iwl_trans *trans)
 {
+	iwl_trans_pcie_tx_free(trans);
+	iwl_trans_pcie_rx_free(trans);
 	free_irq(bus(trans)->irq, trans);
 	iwl_free_isr_ict(trans);
 	trans->shrd->trans = NULL;
@@ -1860,9 +1862,6 @@ const struct iwl_trans_ops trans_ops_pcie = {
 
 	.tx_start = iwl_trans_pcie_tx_start,
 
-	.rx_free = iwl_trans_pcie_rx_free,
-	.tx_free = iwl_trans_pcie_tx_free,
-
 	.send_cmd = iwl_trans_pcie_send_cmd,
 	.send_cmd_pdu = iwl_trans_pcie_send_cmd_pdu,
 
@@ -1875,7 +1874,6 @@ const struct iwl_trans_ops trans_ops_pcie = {
 
 	.kick_nic = iwl_trans_pcie_kick_nic,
 
-	.disable_sync_irq = iwl_trans_pcie_disable_sync_irq,
 	.free = iwl_trans_pcie_free,
 
 	.dbgfs_register = iwl_trans_pcie_dbgfs_register,
diff --git a/drivers/net/wireless/iwlwifi/iwl-trans.h b/drivers/net/wireless/iwlwifi/iwl-trans.h
index 0da6ad5..e72e480 100644
--- a/drivers/net/wireless/iwlwifi/iwl-trans.h
+++ b/drivers/net/wireless/iwlwifi/iwl-trans.h
@@ -88,8 +88,6 @@ struct iwl_shared;
  * @tx_start: starts and configures all the Tx fifo - usually done once the fw
  *           is alive.
  * @stop_device:stops the whole device (embedded CPU put to reset)
- * @rx_free: frees the rx memory
- * @tx_free: frees the tx memory
  * @send_cmd:send a host command
  * @send_cmd_pdu:send a host command: flags can be CMD_*
  * @get_tx_cmd: returns a pointer to a new Tx cmd for the upper layer use
@@ -99,9 +97,6 @@ struct iwl_shared;
  *                 ready and a successful ADDBA response has been received.
  * @txq_agg_disable: de-configure a Tx queue to send AMPDUs
  * @kick_nic: remove the RESET from the embedded CPU and let it run
- * @disable_sync_irq: Disable and sync: after this handler returns, it is
- *	guaranteed that all the ISR / tasklet etc... have finished running
- *	and the transport layer shall not pass any Rx.
  * @free: release all the ressource for the transport layer itself such as
  *        irq, tasklet etc...
  * @dbgfs_register: add the dbgfs files under this directory. Files will be
@@ -117,8 +112,6 @@ struct iwl_trans_ops {
 	int (*prepare_card_hw)(struct iwl_trans *trans);
 	void (*stop_device)(struct iwl_trans *trans);
 	void (*tx_start)(struct iwl_trans *trans);
-	void (*tx_free)(struct iwl_trans *trans);
-	void (*rx_free)(struct iwl_trans *trans);
 
 	int (*send_cmd)(struct iwl_trans *trans, struct iwl_host_cmd *cmd);
 
@@ -138,7 +131,6 @@ struct iwl_trans_ops {
 
 	void (*kick_nic)(struct iwl_trans *trans);
 
-	void (*disable_sync_irq)(struct iwl_trans *trans);
 	void (*free)(struct iwl_trans *trans);
 
 	int (*dbgfs_register)(struct iwl_trans *trans, struct dentry* dir);
@@ -187,16 +179,6 @@ static inline void iwl_trans_tx_start(struct iwl_trans *trans)
 	trans->ops->tx_start(trans);
 }
 
-static inline void iwl_trans_rx_free(struct iwl_trans *trans)
-{
-	trans->ops->rx_free(trans);
-}
-
-static inline void iwl_trans_tx_free(struct iwl_trans *trans)
-{
-	trans->ops->tx_free(trans);
-}
-
 static inline int iwl_trans_send_cmd(struct iwl_trans *trans,
 				struct iwl_host_cmd *cmd)
 {
@@ -247,11 +229,6 @@ static inline void iwl_trans_kick_nic(struct iwl_trans *trans)
 	trans->ops->kick_nic(trans);
 }
 
-static inline void iwl_trans_disable_sync_irq(struct iwl_trans *trans)
-{
-	trans->ops->disable_sync_irq(trans);
-}
-
 static inline void iwl_trans_free(struct iwl_trans *trans)
 {
 	trans->ops->free(trans);
-- 
1.7.0.4


  parent reply	other threads:[~2011-08-13 18:18 UTC|newest]

Thread overview: 80+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-13 17:37 [PATCH 00/60] update for 3.2 Wey-Yi Guy
2011-08-13 17:37 ` [PATCH 01/60] iwlagn: Rename iwlcore prefix Wey-Yi Guy
2011-08-13 17:37 ` [PATCH 02/60] iwlagn: remove out-dated comments Wey-Yi Guy
2011-08-13 17:37 ` [PATCH 03/60] iwlagn: use iwl_get_debug_level instead of iwl_debug_level Wey-Yi Guy
2011-08-13 17:37 ` [PATCH 04/60] iwlagn: introduce iwl-shared.h Wey-Yi Guy
2011-08-13 17:37 ` [PATCH 05/60] iwlagn: introduce struct iwl-shared - known by all layers Wey-Yi Guy
2011-08-15  8:10   ` Stanislaw Gruszka
2011-08-15  8:43     ` Stanislaw Gruszka
2011-08-15 13:13       ` Guy, Wey-Yi
2011-08-15 14:21         ` Stanislaw Gruszka
2011-08-15 13:46           ` Guy, Wey-Yi
2011-08-15 14:44             ` Stanislaw Gruszka
2011-08-15 14:10               ` Guy, Wey-Yi
2011-08-15 15:12                 ` Stanislaw Gruszka
2011-08-15 15:29                   ` Guy, Wey-Yi
2011-08-16  9:26                     ` Stanislaw Gruszka
2011-08-16 14:04                       ` wwguy
2011-08-16 15:12                         ` Stanislaw Gruszka
2011-08-16 16:23                           ` Grumbach, Emmanuel
2011-08-17 15:16                             ` Stanislaw Gruszka
2011-08-17 20:36                               ` wwguy
2011-08-18  4:49                                 ` Grumbach, Emmanuel
2011-08-18 13:57                                   ` Stanislaw Gruszka
2011-08-13 17:37 ` [PATCH 06/60] iwlagn: debug_level moves to struct iwl_shared Wey-Yi Guy
2011-08-13 17:37 ` [PATCH 07/60] iwlagn: hw_params moves to iwl_shared Wey-Yi Guy
2011-08-13 17:37 ` [PATCH 08/60] iwlagn: cmd_queue " Wey-Yi Guy
2011-08-13 17:37 ` [PATCH 09/60] iwlagn: workqueue " Wey-Yi Guy
2011-08-13 17:37 ` [PATCH 10/60] iwlagn: priv->status " Wey-Yi Guy
2011-08-13 17:37 ` [PATCH 11/60] iwlagn: priv->lock " Wey-Yi Guy
2011-08-13 17:37 ` [PATCH 12/60] iwlagn: priv->mutex " Wey-Yi Guy
2011-08-13 17:37 ` [PATCH 13/60] iwlagn: modify the debug macro to be usable by all the layers Wey-Yi Guy
2011-08-13 17:37 ` [PATCH 14/60] iwlagn: add IWL_DEBUG_FW_ERRORS Wey-Yi Guy
2011-08-13 17:37 ` [PATCH 15/60] iwlagn: priv->sta_lock moves to iwl_shared Wey-Yi Guy
2011-08-13 17:37 ` [PATCH 16/60] iwlagn: bus layer chooses its transport layer Wey-Yi Guy
2011-08-13 17:37 ` [PATCH 17/60] iwlagn: add comments to iwl_bus / iwl_trans Wey-Yi Guy
2011-08-13 17:37 ` [PATCH 18/60] iwlagn: transport handler can register debugfs entries Wey-Yi Guy
2011-08-13 17:37 ` [PATCH 19/60] iwlagn: iwl_rx_queue moves to the iwl_trans_pcie Wey-Yi Guy
2011-08-13 17:37 ` [PATCH 20/60] iwlagn: move iwl_suspend / iwl_resume to the transport layer Wey-Yi Guy
2011-08-13 17:37 ` [PATCH 21/60] iwlagn: move ISR related data to " Wey-Yi Guy
2011-08-13 17:37 ` [PATCH 22/60] iwlagn: move the NIC error flow to the " Wey-Yi Guy
2011-08-13 17:37 ` [PATCH 23/60] iwlagn: enable 11n aggregation without checking traffic load Wey-Yi Guy
2011-08-13 17:38 ` [PATCH 24/60] iwlagn: support small form factor SKU of 6205 Wey-Yi Guy
2011-08-13 17:38 ` [PATCH 25/60] iwlagn: more comments for bt channel inhibition Wey-Yi Guy
2011-08-13 17:38 ` [PATCH 26/60] iwlagn: add comments to module parameters Wey-Yi Guy
2011-08-13 17:38 ` [PATCH 27/60] iwlagn: move isr_statistics to transport layer Wey-Yi Guy
2011-08-13 17:38 ` [PATCH 28/60] iwlagn: reclaim the packets in " Wey-Yi Guy
2011-08-13 17:38 ` [PATCH 29/60] iwlagn: move reclaim related functions Wey-Yi Guy
2011-08-13 17:38 ` [PATCH 30/60] iwlagn: move scd_bc_tbls and scd_base_addr to iwl_trans_pcie Wey-Yi Guy
2011-08-13 17:38 ` [PATCH 31/60] iwlagn: fix the check of IWLAGN_FIRST_AMPDU_QUEUE Wey-Yi Guy
2011-08-13 17:38 ` [PATCH 33/60] iwlagn: move iwl_free_pages to iwl-shared.h Wey-Yi Guy
2011-08-13 17:38 ` [PATCH 34/60] iwlagn: transport layer should receive iwl_trans Wey-Yi Guy
2011-08-13 17:38 ` [PATCH 35/60] iwlagn: move hcmd_lock to transport layer Wey-Yi Guy
2011-08-13 17:38 ` [PATCH 36/60] iwlagn: move dump_csr and dump_fh " Wey-Yi Guy
2011-08-13 17:38 ` [PATCH 37/60] iwlagn: remove references to priv from the " Wey-Yi Guy
2011-08-13 17:38 ` [PATCH 38/60] iwlagn: remove unused parameters from hw_params Wey-Yi Guy
2011-08-13 17:38 ` [PATCH 39/60] iwlagn: iwl-dev.h doesn't include iwl-fh.h any more Wey-Yi Guy
2011-08-13 17:38 ` [PATCH 40/60] iwlagn: move Keep Warm to transport layer Wey-Yi Guy
2011-08-13 17:38 ` [PATCH 41/60] iwlagn: add missing includes Wey-Yi Guy
2011-08-13 17:38 ` [PATCH 42/60] iwlagn: all function iwl-io.c receive iwl_bus Wey-Yi Guy
2011-08-13 17:38 ` [PATCH 43/60] iwlagn: fix compile warnings when CONFIG_PM_SLEEP is not set Wey-Yi Guy
2011-08-13 17:38 ` [PATCH 44/60] iwlagn: iwl-pci doesn't include iwl-dev any more Wey-Yi Guy
2011-08-13 17:38 ` [PATCH 45/60] iwlagn: adding special "D" SKU for 2000 series Wey-Yi Guy
2011-08-13 17:38 ` [PATCH 46/60] iwlagn: iwl_tid_data moves to iwl-shared Wey-Yi Guy
2011-08-13 17:38 ` [PATCH 47/60] iwlagn: remove dereferences of priv from transport Wey-Yi Guy
2011-08-13 17:38 ` Wey-Yi Guy [this message]
2011-08-13 17:38 ` [PATCH 49/60] iwlagn: upper layer stores iwl_rxon_context in skb's CB Wey-Yi Guy
2011-08-13 17:38 ` [PATCH 50/60] iwlagn: set tx_fifo for ampdu in transport layer Wey-Yi Guy
2011-08-13 17:38 ` [PATCH 51/60] iwlagn: upper layer uses slabs to allocate tx cmds Wey-Yi Guy
2011-08-13 17:38 ` [PATCH 52/60] iwlagn: move the mapping ac to queue / fifo to transport Wey-Yi Guy
2011-08-13 17:38 ` [PATCH 53/60] iwlagn: allocate resources for TX BA session in transport Wey-Yi Guy
2011-08-13 17:38 ` [PATCH 54/60] iwlagn: move the check_empty logic to the transport layer Wey-Yi Guy
2011-08-13 17:38 ` [PATCH 55/60] iwlagn: move the disable agg logic to " Wey-Yi Guy
2011-08-13 17:38 ` [PATCH 56/60] iwlagn: cosmetics in iwl-trans.h Wey-Yi Guy
2011-08-13 17:38 ` [PATCH 57/60] iwlagn: move wait_for_tx_queue_empty to transport layer Wey-Yi Guy
2011-08-13 17:38 ` [PATCH 58/60] iwlagn: move check_stuck_queue " Wey-Yi Guy
2011-08-13 17:38 ` [PATCH 59/60] iwlagn: move the stop / wake queue logic " Wey-Yi Guy
2011-08-13 17:38 ` [PATCH 60/60] iwlagn: move tx queues " Wey-Yi Guy
2011-08-24 18:29 ` [PATCH 00/60] update for 3.2 John W. Linville
2011-08-24 20:09   ` Guy, Wey-Yi
2011-08-26  6:10 [RESEND PATCH " Wey-Yi Guy
2011-08-26  6:11 ` [PATCH 48/60] iwlagn: stop the device before freeing it Wey-Yi Guy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1313257116-2697-49-git-send-email-wey-yi.w.guy@intel.com \
    --to=wey-yi.w.guy@intel.com \
    --cc=emmanuel.grumbach@intel.com \
    --cc=linux-wireless@vger.kernel.org \
    --cc=linville@tuxdriver.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.