From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 0F683A0C50; Fri, 16 Jul 2021 16:41:49 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B9E864067B; Fri, 16 Jul 2021 16:41:48 +0200 (CEST) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mails.dpdk.org (Postfix) with ESMTP id D385440151 for ; Fri, 16 Jul 2021 16:41:47 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10046"; a="190418970" X-IronPort-AV: E=Sophos;i="5.84,245,1620716400"; d="scan'208";a="190418970" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jul 2021 07:41:46 -0700 X-IronPort-AV: E=Sophos;i="5.84,245,1620716400"; d="scan'208";a="494954273" Received: from bricha3-mobl.ger.corp.intel.com ([10.252.26.216]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-SHA; 16 Jul 2021 07:41:42 -0700 Date: Fri, 16 Jul 2021 15:41:39 +0100 From: Bruce Richardson To: Chengwen Feng Cc: thomas@monjalon.net, ferruh.yigit@intel.com, jerinj@marvell.com, jerinjacobk@gmail.com, andrew.rybchenko@oktetlabs.ru, dev@dpdk.org, mb@smartsharesystems.com, nipun.gupta@nxp.com, hemant.agrawal@nxp.com, maxime.coquelin@redhat.com, honnappa.nagarahalli@arm.com, david.marchand@redhat.com, sburla@marvell.com, pkapoor@marvell.com, konstantin.ananyev@intel.com Message-ID: References: <1625231891-2963-1-git-send-email-fengchengwen@huawei.com> <1626403535-40051-1-git-send-email-fengchengwen@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1626403535-40051-1-git-send-email-fengchengwen@huawei.com> Subject: Re: [dpdk-dev] [PATCH v5] dmadev: introduce DMA device library X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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" On Fri, Jul 16, 2021 at 10:45:35AM +0800, Chengwen Feng wrote: > This patch introduce 'dmadevice' which is a generic type of DMA > device. > > The APIs of dmadev library exposes some generic operations which can > enable configuration and I/O with the DMA devices. > > Signed-off-by: Chengwen Feng > --- > + > +static struct rte_dmadev * > +dmadev_allocate(const char *name) > +{ > + struct rte_dmadev *dev; > + uint16_t dev_id; > + > + dev = dmadev_find(name); > + if (dev != NULL) { > + RTE_DMADEV_LOG(ERR, "DMA device already allocated\n"); > + return NULL; > + } > + > + dev_id = dmadev_find_free_dev(); > + if (dev_id == RTE_DMADEV_MAX_DEVS) { > + RTE_DMADEV_LOG(ERR, "Reached maximum number of DMA devices\n"); > + return NULL; > + } > + > + if (dmadev_shared_data_prepare() != 0) { > + RTE_DMADEV_LOG(ERR, "Cannot allocate DMA shared data\n"); > + return NULL; > + } > + The order of the "shared_data_prepare" and "find_free_dev" calls needs to be reversed. When calling allocate for the first dmadev driver you will get a segfault in find function, since it accesses the shared data which has not been created yet. Regards, /Bruce