From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id 27BD0568D for ; Mon, 28 Dec 2015 06:38:25 +0100 (CET) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga103.jf.intel.com with ESMTP; 27 Dec 2015 21:38:24 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,489,1444719600"; d="scan'208";a="870421979" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by fmsmga001.fm.intel.com with ESMTP; 27 Dec 2015 21:38:23 -0800 Received: from fmsmsx119.amr.corp.intel.com (10.18.124.207) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.248.2; Sun, 27 Dec 2015 21:38:23 -0800 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by FMSMSX119.amr.corp.intel.com (10.18.124.207) with Microsoft SMTP Server (TLS) id 14.3.248.2; Sun, 27 Dec 2015 21:38:23 -0800 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.111]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.58]) with mapi id 14.03.0248.002; Mon, 28 Dec 2015 13:38:20 +0800 From: "Xie, Huawei" To: Yuanhan Liu Thread-Topic: [PATCH 3/4] virtio: return 1 to tell the upper layer we don't take over this device Thread-Index: AQHRQS/SfmnkARVDfEaqvr/PX9AxxZ7f3ZFw Date: Mon, 28 Dec 2015 05:38:20 +0000 Message-ID: References: <20151222035041.GA7532@pxdev.xzpeter.org> <1450982292-129560-1-git-send-email-huawei.xie@intel.com> <1450982292-129560-4-git-send-email-huawei.xie@intel.com> <20151228052513.GD18863@yliu-dev.sh.intel.com> In-Reply-To: <20151228052513.GD18863@yliu-dev.sh.intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Cc: "dev@dpdk.org" Subject: Re: [dpdk-dev] [PATCH 3/4] virtio: return 1 to tell the upper layer we don't take over this device X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Dec 2015 05:38:25 -0000 > -----Original Message----- > From: Yuanhan Liu [mailto:yuanhan.liu@linux.intel.com] > Sent: Monday, December 28, 2015 1:25 PM > To: Xie, Huawei > Cc: dev@dpdk.org; Jayakumar, Muthurajan; Troitsky, Nikita; > peterx@redhat.com; stephen@networkplumber.org; > Changchun.ouyang@hotmail.com; thomas.monjalon@6wind.com > Subject: Re: [PATCH 3/4] virtio: return 1 to tell the upper layer we > don't take over this device >=20 > On Fri, Dec 25, 2015 at 02:38:11AM +0800, Huawei Xie wrote: > > if virtio_resource_init fails, cleanup the resource and return 1 to > > tell the upper layer we don't take over this device. > > return -1 means error and DPDK will exit. > > > > Signed-off-by: Huawei Xie > > --- > > drivers/net/virtio/virtio_ethdev.c | 8 ++++++-- > > 1 file changed, 6 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/net/virtio/virtio_ethdev.c > b/drivers/net/virtio/virtio_ethdev.c > > index d928339..00015ef 100644 > > --- a/drivers/net/virtio/virtio_ethdev.c > > +++ b/drivers/net/virtio/virtio_ethdev.c > > @@ -1287,8 +1287,12 @@ eth_virtio_dev_init(struct rte_eth_dev > *eth_dev) > > > > pci_dev =3D eth_dev->pci_dev; > > > > - if (virtio_resource_init(pci_dev) < 0) > > - return -1; > > + /* Return 1 to tell the upper layer we don't take over this > device. */ > > + if (virtio_resource_init(pci_dev) < 0) { > > + rte_free(eth_dev->data->mac_addrs); > > + eth_dev->data->mac_addrs =3D NULL; >=20 > This assignment looks unnecessary to me. >=20 Noted this when write this code. It is ok not to reset as this layer is res= ponsible for all the allocation/free. >=20 > And, I think above comment is better to put here, right above the > return > statement. >=20 > > + return 1; > > + } >=20 > --yliu