Commit fc75122f authored by Sebastian Andrzej Siewior's avatar Sebastian Andrzej Siewior Committed by Kalle Valo

libertas_tf: 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.

I am removing the
	BUG_ON(!in_interrupt());

check because it serves no purpose. Running the completion callback in
BH context makes in_interrupt() still return true but the interrupts
could be enabled. The important part is that ->driver_lock is acquired
with disabled interrupts which is the case now.

Cc: Kalle Valo <kvalo@codeaurora.org>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: linux-wireless@vger.kernel.org
Signed-off-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
parent 3cade2f3
...@@ -603,6 +603,8 @@ static inline void process_cmdrequest(int recvlength, uint8_t *recvbuff, ...@@ -603,6 +603,8 @@ static inline void process_cmdrequest(int recvlength, uint8_t *recvbuff,
struct if_usb_card *cardp, struct if_usb_card *cardp,
struct lbtf_private *priv) struct lbtf_private *priv)
{ {
unsigned long flags;
if (recvlength > LBS_CMD_BUFFER_SIZE) { if (recvlength > LBS_CMD_BUFFER_SIZE) {
lbtf_deb_usbd(&cardp->udev->dev, lbtf_deb_usbd(&cardp->udev->dev,
"The receive buffer is too large\n"); "The receive buffer is too large\n");
...@@ -610,14 +612,12 @@ static inline void process_cmdrequest(int recvlength, uint8_t *recvbuff, ...@@ -610,14 +612,12 @@ static inline void process_cmdrequest(int recvlength, uint8_t *recvbuff,
return; return;
} }
BUG_ON(!in_interrupt()); spin_lock_irqsave(&priv->driver_lock, flags);
spin_lock(&priv->driver_lock);
memcpy(priv->cmd_resp_buff, recvbuff + MESSAGE_HEADER_LEN, memcpy(priv->cmd_resp_buff, recvbuff + MESSAGE_HEADER_LEN,
recvlength - MESSAGE_HEADER_LEN); recvlength - MESSAGE_HEADER_LEN);
kfree_skb(skb); kfree_skb(skb);
lbtf_cmd_response_rx(priv); lbtf_cmd_response_rx(priv);
spin_unlock(&priv->driver_lock); spin_unlock_irqrestore(&priv->driver_lock, flags);
} }
/** /**
......
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