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 48EC7A00C3 for ; 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 380A140042; 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.133.124]) by mails.dpdk.org (Postfix) with ESMTP id A426A40042 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-f71.google.com (mail-lf1-f71.google.com [209.85.167.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-286-zpPWz0GSPQWJDjpJy0m5qA-1; Thu, 20 Jan 2022 03:08:29 -0500 X-MC-Unique: zpPWz0GSPQWJDjpJy0m5qA-1 Received: by mail-lf1-f71.google.com with SMTP id k11-20020a0565123d8b00b00432719f58dbso3165484lfv.22 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=3nB3em688YTGFDMWsRdsjACRB4ivuP/7pw867ckEyT5uMvOngmSuYZikMHQ9FwD6PU oGtNveigVj2xjCyMcSrWlPYuNz3XOvG4VwzaYlt4QsuWbB56sd2BBrAZ4zXgbQvQCFV9 OIBvbmpdRDVwvrT03fLegzw07Y1qnzVcPhBbOx4RF04cqLWvOj/b8VQcd50iYyz+aLbq DBM1TMnh1QkNmEMVqOxWztbo56mTfdM94usXsDl23zcyER/RZAkY7lNbxFAcfGugMywa BT4CIYz3R96EnyC/CrFSRJNvKuP/sGLmT4dD1lceBWVDUI1zCZUx5kOxzrXsskbRW/fq qtAg== X-Gm-Message-State: AOAM5333UNBkCSDCZ9T+eLXBaBIKoHN/J66mHehEVdCH6Sd2ctbsNkqj CEri/6Ng8hHMFgl5ct3T7odeXg1Rjfc+/n4JeVyVPyv2BNEZP9+VNTigriq2JMx7c5YBNNzGC6n qGbNEPy12NZUfn7xnZRRu2H8= X-Received: by 2002:a05:6512:753:: with SMTP id c19mr331595lfs.553.1642666108214; 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: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-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