From mboxrd@z Thu Jan 1 00:00:00 1970 From: Shreyansh Jain Subject: [PATCH] bus/dpaa: fix memory allocation during bus scan Date: Tue, 10 Oct 2017 12:31:55 +0530 Message-ID: <20171010070155.17412-1-shreyansh.jain@nxp.com> Mime-Version: 1.0 Content-Type: text/plain Cc: , , , Shreyansh Jain To: Return-path: Received: from NAM01-SN1-obe.outbound.protection.outlook.com (mail-sn1nam01on0077.outbound.protection.outlook.com [104.47.32.77]) by dpdk.org (Postfix) with ESMTP id 775F21B25A for ; Tue, 10 Oct 2017 08:49:49 +0200 (CEST) List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Fixes: 5b22cf744689 ("bus/dpaa: introducing FMan configurations") Fixes: 37f9b54bd3cf ("net/dpaa: support Tx and Rx queue setup") Cc: shreyansh.jain@nxp.com With the IOVA auto detection changes, bus scan is performed before memory initialization. DPAA bus scan must not use rte_malloc in its path. Signed-off-by: Shreyansh Jain --- drivers/bus/dpaa/base/fman/fman.c | 15 ++++++++------- drivers/net/dpaa/dpaa_ethdev.c | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/bus/dpaa/base/fman/fman.c b/drivers/bus/dpaa/base/fman/fman.c index d0a8ee4..3816dba 100644 --- a/drivers/bus/dpaa/base/fman/fman.c +++ b/drivers/bus/dpaa/base/fman/fman.c @@ -42,8 +42,6 @@ #include #include -#include - /* This header declares the driver interface we implement */ #include #include @@ -72,15 +70,18 @@ if_destructor(struct __fman_if *__if) { struct fman_if_bpool *bp, *tmpbp; + if (!__if) + return; + if (__if->__if.mac_type == fman_offline) goto cleanup; list_for_each_entry_safe(bp, tmpbp, &__if->__if.bpool_list, node) { list_del(&bp->node); - rte_free(bp); + free(bp); } cleanup: - rte_free(__if); + free(__if); } static int @@ -208,7 +209,7 @@ fman_if_init(const struct device_node *dpa_node) mprop = "fsl,fman-mac"; /* Allocate an object for this network interface */ - __if = rte_malloc(NULL, sizeof(*__if), RTE_CACHE_LINE_SIZE); + __if = malloc(sizeof(*__if)); if (!__if) { FMAN_ERR(-ENOMEM, "malloc(%zu)\n", sizeof(*__if)); goto err; @@ -464,7 +465,7 @@ fman_if_init(const struct device_node *dpa_node) uint64_t bpool_host[6] = {0}; const char *pname; /* Allocate an object for the pool */ - bpool = rte_malloc(NULL, sizeof(*bpool), RTE_CACHE_LINE_SIZE); + bpool = malloc(sizeof(*bpool)); if (!bpool) { FMAN_ERR(-ENOMEM, "malloc(%zu)\n", sizeof(*bpool)); goto err; @@ -603,7 +604,7 @@ fman_finish(void) -errno, strerror(errno)); printf("Tearing down %s\n", __if->node_path); list_del(&__if->__if.node); - rte_free(__if); + free(__if); } close(fman_ccsr_map_fd); diff --git a/drivers/net/dpaa/dpaa_ethdev.c b/drivers/net/dpaa/dpaa_ethdev.c index 8dad97e..9f33e44 100644 --- a/drivers/net/dpaa/dpaa_ethdev.c +++ b/drivers/net/dpaa/dpaa_ethdev.c @@ -921,7 +921,7 @@ dpaa_dev_init(struct rte_eth_dev *eth_dev) /* reset bpool list, initialize bpool dynamically */ list_for_each_entry_safe(bp, tmp_bp, &cfg->fman_if->bpool_list, node) { list_del(&bp->node); - rte_free(bp); + free(bp); } /* Populate ethdev structure */ -- 2.9.3