Skip to content

Commit f062671

Browse files
htejunRoland Dreier
authored andcommitted
RDMA: Update workqueue usage
* ib_wq is added, which is used as the common workqueue for infiniband instead of the system workqueue. All system workqueue usages including flush_scheduled_work() callers are converted to use and flush ib_wq. * cancel_delayed_work() + flush_scheduled_work() converted to cancel_delayed_work_sync(). * qib_wq is removed and ib_wq is used instead. This is to prepare for deprecation of flush_scheduled_work(). Signed-off-by: Tejun Heo <[email protected]> Signed-off-by: Roland Dreier <[email protected]>
1 parent 948579c commit f062671

File tree

13 files changed

+39
-50
lines changed

13 files changed

+39
-50
lines changed

drivers/infiniband/core/cache.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ static void ib_cache_event(struct ib_event_handler *handler,
308308
INIT_WORK(&work->work, ib_cache_task);
309309
work->device = event->device;
310310
work->port_num = event->element.port_num;
311-
schedule_work(&work->work);
311+
queue_work(ib_wq, &work->work);
312312
}
313313
}
314314
}
@@ -368,7 +368,7 @@ static void ib_cache_cleanup_one(struct ib_device *device)
368368
int p;
369369

370370
ib_unregister_event_handler(&device->cache.event_handler);
371-
flush_scheduled_work();
371+
flush_workqueue(ib_wq);
372372

373373
for (p = 0; p <= end_port(device) - start_port(device); ++p) {
374374
kfree(device->cache.pkey_cache[p]);

drivers/infiniband/core/device.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
#include <linux/slab.h>
3939
#include <linux/init.h>
4040
#include <linux/mutex.h>
41-
#include <linux/workqueue.h>
4241

4342
#include "core_priv.h"
4443

@@ -52,6 +51,9 @@ struct ib_client_data {
5251
void * data;
5352
};
5453

54+
struct workqueue_struct *ib_wq;
55+
EXPORT_SYMBOL_GPL(ib_wq);
56+
5557
static LIST_HEAD(device_list);
5658
static LIST_HEAD(client_list);
5759

@@ -718,6 +720,10 @@ static int __init ib_core_init(void)
718720
{
719721
int ret;
720722

723+
ib_wq = alloc_workqueue("infiniband", 0, 0);
724+
if (!ib_wq)
725+
return -ENOMEM;
726+
721727
ret = ib_sysfs_setup();
722728
if (ret)
723729
printk(KERN_WARNING "Couldn't create InfiniBand device class\n");
@@ -726,6 +732,7 @@ static int __init ib_core_init(void)
726732
if (ret) {
727733
printk(KERN_WARNING "Couldn't set up InfiniBand P_Key/GID cache\n");
728734
ib_sysfs_cleanup();
735+
destroy_workqueue(ib_wq);
729736
}
730737

731738
return ret;
@@ -736,7 +743,7 @@ static void __exit ib_core_cleanup(void)
736743
ib_cache_cleanup();
737744
ib_sysfs_cleanup();
738745
/* Make sure that any pending umem accounting work is done. */
739-
flush_scheduled_work();
746+
destroy_workqueue(ib_wq);
740747
}
741748

742749
module_init(ib_core_init);

drivers/infiniband/core/sa_query.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ static void ib_sa_event(struct ib_event_handler *handler, struct ib_event *event
425425
port->sm_ah = NULL;
426426
spin_unlock_irqrestore(&port->ah_lock, flags);
427427

428-
schedule_work(&sa_dev->port[event->element.port_num -
428+
queue_work(ib_wq, &sa_dev->port[event->element.port_num -
429429
sa_dev->start_port].update_task);
430430
}
431431
}

drivers/infiniband/core/umem.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ void ib_umem_release(struct ib_umem *umem)
262262
umem->mm = mm;
263263
umem->diff = diff;
264264

265-
schedule_work(&umem->work);
265+
queue_work(ib_wq, &umem->work);
266266
return;
267267
}
268268
} else

drivers/infiniband/hw/ipath/ipath_driver.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -755,7 +755,7 @@ static void __devexit ipath_remove_one(struct pci_dev *pdev)
755755
*/
756756
ipath_shutdown_device(dd);
757757

758-
flush_scheduled_work();
758+
flush_workqueue(ib_wq);
759759

760760
if (dd->verbs_dev)
761761
ipath_unregister_ib_device(dd->verbs_dev);

drivers/infiniband/hw/ipath/ipath_user_pages.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ void ipath_release_user_pages_on_close(struct page **p, size_t num_pages)
220220
work->mm = mm;
221221
work->num_pages = num_pages;
222222

223-
schedule_work(&work->work);
223+
queue_work(ib_wq, &work->work);
224224
return;
225225

226226
bail_mm:

