usb/c67x00: Replace tasklet with work
authorDavidlohr Bueso <dave@stgolabs.net>
Wed, 13 Jan 2021 03:15:37 +0000 (19:15 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 26 Jan 2021 17:36:37 +0000 (18:36 +0100)
Tasklets have long been deprecated as being too heavy on the system
by running in irq context - and this is not a performance critical
path. If a higher priority process wants to run, it must wait for
the tasklet to finish before doing so.

c67x00_do_work() will now run in process context and have further
concurrency (tasklets being serialized among themselves), but this
is done holding the c67x00->lock, so it should be fine. Furthermore,
this patch fixes the usage of the lock in the callback as otherwise
it would need to be irq-safe.

Signed-off-by: Davidlohr Bueso <dbueso@suse.de>
Link: https://lore.kernel.org/r/20210113031537.79859-1-dave@stgolabs.net
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/c67x00/c67x00-hcd.h
drivers/usb/c67x00/c67x00-sched.c

index 6b6b04a..6332a6b 100644 (file)
@@ -76,7 +76,7 @@ struct c67x00_hcd {
        u16 next_td_addr;
        u16 next_buf_addr;
 
-       struct tasklet_struct tasklet;
+       struct work_struct work;
 
        struct completion endpoint_disable;
 
index e65f1a0..c7d3e90 100644 (file)
@@ -1123,24 +1123,26 @@ static void c67x00_do_work(struct c67x00_hcd *c67x00)
 
 /* -------------------------------------------------------------------------- */
 
-static void c67x00_sched_tasklet(struct tasklet_struct *t)
+static void c67x00_sched_work(struct work_struct *work)
 {
-       struct c67x00_hcd *c67x00 = from_tasklet(c67x00, t, tasklet);
+       struct c67x00_hcd *c67x00;
+
+       c67x00 = container_of(work, struct c67x00_hcd, work);
        c67x00_do_work(c67x00);
 }
 
 void c67x00_sched_kick(struct c67x00_hcd *c67x00)
 {
-       tasklet_hi_schedule(&c67x00->tasklet);
+       queue_work(system_highpri_wq, &c67x00->work);
 }
 
 int c67x00_sched_start_scheduler(struct c67x00_hcd *c67x00)
 {
-       tasklet_setup(&c67x00->tasklet, c67x00_sched_tasklet);
+       INIT_WORK(&c67x00->work, c67x00_sched_work);
        return 0;
 }
 
 void c67x00_sched_stop_scheduler(struct c67x00_hcd *c67x00)
 {
-       tasklet_kill(&c67x00->tasklet);
+       cancel_work_sync(&c67x00->work);
 }