Skip to content

Commit 1a1e098

Browse files
committed
Merge tag 'wq-for-6.9-bh-conversions' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/wq
Pull workqueue BH conversions from Tejun Heo: "This contains two patches that convert tasklet users to BH workqueues: backtracetest and usb hcd. DM conversions are being routed through the respective subsystem tree. Hopefully, the next cycle will see a lot more conversions" * tag 'wq-for-6.9-bh-conversions' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/wq: usb: core: hcd: Convert from tasklet to BH workqueue backtracetest: Convert from tasklet to BH workqueue
2 parents ff887eb + 8fea0c8 commit 1a1e098

File tree

3 files changed

+20
-23
lines changed

3 files changed

+20
-23
lines changed

drivers/usb/core/hcd.c

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1664,9 +1664,10 @@ static void __usb_hcd_giveback_urb(struct urb *urb)
16641664
usb_put_urb(urb);
16651665
}
16661666

1667-
static void usb_giveback_urb_bh(struct tasklet_struct *t)
1667+
static void usb_giveback_urb_bh(struct work_struct *work)
16681668
{
1669-
struct giveback_urb_bh *bh = from_tasklet(bh, t, bh);
1669+
struct giveback_urb_bh *bh =
1670+
container_of(work, struct giveback_urb_bh, bh);
16701671
struct list_head local_list;
16711672

16721673
spin_lock_irq(&bh->lock);
@@ -1691,9 +1692,9 @@ static void usb_giveback_urb_bh(struct tasklet_struct *t)
16911692
spin_lock_irq(&bh->lock);
16921693
if (!list_empty(&bh->head)) {
16931694
if (bh->high_prio)
1694-
tasklet_hi_schedule(&bh->bh);
1695+
queue_work(system_bh_highpri_wq, &bh->bh);
16951696
else
1696-
tasklet_schedule(&bh->bh);
1697+
queue_work(system_bh_wq, &bh->bh);
16971698
}
16981699
bh->running = false;
16991700
spin_unlock_irq(&bh->lock);
@@ -1706,7 +1707,7 @@ static void usb_giveback_urb_bh(struct tasklet_struct *t)
17061707
* @status: completion status code for the URB.
17071708
*
17081709
* Context: atomic. The completion callback is invoked in caller's context.
1709-
* For HCDs with HCD_BH flag set, the completion callback is invoked in tasklet
1710+
* For HCDs with HCD_BH flag set, the completion callback is invoked in BH
17101711
* context (except for URBs submitted to the root hub which always complete in
17111712
* caller's context).
17121713
*
@@ -1725,7 +1726,7 @@ void usb_hcd_giveback_urb(struct usb_hcd *hcd, struct urb *urb, int status)
17251726
struct giveback_urb_bh *bh;
17261727
bool running;
17271728

1728-
/* pass status to tasklet via unlinked */
1729+
/* pass status to BH via unlinked */
17291730
if (likely(!urb->unlinked))
17301731
urb->unlinked = status;
17311732

@@ -1747,9 +1748,9 @@ void usb_hcd_giveback_urb(struct usb_hcd *hcd, struct urb *urb, int status)
17471748
if (running)
17481749
;
17491750
else if (bh->high_prio)
1750-
tasklet_hi_schedule(&bh->bh);
1751+
queue_work(system_bh_highpri_wq, &bh->bh);
17511752
else
1752-
tasklet_schedule(&bh->bh);
1753+
queue_work(system_bh_wq, &bh->bh);
17531754
}
17541755
EXPORT_SYMBOL_GPL(usb_hcd_giveback_urb);
17551756

@@ -2540,7 +2541,7 @@ static void init_giveback_urb_bh(struct giveback_urb_bh *bh)
25402541

25412542
spin_lock_init(&bh->lock);
25422543
INIT_LIST_HEAD(&bh->head);
2543-
tasklet_setup(&bh->bh, usb_giveback_urb_bh);
2544+
INIT_WORK(&bh->bh, usb_giveback_urb_bh);
25442545
}
25452546

25462547
struct usb_hcd *__usb_create_hcd(const struct hc_driver *driver,
@@ -2926,7 +2927,7 @@ int usb_add_hcd(struct usb_hcd *hcd,
29262927
&& device_can_wakeup(&hcd->self.root_hub->dev))
29272928
dev_dbg(hcd->self.controller, "supports USB remote wakeup\n");
29282929

2929-
/* initialize tasklets */
2930+
/* initialize BHs */
29302931
init_giveback_urb_bh(&hcd->high_prio_bh);
29312932
hcd->high_prio_bh.high_prio = true;
29322933
init_giveback_urb_bh(&hcd->low_prio_bh);
@@ -3036,7 +3037,7 @@ void usb_remove_hcd(struct usb_hcd *hcd)
30363037
mutex_unlock(&usb_bus_idr_lock);
30373038

30383039
/*
3039-
* tasklet_kill() isn't needed here because:
3040+
* flush_work() isn't needed here because:
30403041
* - driver's disconnect() called from usb_disconnect() should
30413042
* make sure its URBs are completed during the disconnect()
30423043
* callback

include/linux/usb/hcd.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ struct giveback_urb_bh {
5555
bool high_prio;
5656
spinlock_t lock;
5757
struct list_head head;
58-
struct tasklet_struct bh;
58+
struct work_struct bh;
5959
struct usb_host_endpoint *completing_ep;
6060
};
6161

kernel/backtracetest.c

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,24 +21,20 @@ static void backtrace_test_normal(void)
2121
dump_stack();
2222
}
2323

24-
static DECLARE_COMPLETION(backtrace_work);
25-
26-
static void backtrace_test_irq_callback(unsigned long data)
24+
static void backtrace_test_bh_workfn(struct work_struct *work)
2725
{
2826
dump_stack();
29-
complete(&backtrace_work);
3027
}
3128

32-
static DECLARE_TASKLET_OLD(backtrace_tasklet, &backtrace_test_irq_callback);
29+
static DECLARE_WORK(backtrace_bh_work, &backtrace_test_bh_workfn);
3330

34-
static void backtrace_test_irq(void)
31+
static void backtrace_test_bh(void)
3532
{
36-
pr_info("Testing a backtrace from irq context.\n");
33+
pr_info("Testing a backtrace from BH context.\n");
3734
pr_info("The following trace is a kernel self test and not a bug!\n");
3835

39-
init_completion(&backtrace_work);
40-
tasklet_schedule(&backtrace_tasklet);
41-
wait_for_completion(&backtrace_work);
36+
queue_work(system_bh_wq, &backtrace_bh_work);
37+
flush_work(&backtrace_bh_work);
4238
}
4339

4440
#ifdef CONFIG_STACKTRACE
@@ -65,7 +61,7 @@ static int backtrace_regression_test(void)
6561
pr_info("====[ backtrace testing ]===========\n");
6662

6763
backtrace_test_normal();
68-
backtrace_test_irq();
64+
backtrace_test_bh();
6965
backtrace_test_saved();
7066

7167
pr_info("====[ end of backtrace testing ]====\n");

0 commit comments

Comments
 (0)