From: Luca Coelho <luciano.coe...@intel.com>

New FW versions require the D0I3_END_CMD to be sent as the first
command to the FW in the resume flow.  If the TLV is set, send that
command first, otherwise keep the original behavior (i.e. send last).

Signed-off-by: Luca Coelho <luciano.coe...@intel.com>
---
 drivers/net/wireless/intel/iwlwifi/iwl-fw-file.h |  1 +
 drivers/net/wireless/intel/iwlwifi/mvm/d3.c      | 22 +++++++++++++++++++---
 2 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-fw-file.h 
b/drivers/net/wireless/intel/iwlwifi/iwl-fw-file.h
index 52616f3c0184..a216657b3c60 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-fw-file.h
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-fw-file.h
@@ -353,6 +353,7 @@ enum iwl_ucode_tlv_capa {
        IWL_UCODE_TLV_CAPA_STA_PM_NOTIF                 = (__force 
iwl_ucode_tlv_capa_t)38,
        IWL_UCODE_TLV_CAPA_BINDING_CDB_SUPPORT          = (__force 
iwl_ucode_tlv_capa_t)39,
        IWL_UCODE_TLV_CAPA_CDB_SUPPORT                  = (__force 
iwl_ucode_tlv_capa_t)40,
+       IWL_UCODE_TLV_CAPA_D0I3_END_FIRST               = (__force 
iwl_ucode_tlv_capa_t)41,
        IWL_UCODE_TLV_CAPA_EXTENDED_DTS_MEASURE         = (__force 
iwl_ucode_tlv_capa_t)64,
        IWL_UCODE_TLV_CAPA_SHORT_PM_TIMEOUTS            = (__force 
iwl_ucode_tlv_capa_t)65,
        IWL_UCODE_TLV_CAPA_BT_MPLUT_SUPPORT             = (__force 
iwl_ucode_tlv_capa_t)67,
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/d3.c 
b/drivers/net/wireless/intel/iwlwifi/mvm/d3.c
index f5b65c1ef42f..0028325fa22d 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/d3.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/d3.c
@@ -7,7 +7,7 @@
  *
  * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
  * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
- * Copyright(c) 2016   Intel Deutschland GmbH
+ * Copyright(c) 2016 - 2017 Intel Deutschland GmbH
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of version 2 of the GNU General Public License as
@@ -34,7 +34,7 @@
  *
  * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
  * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
- * Copyright(c) 2016   Intel Deutschland GmbH
+ * Copyright(c) 2016 - 2017 Intel Deutschland GmbH
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -2075,6 +2075,8 @@ static int __iwl_mvm_resume(struct iwl_mvm *mvm, bool 
test)
        bool keep = false;
        bool unified_image = fw_has_capa(&mvm->fw->ucode_capa,
                                         IWL_UCODE_TLV_CAPA_CNSLDTD_D3_D0_IMG);
+       bool d0i3_first = fw_has_capa(&mvm->fw->ucode_capa,
+                                     IWL_UCODE_TLV_CAPA_D0I3_END_FIRST);
 
        mutex_lock(&mvm->mutex);
 
@@ -2095,6 +2097,15 @@ static int __iwl_mvm_resume(struct iwl_mvm *mvm, bool 
test)
        /* query SRAM first in case we want event logging */
        iwl_mvm_read_d3_sram(mvm);
 
+       if (d0i3_first) {
+               ret = iwl_mvm_send_cmd_pdu(mvm, D0I3_END_CMD, 0, 0, NULL);
+               if (ret < 0) {
+                       IWL_ERR(mvm, "Failed to send D0I3_END_CMD first (%d)\n",
+                               ret);
+                       goto err;
+               }
+       }
+
        /*
         * Query the current location and source from the D3 firmware so we
         * can play it back when we re-intiailize the D0 firmware
@@ -2140,9 +2151,14 @@ static int __iwl_mvm_resume(struct iwl_mvm *mvm, bool 
test)
                        iwl_mvm_d3_disconnect_iter, keep ? vif : NULL);
 
 out:
+       /* no need to reset the device in unified images, if successful */
        if (unified_image && !ret) {
+               /* nothing else to do if we already sent D0I3_END_CMD */
+               if (d0i3_first)
+                       return 0;
+
                ret = iwl_mvm_send_cmd_pdu(mvm, D0I3_END_CMD, 0, 0, NULL);
-               if (!ret) /* D3 ended successfully - no need to reset device */
+               if (!ret)
                        return 0;
        }
 
-- 
2.11.0

Reply via email to