From mboxrd@z Thu Jan 1 00:00:00 1970 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) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xE9GNVDIrKh4NxR3dtF3vYhiA0ol/6MLNkyHpR3uhng=; b=Ep40PVWo33HFnQSL8ODif1s90Ztfwj2y9ZvJ3bvdBV9C55Q5N7iJxoIvfLT/Nqw3tbEP2QtuKgylYtzXv4b7kwKy8Rwwd9tsqfNAZ8vj0fSR+3wKfVevRnhqRMbY8K45INITh/1BRxYkD2d5q9oaInZMvJFluvLc19G0myAwQcQ= Received: from BYAPR07MB5365.namprd07.prod.outlook.com (20.177.125.18) by BYAPR07MB5320.namprd07.prod.outlook.com (20.177.124.225) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1143.18; Sat, 29 Sep 2018 08:14:31 +0000 Received: from BYAPR07MB5365.namprd07.prod.outlook.com ([fe80::2047:9647:f196:bde0]) by BYAPR07MB5365.namprd07.prod.outlook.com ([fe80::2047:9647:f196:bde0%6]) with mapi id 15.20.1143.022; Sat, 29 Sep 2018 08:14:31 +0000 From: "Mody, Rasesh" To: "dev@dpdk.org" CC: "Mody, Rasesh" , "ferruh.yigit@intel.com" , Dept-Eng DPDK Dev Thread-Topic: [PATCH 07/18] net/qede/base: add error handling for mutex allocation Thread-Index: AQHUV8xycA7A0h+vmk6K1WvA5PJnxg== 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> In-Reply-To: <1538208822-9726-1-git-send-email-rasesh.mody@cavium.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: BYAPR11CA0059.namprd11.prod.outlook.com (2603:10b6:a03:80::36) To BYAPR07MB5365.namprd07.prod.outlook.com (2603:10b6:a03:64::18) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Rasesh.Mody@cavium.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [198.186.1.5] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; BYAPR07MB5320; 6:ecu95c8kd6GC5lohJ73/Qh1Py2V202g5vtd7gbLOMstbWKaiUtyh+WeazJZRWZ76aBpeOVBYq9Tgpyx9xDkppptnyEpkCYlY8roeSsUEyV47/GF42lC6XVbxAp42XDCAtfboOY288V0vcIHGa1O3c8ic75cw6IsKN0lFPnyARqsCK7yF9SGIS2dX+SPI3AnP/R2J8zWY35+Z4sNFmhWAmwDaRsET5cme2DEVXJL8TMhUPT/rAD3JswPhr6E8oE7GCpwRdec2m5WGnNVOQGAnsN5keAmCGWq13TAaLtUzE8aWgsMZjZSLTSsICaZIw5n89xWOGGBVSltP/2/3hLcjbU9DP4l5V5RAqbCaCETQ6jUfNEOXRPPSNJ6eFFe7IyqrMnMupwQAFiaG1d4WWVLGSP8MDsz0Y88/BF7L7kn4D5Tw4qAcI/x4rD2zOMGc7qMwsQVRsb2YWH9ew8OdUWNVcg==; 5:n8Mjm8w0TwFf1UW984Ct/ECuEHyp+l+jsSeNq+2P6QtC2L+e+cTOF5qeSLgqokZIq3DUYthb+8dqhP02x2lAVamoF81fsYa9KP20BubJ7FHvn16a81PjV2FJZ758+HgqhUORUEZnvAcksV1ENhBk4OzAiV8yd6fm48lEFqaTIqo=; 7:LrPlBZjqcLwu5VWkVHdcBi+72ZnuajfuXHZub5P8RaapoGZ4a7dvHXz5PPQUYQmdByeV2uzASTyfSo4Xoytxr1F7i6/BOHHChD8JS1F8yO6D1jb/Caj0y5MOtikh041Nr4MYyLxRrRi9qYK7mGQAlpG5LPfy3aKXjTmPstkBNhAdCK6AqoGFsYGlNjhnO4eGEbhoOj/iSnrFcZzBymC+wbt4ixQev+5rbZDK/6K4eoxsuCbnHyxMi4wypD9zNQ66 x-ms-office365-filtering-correlation-id: 6f30ae21-a263-41c2-3e58-08d625e39541 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(4534165)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(2017052603328)(7153060)(7193020); SRVR:BYAPR07MB5320; x-ms-traffictypediagnostic: BYAPR07MB5320: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(823301075)(3231355)(944501410)(52105095)(3002001)(10201501046)(93006095)(93001095)(149066)(150057)(6041310)(20161123564045)(20161123560045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(201708071742011)(7699051); SRVR:BYAPR07MB5320; BCL:0; PCL:0; RULEID:; SRVR:BYAPR07MB5320; x-forefront-prvs: 0810818DA0 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(979002)(376002)(366004)(396003)(136003)(346002)(39860400002)(199004)(189003)(97736004)(256004)(14454004)(4326008)(11346002)(2501003)(2900100001)(99286004)(54906003)(1730700003)(86362001)(68736007)(446003)(3846002)(25786009)(76176011)(5660300001)(2616005)(8676002)(305945005)(8936002)(486006)(107886003)(2351001)(26005)(2906002)(14444005)(5250100002)(71190400001)(5640700003)(36756003)(6436002)(6486002)(53936002)(316002)(72206003)(386003)(105586002)(71200400001)(6916009)(102836004)(6512007)(6116002)(6506007)(7736002)(81156014)(81166006)(186003)(52116002)(476003)(478600001)(66066001)(34290500001)(106356001)(969003)(989001)(999001)(1009001)(1019001); DIR:OUT; SFP:1101; SCL:1; SRVR:BYAPR07MB5320; H:BYAPR07MB5365.namprd07.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: cavium.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: iWkQe1fbLvInjocM2Cste5449UN1XX97iFoUj7wOn5N95Mpd+qjjNRG+P8fbniRi+gHXyE/p0bmVavgmzc5JgMvMyOConQWl+BEH+iDt8CdMCE7HY1oMFUemacSgQKPqdY9SxE00qg9qwrJLw9JHbgM045/8E01ve7DeMbYGmFWDiTjXlWqSwHoVM2k83x41JcfDOjLcIRtoOzCwJn38GwHIPrzWHqseiPqWLmr0d17xyuhR4MrdMdrWncQnHerGeSBAWTdVgRtMDJ7WL8thBds5+vjQz9pKvBmJeG14/4aN3Aob/05Y4uWnb7xyTmaqoyphGvLgrWESlqXJgLX0hHFYENukd6F7LqVPLyYNhd4= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6f30ae21-a263-41c2-3e58-08d625e39541 X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Sep 2018 08:14:31.6232 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR07MB5320 Subject: [dpdk-dev] [PATCH 07/18] net/qede/base: add error handling for mutex allocation 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: Sat, 29 Sep 2018 08:14:38 -0000 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