OSDN Git Service

USB: serial: ti_usb_3410_5052: use irqsave() in USB's complete callback
authorJohn Ogness <john.ogness@linutronix.de>
Sat, 23 Jun 2018 22:32:14 +0000 (00:32 +0200)
committerJohan Hovold <johan@kernel.org>
Tue, 26 Jun 2018 13:26:18 +0000 (15:26 +0200)
The USB completion callback does not disable interrupts while acquiring
the lock. We want to remove the local_irq_disable() invocation from
__usb_hcd_giveback_urb() and therefore it is required for the callback
handler to disable the interrupts while acquiring the lock.
The callback may be invoked either in IRQ or BH context depending on the
USB host controller.
Use the _irqsave() variant of the locking primitives.

Signed-off-by: John Ogness <john.ogness@linutronix.de>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Johan Hovold <johan@kernel.org>
drivers/usb/serial/ti_usb_3410_5052.c

index 6b22857..3010878 100644 (file)
@@ -1215,6 +1215,7 @@ static void ti_bulk_in_callback(struct urb *urb)
        struct usb_serial_port *port = tport->tp_port;
        struct device *dev = &urb->dev->dev;
        int status = urb->status;
+       unsigned long flags;
        int retval = 0;
 
        switch (status) {
@@ -1247,20 +1248,20 @@ static void ti_bulk_in_callback(struct urb *urb)
                                __func__);
                else
                        ti_recv(port, urb->transfer_buffer, urb->actual_length);
-               spin_lock(&tport->tp_lock);
+               spin_lock_irqsave(&tport->tp_lock, flags);
                port->icount.rx += urb->actual_length;
-               spin_unlock(&tport->tp_lock);
+               spin_unlock_irqrestore(&tport->tp_lock, flags);
        }
 
 exit:
        /* continue to read unless stopping */
-       spin_lock(&tport->tp_lock);
+       spin_lock_irqsave(&tport->tp_lock, flags);
        if (tport->tp_read_urb_state == TI_READ_URB_RUNNING)
                retval = usb_submit_urb(urb, GFP_ATOMIC);
        else if (tport->tp_read_urb_state == TI_READ_URB_STOPPING)
                tport->tp_read_urb_state = TI_READ_URB_STOPPED;
 
-       spin_unlock(&tport->tp_lock);
+       spin_unlock_irqrestore(&tport->tp_lock, flags);
        if (retval)
                dev_err(dev, "%s - resubmit read urb failed, %d\n",
                        __func__, retval);