From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0b-0016ce01.pphosted.com (mx0b-0016ce01.pphosted.com [67.231.156.153]) by dpdk.org (Postfix) with ESMTP id 1295DF96E for ; Mon, 27 Feb 2017 08:58:12 +0100 (CET) Received: from pps.filterd (m0085408.ppops.net [127.0.0.1]) by mx0b-0016ce01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v1R7vqco011247; Sun, 26 Feb 2017 23:58:11 -0800 Received: from avcashub1.qlogic.com ([198.186.0.116]) by mx0b-0016ce01.pphosted.com with ESMTP id 28ut281v2g-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Sun, 26 Feb 2017 23:58:11 -0800 Received: from avluser05.qlc.com (10.1.113.115) by qlc.com (10.1.4.191) with Microsoft SMTP Server id 14.3.235.1; Sun, 26 Feb 2017 23:58:10 -0800 Received: (from rmody@localhost) by avluser05.qlc.com (8.14.4/8.14.4/Submit) id v1R7wA3e010432; Sun, 26 Feb 2017 23:58:10 -0800 X-Authentication-Warning: avluser05.qlc.com: rmody set sender to rasesh.mody@cavium.com using -f From: Rasesh Mody To: CC: Rasesh Mody , Date: Sun, 26 Feb 2017 23:56:42 -0800 Message-ID: <1488182237-10247-27-git-send-email-rasesh.mody@cavium.com> X-Mailer: git-send-email 1.7.10.3 In-Reply-To: <1488182237-10247-1-git-send-email-rasesh.mody@cavium.com> References: <1488182237-10247-1-git-send-email-rasesh.mody@cavium.com> MIME-Version: 1.0 Content-Type: text/plain disclaimer: bypass X-Proofpoint-Virus-Version: vendor=nai engine=5800 definitions=8451 signatures=669242 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=3 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1702020001 definitions=main-1702270081 Subject: [dpdk-dev] [PATCH 26/61] net/qede/base: fix to set pointers to NULL after freeing X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 27 Feb 2017 07:58:13 -0000 Set pointers to NULL after being freed Signed-off-by: Rasesh Mody --- drivers/net/qede/base/ecore_dev.c | 45 +++++++----------------- drivers/net/qede/base/ecore_init_ops.c | 4 +++ drivers/net/qede/base/ecore_int.c | 4 +++ drivers/net/qede/base/ecore_spq.c | 60 ++++++++++++++++++-------------- drivers/net/qede/base/ecore_spq.h | 35 +++++++------------ drivers/net/qede/base/ecore_sriov.c | 1 + 6 files changed, 67 insertions(+), 82 deletions(-) diff --git a/drivers/net/qede/base/ecore_dev.c b/drivers/net/qede/base/ecore_dev.c index 35574d4..3591381 100644 --- a/drivers/net/qede/base/ecore_dev.c +++ b/drivers/net/qede/base/ecore_dev.c @@ -173,12 +173,9 @@ void ecore_resc_free(struct ecore_dev *p_dev) ecore_cxt_mngr_free(p_hwfn); ecore_qm_info_free(p_hwfn); ecore_spq_free(p_hwfn); - ecore_eq_free(p_hwfn, p_hwfn->p_eq); - ecore_consq_free(p_hwfn, p_hwfn->p_consq); + ecore_eq_free(p_hwfn); + ecore_consq_free(p_hwfn); ecore_int_free(p_hwfn); -#ifdef CONFIG_ECORE_LL2 - ecore_ll2_free(p_hwfn, p_hwfn->p_ll2_info); -#endif ecore_iov_free(p_hwfn); ecore_dmae_info_free(p_hwfn); ecore_dcbx_info_free(p_hwfn, p_hwfn->p_dcbx_info); @@ -844,11 +841,6 @@ static enum _ecore_status_t ecore_alloc_qm_data(struct ecore_hwfn *p_hwfn) enum _ecore_status_t ecore_resc_alloc(struct ecore_dev *p_dev) { - struct ecore_consq *p_consq; - struct ecore_eq *p_eq; -#ifdef CONFIG_ECORE_LL2 - struct ecore_ll2_info *p_ll2_info; -#endif enum _ecore_status_t rc = ECORE_SUCCESS; int i; @@ -996,24 +988,13 @@ enum _ecore_status_t ecore_resc_alloc(struct ecore_dev *p_dev) goto alloc_no_mem; } - p_eq = ecore_eq_alloc(p_hwfn, (u16)n_eqes); - if (!p_eq) - goto alloc_no_mem; - p_hwfn->p_eq = p_eq; + rc = ecore_eq_alloc(p_hwfn, (u16)n_eqes); + if (rc) + goto alloc_err; - p_consq = ecore_consq_alloc(p_hwfn); - if (!p_consq) - goto alloc_no_mem; - p_hwfn->p_consq = p_consq; - -#ifdef CONFIG_ECORE_LL2 - if (p_hwfn->using_ll2) { - p_ll2_info = ecore_ll2_alloc(p_hwfn); - if (!p_ll2_info) - goto alloc_no_mem; - p_hwfn->p_ll2_info = p_ll2_info; - } -#endif + rc = ecore_consq_alloc(p_hwfn); + if (rc) + goto alloc_err; /* DMA info initialization */ rc = ecore_dmae_info_alloc(p_hwfn); @@ -1061,8 +1042,8 @@ void ecore_resc_setup(struct ecore_dev *p_dev) ecore_cxt_mngr_setup(p_hwfn); ecore_spq_setup(p_hwfn); - ecore_eq_setup(p_hwfn, p_hwfn->p_eq); - ecore_consq_setup(p_hwfn, p_hwfn->p_consq); + ecore_eq_setup(p_hwfn); + ecore_consq_setup(p_hwfn); /* Read shadow of current MFW mailbox */ ecore_mcp_read_mb(p_hwfn, p_hwfn->p_main_ptt); @@ -1073,10 +1054,6 @@ void ecore_resc_setup(struct ecore_dev *p_dev) ecore_int_setup(p_hwfn, p_hwfn->p_main_ptt); ecore_iov_setup(p_hwfn, p_hwfn->p_main_ptt); -#ifdef CONFIG_ECORE_LL2 - if (p_hwfn->using_ll2) - ecore_ll2_setup(p_hwfn, p_hwfn->p_ll2_info); -#endif } } @@ -2370,6 +2347,7 @@ static void ecore_hw_hwfn_free(struct ecore_hwfn *p_hwfn) { ecore_ptt_pool_free(p_hwfn); OSAL_FREE(p_hwfn->p_dev, p_hwfn->hw_info.p_igu_info); + p_hwfn->hw_info.p_igu_info = OSAL_NULL; } /* Setup bar access */ @@ -3654,6 +3632,7 @@ static void ecore_chain_free_pbl(struct ecore_dev *p_dev, p_chain->pbl.p_phys_table, pbl_size); out: OSAL_VFREE(p_dev, p_chain->pbl.pp_virt_addr_tbl); + p_chain->pbl.pp_virt_addr_tbl = OSAL_NULL; } void ecore_chain_free(struct ecore_dev *p_dev, struct ecore_chain *p_chain) diff --git a/drivers/net/qede/base/ecore_init_ops.c b/drivers/net/qede/base/ecore_init_ops.c index b907a95..3d0273b 100644 --- a/drivers/net/qede/base/ecore_init_ops.c +++ b/drivers/net/qede/base/ecore_init_ops.c @@ -115,6 +115,7 @@ enum _ecore_status_t ecore_init_alloc(struct ecore_hwfn *p_hwfn) sizeof(u32) * RUNTIME_ARRAY_SIZE); if (!rt_data->init_val) { OSAL_FREE(p_hwfn->p_dev, rt_data->b_valid); + rt_data->b_valid = OSAL_NULL; return ECORE_NOMEM; } @@ -124,7 +125,9 @@ enum _ecore_status_t ecore_init_alloc(struct ecore_hwfn *p_hwfn) void ecore_init_free(struct ecore_hwfn *p_hwfn) { OSAL_FREE(p_hwfn->p_dev, p_hwfn->rt_data.init_val); + p_hwfn->rt_data.init_val = OSAL_NULL; OSAL_FREE(p_hwfn->p_dev, p_hwfn->rt_data.b_valid); + p_hwfn->rt_data.b_valid = OSAL_NULL; } static enum _ecore_status_t ecore_init_array_dmae(struct ecore_hwfn *p_hwfn, @@ -506,6 +509,7 @@ enum _ecore_status_t ecore_init_run(struct ecore_hwfn *p_hwfn, } #ifdef CONFIG_ECORE_ZIPPED_FW OSAL_FREE(p_hwfn->p_dev, p_hwfn->unzip_buf); + p_hwfn->unzip_buf = OSAL_NULL; #endif return rc; } diff --git a/drivers/net/qede/base/ecore_int.c b/drivers/net/qede/base/ecore_int.c index e5a4359..ffcae46 100644 --- a/drivers/net/qede/base/ecore_int.c +++ b/drivers/net/qede/base/ecore_int.c @@ -1229,7 +1229,9 @@ static void ecore_int_sb_attn_free(struct ecore_hwfn *p_hwfn) p_sb->sb_phys, SB_ATTN_ALIGNED_SIZE(p_hwfn)); } + OSAL_FREE(p_hwfn->p_dev, p_sb); + p_hwfn->p_sb_attn = OSAL_NULL; } static void ecore_int_sb_attn_setup(struct ecore_hwfn *p_hwfn, @@ -1593,6 +1595,7 @@ static void ecore_int_sp_sb_free(struct ecore_hwfn *p_hwfn) } OSAL_FREE(p_hwfn->p_dev, p_sb); + p_hwfn->p_sp_sb = OSAL_NULL; } static enum _ecore_status_t ecore_int_sp_sb_alloc(struct ecore_hwfn *p_hwfn, @@ -2126,6 +2129,7 @@ static enum _ecore_status_t ecore_int_sp_dpc_alloc(struct ecore_hwfn *p_hwfn) static void ecore_int_sp_dpc_free(struct ecore_hwfn *p_hwfn) { OSAL_FREE(p_hwfn->p_dev, p_hwfn->sp_dpc); + p_hwfn->sp_dpc = OSAL_NULL; } enum _ecore_status_t ecore_int_alloc(struct ecore_hwfn *p_hwfn, diff --git a/drivers/net/qede/base/ecore_spq.c b/drivers/net/qede/base/ecore_spq.c index fa2bce3..23ed772 100644 --- a/drivers/net/qede/base/ecore_spq.c +++ b/drivers/net/qede/base/ecore_spq.c @@ -355,7 +355,7 @@ enum _ecore_status_t ecore_eq_completion(struct ecore_hwfn *p_hwfn, return rc; } -struct ecore_eq *ecore_eq_alloc(struct ecore_hwfn *p_hwfn, u16 num_elem) +enum _ecore_status_t ecore_eq_alloc(struct ecore_hwfn *p_hwfn, u16 num_elem) { struct ecore_eq *p_eq; @@ -364,7 +364,7 @@ struct ecore_eq *ecore_eq_alloc(struct ecore_hwfn *p_hwfn, u16 num_elem) if (!p_eq) { DP_NOTICE(p_hwfn, true, "Failed to allocate `struct ecore_eq'\n"); - return OSAL_NULL; + return ECORE_NOMEM; } /* Allocate and initialize EQ chain*/ @@ -374,7 +374,7 @@ struct ecore_eq *ecore_eq_alloc(struct ecore_hwfn *p_hwfn, u16 num_elem) ECORE_CHAIN_CNT_TYPE_U16, num_elem, sizeof(union event_ring_element), - &p_eq->chain, OSAL_NULL)) { + &p_eq->chain, OSAL_NULL) != ECORE_SUCCESS) { DP_NOTICE(p_hwfn, true, "Failed to allocate eq chain\n"); goto eq_allocate_fail; } @@ -383,25 +383,28 @@ struct ecore_eq *ecore_eq_alloc(struct ecore_hwfn *p_hwfn, u16 num_elem) ecore_int_register_cb(p_hwfn, ecore_eq_completion, p_eq, &p_eq->eq_sb_index, &p_eq->p_fw_cons); - return p_eq; + p_hwfn->p_eq = p_eq; + return ECORE_SUCCESS; eq_allocate_fail: - ecore_eq_free(p_hwfn, p_eq); - return OSAL_NULL; + OSAL_FREE(p_hwfn->p_dev, p_eq); + return ECORE_NOMEM; } -void ecore_eq_setup(struct ecore_hwfn *p_hwfn, struct ecore_eq *p_eq) +void ecore_eq_setup(struct ecore_hwfn *p_hwfn) { - ecore_chain_reset(&p_eq->chain); + ecore_chain_reset(&p_hwfn->p_eq->chain); } -void ecore_eq_free(struct ecore_hwfn *p_hwfn, struct ecore_eq *p_eq) +void ecore_eq_free(struct ecore_hwfn *p_hwfn) { - if (!p_eq) + if (!p_hwfn->p_eq) return; - ecore_chain_free(p_hwfn->p_dev, &p_eq->chain); - OSAL_FREE(p_hwfn->p_dev, p_eq); - p_eq = OSAL_NULL; + + ecore_chain_free(p_hwfn->p_dev, &p_hwfn->p_eq->chain); + + OSAL_FREE(p_hwfn->p_dev, p_hwfn->p_eq); + p_hwfn->p_eq = OSAL_NULL; } /*************************************************************************** @@ -554,7 +557,9 @@ void ecore_spq_free(struct ecore_hwfn *p_hwfn) ecore_chain_free(p_hwfn->p_dev, &p_spq->chain); OSAL_SPIN_LOCK_DEALLOC(&p_spq->lock); + OSAL_FREE(p_hwfn->p_dev, p_spq); + p_hwfn->p_spq = OSAL_NULL; } enum _ecore_status_t @@ -944,7 +949,7 @@ enum _ecore_status_t ecore_spq_completion(struct ecore_hwfn *p_hwfn, return rc; } -struct ecore_consq *ecore_consq_alloc(struct ecore_hwfn *p_hwfn) +enum _ecore_status_t ecore_consq_alloc(struct ecore_hwfn *p_hwfn) { struct ecore_consq *p_consq; @@ -954,7 +959,7 @@ struct ecore_consq *ecore_consq_alloc(struct ecore_hwfn *p_hwfn) if (!p_consq) { DP_NOTICE(p_hwfn, true, "Failed to allocate `struct ecore_consq'\n"); - return OSAL_NULL; + return ECORE_NOMEM; } /* Allocate and initialize EQ chain */ @@ -964,28 +969,31 @@ struct ecore_consq *ecore_consq_alloc(struct ecore_hwfn *p_hwfn) ECORE_CHAIN_CNT_TYPE_U16, ECORE_CHAIN_PAGE_SIZE / 0x80, 0x80, - &p_consq->chain, OSAL_NULL)) { + &p_consq->chain, OSAL_NULL) != ECORE_SUCCESS) { DP_NOTICE(p_hwfn, true, "Failed to allocate consq chain"); goto consq_allocate_fail; } - return p_consq; + p_hwfn->p_consq = p_consq; + return ECORE_SUCCESS; consq_allocate_fail: - ecore_consq_free(p_hwfn, p_consq); - return OSAL_NULL; + OSAL_FREE(p_hwfn->p_dev, p_consq); + return ECORE_NOMEM; } -void ecore_consq_setup(struct ecore_hwfn *p_hwfn, struct ecore_consq *p_consq) +void ecore_consq_setup(struct ecore_hwfn *p_hwfn) { - ecore_chain_reset(&p_consq->chain); + ecore_chain_reset(&p_hwfn->p_consq->chain); } -void ecore_consq_free(struct ecore_hwfn *p_hwfn, struct ecore_consq *p_consq) +void ecore_consq_free(struct ecore_hwfn *p_hwfn) { - if (!p_consq) + if (!p_hwfn->p_consq) return; - ecore_chain_free(p_hwfn->p_dev, &p_consq->chain); - OSAL_FREE(p_hwfn->p_dev, p_consq); - p_consq = OSAL_NULL; + + ecore_chain_free(p_hwfn->p_dev, &p_hwfn->p_consq->chain); + + OSAL_FREE(p_hwfn->p_dev, p_hwfn->p_consq); + p_hwfn->p_consq = OSAL_NULL; } diff --git a/drivers/net/qede/base/ecore_spq.h b/drivers/net/qede/base/ecore_spq.h index 717ede3..e2468b7 100644 --- a/drivers/net/qede/base/ecore_spq.h +++ b/drivers/net/qede/base/ecore_spq.h @@ -194,28 +194,23 @@ void ecore_spq_return_entry(struct ecore_hwfn *p_hwfn, * @param p_hwfn * @param num_elem number of elements in the eq * - * @return struct ecore_eq* - a newly allocated structure; NULL upon error. + * @return enum _ecore_status_t */ -struct ecore_eq *ecore_eq_alloc(struct ecore_hwfn *p_hwfn, - u16 num_elem); +enum _ecore_status_t ecore_eq_alloc(struct ecore_hwfn *p_hwfn, u16 num_elem); /** - * @brief ecore_eq_setup - Reset the SPQ to its start state. + * @brief ecore_eq_setup - Reset the EQ to its start state. * * @param p_hwfn - * @param p_eq */ -void ecore_eq_setup(struct ecore_hwfn *p_hwfn, - struct ecore_eq *p_eq); +void ecore_eq_setup(struct ecore_hwfn *p_hwfn); /** - * @brief ecore_eq_deallocate - deallocates the given EQ struct. + * @brief ecore_eq_free - deallocates the given EQ struct. * * @param p_hwfn - * @param p_eq */ -void ecore_eq_free(struct ecore_hwfn *p_hwfn, - struct ecore_eq *p_eq); +void ecore_eq_free(struct ecore_hwfn *p_hwfn); /** * @brief ecore_eq_prod_update - update the FW with default EQ producer @@ -261,32 +256,26 @@ enum _ecore_status_t ecore_spq_completion(struct ecore_hwfn *p_hwfn, u32 ecore_spq_get_cid(struct ecore_hwfn *p_hwfn); /** - * @brief ecore_consq_alloc - Allocates & initializes an ConsQ - * struct + * @brief ecore_consq_alloc - Allocates & initializes an ConsQ struct * * @param p_hwfn * - * @return struct ecore_eq* - a newly allocated structure; NULL upon error. + * @return enum _ecore_status_t */ -struct ecore_consq *ecore_consq_alloc(struct ecore_hwfn *p_hwfn); +enum _ecore_status_t ecore_consq_alloc(struct ecore_hwfn *p_hwfn); /** - * @brief ecore_consq_setup - Reset the ConsQ to its start - * state. + * @brief ecore_consq_setup - Reset the ConsQ to its start state. * * @param p_hwfn - * @param p_eq */ -void ecore_consq_setup(struct ecore_hwfn *p_hwfn, - struct ecore_consq *p_consq); +void ecore_consq_setup(struct ecore_hwfn *p_hwfn); /** * @brief ecore_consq_free - deallocates the given ConsQ struct. * * @param p_hwfn - * @param p_eq */ -void ecore_consq_free(struct ecore_hwfn *p_hwfn, - struct ecore_consq *p_consq); +void ecore_consq_free(struct ecore_hwfn *p_hwfn); #endif /* __ECORE_SPQ_H__ */ diff --git a/drivers/net/qede/base/ecore_sriov.c b/drivers/net/qede/base/ecore_sriov.c index ce14460..87ffa34 100644 --- a/drivers/net/qede/base/ecore_sriov.c +++ b/drivers/net/qede/base/ecore_sriov.c @@ -573,6 +573,7 @@ void ecore_iov_free(struct ecore_hwfn *p_hwfn) if (IS_PF_SRIOV_ALLOC(p_hwfn)) { ecore_iov_free_vfdb(p_hwfn); OSAL_FREE(p_hwfn->p_dev, p_hwfn->pf_iov_info); + p_hwfn->pf_iov_info = OSAL_NULL; } } -- 1.7.10.3