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.

dbc_rx_push() will now run in process context and have further
concurrency - tasklets being serialized among themselves, but this
is done holding the port_lock, so it should be fine.

Signed-off-by: Davidlohr Bueso <dbu...@suse.de>
---
 drivers/usb/host/xhci-dbgcap.h |  2 +-
 drivers/usb/host/xhci-dbgtty.c | 19 +++++++++++--------
 2 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/drivers/usb/host/xhci-dbgcap.h b/drivers/usb/host/xhci-dbgcap.h
index c70b78d504eb..aec66009af51 100644
--- a/drivers/usb/host/xhci-dbgcap.h
+++ b/drivers/usb/host/xhci-dbgcap.h
@@ -104,7 +104,7 @@ struct dbc_port {
        struct list_head                read_pool;
        struct list_head                read_queue;
        unsigned int                    n_read;
-       struct tasklet_struct           push;
+       struct work_struct              push;
 
        struct list_head                write_pool;
        struct kfifo                    write_fifo;
diff --git a/drivers/usb/host/xhci-dbgtty.c b/drivers/usb/host/xhci-dbgtty.c
index ae4e4ab638b5..50da77d92cf6 100644
--- a/drivers/usb/host/xhci-dbgtty.c
+++ b/drivers/usb/host/xhci-dbgtty.c
@@ -108,7 +108,7 @@ dbc_read_complete(struct xhci_dbc *dbc, struct dbc_request 
*req)
 
        spin_lock_irqsave(&port->port_lock, flags);
        list_add_tail(&req->list_pool, &port->read_queue);
-       tasklet_schedule(&port->push);
+       schedule_work(&port->push);
        spin_unlock_irqrestore(&port->port_lock, flags);
 }
 
@@ -272,7 +272,7 @@ static void dbc_tty_unthrottle(struct tty_struct *tty)
        unsigned long           flags;
 
        spin_lock_irqsave(&port->port_lock, flags);
-       tasklet_schedule(&port->push);
+       schedule_work(&port->push);
        spin_unlock_irqrestore(&port->port_lock, flags);
 }
 
@@ -288,15 +288,18 @@ static const struct tty_operations dbc_tty_ops = {
        .unthrottle             = dbc_tty_unthrottle,
 };
 
-static void dbc_rx_push(struct tasklet_struct *t)
+static void dbc_rx_push(struct work_struct *work)
 {
        struct dbc_request      *req;
        struct tty_struct       *tty;
        unsigned long           flags;
        bool                    do_push = false;
        bool                    disconnect = false;
-       struct dbc_port         *port = from_tasklet(port, t, push);
-       struct list_head        *queue = &port->read_queue;
+       struct dbc_port         *port;
+       struct list_head        *queue;
+
+       port = container_of(work, struct dbc_port, push);
+       queue = &port->read_queue;
 
        spin_lock_irqsave(&port->port_lock, flags);
        tty = port->port.tty;
@@ -349,7 +352,7 @@ static void dbc_rx_push(struct tasklet_struct *t)
        if (!list_empty(queue) && tty) {
                if (!tty_throttled(tty)) {
                        if (do_push)
-                               tasklet_schedule(&port->push);
+                               schedule_work(&port->push);
                        else
                                pr_warn("ttyDBC0: RX not scheduled?\n");
                }
@@ -382,7 +385,7 @@ xhci_dbc_tty_init_port(struct xhci_dbc *dbc, struct 
dbc_port *port)
 {
        tty_port_init(&port->port);
        spin_lock_init(&port->port_lock);
-       tasklet_setup(&port->push, dbc_rx_push);
+       INIT_WORK(&port->push, dbc_rx_push);
        INIT_LIST_HEAD(&port->read_pool);
        INIT_LIST_HEAD(&port->read_queue);
        INIT_LIST_HEAD(&port->write_pool);
@@ -394,7 +397,7 @@ xhci_dbc_tty_init_port(struct xhci_dbc *dbc, struct 
dbc_port *port)
 static void
 xhci_dbc_tty_exit_port(struct dbc_port *port)
 {
-       tasklet_kill(&port->push);
+       cancel_work_sync(&port->push);
        tty_port_destroy(&port->port);
 }
 
-- 
2.26.2

Reply via email to