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 CC9E7A04A8; Tue, 25 Jan 2022 05:47:26 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 46B8E42825; Tue, 25 Jan 2022 05:47:26 +0100 (CET) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by mails.dpdk.org (Postfix) with ESMTP id 0CEBF4013F; Tue, 25 Jan 2022 05:47:23 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1643086044; x=1674622044; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=0W59tYMU9RM84L3z1o0GfdRAkK3nnGdXYyKwOgAl/SE=; b=b1hABdE/ROXolyNj48MC+kKkbEL1kXvUTN8JU9v+vE8MPLVKphOBQGs8 2nduPfSalW1l69LRtdt6JE/dDo7OXnSyGj9vMhiTo56m89FeSANMhwZhS 9BUH9mx5p2HuLiahcKIRCOlCpeZktjMPJVi5qE9mh60F1E03yxlAsaMDV nhrI0TrJclJ7lBZj1ZI+MNICeHpNBl+APRibYVAzafNpqX7LIXgvyPrCe 9wGU6SfhAd5j9CQGqZR9XJoplf9fFME4Ia5rofB6bl1gky9+BhB4qeBIo /MmKfWMPBJCeg273IhsNYOZpajl4Md1ZzDvSvSuZySweQGPUJ5mWhZcMn Q==; X-IronPort-AV: E=McAfee;i="6200,9189,10237"; a="306933239" X-IronPort-AV: E=Sophos;i="5.88,314,1635231600"; d="scan'208";a="306933239" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jan 2022 20:47:23 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,314,1635231600"; d="scan'208";a="479350117" Received: from fmsmsx601.amr.corp.intel.com ([10.18.126.81]) by orsmga006.jf.intel.com with ESMTP; 24 Jan 2022 20:47:22 -0800 Received: from shsmsx603.ccr.corp.intel.com (10.109.6.143) by fmsmsx601.amr.corp.intel.com (10.18.126.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20; Mon, 24 Jan 2022 20:47:22 -0800 Received: from shsmsx601.ccr.corp.intel.com (10.109.6.141) by SHSMSX603.ccr.corp.intel.com (10.109.6.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20; Tue, 25 Jan 2022 12:47:20 +0800 Received: from shsmsx601.ccr.corp.intel.com ([10.109.6.141]) by SHSMSX601.ccr.corp.intel.com ([10.109.6.141]) with mapi id 15.01.2308.020; Tue, 25 Jan 2022 12:47:20 +0800 From: "Zhang, Qi Z" To: "Xu, Rosen" , "Huang, Wei" , "dev@dpdk.org" CC: "stable@dpdk.org" , "Zhang, Tianfei" , "Yigit, Ferruh" , "stephen@networkplumber.org" , "david.marchand@redhat.com" Subject: RE: [PATCH v8] raw/ifpga: fix pthread cannot join Thread-Topic: [PATCH v8] raw/ifpga: fix pthread cannot join Thread-Index: AQHYENXqVS5dPUtDdk6xVQinsIptxKxycfAAgAC5mgA= Date: Tue, 25 Jan 2022 04:47:20 +0000 Message-ID: <7794c39bdd714f4dbeed22d8d7f5523e@intel.com> References: <20220124023912.18650-1-wei.huang@intel.com> <20220124035005.18955-1-wei.huang@intel.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-reaction: no-action dlp-version: 11.6.200.16 dlp-product: dlpe-windows x-originating-ip: [10.239.127.36] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 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 > -----Original Message----- > From: Xu, Rosen > Sent: Tuesday, January 25, 2022 9:43 AM > To: Huang, Wei ; dev@dpdk.org; Zhang, Qi Z > > Cc: stable@dpdk.org; Zhang, Tianfei ; Yigit, Fer= ruh > ; stephen@networkplumber.org; > david.marchand@redhat.com > Subject: RE: [PATCH v8] raw/ifpga: fix pthread cannot join >=20 > Hi, >=20 > > -----Original Message----- > > From: Huang, Wei > > Sent: Monday, January 24, 2022 11:50 > > To: dev@dpdk.org; Xu, Rosen ; Zhang, Qi Z > > > > Cc: stable@dpdk.org; Zhang, Tianfei ; Yigit, > > Ferruh ; stephen@networkplumber.org; > > david.marchand@redhat.com > > Subject: [PATCH v8] raw/ifpga: fix pthread cannot join > > > > 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 > > --- > > v5: use builtin atomic function to access ifpga_monitor_start flag > > --- > > v6: use __atomic_xxx_n to replace rte_atomicNN_xxx > > --- > > v7: fix typo > > --- > > v8: solve patch applying issue > > --- > > drivers/raw/ifpga/ifpga_rawdev.c | 12 ++++++------ > > 1 file changed, 6 insertions(+), 6 deletions(-) > > > > diff --git a/drivers/raw/ifpga/ifpga_rawdev.c > > b/drivers/raw/ifpga/ifpga_rawdev.c > > index 8d9db58..19c2357 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 (__atomic_load_n(&ifpga_monitor_start, > > __ATOMIC_RELAXED)) { > > gsd_enable =3D 0; > > for (i =3D 0; i < IFPGA_RAWDEV_NUM; i++) { > > ifpga_rdev =3D &ifpga_rawdevices[i]; @@ -525,7 +525,7 > @@ static int > > set_surprise_link_check_aer( { > > int ret; > > > > - if (ifpga_monitor_start =3D=3D 0) { > > + if (!__atomic_load_n(&ifpga_monitor_start, __ATOMIC_RELAXED)) { > > ret =3D rte_ctrl_thread_create(&ifpga_monitor_start_thread, > > "ifpga-monitor", NULL, > > ifpga_rawdev_gsd_handle, NULL); > @@ -534,7 +534,7 @@ static > > int set_surprise_link_check_aer( > > "Fail to create ifpga monitor thread"); > > return -1; > > } > > - ifpga_monitor_start =3D 1; > > + __atomic_store_n(&ifpga_monitor_start, 1, > > __ATOMIC_RELAXED); > > } > > > > return 0; > > @@ -544,7 +544,9 @@ static int set_surprise_link_check_aer( { > > int ret; > > > > - if (ifpga_monitor_start =3D=3D 1) { > > + if (__atomic_load_n(&ifpga_monitor_start, __ATOMIC_RELAXED)) { > > + __atomic_store_n(&ifpga_monitor_start, 0, > > __ATOMIC_RELAXED); > > + > > ret =3D 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 =3D 0; > > - > > return ret; > > } > > > > -- > > 1.8.3.1 >=20 > Acked-by: Rosen Xu Applied to dpdk-next-net-intel. Thanks Qi >=20