Commit c75d18cc authored by John Ogness's avatar John Ogness Committed by Johan Hovold

USB: serial: cyberjack: use irqsave() in USB's complete callback

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: default avatarJohn Ogness <john.ogness@linutronix.de>
Signed-off-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
parent 3391ca1d
...@@ -255,6 +255,7 @@ static void cyberjack_read_int_callback(struct urb *urb) ...@@ -255,6 +255,7 @@ static void cyberjack_read_int_callback(struct urb *urb)
struct device *dev = &port->dev; struct device *dev = &port->dev;
unsigned char *data = urb->transfer_buffer; unsigned char *data = urb->transfer_buffer;
int status = urb->status; int status = urb->status;
unsigned long flags;
int result; int result;
/* the urb might have been killed. */ /* the urb might have been killed. */
...@@ -270,13 +271,13 @@ static void cyberjack_read_int_callback(struct urb *urb) ...@@ -270,13 +271,13 @@ static void cyberjack_read_int_callback(struct urb *urb)
/* This is a announcement of coming bulk_ins. */ /* This is a announcement of coming bulk_ins. */
unsigned short size = ((unsigned short)data[3]<<8)+data[2]+3; unsigned short size = ((unsigned short)data[3]<<8)+data[2]+3;
spin_lock(&priv->lock); spin_lock_irqsave(&priv->lock, flags);
old_rdtodo = priv->rdtodo; old_rdtodo = priv->rdtodo;
if (old_rdtodo > SHRT_MAX - size) { if (old_rdtodo > SHRT_MAX - size) {
dev_dbg(dev, "To many bulk_in urbs to do.\n"); dev_dbg(dev, "To many bulk_in urbs to do.\n");
spin_unlock(&priv->lock); spin_unlock_irqrestore(&priv->lock, flags);
goto resubmit; goto resubmit;
} }
...@@ -285,7 +286,7 @@ static void cyberjack_read_int_callback(struct urb *urb) ...@@ -285,7 +286,7 @@ static void cyberjack_read_int_callback(struct urb *urb)
dev_dbg(dev, "%s - rdtodo: %d\n", __func__, priv->rdtodo); dev_dbg(dev, "%s - rdtodo: %d\n", __func__, priv->rdtodo);
spin_unlock(&priv->lock); spin_unlock_irqrestore(&priv->lock, flags);
if (!old_rdtodo) { if (!old_rdtodo) {
result = usb_submit_urb(port->read_urb, GFP_ATOMIC); result = usb_submit_urb(port->read_urb, GFP_ATOMIC);
...@@ -309,6 +310,7 @@ static void cyberjack_read_bulk_callback(struct urb *urb) ...@@ -309,6 +310,7 @@ static void cyberjack_read_bulk_callback(struct urb *urb)
struct cyberjack_private *priv = usb_get_serial_port_data(port); struct cyberjack_private *priv = usb_get_serial_port_data(port);
struct device *dev = &port->dev; struct device *dev = &port->dev;
unsigned char *data = urb->transfer_buffer; unsigned char *data = urb->transfer_buffer;
unsigned long flags;
short todo; short todo;
int result; int result;
int status = urb->status; int status = urb->status;
...@@ -325,7 +327,7 @@ static void cyberjack_read_bulk_callback(struct urb *urb) ...@@ -325,7 +327,7 @@ static void cyberjack_read_bulk_callback(struct urb *urb)
tty_flip_buffer_push(&port->port); tty_flip_buffer_push(&port->port);
} }
spin_lock(&priv->lock); spin_lock_irqsave(&priv->lock, flags);
/* Reduce urbs to do by one. */ /* Reduce urbs to do by one. */
priv->rdtodo -= urb->actual_length; priv->rdtodo -= urb->actual_length;
...@@ -334,7 +336,7 @@ static void cyberjack_read_bulk_callback(struct urb *urb) ...@@ -334,7 +336,7 @@ static void cyberjack_read_bulk_callback(struct urb *urb)
priv->rdtodo = 0; priv->rdtodo = 0;
todo = priv->rdtodo; todo = priv->rdtodo;
spin_unlock(&priv->lock); spin_unlock_irqrestore(&priv->lock, flags);
dev_dbg(dev, "%s - rdtodo: %d\n", __func__, todo); dev_dbg(dev, "%s - rdtodo: %d\n", __func__, todo);
...@@ -354,6 +356,7 @@ static void cyberjack_write_bulk_callback(struct urb *urb) ...@@ -354,6 +356,7 @@ static void cyberjack_write_bulk_callback(struct urb *urb)
struct cyberjack_private *priv = usb_get_serial_port_data(port); struct cyberjack_private *priv = usb_get_serial_port_data(port);
struct device *dev = &port->dev; struct device *dev = &port->dev;
int status = urb->status; int status = urb->status;
unsigned long flags;
set_bit(0, &port->write_urbs_free); set_bit(0, &port->write_urbs_free);
if (status) { if (status) {
...@@ -362,7 +365,7 @@ static void cyberjack_write_bulk_callback(struct urb *urb) ...@@ -362,7 +365,7 @@ static void cyberjack_write_bulk_callback(struct urb *urb)
return; return;
} }
spin_lock(&priv->lock); spin_lock_irqsave(&priv->lock, flags);
/* only do something if we have more data to send */ /* only do something if we have more data to send */
if (priv->wrfilled) { if (priv->wrfilled) {
...@@ -406,7 +409,7 @@ static void cyberjack_write_bulk_callback(struct urb *urb) ...@@ -406,7 +409,7 @@ static void cyberjack_write_bulk_callback(struct urb *urb)
} }
exit: exit:
spin_unlock(&priv->lock); spin_unlock_irqrestore(&priv->lock, flags);
usb_serial_port_softint(port); usb_serial_port_softint(port);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment