[v3,67/69] net/ice/base: changes in flow and profile removal

Message ID 20190619151846.113820-68-leyi.rong@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Qi Zhang
Headers
Series shared code update |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Leyi Rong June 19, 2019, 3:18 p.m. UTC
  - Add function to remove ES profile map as it is now being used in
clearing and freeing HW tables.
- Locks were initially not used for releasing ES profile maps and
flow profiles as the sequence is part of driver unload. Adding
calls to acquire and release locks to ensure that any calls made
by the VF VSI during VFR or unload do not result in memory
access violations.

Signed-off-by: Vignesh Sridhar <vignesh.sridhar@intel.com>
Signed-off-by: Paul M Stillwell Jr <paul.m.stillwell.jr@intel.com>
Signed-off-by: Leyi Rong <leyi.rong@intel.com>
---
 drivers/net/ice/base/ice_flex_pipe.c | 35 +++++++++++++++++++---------
 1 file changed, 24 insertions(+), 11 deletions(-)
  

Patch

diff --git a/drivers/net/ice/base/ice_flex_pipe.c b/drivers/net/ice/base/ice_flex_pipe.c
index 5f14d0488..c1f23ec02 100644
--- a/drivers/net/ice/base/ice_flex_pipe.c
+++ b/drivers/net/ice/base/ice_flex_pipe.c
@@ -2988,6 +2988,26 @@  void ice_fill_blk_tbls(struct ice_hw *hw)
 	ice_init_sw_db(hw);
 }
 
+/**
+ * ice_free_prof_map - free profile map
+ * @hw: pointer to the hardware structure
+ * @blk_idx: HW block index
+ */
+static void ice_free_prof_map(struct ice_hw *hw, u8 blk_idx)
+{
+	struct ice_es *es = &hw->blk[blk_idx].es;
+	struct ice_prof_map *del, *tmp;
+
+	ice_acquire_lock(&es->prof_map_lock);
+	LIST_FOR_EACH_ENTRY_SAFE(del, tmp, &es->prof_map,
+				 ice_prof_map, list) {
+		LIST_DEL(&del->list);
+		ice_free(hw, del);
+	}
+	INIT_LIST_HEAD(&es->prof_map);
+	ice_release_lock(&es->prof_map_lock);
+}
+
 /**
  * ice_free_flow_profs - free flow profile entries
  * @hw: pointer to the hardware structure
@@ -2997,10 +3017,7 @@  static void ice_free_flow_profs(struct ice_hw *hw, u8 blk_idx)
 {
 	struct ice_flow_prof *p, *tmp;
 
-	/* This call is being made as part of resource deallocation
-	 * during unload. Lock acquire and release will not be
-	 * necessary here.
-	 */
+	ice_acquire_lock(&hw->fl_profs_locks[blk_idx]);
 	LIST_FOR_EACH_ENTRY_SAFE(p, tmp, &hw->fl_profs[blk_idx],
 				 ice_flow_prof, l_entry) {
 		struct ice_flow_entry *e, *t;
@@ -3014,6 +3031,7 @@  static void ice_free_flow_profs(struct ice_hw *hw, u8 blk_idx)
 			ice_free(hw, p->acts);
 		ice_free(hw, p);
 	}
+	ice_release_lock(&hw->fl_profs_locks[blk_idx]);
 
 	/* if driver is in reset and tables are being cleared
 	 * re-initialize the flow profile list heads
@@ -3050,17 +3068,12 @@  void ice_free_hw_tbls(struct ice_hw *hw)
 	for (i = 0; i < ICE_BLK_COUNT; i++) {
 		if (hw->blk[i].is_list_init) {
 			struct ice_es *es = &hw->blk[i].es;
-			struct ice_prof_map *del, *tmp;
-
-			LIST_FOR_EACH_ENTRY_SAFE(del, tmp, &es->prof_map,
-						 ice_prof_map, list) {
-				LIST_DEL(&del->list);
-				ice_free(hw, del);
-			}
 
+			ice_free_prof_map(hw, i);
 			ice_destroy_lock(&es->prof_map_lock);
 			ice_free_flow_profs(hw, i);
 			ice_destroy_lock(&hw->fl_profs_locks[i]);
+
 			hw->blk[i].is_list_init = false;
 		}
 		ice_free_vsig_tbl(hw, (enum ice_block)i);