linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
To: linux-wireless@vger.kernel.org
Cc: Eliad Peller <eliad@wizery.com>,
	Eliad Peller <eliadx.peller@intel.com>,
	Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Subject: [PATCH 18/33] iwlwifi: mvm: support IWL_D0I3_MODE_ON_SUSPEND d0i3 mode
Date: Tue, 30 Dec 2014 16:18:53 +0200	[thread overview]
Message-ID: <1419949148-24046-18-git-send-email-emmanuel.grumbach@intel.com> (raw)
In-Reply-To: <1419948357.21410.4.camel@egrumbacBox>

From: Eliad Peller <eliad@wizery.com>

Enter d0i3 on suspend, and exit d0i3. Wait for the
command responses in both cases.

Use this mode in case of pcie trans.

Signed-off-by: Eliad Peller <eliadx.peller@intel.com>
Reviewed-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
---
 drivers/net/wireless/iwlwifi/mvm/d3.c       | 40 +++++++++++++++++++++++++++++
 drivers/net/wireless/iwlwifi/mvm/mac80211.c |  7 +++++
 drivers/net/wireless/iwlwifi/mvm/mvm.h      |  2 ++
 drivers/net/wireless/iwlwifi/mvm/ops.c      |  5 ++--
 drivers/net/wireless/iwlwifi/pcie/trans.c   |  1 +
 5 files changed, 53 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/iwlwifi/mvm/d3.c b/drivers/net/wireless/iwlwifi/mvm/d3.c
index a64894c..4b5849e 100644
--- a/drivers/net/wireless/iwlwifi/mvm/d3.c
+++ b/drivers/net/wireless/iwlwifi/mvm/d3.c
@@ -1137,6 +1137,29 @@ static int __iwl_mvm_suspend(struct ieee80211_hw *hw,
 	return ret;
 }
 
+static int iwl_mvm_enter_d0i3_sync(struct iwl_mvm *mvm)
+{
+	struct iwl_notification_wait wait_d3;
+	static const u8 d3_notif[] = { D3_CONFIG_CMD };
+	int ret;
+
+	iwl_init_notification_wait(&mvm->notif_wait, &wait_d3,
+				   d3_notif, ARRAY_SIZE(d3_notif),
+				   NULL, NULL);
+
+	ret = iwl_mvm_enter_d0i3(mvm->hw->priv);
+	if (ret)
+		goto remove_notif;
+
+	ret = iwl_wait_notification(&mvm->notif_wait, &wait_d3, HZ);
+	WARN_ON_ONCE(ret);
+	return ret;
+
+remove_notif:
+	iwl_remove_notification(&mvm->notif_wait, &wait_d3);
+	return ret;
+}
+
 int iwl_mvm_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
 {
 	struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
@@ -1144,6 +1167,13 @@ int iwl_mvm_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
 	iwl_trans_suspend(mvm->trans);
 	if (wowlan->any) {
 		/* 'any' trigger means d0i3 usage */
+		if (mvm->trans->d0i3_mode == IWL_D0I3_MODE_ON_SUSPEND) {
+			int ret = iwl_mvm_enter_d0i3_sync(mvm);
+
+			if (ret)
+				return ret;
+		}
+
 		mutex_lock(&mvm->d0i3_suspend_mutex);
 		__set_bit(D0I3_DEFER_WAKEUP, &mvm->d0i3_suspend_flags);
 		mutex_unlock(&mvm->d0i3_suspend_mutex);
@@ -1879,6 +1909,16 @@ int iwl_mvm_resume(struct ieee80211_hw *hw)
 
 	if (mvm->hw->wiphy->wowlan_config->any) {
 		/* 'any' trigger means d0i3 usage */
+		if (mvm->trans->d0i3_mode == IWL_D0I3_MODE_ON_SUSPEND) {
+			int ret = iwl_mvm_exit_d0i3(hw->priv);
+
+			if (ret)
+				return ret;
+			/*
+			 * d0i3 exit will be deferred until reconfig_complete.
+			 * make sure there we are out of d0i3.
+			 */
+		}
 		return 0;
 	}
 
diff --git a/drivers/net/wireless/iwlwifi/mvm/mac80211.c b/drivers/net/wireless/iwlwifi/mvm/mac80211.c
index fd0f8ce..29f0feb 100644
--- a/drivers/net/wireless/iwlwifi/mvm/mac80211.c
+++ b/drivers/net/wireless/iwlwifi/mvm/mac80211.c
@@ -1021,6 +1021,13 @@ static void iwl_mvm_resume_complete(struct iwl_mvm *mvm)
 		IWL_DEBUG_RPM(mvm, "Run deferred d0i3 exit\n");
 		_iwl_mvm_exit_d0i3(mvm);
 	}
+
+	if (mvm->trans->d0i3_mode == IWL_D0I3_MODE_ON_SUSPEND)
+		if (!wait_event_timeout(mvm->d0i3_exit_waitq,
+					!test_bit(IWL_MVM_STATUS_IN_D0I3,
+						  &mvm->status),
+					HZ))
+			WARN_ONCE(1, "D0i3 exit on resume timed out\n");
 }
 
 static void