drivers/infiniband/hw/qib/qib_iba7220.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1692,8 +1692,7 @@ static void qib_7220_quiet_serdes(struct qib_pportdata *ppd)
16921692
ppd->lflags &= ~QIBL_IB_AUTONEG_INPROG;
16931693
spin_unlock_irqrestore(&ppd->lflags_lock, flags);
16941694
wake_up(&ppd->cpspec->autoneg_wait);
1695-
cancel_delayed_work(&ppd->cpspec->autoneg_work);
1696-
flush_scheduled_work();
1695+
cancel_delayed_work_sync(&ppd->cpspec->autoneg_work);
16971696

16981697
shutdown_7220_relock_poll(ppd->dd);
16991698
val = qib_read_kreg64(ppd->dd, kr_xgxs_cfg);
@@ -3515,8 +3514,8 @@ static void try_7220_autoneg(struct qib_pportdata *ppd)
35153514

35163515
toggle_7220_rclkrls(ppd->dd);
35173516
/* 2 msec is minimum length of a poll cycle */
3518-
schedule_delayed_work(&ppd->cpspec->autoneg_work,
3519-
msecs_to_jiffies(2));
3517+
queue_delayed_work(ib_wq, &ppd->cpspec->autoneg_work,
3518+
msecs_to_jiffies(2));
35203519
}
35213520

35223521
/*

drivers/infiniband/hw/qib/qib_iba7322.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2406,10 +2406,9 @@ static void qib_7322_mini_quiet_serdes(struct qib_pportdata *ppd)
24062406
ppd->lflags &= ~QIBL_IB_AUTONEG_INPROG;
24072407
spin_unlock_irqrestore(&ppd->lflags_lock, flags);
24082408
wake_up(&ppd->cpspec->autoneg_wait);
2409-
cancel_delayed_work(&ppd->cpspec->autoneg_work);
2409+
cancel_delayed_work_sync(&ppd->cpspec->autoneg_work);
24102410
if (ppd->dd->cspec->r1)
2411-
cancel_delayed_work(&ppd->cpspec->ipg_work);
2412-
flush_scheduled_work();
2411+
cancel_delayed_work_sync(&ppd->cpspec->ipg_work);
24132412

24142413
ppd->cpspec->chase_end = 0;
24152414
if (ppd->cpspec->chase_timer.data) /* if initted */
@@ -2706,7 +2705,7 @@ static noinline void unknown_7322_gpio_intr(struct qib_devdata *dd)
27062705
if (!(pins & mask)) {
27072706
++handled;
27082707
qd->t_insert = get_jiffies_64();
2709-
schedule_work(&qd->work);
2708+
queue_work(ib_wq, &qd->work);
27102709
}
27112710
}
27122711
}
@@ -4990,8 +4989,8 @@ static void try_7322_autoneg(struct qib_pportdata *ppd)
49904989
set_7322_ibspeed_fast(ppd, QIB_IB_DDR);
49914990
qib_7322_mini_pcs_reset(ppd);
49924991
/* 2 msec is minimum length of a poll cycle */
4993-
schedule_delayed_work(&ppd->cpspec->autoneg_work,
4994-
msecs_to_jiffies(2));
4992+
queue_delayed_work(ib_wq, &ppd->cpspec->autoneg_work,
4993+
msecs_to_jiffies(2));
49954994
}
49964995

49974996
/*
@@ -5121,7 +5120,8 @@ static void try_7322_ipg(struct qib_pportdata *ppd)
51215120
ib_free_send_mad(send_buf);
51225121
retry:
51235122
delay = 2 << ppd->cpspec->ipg_tries;
5124-
schedule_delayed_work(&ppd->cpspec->ipg_work, msecs_to_jiffies(delay));
5123+
queue_delayed_work(ib_wq, &ppd->cpspec->ipg_work,
5124+
msecs_to_jiffies(delay));
51255125
}
51265126

51275127
/*

drivers/infiniband/hw/qib/qib_init.c

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ unsigned qib_wc_pat = 1; /* default (1) is to use PAT, not MTRR */
8080
module_param_named(wc_pat, qib_wc_pat, uint, S_IRUGO);
8181
MODULE_PARM_DESC(wc_pat, "enable write-combining via PAT mechanism");
8282

83-
struct workqueue_struct *qib_wq;
8483
struct workqueue_struct *qib_cq_wq;
8584

8685
static void verify_interrupt(unsigned long);
@@ -1044,24 +1043,10 @@ static int __init qlogic_ib_init(void)
10441043
if (ret)
10451044
goto bail;
10461045

1047-
/*
1048-
* We create our own workqueue mainly because we want to be
1049-
* able to flush it when devices are being removed. We can't
1050-
* use schedule_work()/flush_scheduled_work() because both
1051-
* unregister_netdev() and linkwatch_event take the rtnl lock,
1052-
* so flush_scheduled_work() can deadlock during device
1053-
* removal.
1054-
*/
1055-
qib_wq = create_workqueue("qib");
1056-
if (!qib_wq) {
1057-
ret = -ENOMEM;
1058-
goto bail_dev;
1059-
}
1060-
10611046
qib_cq_wq = create_singlethread_workqueue("qib_cq");
10621047
if (!qib_cq_wq) {
10631048
ret = -ENOMEM;
1064-
goto bail_wq;
1049+
goto bail_dev;
10651050
}
10661051

