From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753653AbcFMUOG (ORCPT ); Mon, 13 Jun 2016 16:14:06 -0400 Received: from mga02.intel.com ([134.134.136.20]:17494 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751009AbcFMUOE (ORCPT ); Mon, 13 Jun 2016 16:14:04 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,467,1459839600"; d="scan'208";a="996833828" From: "Jiang, Dave" To: "Allen.Hubbe@emc.com" , "logang@deltatee.com" , "jdmason@kudzu.us" CC: "linux-kernel@vger.kernel.org" , "shuahkh@osg.samsung.com" , "sudipm.mukherjee@gmail.com" , "linux-kselftest@vger.kernel.org" , "arnd@arndb.de" , "linux-ntb@googlegroups.com" Subject: Re: [PATCH 4/8] ntb_perf: Wait for link before running test Thread-Topic: [PATCH 4/8] ntb_perf: Wait for link before running test Thread-Index: AQHRw2s2tHGZJLi7c0mDbbCF9AAPmZ/oTq6A Date: Mon, 13 Jun 2016 20:14:01 +0000 Message-ID: <1465848825.16234.251.camel@intel.com> References: <71664260d670af5f24beb9c825791802659f3cd2.1465598632.git.logang@deltatee.com> In-Reply-To: <71664260d670af5f24beb9c825791802659f3cd2.1465598632.git.logang@deltatee.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [143.182.137.38] Content-Type: text/plain; charset="utf-8" Content-ID: <338A24E7F24FB24AAEC8D7631A02CA58@intel.com> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by mail.home.local id u5DKEBSV011726 On Fri, 2016-06-10 at 16:54 -0600, Logan Gunthorpe wrote: > Instead of returning immediately with an error when the link is > down, wait for the link to come up (or the user sends a SIGINT). > > This is to make scripting ntb_perf easier. > > Signed-off-by: Logan Gunthorpe Acked-by: Dave Jiang > --- >  drivers/ntb/test/ntb_perf.c | 5 ++++- >  1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/drivers/ntb/test/ntb_perf.c > b/drivers/ntb/test/ntb_perf.c > index 05a8705..f0784e5 100644 > --- a/drivers/ntb/test/ntb_perf.c > +++ b/drivers/ntb/test/ntb_perf.c > @@ -135,6 +135,7 @@ struct perf_ctx { >   bool link_is_up; >   struct work_struct link_cleanup; >   struct delayed_work link_work; > + wait_queue_head_t link_wq; >   struct dentry *debugfs_node_dir; >   struct dentry *debugfs_run; >   struct dentry *debugfs_threads; > @@ -533,6 +534,7 @@ static void perf_link_work(struct work_struct > *work) >   goto out1; >   >   perf->link_is_up = true; > + wake_up(&perf->link_wq); >   >   return; >   > @@ -653,7 +655,7 @@ static ssize_t debugfs_run_write(struct file > *filp, const char __user *ubuf, >   int node, i; >   DECLARE_WAIT_QUEUE_HEAD(wq); >   > - if (!perf->link_is_up) > + if (wait_event_interruptible(perf->link_wq, perf- > >link_is_up)) >   return -ENOLINK; >   >   if (perf->perf_threads == 0) > @@ -783,6 +785,7 @@ static int perf_probe(struct ntb_client *client, > struct ntb_dev *ntb) >   mutex_init(&perf->run_mutex); >   spin_lock_init(&perf->db_lock); >   perf_setup_mw(ntb, perf); > + init_waitqueue_head(&perf->link_wq); >   INIT_DELAYED_WORK(&perf->link_work, perf_link_work); >   INIT_WORK(&perf->link_cleanup, perf_link_cleanup); >   > --  > 2.1.4 >