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 AD6A9A00C3; Thu, 20 Jan 2022 09:08:33 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5889141C27; Thu, 20 Jan 2022 09:08:33 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id BB9E5411A4 for ; Thu, 20 Jan 2022 09:08:31 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642666111; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=e41mHGaJAexlIjvqKvA7wL9Y93G2FUSDxg1NELE8i50=; b=Fj+wvqWLVSt/gu5tkilb4kTlgOHMigDsmfF/SuaC7XOcsThVpU433Y9xM2GU15qewOCuKL MfSThE4FzZ+AXEUO/L5Pa5naoCX6bObVqALxUkIWSML/2gOyxaP1GAgfZoqik45zH9mAlD G0jXwgfiD2lW5Vc9FVEThR/Lh1t68ZU= Received: from mail-lf1-f69.google.com (mail-lf1-f69.google.com [209.85.167.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-161-g_gQCqLJMIm9EIyxphRbvQ-1; Thu, 20 Jan 2022 03:08:29 -0500 X-MC-Unique: g_gQCqLJMIm9EIyxphRbvQ-1 Received: by mail-lf1-f69.google.com with SMTP id q15-20020a19430f000000b004358f84b644so367060lfa.7 for ; Thu, 20 Jan 2022 00:08:29 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=e41mHGaJAexlIjvqKvA7wL9Y93G2FUSDxg1NELE8i50=; b=uHMqFrXYMFTHFuMlCkinP/Crnc1KPo7rWL2JEU7QXdJoWZnM8xy6kAgXYM/fketbWE Er889DpUarGF0LtX2whl7LpBQldvderCUXaS9paAks7EQBlF5OgkW0mqNv5yS3Gde/rI 0+gJUEADPOsSxiRFPXUTSAmX64fGVHi0grqytjuSyuqSoWUmWzcxfVj/AU/UA9MoNBH/ a41F4bV/6yMBcxTbNf4F73jcGaQYs6jDEj/0dxarN0VZyMU50jsgJOCyZ+UgnvjvAD6t Bwf2cjFP+ZoXy9DQBKUL7EVA0JPGSPL2GWt/JIcJf6TOkF+8/h8gHDEOctM6spZtq2qT hDLw== X-Gm-Message-State: AOAM531NRU6+kSI5K3QOv5jGUnlSnBy338ChTC5rXZYjd1e3pxA5lPuL llg1PT4oEVbUieJ43zT+tdXU857vM6rms4U9hwhzxfy200gz906bXKIGidl6zA9jMi5kvRmFvOx rI/LQSP9ODgQUwJ/ernM= X-Received: by 2002:a05:6512:753:: with SMTP id c19mr331600lfs.553.1642666108239; Thu, 20 Jan 2022 00:08:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJxqtCLwxBAx+doxdwtwjd4eoK0sJey/jFnRjj05jg3SnviyiPi4SGzm5Pt5XzhOYgbApXZ9YTzgdua2ysdVP8M= X-Received: by 2002:a05:6512:753:: with SMTP id c19mr331583lfs.553.1642666107998; Thu, 20 Jan 2022 00:08:27 -0800 (PST) MIME-Version: 1.0 References: <20220120023535.6747-1-wei.huang@intel.com> <20220120055814.7244-1-wei.huang@intel.com> In-Reply-To: <20220120055814.7244-1-wei.huang@intel.com> From: David Marchand Date: Thu, 20 Jan 2022 09:08:16 +0100 Message-ID: Subject: Re: [PATCH v3] raw/ifpga: fix pthread cannot join To: Wei Huang Cc: dev , Rosen Xu , Qi Zhang , dpdk stable , "Zhang, Tianfei" , "Yigit, Ferruh" Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dmarchan@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" 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 On Thu, Jan 20, 2022 at 7:01 AM Wei Huang wrote: > > 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 Evaluating/setting a pthread_t variable is a bad idea: this type should be considered opaque. Plus here, the ifpga_monitor_start variable already indicates whether ifpga_monitor_start_thread is valid. Only checking for ifpga_monitor_start in ifpga_rawdev_gsd_handle loop should be enough. > --- > drivers/raw/ifpga/ifpga_rawdev.c | 11 +++++++---- > 1 file changed, 7 insertions(+), 4 deletions(-) > > diff --git a/drivers/raw/ifpga/ifpga_rawdev.c b/drivers/raw/ifpga/ifpga_rawdev.c > index 8d9db58..2bc569b 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,18 +542,21 @@ static int set_surprise_link_check_aer( > static int > ifpga_monitor_stop_func(void) > { > + void *status; This status variable is unused, no need for it. > 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"); > > - 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; > + ifpga_monitor_start_thread = 0; > > return ret; > } > -- > 1.8.3.1 > -- David Marchand