diff --git a/drivers/net/wireless/iwlwifi/mvm/mvm.h b/drivers/net/wireless/iwlwifi/mvm/mvm.h
index e608dc4..33a674a 100644
--- a/drivers/net/wireless/iwlwifi/mvm/mvm.h
+++ b/drivers/net/wireless/iwlwifi/mvm/mvm.h
@@ -1187,6 +1187,8 @@ void iwl_mvm_unref(struct iwl_mvm *mvm, enum iwl_mvm_ref_type ref_type);
 int iwl_mvm_ref_sync(struct iwl_mvm *mvm, enum iwl_mvm_ref_type ref_type);
 bool iwl_mvm_ref_taken(struct iwl_mvm *mvm);
 void iwl_mvm_d0i3_enable_tx(struct iwl_mvm *mvm, __le16 *qos_seq);
+int iwl_mvm_enter_d0i3(struct iwl_op_mode *op_mode);
+int iwl_mvm_exit_d0i3(struct iwl_op_mode *op_mode);
 int _iwl_mvm_exit_d0i3(struct iwl_mvm *mvm);
 
 /* BT Coex */
diff --git a/drivers/net/wireless/iwlwifi/mvm/ops.c b/drivers/net/wireless/iwlwifi/mvm/ops.c
index b2fa3b8..17f58ca 100644
--- a/drivers/net/wireless/iwlwifi/mvm/ops.c
+++ b/drivers/net/wireless/iwlwifi/mvm/ops.c
@@ -1030,7 +1030,8 @@ static void iwl_mvm_set_wowlan_data(struct iwl_mvm *mvm,
 out:
 	rcu_read_unlock();
 }
-static int iwl_mvm_enter_d0i3(struct iwl_op_mode *op_mode)
+
+int iwl_mvm_enter_d0i3(struct iwl_op_mode *op_mode)
 {
 	struct iwl_mvm *mvm = IWL_OP_MODE_GET_MVM(op_mode);
 	u32 flags = CMD_ASYNC | CMD_HIGH_PRIO | CMD_SEND_IN_IDLE;
@@ -1244,7 +1245,7 @@ out:
 	return ret;
 }
 
