aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLogan Gunthorpe <logang@deltatee.com>2016-06-20 15:15:13 -0400
committerJon Mason <jdmason@kudzu.us>2016-08-05 10:21:08 -0400
commit35539b54ac339e2b2dee8c74bc9f0b06f11b11cf (patch)
treeaacbc52f3228f89211c12ef9d1c3b4ef21f72f7a
parent20572ee1c577609f38b56b81c760dcb4151f1dbf (diff)
ntb_perf: clear link_is_up flag when the link goes down.
When the link goes down, the link_is_up flag did not return to false. This could have caused some subtle corner case bugs when the link goes up and down quickly. Once that was fixed, there was found to be a race if the link was brought down then immediately up. The link_cleanup work would occasionally be scheduled after the next link up event. This would cancel the link_work that was supposed to occur and leave ntb_perf in an unusable state. To fix this we get rid of the link_cleanup work and put the actions directly in the link_down event. 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.c28
1 files changed, 9 insertions, 19 deletions
diff --git a/drivers/ntb/test/ntb_perf.c b/drivers/ntb/test/ntb_perf.c
index f0784e50ceb7..6a50f20bf1cd 100644
--- a/drivers/ntb/test/ntb_perf.c
+++ b/drivers/ntb/test/ntb_perf.c
@@ -133,7 +133,6 @@ struct perf_ctx {
133 spinlock_t db_lock; 133 spinlock_t db_lock;
134 struct perf_mw mw; 134 struct perf_mw mw;
135 bool link_is_up; 135 bool link_is_up;
136 struct work_struct link_cleanup;
137 struct delayed_work link_work; 136 struct delayed_work link_work;
138 wait_queue_head_t link_wq; 137 wait_queue_head_t link_wq;
139 struct dentry *debugfs_node_dir; 138 struct dentry *debugfs_node_dir;
@@ -158,10 +157,16 @@ static void perf_link_event(void *ctx)
158{ 157{
159 struct perf_ctx *perf = ctx; 158 struct perf_ctx *perf = ctx;
160 159
161 if (ntb_link_is_up(perf->ntb, NULL, NULL) == 1) 160 if (ntb_link_is_up(perf->ntb, NULL, NULL) == 1) {
162 schedule_delayed_work(&perf->link_work, 2*HZ); 161 schedule_delayed_work(&perf->link_work, 2*HZ);
163 else 162 } else {
164 schedule_work(&perf->link_cleanup); 163 dev_dbg(&perf->ntb->pdev->dev, "link down\n");
164
165 if (!perf->link_is_up)
166 cancel_delayed_work_sync(&perf->link_work);
167
168 perf->link_is_up = false;
169 }
165} 170}
166 171
167static void perf_db_event(void *ctx, int vec) 172static void perf_db_event(void *ctx, int vec)
@@ -547,18 +552,6 @@ out:
547 msecs_to_jiffies(PERF_LINK_DOWN_TIMEOUT)); 552 msecs_to_jiffies(PERF_LINK_DOWN_TIMEOUT));
548} 553}
549 554
550static void perf_link_cleanup(struct work_struct *work)
551{
552 struct perf_ctx *perf = container_of(work,
553 struct perf_ctx,
554 link_cleanup);
555
556 dev_dbg(&perf->ntb->pdev->dev, "%s called\n", __func__);
557
558 if (!perf->link_is_up)
559 cancel_delayed_work_sync(&perf->link_work);
560}
561
562static int perf_setup_mw(struct ntb_dev *ntb, struct perf_ctx *perf) 555static int perf_setup_mw(struct ntb_dev *ntb, struct perf_ctx *perf)
563{ 556{
564 struct perf_mw *mw; 557 struct perf_mw *mw;
@@ -787,7 +780,6 @@ static int perf_probe(struct ntb_client *client, struct ntb_dev *ntb)
787 perf_setup_mw(ntb, perf); 780 perf_setup_mw(ntb, perf);
788 init_waitqueue_head(&perf->link_wq); 781 init_waitqueue_head(&perf->link_wq);
789 INIT_DELAYED_WORK(&perf->link_work, perf_link_work); 782 INIT_DELAYED_WORK(&perf->link_work, perf_link_work);
790 INIT_WORK(&perf->link_cleanup, perf_link_cleanup);
791 783
792 rc = ntb_set_ctx(ntb, perf, &perf_ops); 784 rc = ntb_set_ctx(ntb, perf, &perf_ops);
793 if (rc) 785 if (rc)
@@ -807,7 +799,6 @@ static int perf_probe(struct ntb_client *client, struct ntb_dev *ntb)
807 799
808err_ctx: 800err_ctx:
809 cancel_delayed_work_sync(&perf->link_work); 801 cancel_delayed_work_sync(&perf->link_work);
810 cancel_work_sync(&perf->link_cleanup);
811 kfree(perf); 802 kfree(perf);
812err_perf: 803err_perf:
813 return rc; 804 return rc;
@@ -823,7 +814,6 @@ static void perf_remove(struct ntb_client *client, struct ntb_dev *ntb)
823 mutex_lock(&perf->run_mutex); 814 mutex_lock(&perf->run_mutex);
824 815
825 cancel_delayed_work_sync(&perf->link_work); 816 cancel_delayed_work_sync(&perf->link_work);
826 cancel_work_sync(&perf->link_cleanup);
827 817
828 ntb_clear_ctx(ntb); 818 ntb_clear_ctx(ntb);
829 ntb_link_disable(ntb); 819 ntb_link_disable(ntb);