[v1] raw/ifpga: fix pthread cannot join

Message ID 20220119055415.4424-1-wei.huang@intel.com (mailing list archive)
State Rejected, archived
Delegated to: Qi Zhang
Headers
Series [v1] raw/ifpga: fix pthread cannot join |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/github-robot: build success github build: passed
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional fail Functional Testing issues
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-abi-testing success Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS

Commit Message

Wei Huang Jan. 19, 2022, 5:54 a.m. UTC
  From: Tianfei Zhang <tianfei.zhang@intel.com>

When we want to close a thread, we should set a flag to
thread handler function.

Fixes: 9c006c45 ("raw/ifpga: scan PCIe BDF device tree")
Cc: stable@dpdk.org

Signed-off-by: Tianfei Zhang <tianfei.zhang@intel.com>
---
 drivers/raw/ifpga/ifpga_rawdev.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
  

Comments

Xu, Rosen Jan. 19, 2022, 10:45 a.m. UTC | #1
Hi Wei,

Some ci/iol-intel-Functional issues, pls check. Thanks a lot.

> -----Original Message-----
> From: Huang, Wei <wei.huang@intel.com>
> Sent: Wednesday, January 19, 2022 13:54
> To: dev@dpdk.org; Xu, Rosen <rosen.xu@intel.com>; Zhang, Qi Z
> <qi.z.zhang@intel.com>
> Cc: stable@dpdk.org; Zhang, Tianfei <tianfei.zhang@intel.com>; Yigit, Ferruh
> <ferruh.yigit@intel.com>
> Subject: [PATCH v1] raw/ifpga: fix pthread cannot join
> 
> From: Tianfei Zhang <tianfei.zhang@intel.com>
> 
> When we want to close a thread, we should set a flag to thread handler
> function.
> 
> Fixes: 9c006c45 ("raw/ifpga: scan PCIe BDF device tree")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Tianfei Zhang <tianfei.zhang@intel.com>
> ---
>  drivers/raw/ifpga/ifpga_rawdev.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/raw/ifpga/ifpga_rawdev.c
> b/drivers/raw/ifpga/ifpga_rawdev.c
> index 8d9db58..9663b67 100644
> --- a/drivers/raw/ifpga/ifpga_rawdev.c
> +++ b/drivers/raw/ifpga/ifpga_rawdev.c
> @@ -497,7 +497,7 @@ static int set_surprise_link_check_aer(
>  	int gsd_enable, ret;
>  #define MS 1000
> 
> -	while (1) {
> +	while (ifpga_monitor_start) {
>  		gsd_enable = 0;
>  		for (i = 0; i < IFPGA_RAWDEV_NUM; i++) {
>  			ifpga_rdev = &ifpga_rawdevices[i];
> @@ -544,7 +544,9 @@ static int set_surprise_link_check_aer(  {
>  	int ret;
> 
> -	if (ifpga_monitor_start == 1) {
> +	if (ifpga_monitor_start == 1 && ifpga_monitor_start_thread) {
> +		ifpga_monitor_start = 0;
> +
>  		ret = pthread_cancel(ifpga_monitor_start_thread);
>  		if (ret)
>  			IFPGA_RAWDEV_PMD_ERR("Can't cancel the
> thread"); @@ -553,8 +555,6 @@ static int set_surprise_link_check_aer(
>  		if (ret)
>  			IFPGA_RAWDEV_PMD_ERR("Can't join the thread");
> 
> -		ifpga_monitor_start = 0;
> -
>  		return ret;
>  	}
> 
> --
> 1.8.3.1
  

Patch

diff --git a/drivers/raw/ifpga/ifpga_rawdev.c b/drivers/raw/ifpga/ifpga_rawdev.c
index 8d9db58..9663b67 100644
--- a/drivers/raw/ifpga/ifpga_rawdev.c
+++ b/drivers/raw/ifpga/ifpga_rawdev.c
@@ -497,7 +497,7 @@  static int set_surprise_link_check_aer(
 	int gsd_enable, ret;
 #define MS 1000
 
-	while (1) {
+	while (ifpga_monitor_start) {
 		gsd_enable = 0;
 		for (i = 0; i < IFPGA_RAWDEV_NUM; i++) {
 			ifpga_rdev = &ifpga_rawdevices[i];
@@ -544,7 +544,9 @@  static int set_surprise_link_check_aer(
 {
 	int ret;
 
-	if (ifpga_monitor_start == 1) {
+	if (ifpga_monitor_start == 1 && ifpga_monitor_start_thread) {
+		ifpga_monitor_start = 0;
+
 		ret = pthread_cancel(ifpga_monitor_start_thread);
 		if (ret)
 			IFPGA_RAWDEV_PMD_ERR("Can't cancel the thread");
@@ -553,8 +555,6 @@  static int set_surprise_link_check_aer(
 		if (ret)
 			IFPGA_RAWDEV_PMD_ERR("Can't join the thread");
 
-		ifpga_monitor_start = 0;
-
 		return ret;
 	}