diff options
author | Brett Creeley <brett.creeley@intel.com> | 2019-04-16 13:21:19 -0400 |
---|---|---|
committer | Jeff Kirsher <jeffrey.t.kirsher@intel.com> | 2019-05-04 17:22:55 -0400 |
commit | a85a3847fb5164f08e2a5c0cc0b386f0a79293a6 (patch) | |
tree | 380ab4827437ec64a3548ed4c3715f9928397a5b /drivers/net/ethernet/intel/ice/ice_lib.c | |
parent | 207e3721acb4982f73453762ed8d6f3c7dc3de35 (diff) |
ice: Always free/allocate q_vectors
Currently when probing/removing the driver we allocate/deallocate
each vsi->q_vectors array in ice_vsi_alloc_arrays() and
ice_vsi_free_arrays() respectively. However, we don't do this
during the reset and VSI rebuild flow. This is inconsistent
and unnecessary to have a difference between the two flows.
This patch makes the change to always allocate/deallocate the
vsi->q_vectors array regardless of the driver flow we are in.
Also, update the comment for ice_vsi_free_arrays() to be more
descriptive.
Signed-off-by: Brett Creeley <brett.creeley@intel.com>
Signed-off-by: Anirudh Venkataramanan <anirudh.venkataramanan@intel.com>
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Diffstat (limited to 'drivers/net/ethernet/intel/ice/ice_lib.c')
-rw-r--r-- | drivers/net/ethernet/intel/ice/ice_lib.c | 34 |
1 files changed, 14 insertions, 20 deletions
diff --git a/drivers/net/ethernet/intel/ice/ice_lib.c b/drivers/net/ethernet/intel/ice/ice_lib.c index caa00e8873ec..7a88bf639376 100644 --- a/drivers/net/ethernet/intel/ice/ice_lib.c +++ b/drivers/net/ethernet/intel/ice/ice_lib.c | |||
@@ -232,12 +232,11 @@ static int ice_vsi_ctrl_rx_rings(struct ice_vsi *vsi, bool ena) | |||
232 | /** | 232 | /** |
233 | * ice_vsi_alloc_arrays - Allocate queue and vector pointer arrays for the VSI | 233 | * ice_vsi_alloc_arrays - Allocate queue and vector pointer arrays for the VSI |
234 | * @vsi: VSI pointer | 234 | * @vsi: VSI pointer |
235 | * @alloc_qvectors: a bool to specify if q_vectors need to be allocated. | ||
236 | * | 235 | * |
237 | * On error: returns error code (negative) | 236 | * On error: returns error code (negative) |
238 | * On success: returns 0 | 237 | * On success: returns 0 |
239 | */ | 238 | */ |
240 | static int ice_vsi_alloc_arrays(struct ice_vsi *vsi, bool alloc_qvectors) | 239 | static int ice_vsi_alloc_arrays(struct ice_vsi *vsi) |
241 | { | 240 | { |
242 | struct ice_pf *pf = vsi->back; | 241 | struct ice_pf *pf = vsi->back; |
243 | 242 | ||
@@ -252,15 +251,11 @@ static int ice_vsi_alloc_arrays(struct ice_vsi *vsi, bool alloc_qvectors) | |||
252 | if (!vsi->rx_rings) | 251 | if (!vsi->rx_rings) |
253 | goto err_rxrings; | 252 | goto err_rxrings; |
254 | 253 | ||
255 | if (alloc_qvectors) { | 254 | /* allocate memory for q_vector pointers */ |
256 | /* allocate memory for q_vector pointers */ | 255 | vsi->q_vectors = devm_kcalloc(&pf->pdev->dev, vsi->num_q_vectors, |
257 | vsi->q_vectors = devm_kcalloc(&pf->pdev->dev, | 256 | sizeof(*vsi->q_vectors), GFP_KERNEL); |
258 | vsi->num_q_vectors, | 257 | if (!vsi->q_vectors) |
259 | sizeof(*vsi->q_vectors), | 258 | goto err_vectors; |
260 | GFP_KERNEL); | ||
261 | if (!vsi->q_vectors) | ||
262 | goto err_vectors; | ||
263 | } | ||
264 | 259 | ||
265 | return 0; | 260 | return 0; |
266 | 261 | ||
@@ -389,16 +384,15 @@ void ice_vsi_delete(struct ice_vsi *vsi) | |||
389 | } | 384 | } |
390 | 385 | ||
391 | /** | 386 | /** |
392 | * ice_vsi_free_arrays - clean up VSI resources | 387 | * ice_vsi_free_arrays - De-allocate queue and vector pointer arrays for the VSI |
393 | * @vsi: pointer to VSI being cleared | 388 | * @vsi: pointer to VSI being cleared |
394 | * @free_qvectors: bool to specify if q_vectors should be deallocated | ||
395 | */ | 389 | */ |
396 | static void ice_vsi_free_arrays(struct ice_vsi *vsi, bool free_qvectors) | 390 | static void ice_vsi_free_arrays(struct ice_vsi *vsi) |
397 | { | 391 | { |
398 | struct ice_pf *pf = vsi->back; | 392 | struct ice_pf *pf = vsi->back; |
399 | 393 | ||
400 | /* free the ring and vector containers */ | 394 | /* free the ring and vector containers */ |
401 | if (free_qvectors && vsi->q_vectors) { | 395 | if (vsi->q_vectors) { |
402 | devm_kfree(&pf->pdev->dev, vsi->q_vectors); | 396 | devm_kfree(&pf->pdev->dev, vsi->q_vectors); |
403 | vsi->q_vectors = NULL; | 397 | vsi->q_vectors = NULL; |
404 | } | 398 | } |
@@ -446,7 +440,7 @@ int ice_vsi_clear(struct ice_vsi *vsi) | |||
446 | if (vsi->idx < pf->next_vsi) | 440 | if (vsi->idx < pf->next_vsi) |
447 | pf->next_vsi = vsi->idx; | 441 | pf->next_vsi = vsi->idx; |
448 | 442 | ||
449 | ice_vsi_free_arrays(vsi, true); | 443 | ice_vsi_free_arrays(vsi); |
450 | mutex_unlock(&pf->sw_mutex); | 444 | mutex_unlock(&pf->sw_mutex); |
451 | devm_kfree(&pf->pdev->dev, vsi); | 445 | devm_kfree(&pf->pdev->dev, vsi); |
452 | 446 | ||
@@ -512,14 +506,14 @@ ice_vsi_alloc(struct ice_pf *pf, enum ice_vsi_type type, u16 vf_id) | |||
512 | 506 | ||
513 | switch (vsi->type) { | 507 | switch (vsi->type) { |
514 | case ICE_VSI_PF: | 508 | case ICE_VSI_PF: |
515 | if (ice_vsi_alloc_arrays(vsi, true)) | 509 | if (ice_vsi_alloc_arrays(vsi)) |
516 | goto err_rings; | 510 | goto err_rings; |
517 | 511 | ||
518 | /* Setup default MSIX irq handler for VSI */ | 512 | /* Setup default MSIX irq handler for VSI */ |
519 | vsi->irq_handler = ice_msix_clean_rings; | 513 | vsi->irq_handler = ice_msix_clean_rings; |
520 | break; | 514 | break; |
521 | case ICE_VSI_VF: | 515 | case ICE_VSI_VF: |
522 | if (ice_vsi_alloc_arrays(vsi, true)) | 516 | if (ice_vsi_alloc_arrays(vsi)) |
523 | goto err_rings; | 517 | goto err_rings; |
524 | break; | 518 | break; |
525 | default: | 519 | default: |
@@ -2809,7 +2803,7 @@ int ice_vsi_rebuild(struct ice_vsi *vsi) | |||
2809 | vsi->hw_base_vector = 0; | 2803 | vsi->hw_base_vector = 0; |
2810 | 2804 | ||
2811 | ice_vsi_clear_rings(vsi); | 2805 | ice_vsi_clear_rings(vsi); |
2812 | ice_vsi_free_arrays(vsi, false); | 2806 | ice_vsi_free_arrays(vsi); |
2813 | ice_dev_onetime_setup(&pf->hw); | 2807 | ice_dev_onetime_setup(&pf->hw); |
2814 | if (vsi->type == ICE_VSI_VF) | 2808 | if (vsi->type == ICE_VSI_VF) |
2815 | ice_vsi_set_num_qs(vsi, vf->vf_id); | 2809 | ice_vsi_set_num_qs(vsi, vf->vf_id); |
@@ -2822,7 +2816,7 @@ int ice_vsi_rebuild(struct ice_vsi *vsi) | |||
2822 | if (ret < 0) | 2816 | if (ret < 0) |
2823 | goto err_vsi; | 2817 | goto err_vsi; |
2824 | 2818 | ||
2825 | ret = ice_vsi_alloc_arrays(vsi, false); | 2819 | ret = ice_vsi_alloc_arrays(vsi); |
2826 | if (ret < 0) | 2820 | if (ret < 0) |
2827 | goto err_vsi; | 2821 | goto err_vsi; |
2828 | 2822 | ||