[06/16] bus/fslmc: limit pthread destructor called for dpaa2 only

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

Checks

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

Commit Message

Hemant Agrawal March 2, 2020, 2:58 p.m. UTC
  From: Nipun Gupta <nipun.gupta@nxp.com>

The destructor was being called for non-dpaa2 as well

Signed-off-by: Nipun Gupta <nipun.gupta@nxp.com>
---
 drivers/bus/fslmc/portal/dpaa2_hw_dpio.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
  

Patch

diff --git a/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c b/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
index 1a1453ea3..054d45306 100644
--- a/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
+++ b/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
@@ -299,6 +299,13 @@  static struct dpaa2_dpio_dev *dpaa2_get_qbman_swp(void)
 		return NULL;
 	}
 
+	ret = pthread_setspecific(dpaa2_portal_key, (void *)dpio_dev);
+	if (ret) {
+		DPAA2_BUS_ERR("pthread_setspecific failed with ret: %d", ret);
+		dpaa2_put_qbman_swp(dpio_dev);
+		return NULL;
+	}
+
 	return dpio_dev;
 }
 
@@ -346,12 +353,14 @@  dpaa2_affine_qbman_ethrx_swp(void)
 	return 0;
 }
 
-static void __attribute__((destructor(102))) dpaa2_portal_finish(void *arg)
+static void dpaa2_portal_finish(void *arg)
 {
 	RTE_SET_USED(arg);
 
 	dpaa2_put_qbman_swp(RTE_PER_LCORE(_dpaa2_io).dpio_dev);
 	dpaa2_put_qbman_swp(RTE_PER_LCORE(_dpaa2_io).ethrx_dpio_dev);
+
+	pthread_setspecific(dpaa2_portal_key, NULL);
 }
 
 /*