From: Sebastian Andrzej Siewior <bigeasy@linutronix.de> To: linux-bluetooth@vger.kernel.org Cc: linux-usb@vger.kernel.org, tglx@linutronix.de, Sebastian Andrzej Siewior <bigeasy@linutronix.de>, Marcel Holtmann <marcel@holtmann.org>, Johan Hedberg <johan.hedberg@gmail.com> Subject: [PATCH] Bluetooth: btusb: use irqsave() in URB's complete callback Date: Tue, 19 Jun 2018 23:56:57 +0200 [thread overview] Message-ID: <20180619215657.13745-1-bigeasy@linutronix.de> (raw) 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> --- drivers/bluetooth/btusb.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index f73a27ea28cc..f262163fecd5 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c @@ -509,9 +509,10 @@ static inline void btusb_free_frags(struct btusb_data = *data) static int btusb_recv_intr(struct btusb_data *data, void *buffer, int coun= t) { struct sk_buff *skb; + unsigned long flags; int err =3D 0; =20 - spin_lock(&data->rxlock); + spin_lock_irqsave(&data->rxlock, flags); skb =3D data->evt_skb; =20 while (count) { @@ -556,7 +557,7 @@ static int btusb_recv_intr(struct btusb_data *data, voi= d *buffer, int count) } =20 data->evt_skb =3D skb; - spin_unlock(&data->rxlock); + spin_unlock_irqrestore(&data->rxlock, flags); =20 return err; } @@ -564,9 +565,10 @@ static int btusb_recv_intr(struct btusb_data *data, vo= id *buffer, int count) static int btusb_recv_bulk(struct btusb_data *data, void *buffer, int coun= t) { struct sk_buff *skb; + unsigned long flags; int err =3D 0; =20 - spin_lock(&data->rxlock); + spin_lock_irqsave(&data->rxlock, flags); skb =3D data->acl_skb; =20 while (count) { @@ -613,7 +615,7 @@ static int btusb_recv_bulk(struct btusb_data *data, voi= d *buffer, int count) } =20 data->acl_skb =3D skb; - spin_unlock(&data->rxlock); + spin_unlock_irqrestore(&data->rxlock, flags); =20 return err; } @@ -621,9 +623,10 @@ static int btusb_recv_bulk(struct btusb_data *data, vo= id *buffer, int count) static int btusb_recv_isoc(struct btusb_data *data, void *buffer, int coun= t) { struct sk_buff *skb; + unsigned long flags; int err =3D 0; =20 - spin_lock(&data->rxlock); + spin_lock_irqsave(&data->rxlock, flags); skb =3D data->sco_skb; =20 while (count) { @@ -668,7 +671,7 @@ static int btusb_recv_isoc(struct btusb_data *data, voi= d *buffer, int count) } =20 data->sco_skb =3D skb; - spin_unlock(&data->rxlock); + spin_unlock_irqrestore(&data->rxlock, flags); =20 return err; } @@ -1066,6 +1069,7 @@ static void btusb_tx_complete(struct urb *urb) struct sk_buff *skb =3D urb->context; struct hci_dev *hdev =3D (struct hci_dev *)skb->dev; struct btusb_data *data =3D hci_get_drvdata(hdev); + unsigned long flags; =20 BT_DBG("%s urb %p status %d count %d", hdev->name, urb, urb->status, urb->actual_length); @@ -1079,9 +1083,9 @@ static void btusb_tx_complete(struct urb *urb) hdev->stat.err_tx++; =20 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); =20 kfree(urb->setup_packet); =20 --=20 2.17.1
WARNING: multiple messages have this Message-ID (diff)
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de> To: linux-bluetooth@vger.kernel.org Cc: linux-usb@vger.kernel.org, tglx@linutronix.de, Sebastian Andrzej Siewior <bigeasy@linutronix.de>, Marcel Holtmann <marcel@holtmann.org>, Johan Hedberg <johan.hedberg@gmail.com> Subject: Bluetooth: btusb: use irqsave() in URB's complete callback Date: Tue, 19 Jun 2018 23:56:57 +0200 [thread overview] Message-ID: <20180619215657.13745-1-bigeasy@linutronix.de> (raw) 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> --- drivers/bluetooth/btusb.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index f73a27ea28cc..f262163fecd5 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c @@ -509,9 +509,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) { @@ -556,7 +557,7 @@ 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; } @@ -564,9 +565,10 @@ static int btusb_recv_intr(struct btusb_data *data, void *buffer, int count) 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) { @@ -613,7 +615,7 @@ 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; } @@ -621,9 +623,10 @@ static int btusb_recv_bulk(struct btusb_data *data, void *buffer, int count) 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) { @@ -668,7 +671,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; } @@ -1066,6 +1069,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); @@ -1079,9 +1083,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);
next reply other threads:[~2018-06-19 21:56 UTC|newest] Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top 2018-06-19 21:56 Sebastian Andrzej Siewior [this message] 2018-06-19 21:56 ` Bluetooth: btusb: use irqsave() in URB's complete callback Sebastian Andrzej Siewior 2018-06-21 12:43 ` [PATCH] " Marcel Holtmann 2018-06-21 12:43 ` Marcel Holtmann 2018-06-21 12:52 ` [PATCH] " Sebastian Andrzej Siewior 2018-06-21 12:52 ` Sebastian Andrzej Siewior 2018-06-21 15:34 ` [PATCH] " Alan Stern 2018-06-21 15:34 ` Alan Stern 2018-07-01 15:19 ` [PATCH] " Sebastian Andrzej Siewior 2018-07-01 15:19 ` Sebastian Andrzej Siewior 2018-07-06 10:46 ` [PATCH] " Marcel Holtmann 2018-07-06 10:46 ` Marcel Holtmann
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20180619215657.13745-1-bigeasy@linutronix.de \ --to=bigeasy@linutronix.de \ --cc=johan.hedberg@gmail.com \ --cc=linux-bluetooth@vger.kernel.org \ --cc=linux-usb@vger.kernel.org \ --cc=marcel@holtmann.org \ --cc=tglx@linutronix.de \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.