summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMika Westerberg <mika.westerberg@linux.intel.com>2018-10-22 07:47:01 -0400
committerMika Westerberg <mika.westerberg@linux.intel.com>2019-04-18 04:18:53 -0400
commit559c1e1e013437bf190469efbcbd8bc803285853 (patch)
tree670acc0667337e573aa5291e63a1b8ba031a7ff7
parentab9f31cfa89ad700f83bfaf30dc8703c4f609d0f (diff)
thunderbolt: Run tb_xdp_handle_request() in system workqueue
We run all XDomain requests during discovery in tb->wq and since it only runs one work at the time it means that sending back reply to the other domain may be delayed too much depending whether there is an active XDomain discovery request running. To make sure we can send reply to the other domain as soon as possible run tb_xdp_handle_request() in system workqueue instead. Since the device can be hot-removed in the middle we need to make sure the domain structure is still around when the function is run so increase reference count before we schedule the reply work. Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
-rw-r--r--drivers/thunderbolt/tb.h7
-rw-r--r--drivers/thunderbolt/xdomain.c6
2 files changed, 11 insertions, 2 deletions
diff --git a/drivers/thunderbolt/tb.h b/drivers/thunderbolt/tb.h
index 56eed0bc3c2b..89b5d18f6035 100644
--- a/drivers/thunderbolt/tb.h
+++ b/drivers/thunderbolt/tb.h
@@ -492,6 +492,13 @@ int tb_domain_approve_xdomain_paths(struct tb *tb, struct tb_xdomain *xd);
492int tb_domain_disconnect_xdomain_paths(struct tb *tb, struct tb_xdomain *xd); 492int tb_domain_disconnect_xdomain_paths(struct tb *tb, struct tb_xdomain *xd);
493int tb_domain_disconnect_all_paths(struct tb *tb); 493int tb_domain_disconnect_all_paths(struct tb *tb);
494 494
495static inline struct tb *tb_domain_get(struct tb *tb)
496{
497 if (tb)
498 get_device(&tb->dev);
499 return tb;
500}
501
495static inline void tb_domain_put(struct tb *tb) 502static inline void tb_domain_put(struct tb *tb)
496{ 503{
497 put_device(&tb->dev); 504 put_device(&tb->dev);
diff --git a/drivers/thunderbolt/xdomain.c b/drivers/thunderbolt/xdomain.c
index 7bae92bc486f..44d3b2e486cd 100644
--- a/drivers/thunderbolt/xdomain.c
+++ b/drivers/thunderbolt/xdomain.c
@@ -524,6 +524,8 @@ static void tb_xdp_handle_request(struct work_struct *work)
524out: 524out:
525 kfree(xw->pkg); 525 kfree(xw->pkg);
526 kfree(xw); 526 kfree(xw);
527
528 tb_domain_put(tb);
527} 529}
528 530
529static bool 531static bool
@@ -542,9 +544,9 @@ tb_xdp_schedule_request(struct tb *tb, const struct tb_xdp_header *hdr,
542 kfree(xw); 544 kfree(xw);
543 return false; 545 return false;
544 } 546 }
545 xw->tb = tb; 547 xw->tb = tb_domain_get(tb);
546 548
547 queue_work(tb->wq, &xw->work); 549 schedule_work(&xw->work);
548 return true; 550 return true;
549} 551}
550 552