aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLogan Gunthorpe <logang@deltatee.com>2016-06-20 15:15:07 -0400
committerJon Mason <jdmason@kudzu.us>2016-08-05 10:21:07 -0400
commit26dc638ae6e32bddfb8d3da0fc93946955c28c78 (patch)
tree6c45c18b7abcd8b5882d3768417a0bebed1243a4
parent58fd0f3b1539a5bad451a823c9d039ea23387b23 (diff)
ntb_perf: Wait for link before running test
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@deltatee.com> Acked-by: Dave Jiang <dave.jiang@intel.com> Signed-off-by: Jon Mason <jdmason@kudzu.us>
-rw-r--r--drivers/ntb/test/ntb_perf.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/ntb/test/ntb_perf.c b/drivers/ntb/test/ntb_perf.c
index 05a870524a67..f0784e50ceb7 100644
--- a/drivers/ntb/test/ntb_perf.c
+++ b/drivers/ntb/test/ntb_perf.c
@@ -135,6 +135,7 @@ struct perf_ctx {
135 bool link_is_up; 135 bool link_is_up;
136 struct work_struct link_cleanup; 136 struct work_struct link_cleanup;
137 struct delayed_work link_work; 137 struct delayed_work link_work;
138 wait_queue_head_t link_wq;
138 struct dentry *debugfs_node_dir; 139 struct dentry *debugfs_node_dir;
139 struct dentry *debugfs_run; 140 struct dentry *debugfs_run;
140 struct dentry *debugfs_threads; 141 struct dentry *debugfs_threads;
@@ -533,6 +534,7 @@ static void perf_link_work(struct work_struct *work)
533 goto out1; 534 goto out1;
534 535
535 perf->link_is_up = true; 536 perf->link_is_up = true;
537 wake_up(&perf->link_wq);
536 538
537 return; 539 return;
538 540
@@ -653,7 +655,7 @@ static ssize_t debugfs_run_write(struct file *filp, const char __user *ubuf,
653 int node, i; 655 int node, i;
654 DECLARE_WAIT_QUEUE_HEAD(wq); 656 DECLARE_WAIT_QUEUE_HEAD(wq);
655 657
656 if (!perf->link_is_up) 658 if (wait_event_interruptible(perf->link_wq, perf->link_is_up))
657 return -ENOLINK; 659 return -ENOLINK;
658 660
659 if (perf->perf_threads == 0) 661 if (perf->perf_threads == 0)
@@ -783,6 +785,7 @@ static int perf_probe(struct ntb_client *client, struct ntb_dev *ntb)
783 mutex_init(&perf->run_mutex); 785 mutex_init(&perf->run_mutex);
784 spin_lock_init(&perf->db_lock); 786 spin_lock_init(&perf->db_lock);
785 perf_setup_mw(ntb, perf); 787 perf_setup_mw(ntb, perf);
788 init_waitqueue_head(&perf->link_wq);
786 INIT_DELAYED_WORK(&perf->link_work, perf_link_work); 789 INIT_DELAYED_WORK(&perf->link_work, perf_link_work);
787 INIT_WORK(&perf->link_cleanup, perf_link_cleanup); 790 INIT_WORK(&perf->link_cleanup, perf_link_cleanup);
788 791