10671052
/*
@@ -1091,8 +1076,6 @@ static int __init qlogic_ib_init(void)
10911076
idr_destroy(&qib_unit_table);
10921077
bail_cq_wq:
10931078
destroy_workqueue(qib_cq_wq);
1094-
bail_wq:
1095-
destroy_workqueue(qib_wq);
10961079
bail_dev:
10971080
qib_dev_cleanup();
10981081
bail:
@@ -1116,7 +1099,6 @@ static void __exit qlogic_ib_cleanup(void)
11161099

11171100
pci_unregister_driver(&qib_driver);
11181101

1119-
destroy_workqueue(qib_wq);
11201102
destroy_workqueue(qib_cq_wq);
11211103

11221104
qib_cpulist_count = 0;
@@ -1289,7 +1271,7 @@ static int __devinit qib_init_one(struct pci_dev *pdev,
12891271

12901272
if (qib_mini_init || initfail || ret) {
12911273
qib_stop_timers(dd);
1292-
flush_scheduled_work();
1274+
flush_workqueue(ib_wq);
12931275
for (pidx = 0; pidx < dd->num_pports; ++pidx)
12941276
dd->f_quiet_serdes(dd->pport + pidx);
12951277
if (qib_mini_init)
@@ -1338,8 +1320,8 @@ static void __devexit qib_remove_one(struct pci_dev *pdev)
13381320

13391321
qib_stop_timers(dd);
13401322

1341-
/* wait until all of our (qsfp) schedule_work() calls complete */
1342-
flush_scheduled_work();
1323+
/* wait until all of our (qsfp) queue_work() calls complete */
1324+
flush_workqueue(ib_wq);
13431325

13441326
ret = qibfs_remove(dd);
13451327
if (ret)

drivers/infiniband/hw/qib/qib_qsfp.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -485,18 +485,17 @@ void qib_qsfp_init(struct qib_qsfp_data *qd,
485485
goto bail;
486486
/* We see a module, but it may be unwise to look yet. Just schedule */
487487
qd->t_insert = get_jiffies_64();
488-
schedule_work(&qd->work);
488+
queue_work(ib_wq, &qd->work);
489489
bail:
490490
return;
491491
}
492492

493493
void qib_qsfp_deinit(struct qib_qsfp_data *qd)
494494
{
495495
/*
496-
* There is nothing to do here for now. our
497-
* work is scheduled with schedule_work(), and
498-
* flush_scheduled_work() from remove_one will
499-
* block until all work ssetup with schedule_work()
496+
* There is nothing to do here for now. our work is scheduled
497+
* with queue_work(), and flush_workqueue() from remove_one
498+
* will block until all work setup with queue_work()
500499
* completes.
501500
*/
502501
}

drivers/infiniband/hw/qib/qib_verbs.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -805,7 +805,6 @@ static inline int qib_send_ok(struct qib_qp *qp)
805805
!(qp->s_flags & QIB_S_ANY_WAIT_SEND));
806806
}
807807

808-
extern struct workqueue_struct *qib_wq;
809808
extern struct workqueue_struct *qib_cq_wq;
810809

811810
/*
@@ -814,7 +813,7 @@ extern struct workqueue_struct *qib_cq_wq;
814813
static inline void qib_schedule_send(struct qib_qp *qp)
815814
{
816815
if (qib_send_ok(qp))
817-
queue_work(qib_wq, &qp->s_work);
816+
queue_work(ib_wq, &qp->s_work);
818817
}
819818

820819
static inline int qib_pkey_ok(u16 pkey1, u16 pkey2)

drivers/infiniband/ulp/srp/ib_srp.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,7 @@ static int srp_reconnect_target(struct srp_target_port *target)
638638
if (target->state == SRP_TARGET_CONNECTING) {
639639
target->state = SRP_TARGET_DEAD;
640640
INIT_WORK(&target->work, srp_remove_work);
641-
schedule_work(&target->work);
641+
queue_work(ib_wq, &target->work);
642642
}
643643
spin_unlock_irq(&target->lock);
644644

@@ -2199,7 +2199,7 @@ static void srp_remove_one(struct ib_device *device)
21992199
* started before we marked our target ports as
22002200
* removed, and any target port removal tasks.
22012201
*/
2202-
flush_scheduled_work();
2202+
flush_workqueue(ib_wq);
22032203

22042204
list_for_each_entry_safe(target, tmp_target,
22052205
&host->target_list, list) {

include/rdma/ib_verbs.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,13 @@
4747
#include <linux/list.h>
4848
#include <linux/rwsem.h>
4949
#include <linux/scatterlist.h>
50+
#include <linux/workqueue.h>
5051

5152
#include <asm/atomic.h>
5253
#include <asm/uaccess.h>
5354

55+
extern struct workqueue_struct *ib_wq;
56+
5457
union ib_gid {
5558
u8 raw[16];
5659
struct {

0 commit comments

Comments
 (0)