-static int iwl_mvm_exit_d0i3(struct iwl_op_mode *op_mode)
+int iwl_mvm_exit_d0i3(struct iwl_op_mode *op_mode)
 {
 	struct iwl_mvm *mvm = IWL_OP_MODE_GET_MVM(op_mode);
 
diff --git a/drivers/net/wireless/iwlwifi/pcie/trans.c b/drivers/net/wireless/iwlwifi/pcie/trans.c
index fbdbec8..daec2f8 100644
--- a/drivers/net/wireless/iwlwifi/pcie/trans.c
+++ b/drivers/net/wireless/iwlwifi/pcie/trans.c
@@ -2453,6 +2453,7 @@ struct iwl_trans *iwl_trans_pcie_alloc(struct pci_dev *pdev,
 	}
 
 	trans_pcie->inta_mask = CSR_INI_SET_MASK;
+	trans->d0i3_mode = IWL_D0I3_MODE_ON_SUSPEND;
 
 	return trans;
 
-- 
1.9.1


  parent reply	other threads:[~2014-12-30 14:20 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-30 14:05 pull request: iwlwifi-next 2012-12-30 Grumbach, Emmanuel
2014-12-30 14:18 ` [PATCH 01/33] iwlwifi: remove MODULE_VERSION Emmanuel Grumbach
2014-12-30 14:18 ` [PATCH 02/33] iwlwifi: mvm: add fw runtime stack to dump data Emmanuel Grumbach
2014-12-30 14:18 ` [PATCH 03/33] Revert "iwlwifi: use correct fw file in 8000 b-step" Emmanuel Grumbach
2015-01-06 17:30   ` Kalle Valo
2014-12-30 14:18 ` [PATCH 04/33] iwlwifi: mvm: support LnP 1x1 antenna configuration Emmanuel Grumbach
2014-12-30 14:18 ` [PATCH 05/33] iwlwifi: pcie: let the Manageability Engine know when we leave Emmanuel Grumbach
2014-12-30 14:18 ` [PATCH 06/33] iwlwifi: mvm: add debugfs to trigger fw debug logs collection Emmanuel Grumbach
2014-12-30 14:18 ` [PATCH 07/33] iwlwifi: mvm: allow RSSI compensation Emmanuel Grumbach
2014-12-30 14:18 ` [PATCH 08/33] iwlwifi: mvm: Set the HW step in the core dump Emmanuel Grumbach
2014-12-30 14:18 ` [PATCH 09/33] iwlwifi: mvm: clear tt values when entering CT-kill Emmanuel Grumbach
2014-12-30 14:18 ` [PATCH 10/33] iwlwifi: mvm: rs: fix max rate allowed if no rate is allowed Emmanuel Grumbach
2014-12-30 14:18 ` [PATCH 11/33] iwlwifi: mvm: support additional nvm_file in family 8000 B step Emmanuel Grumbach
2014-12-30 14:18 ` [PATCH 12/33] iwlwifi: mvm: add smem content to dump data Emmanuel Grumbach
2014-12-30 14:18 ` [PATCH 13/33] iwlwifi: mvm: change SMEM dump to general purpose memory dump Emmanuel Grumbach
2014-12-30 14:18 ` [PATCH 14/33] iwlwifi: mvm: convert the SRAM dump to the generic " Emmanuel Grumbach
2014-12-30 14:18 ` [PATCH 15/33] iwlwifi: pcie: add basic reference accounting Emmanuel Grumbach
2014-12-30 14:18 ` [PATCH 16/33] iwlwifi: mvm: allow both d0i3 and d3 wowlan configuration modes Emmanuel Grumbach
2014-12-30 14:18 ` [PATCH 17/33] iwlwifi: support multiple d0i3 modes Emmanuel Grumbach
2014-12-30 14:18 ` Emmanuel Grumbach [this message]
2014-12-30 14:18 ` [PATCH 19/33] iwlwifi: mvm: consider d0i3_disable in iwl_mvm_is_d0i3_supported() Emmanuel Grumbach
2014-12-30 14:18 ` [PATCH 20/33] iwlwifi: mvm: wait for d0i3 exit on hw restart Emmanuel Grumbach
2014-12-30 14:18 ` [PATCH 21/33] iwlwifi: mvm: support 2 different channels Emmanuel Grumbach
2014-12-30 14:18 ` [PATCH 22/33] iwlwifi: dvm: tt: Use setup_timer Emmanuel Grumbach
2014-12-30 14:18 ` [PATCH 23/33] iwlwifi: dvm: main: " Emmanuel Grumbach
2014-12-30 14:18 ` [PATCH 24/33] iwlwifi: mvm: clean refs before stop_device() Emmanuel Grumbach
2014-12-30 14:19 ` [PATCH 25/33] iwlwifi: remove useless extern definition of iwl4265_2ac_sdio_cfg Emmanuel Grumbach
2014-12-30 14:19 ` [PATCH 26/33] iwlwifi: mvm: use iwl_mvm_vif_from_mac80211() consistently Emmanuel Grumbach
2014-12-30 14:19 ` [PATCH 27/33] iwlwifi: mvm: use iwl_mvm_sta_from_mac80211() consistently Emmanuel Grumbach
2014-12-30 14:19 ` [PATCH 28/33] iwlwifi: tlv: add support for IWL_UCODE_TLV_SDIO_ADMA_ADDR TLV Emmanuel Grumbach
2014-12-30 14:19 ` [PATCH 29/33] iwlwifi: mvm: ask the fw to wakeup (from d0i3) on sysassert Emmanuel Grumbach
2014-12-30 14:19 ` [PATCH 30/33] iwlwifi: mvm: Configure EBS scan ratio Emmanuel Grumbach
2014-12-30 14:19 ` [PATCH 31/33] iwlwifi: mvm: call to pcie_apply_destination also on family 8000 B step Emmanuel Grumbach
2014-12-30 14:19 ` [PATCH 32/33] iwlwifi: mvm: Alter passive scan fragmentation parameters in case of multi-MAC Emmanuel Grumbach
2014-12-30 14:19 ` [PATCH 33/33] iwlwifi: mvm: rs: organize and cleanup consts Emmanuel Grumbach
2015-01-06 17:37 ` pull request: iwlwifi-next 2012-12-30 Kalle Valo

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=1419949148-24046-18-git-send-email-emmanuel.grumbach@intel.com \
    --to=emmanuel.grumbach@intel.com \
    --cc=eliad@wizery.com \
    --cc=eliadx.peller@intel.com \
    --cc=linux-wireless@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).