Bluetooth: btmrvl: fix card reset and suspend race issue
PATCH 1/1 Bluetooth: btmrvl: fix card reset and suspend race issue
Sometimes suspend thread queues a command and wait for it's response, meanwhile WLAN driver power cycles the card which leads to crash. This patch makes sure that suspend thread is woken up in remove path.
--- drivers/bluetooth/btmrvl_main.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/bluetooth/btmrvl_main.c +8 -3
@@ -207,10 +207,14 @@ static int btmrvl_send_sync_cmd(struct btmrvl_private *priv, u16 opcode,wake_up_interruptible (&priv->main_thread.wait_q);if (!wait_event_interruptible_timeout (priv->adapter->cmd_wait_q, - priv->adapter->cmd_complete, + priv->adapter->cmd_complete || + priv->surprise_removed,msecs_to_jiffies (WAIT_UNTIL_CMD_RESP )))return -ETIMEDOUT ; +if (priv->surprise_removed) +return -EFAULT ; +return 0 ; }
@@ -292,9 +296,10 @@ int btmrvl_enable_hs(struct btmrvl_private *priv) } ret =wait_event_interruptible_timeout (adapter->event_hs_wait_q, - adapter->hs_state, + adapter->hs_state || + priv->surprise_removed,msecs_to_jiffies (WAIT_UNTIL_HS_STATE_CHANGED )); -if (ret <0 ) { +if (ret <0 || priv->surprise_removed) {BT_ERR ("event_hs_wait_q terminated (%d): %d,%d,%d" , ret, adapter->hs_state, adapter->ps_state, adapter->wakeup_tries);
Signature · 1 line
1.8.1.4
Marcel Holtmann
maintainerHi Amitkumar,
Quoted 15 lines
Sometimes suspend thread queues a command and wait for it's response, meanwhile WLAN driver power cycles the card which leads to crash. This patch makes sure that suspend thread is woken up in remove path.
Signed-off-by Amitkumar Karwar <[email protected]>---
drivers/bluetooth/btmrvl_main.c| 11 ++++++++---1 file changed, 8 insertions(+), 3 deletions(-)drivers/bluetooth/btmrvl_main.c +0
-0
drivers/bluetooth/btmrvl_main.c static int btmrvl_send_sync_cmd(struct btmrvl_private *priv, u16 opcode, · line 212
Quoted 7 lines
drivers/bluetooth/btmrvl_main.c +2
-1@@ -207,10 +207,14 @@ static int btmrvl_send_sync_cmd(struct btmrvl_private *priv, u16 opcode,wake_up_interruptible (&priv->main_thread.wait_q);if (!wait_event_interruptible_timeout (priv->adapter->cmd_wait_q, - priv->adapter->cmd_complete, + priv->adapter->cmd_complete || + priv->surprise_removed,msecs_to_jiffies (WAIT_UNTIL_CMD_RESP )))
I know that even before this patch the coding style was off, but please do not make it worse. So lets fix the coding style here as well.
Quoted 9 lines
drivers/bluetooth/btmrvl_main.c +3
-0return -ETIMEDOUT ; +if (priv->surprise_removed) +return -EFAULT ; +return 0 ; }
drivers/bluetooth/btmrvl_main.c int btmrvl_enable_hs(struct btmrvl_private *priv) · line 301
Quoted 7 lines
drivers/bluetooth/btmrvl_main.c +2
-1@@ -292,9 +296,10 @@ int btmrvl_enable_hs(struct btmrvl_private *priv) } ret =wait_event_interruptible_timeout (adapter->event_hs_wait_q, - adapter->hs_state, + adapter->hs_state || + priv->surprise_removed,msecs_to_jiffies (WAIT_UNTIL_HS_STATE_CHANGED ));
Same here. I would have the mecs_to_jiffies in the constant declaration.
Regards
Marcel
Hi Marcel,
Quoted 40 lines
Hi Amitkumar,
drivers/bluetooth/btmrvl_main.c static int btmrvl_send_sync_cmd(struct
Quoted 14 lines
Sometimes suspend thread queues a command and wait for it's response, meanwhile WLAN driver power cycles the card which leads to crash. This patch makes sure that suspend thread is woken up in remove path.
Signed-off-by Amitkumar Karwar <[email protected]>---
drivers/bluetooth/btmrvl_main.c| 11 ++++++++---1 file changed, 8 insertions(+), 3 deletions(-)(quoted diff) +0
-0
b/drivers/bluetooth/btmrvl_main.cindex c4a542c..27fa98f 100644drivers/bluetooth/btmrvl_main.c +0
-0@@ -207,10 +207,14 @@ static int btmrvl_send_sync_cmd(struct
btmrvl_private*priv, u16 opcode,drivers/bluetooth/btmrvl_main.c static int btmrvl_send_sync_cmd(struct btmrvl_private *priv, u16 opcode, · line 212
Quoted 7 lines
drivers/bluetooth/btmrvl_main.c +2
-1wake_up_interruptible (&priv->main_thread.wait_q);if (!wait_event_interruptible_timeout (priv->adapter->cmd_wait_q, - priv->adapter->cmd_complete, + priv->adapter->cmd_complete || + priv->surprise_removed,msecs_to_jiffies (WAIT_UNTIL_CMD_RESP )))I know that even before this patch the coding style was off, but please do not make it worse. So lets fix the coding style here as well.
Quoted 11 lines
drivers/bluetooth/btmrvl_main.c +3
-0return -ETIMEDOUT ; +if (priv->surprise_removed) +return -EFAULT ; +return 0 ; }@@ -292,9 +296,10 @@ int btmrvl_enable_hs(struct btmrvl_private *priv) }
Quoted 8 lines
drivers/bluetooth/btmrvl_main.c int btmrvl_enable_hs(struct btmrvl_private *priv) · line 301
Quoted 5 lines
drivers/bluetooth/btmrvl_main.c +2
-1ret =3D wait_event_interruptible_timeout(adapter->event_hs_wait_q, - adapter->hs_state, + adapter->hs_state || + priv->surprise_removed,msecs_to_jiffies (WAIT_UNTIL_HS_STATE_CHANGED ));Same here. I would have the
mecs_to_jiffiesin the constant declaration.
Thanks for your comments. I will create a separate patch to move mecs_to_ji= ffies to macro definition and coding style and send updated version.
BR,
Amit