[dpdk-dev] [PATCH v5] dmadev: introduce DMA device library
Bruce Richardson
bruce.richardson at intel.com
Fri Jul 16 16:41:39 CEST 2021
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 <fengchengwen at huawei.com>
> ---
<snip>
> +
> +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
More information about the dev
mailing list