Skip to content

Commit

Permalink
Bluetooth: btusb: use irqsave() in URB's complete callback
Browse files Browse the repository at this point in the history
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.

Cc: Marcel Holtmann <marcel@holtmann.org>
Cc: Johan Hedberg <johan.hedberg@gmail.com>
Cc: linux-bluetooth@vger.kernel.org
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
  • Loading branch information
Sebastian Andrzej Siewior authored and Marcel Holtmann committed Jul 6, 2018
1 parent 45ae68b commit a5e50d5
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions drivers/bluetooth/btusb.c
Original file line number Diff line number Diff line change
Expand Up @@ -510,9 +510,10 @@ static inline void btusb_free_frags(struct btusb_data *data)
static int btusb_recv_intr(struct btusb_data *data, void *buffer, int count)
{
struct sk_buff *skb;
unsigned long flags;
int err = 0;

spin_lock(&data->rxlock);
spin_lock_irqsave(&data->rxlock, flags);
skb = data->evt_skb;

while (count) {
Expand Down Expand Up @@ -557,17 +558,18 @@ static int btusb_recv_intr(struct btusb_data *data, void *buffer, int count)
}

data->evt_skb = skb;
spin_unlock(&data->rxlock);
spin_unlock_irqrestore(&data->rxlock, flags);

return err;
}

static int btusb_recv_bulk(struct btusb_data *data, void *buffer, int count)
{
struct sk_buff *skb;
unsigned long flags;
int err = 0;

spin_lock(&data->rxlock);
spin_lock_irqsave(&data->rxlock, flags);
skb = data->acl_skb;

while (count) {
Expand Down Expand Up @@ -614,17 +616,18 @@ static int btusb_recv_bulk(struct btusb_data *data, void *buffer, int count)
}

data->acl_skb = skb;
spin_unlock(&data->rxlock);
spin_unlock_irqrestore(&data->rxlock, flags);

return err;
}

static int btusb_recv_isoc(struct btusb_data *data, void *buffer, int count)
{
struct sk_buff *skb;
unsigned long flags;
int err = 0;

spin_lock(&data->rxlock);
spin_lock_irqsave(&data->rxlock, flags);
skb = data->sco_skb;

while (count) {
Expand Down Expand Up @@ -669,7 +672,7 @@ static int btusb_recv_isoc(struct btusb_data *data, void *buffer, int count)
}

data->sco_skb = skb;
spin_unlock(&data->rxlock);
spin_unlock_irqrestore(&data->rxlock, flags);

return err;
}
Expand Down Expand Up @@ -1067,6 +1070,7 @@ static void btusb_tx_complete(struct urb *urb)
struct sk_buff *skb = urb->context;
struct hci_dev *hdev = (struct hci_dev *)skb->dev;
struct btusb_data *data = hci_get_drvdata(hdev);
unsigned long flags;

BT_DBG("%s urb %p status %d count %d", hdev->name, urb, urb->status,
urb->actual_length);
Expand All @@ -1080,9 +1084,9 @@ static void btusb_tx_complete(struct urb *urb)
hdev->stat.err_tx++;

done:
spin_lock(&data->txlock);
spin_lock_irqsave(&data->txlock, flags);
data->tx_in_flight--;
spin_unlock(&data->txlock);
spin_unlock_irqrestore(&data->txlock, flags);

kfree(urb->setup_packet);

Expand Down

0 comments on commit a5e50d5

Please sign in to comment.