Re: [PATCH 4/8] ntb_perf: Wait for link before running test
From: Jiang, Dave
Date: Mon Jun 13 2016 - 16:14:10 EST
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 <logang@xxxxxxxxxxxx>
Acked-by: Dave Jiang <dave.jiang@xxxxxxxxx>
> ---
> Â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
>