diff mbox series

[05/16] bus/fslmc: support handle portal alloc failure

Message ID 20200302145829.27808-6-hemant.agrawal@nxp.com
State Superseded
Headers show
Series NXP DPAAx fixes and enhancements | expand

Commit Message

Hemant Agrawal March 2, 2020, 2:58 p.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 | 28 ++++++++++++++----------
 1 file changed, 16 insertions(+), 12 deletions(-)

-- 
2.17.1

Comments

Ferruh Yigit March 9, 2020, 5 p.m. UTC | #1
On 3/2/2020 2:58 PM, Hemant Agrawal wrote:
> Add the error handling on failure.

> 

> Signed-off-by: Nipun Gupta <nipun.gupta@nxp.com>

> Signed-off-by: Hemant Agrawal <hemant.agrawal@nxp.com>



Hi,

This commit seems doing,
- Fix 'dpaa2_put_qbman_swp()' which previously may reference the 'dpio_dev' when
it is null, but the function introduced in this patchset, why not fix it at
first place where it is introduced?

- Updates some log messages

- Adds a new log message

- add 'rte_atomic16_clear()' on error in 'dpaa2_get_qbman_swp()'

I assume the title "support handle portal alloc failure" refers to the last one
but can you please give more details in the commit log to clarify it. Also if
this is fixing a defect can you please reflect it in the commit title/log?

Thanks,
ferruh
Ferruh Yigit March 9, 2020, 5:04 p.m. UTC | #2
On 3/9/2020 5:00 PM, Ferruh Yigit wrote:
> On 3/2/2020 2:58 PM, Hemant Agrawal wrote:

>> Add the error handling on failure.

>>

>> Signed-off-by: Nipun Gupta <nipun.gupta@nxp.com>

>> Signed-off-by: Hemant Agrawal <hemant.agrawal@nxp.com>

> 

> 

> Hi,

> 

> This commit seems doing,

> - Fix 'dpaa2_put_qbman_swp()' which previously may reference the 'dpio_dev' when

> it is null, but the function introduced in this patchset, why not fix it at

> first place where it is introduced?

> 

> - Updates some log messages

> 

> - Adds a new log message

> 

> - add 'rte_atomic16_clear()' on error in 'dpaa2_get_qbman_swp()'

> 

> I assume the title "support handle portal alloc failure" refers to the last one

> but can you please give more details in the commit log to clarify it. Also if

> this is fixing a defect can you please reflect it in the commit title/log?

> 

> Thanks,

> ferruh

> 


The comment was for v2, put here by mistake ...
diff mbox series

Patch

diff --git a/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c b/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
index e765a382f..1a1453ea3 100644
--- a/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
+++ b/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
@@ -264,6 +264,16 @@  dpaa2_configure_stashing(struct dpaa2_dpio_dev *dpio_dev)
 	return 0;
 }
 
+static void dpaa2_put_qbman_swp(struct dpaa2_dpio_dev *dpio_dev)
+{
+	if (dpio_dev) {
+#ifdef RTE_LIBRTE_PMD_DPAA2_EVENTDEV
+		dpaa2_dpio_intr_deinit(dpio_dev);
+#endif
+		rte_atomic16_clear(&dpio_dev->ref_count);
+	}
+}
+
 static struct dpaa2_dpio_dev *dpaa2_get_qbman_swp(void)
 {
 	struct dpaa2_dpio_dev *dpio_dev = NULL;
@@ -274,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));
@@ -283,21 +295,13 @@  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;
 	}
 
 	return dpio_dev;
 }
 
-static void dpaa2_put_qbman_swp(struct dpaa2_dpio_dev *dpio_dev)
-{
-#ifdef RTE_LIBRTE_PMD_DPAA2_EVENTDEV
-	dpaa2_dpio_intr_deinit(dpio_dev);
-#endif
-	if (dpio_dev)
-		rte_atomic16_clear(&dpio_dev->ref_count);
-}
-
 int
 dpaa2_affine_qbman_swp(void)
 {
@@ -308,7 +312,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;
@@ -330,7 +334,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;