From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 1E125A0487 for ; Mon, 1 Jul 2019 17:56:25 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id D05A41B9FB; Mon, 1 Jul 2019 17:56:24 +0200 (CEST) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by dpdk.org (Postfix) with ESMTP id 496051B9EE for ; Mon, 1 Jul 2019 17:56:23 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Jul 2019 08:56:11 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.63,439,1557212400"; d="scan'208";a="186523790" Received: from silpixa00399126.ir.intel.com (HELO silpixa00399126.ger.corp.intel.com) ([10.237.223.2]) by fmsmga004.fm.intel.com with ESMTP; 01 Jul 2019 08:56:08 -0700 From: Bruce Richardson To: dev@dpdk.org Cc: thomas@monjalon.net, jerinj@marvell.com, jiayu.hu@intel.com, Bruce Richardson , Shreyansh Jain , Hemant Agrawal Date: Mon, 1 Jul 2019 16:55:52 +0100 Message-Id: <20190701155600.43695-2-bruce.richardson@intel.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190701155600.43695-1-bruce.richardson@intel.com> References: <20190530212525.40370-1-bruce.richardson@intel.com> <20190701155600.43695-1-bruce.richardson@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v4 1/9] rawdev: allow devices to skip extra memory 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Some device drivers want to allocate their own private memory, and should be allowed to do so. Therefore skip memory allocation and associated error checks if zero-length private memory is requested. While adjusting the code for new indent level, fix incorrect error message. Cc: Shreyansh Jain Cc: Hemant Agrawal Signed-off-by: Bruce Richardson --- lib/librte_rawdev/rte_rawdev.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/librte_rawdev/rte_rawdev.c b/lib/librte_rawdev/rte_rawdev.c index 15de2d413..b6f1e1c77 100644 --- a/lib/librte_rawdev/rte_rawdev.c +++ b/lib/librte_rawdev/rte_rawdev.c @@ -496,16 +496,17 @@ rte_rawdev_pmd_allocate(const char *name, size_t dev_priv_size, int socket_id) rawdev = &rte_rawdevs[dev_id]; - rawdev->dev_private = rte_zmalloc_socket("rawdev private", + if (dev_priv_size > 0) { + rawdev->dev_private = rte_zmalloc_socket("rawdev private", dev_priv_size, RTE_CACHE_LINE_SIZE, socket_id); - if (!rawdev->dev_private) { - RTE_RDEV_ERR("Unable to allocate memory to Skeleton dev"); - return NULL; + if (!rawdev->dev_private) { + RTE_RDEV_ERR("Unable to allocate memory for rawdev"); + return NULL; + } } - rawdev->dev_id = dev_id; rawdev->socket_id = socket_id; rawdev->started = 0; -- 2.21.0