net/i40e/base: fix NVM lock
authorQi Zhang <qi.z.zhang@intel.com>
Tue, 9 Jan 2018 20:30:09 +0000 (15:30 -0500)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 16 Jan 2018 17:47:49 +0000 (18:47 +0100)
NVM lock is only required at below situation:
1. its X722 device or
2. API version >= 1.5
or may have issue at firmware downgrade.

Fixes: c5846a125b26 ("net/i40e/base: fix NVM access interfering")
Cc: stable@dpdk.org
Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
Acked-by: Beilei Xing <beilei.xing@intel.com>
drivers/net/i40e/base/i40e_adminq.c
drivers/net/i40e/base/i40e_common.c
drivers/net/i40e/base/i40e_nvm.c
drivers/net/i40e/base/i40e_type.h

index 8cc8c5e..109d4cf 100644 (file)
@@ -694,6 +694,12 @@ enum i40e_status_code i40e_init_adminq(struct i40e_hw *hw)
                hw->flags |= I40E_HW_FLAG_AQ_PHY_ACCESS_CAPABLE;
        }
 
+       /* Newer versions of firmware require lock when reading the NVM */
+       if ((hw->aq.api_maj_ver > 1) ||
+           ((hw->aq.api_maj_ver == 1) &&
+            (hw->aq.api_min_ver >= 5)))
+               hw->flags |= I40E_HW_FLAG_NVM_READ_REQUIRES_LOCK;
+
        if (hw->aq.api_maj_ver > I40E_FW_API_VERSION_MAJOR) {
                ret_code = I40E_ERR_FIRMWARE_API_VERSION;
                goto init_adminq_free_arq;
index f085e3a..8158c7c 100644 (file)
@@ -1037,7 +1037,8 @@ enum i40e_status_code i40e_init_shared_code(struct i40e_hw *hw)
                hw->pf_id = (u8)(func_rid & 0x7);
 
        if (hw->mac.type == I40E_MAC_X722)
-               hw->flags |= I40E_HW_FLAG_AQ_SRCTL_ACCESS_ENABLE;
+               hw->flags |= I40E_HW_FLAG_AQ_SRCTL_ACCESS_ENABLE |
+                            I40E_HW_FLAG_NVM_READ_REQUIRES_LOCK;
 
        status = i40e_init_nvm(hw);
        return status;
index 946778b..fec35a8 100644 (file)
@@ -219,14 +219,17 @@ enum i40e_status_code i40e_read_nvm_word(struct i40e_hw *hw, u16 offset,
 {
        enum i40e_status_code ret_code = I40E_SUCCESS;
 
-       ret_code = i40e_acquire_nvm(hw, I40E_RESOURCE_READ);
+       if (hw->flags & I40E_HW_FLAG_NVM_READ_REQUIRES_LOCK)
+               ret_code = i40e_acquire_nvm(hw, I40E_RESOURCE_READ);
+
        if (!ret_code) {
                if (hw->flags & I40E_HW_FLAG_AQ_SRCTL_ACCESS_ENABLE) {
                        ret_code = i40e_read_nvm_word_aq(hw, offset, data);
                } else {
                        ret_code = i40e_read_nvm_word_srctl(hw, offset, data);
                }
-               i40e_release_nvm(hw);
+               if (hw->flags & I40E_HW_FLAG_NVM_READ_REQUIRES_LOCK)
+                       i40e_release_nvm(hw);
        }
        return ret_code;
 }
index 438e706..23ccd1e 100644 (file)
@@ -722,6 +722,7 @@ struct i40e_hw {
 #define I40E_HW_FLAG_AQ_SRCTL_ACCESS_ENABLE BIT_ULL(0)
 #define I40E_HW_FLAG_802_1AD_CAPABLE        BIT_ULL(1)
 #define I40E_HW_FLAG_AQ_PHY_ACCESS_CAPABLE  BIT_ULL(2)
+#define I40E_HW_FLAG_NVM_READ_REQUIRES_LOCK BIT_ULL(3)
        u64 flags;
 
        /* Used in set switch config AQ command */