From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Mody, Rasesh" Subject: [PATCH 07/18] net/qede/base: add error handling for mutex allocation Date: Sat, 29 Sep 2018 08:14:31 +0000 Message-ID: <1538208822-9726-8-git-send-email-rasesh.mody@cavium.com> References: <1538208822-9726-1-git-send-email-rasesh.mody@cavium.com> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Cc: "Mody, Rasesh" , "ferruh.yigit@intel.com" , Dept-Eng DPDK Dev To: "dev@dpdk.org" Return-path: Received: from NAM04-CO1-obe.outbound.protection.outlook.com (mail-eopbgr690074.outbound.protection.outlook.com [40.107.69.74]) by dpdk.org (Postfix) with ESMTP id 34AD52C37 for ; Sat, 29 Sep 2018 10:14:38 +0200 (CEST) In-Reply-To: <1538208822-9726-1-git-send-email-rasesh.mody@cavium.com> Content-Language: en-US List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Add error handling for mutex allocation failure Signed-off-by: Rasesh Mody --- drivers/net/qede/base/ecore_cxt.c | 11 +++++++---- drivers/net/qede/base/ecore_vf.c | 19 ++++++++++++++++++- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/drivers/net/qede/base/ecore_cxt.c b/drivers/net/qede/base/ecor= e_cxt.c index bf36ce5..6bc6348 100644 --- a/drivers/net/qede/base/ecore_cxt.c +++ b/drivers/net/qede/base/ecore_cxt.c @@ -1133,6 +1133,9 @@ enum _ecore_status_t ecore_cxt_mngr_alloc(struct ecor= e_hwfn *p_hwfn) return ECORE_NOMEM; } =20 + /* Set the cxt mangr pointer prior to further allocations */ + p_hwfn->p_cxt_mngr =3D p_mngr; + /* Initialize ILT client registers */ clients =3D p_mngr->clients; clients[ILT_CLI_CDUC].first.reg =3D ILT_CFG_REG(CDUC, FIRST_ILT); @@ -1174,13 +1177,13 @@ enum _ecore_status_t ecore_cxt_mngr_alloc(struct ec= ore_hwfn *p_hwfn) =20 /* Initialize the dynamic ILT allocation mutex */ #ifdef CONFIG_ECORE_LOCK_ALLOC - OSAL_MUTEX_ALLOC(p_hwfn, &p_mngr->mutex); + if (OSAL_MUTEX_ALLOC(p_hwfn, &p_mngr->mutex)) { + DP_NOTICE(p_hwfn, false, "Failed to alloc p_mngr->mutex\n"); + return ECORE_NOMEM; + } #endif OSAL_MUTEX_INIT(&p_mngr->mutex); =20 - /* Set the cxt mangr pointer priori to further allocations */ - p_hwfn->p_cxt_mngr =3D p_mngr; - return ECORE_SUCCESS; } =20 diff --git a/drivers/net/qede/base/ecore_vf.c b/drivers/net/qede/base/ecore= _vf.c index d2213f7..409b301 100644 --- a/drivers/net/qede/base/ecore_vf.c +++ b/drivers/net/qede/base/ecore_vf.c @@ -565,13 +565,20 @@ enum _ecore_status_t ecore_vf_hw_prepare(struct ecore= _hwfn *p_hwfn) phys, p_iov->bulletin. size); + if (!p_iov->bulletin.p_virt) { + DP_NOTICE(p_hwfn, false, "Failed to alloc bulletin memory\n"); + goto free_pf2vf_reply; + } DP_VERBOSE(p_hwfn, ECORE_MSG_IOV, "VF's bulletin Board [%p virt 0x%lx phys 0x%08x bytes]\n", p_iov->bulletin.p_virt, (unsigned long)p_iov->bulletin.phys, p_iov->bulletin.size); =20 #ifdef CONFIG_ECORE_LOCK_ALLOC - OSAL_MUTEX_ALLOC(p_hwfn, &p_iov->mutex); + if (OSAL_MUTEX_ALLOC(p_hwfn, &p_iov->mutex)) { + DP_NOTICE(p_hwfn, false, "Failed to allocate p_iov->mutex\n"); + goto free_bulletin_mem; + } #endif OSAL_MUTEX_INIT(&p_iov->mutex); =20 @@ -609,6 +616,16 @@ enum _ecore_status_t ecore_vf_hw_prepare(struct ecore_= hwfn *p_hwfn) =20 return rc; =20 +#ifdef CONFIG_ECORE_LOCK_ALLOC +free_bulletin_mem: + OSAL_DMA_FREE_COHERENT(p_hwfn->p_dev, p_iov->bulletin.p_virt, + p_iov->bulletin.phys, + p_iov->bulletin.size); +#endif +free_pf2vf_reply: + OSAL_DMA_FREE_COHERENT(p_hwfn->p_dev, p_iov->pf2vf_reply, + p_iov->pf2vf_reply_phys, + sizeof(union pfvf_tlvs)); free_vf2pf_request: OSAL_DMA_FREE_COHERENT(p_hwfn->p_dev, p_iov->vf2pf_request, p_iov->vf2pf_request_phys, --=20 1.7.10.3