From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id CF3E1A034C; Fri, 21 Jan 2022 02:32:43 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 862CC42712; Fri, 21 Jan 2022 02:32:43 +0100 (CET) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mails.dpdk.org (Postfix) with ESMTP id C06A940042; Fri, 21 Jan 2022 02:32:40 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1642728761; x=1674264761; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=BbSdk6KTIYwV1yTujvzXqWvZ0LDzca0+4xmxLVPY0Ow=; b=bi1/FcUW74D4WACXUbO0jZIcH/rVWMkgYiW4BQ83vGErZtWQn7E2uRXa bqy19HzoKzdQeiv9MeqSxTmDrfoPWmu/cRVabrStFnWCFNQA12oao+5Mh Xj0gKwPaExQdB+zZqkGpdPpTwmd4PXOhcdNX1kRe8dBay+fkWcSVQSABi xVnUSTtef3a2NeD/pnLXNFKiKo+2keT0MS3D2+1tL+ZQWBKDSPd6906O6 +ssNlUo9/IBEU9d8FxiydtaaRmwDHwHEduwG1JKUkIp8VHofqqCBXomGm 4OF8Jo3OClc9bVmHjDO9/J9ITRuOmiTfQmtOBXQ/h0IpMdjlQlmsBca+l g==; X-IronPort-AV: E=McAfee;i="6200,9189,10233"; a="245487349" X-IronPort-AV: E=Sophos;i="5.88,303,1635231600"; d="scan'208";a="245487349" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Jan 2022 17:32:39 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,303,1635231600"; d="scan'208";a="616334386" Received: from unknown (HELO localhost.localdomain.sh.intel.com) ([10.238.175.107]) by FMSMGA003.fm.intel.com with ESMTP; 20 Jan 2022 17:32:37 -0800 From: Wei Huang To: dev@dpdk.org, rosen.xu@intel.com, qi.z.zhang@intel.com Cc: stable@dpdk.org, tianfei.zhang@intel.com, ferruh.yigit@intel.com Subject: [PATCH v4] raw/ifpga: fix pthread cannot join Date: Thu, 20 Jan 2022 20:29:32 -0500 Message-Id: <20220121012932.9827-1-wei.huang@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20220120055814.7244-1-wei.huang@intel.com> References: <20220120055814.7244-1-wei.huang@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Tianfei Zhang When we want to close a thread, we should set a flag to notify thread handler function. Fixes: 9c006c45 ("raw/ifpga: scan PCIe BDF device tree") Cc: stable@dpdk.org Signed-off-by: Tianfei Zhang --- v2: update commit log --- v3: set thread id to 0 after pthread_join --- v4: do not evaluate and set pthread_t variable --- drivers/raw/ifpga/ifpga_rawdev.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/raw/ifpga/ifpga_rawdev.c b/drivers/raw/ifpga/ifpga_rawdev.c index 8d9db58..cb5166e 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]; @@ -542,19 +542,20 @@ static int set_surprise_link_check_aer( static int ifpga_monitor_stop_func(void) { + void *status; int ret; if (ifpga_monitor_start == 1) { + ifpga_monitor_start = 0; + ret = pthread_cancel(ifpga_monitor_start_thread); if (ret) IFPGA_RAWDEV_PMD_ERR("Can't cancel the thread"); - ret = pthread_join(ifpga_monitor_start_thread, NULL); + ret = pthread_join(ifpga_monitor_start_thread, &status); if (ret) IFPGA_RAWDEV_PMD_ERR("Can't join the thread"); - ifpga_monitor_start = 0; - return ret; } -- 1.8.3.1