[v2,06/29] bus/fslmc: support handle portal alloc failure

Message ID 20200707092244.12791-7-hemant.agrawal@nxp.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series NXP DPAAx enhancements |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Hemant Agrawal July 7, 2020, 9:22 a.m. UTC
  Add the error handling on failure.

Signed-off-by: Nipun Gupta <nipun.gupta@nxp.com>
Signed-off-by: Hemant Agrawal <hemant.agrawal@nxp.com>
---
 drivers/bus/fslmc/portal/dpaa2_hw_dpio.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
  

Patch

diff --git a/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c b/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
index 47ae72749..5a12ff35d 100644
--- a/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
+++ b/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
@@ -284,8 +284,10 @@  static struct dpaa2_dpio_dev *dpaa2_get_qbman_swp(void)
 		if (dpio_dev && rte_atomic16_test_and_set(&dpio_dev->ref_count))
 			break;
 	}
-	if (!dpio_dev)
+	if (!dpio_dev) {
+		DPAA2_BUS_ERR("No software portal resource left");
 		return NULL;
+	}
 
 	DPAA2_BUS_DEBUG("New Portal %p (%d) affined thread - %lu",
 			dpio_dev, dpio_dev->index, syscall(SYS_gettid));
@@ -293,6 +295,7 @@  static struct dpaa2_dpio_dev *dpaa2_get_qbman_swp(void)
 	ret = dpaa2_configure_stashing(dpio_dev);
 	if (ret) {
 		DPAA2_BUS_ERR("dpaa2_configure_stashing failed");
+		rte_atomic16_clear(&dpio_dev->ref_count);
 		return NULL;
 	}
 
@@ -316,7 +319,7 @@  dpaa2_affine_qbman_swp(void)
 	if (!RTE_PER_LCORE(_dpaa2_io).dpio_dev) {
 		dpio_dev = dpaa2_get_qbman_swp();
 		if (!dpio_dev) {
-			DPAA2_BUS_ERR("No software portal resource left");
+			DPAA2_BUS_ERR("Error in software portal allocation");
 			return -1;
 		}
 		RTE_PER_LCORE(_dpaa2_io).dpio_dev = dpio_dev;
@@ -338,7 +341,7 @@  dpaa2_affine_qbman_ethrx_swp(void)
 	if (!RTE_PER_LCORE(_dpaa2_io).ethrx_dpio_dev) {
 		dpio_dev = dpaa2_get_qbman_swp();
 		if (!dpio_dev) {
-			DPAA2_BUS_ERR("No software portal resource left");
+			DPAA2_BUS_ERR("Error in software portal allocation");
 			return -1;
 		}
 		RTE_PER_LCORE(_dpaa2_io).ethrx_dpio_dev = dpio_dev;