From: Leyi Rong Date: Wed, 19 Jun 2019 15:18:44 +0000 (+0800) Subject: net/ice/base: change flow and profile removal X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=a0b1a2629b220ac082f067003f4be8edff031487;p=dpdk.git net/ice/base: change flow and profile removal - 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 Signed-off-by: Paul M Stillwell Jr Signed-off-by: Leyi Rong Acked-by: Qi Zhang --- diff --git a/drivers/net/ice/base/ice_flex_pipe.c b/drivers/net/ice/base/ice_flex_pipe.c index 5f14d04883..c1f23ec020 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);