Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH] Bluetooth: btusb: Avoid race condition during controller recovery
@ 2018-05-31  9:50 Amit K Bag
  2018-06-05 14:05 ` Marcel Holtmann
  2018-06-05 14:07 ` Marcel Holtmann
  0 siblings, 2 replies; 7+ messages in thread
From: Amit K Bag @ 2018-05-31  9:50 UTC (permalink / raw)
  To: linux-bluetooth
  Cc: sukumar.ghorai, chethan.tumkur.narayan, ravishankar.srivatsa

From: Chethan T N <chethan.tumkur.narayan@intel.com>

Observed race condition during controller recovery mechanism
resulting the controller not responding to the reset command.

To avoid such race condition need a delay of 2ms soon after the
USB re-enumeration and before sending the Reset command which shall
allow controller to completely recover and process the Reset command.

Change-Id: Ifbc387d4377bc79081244d444d45ba6effc95f23
Signed-off-by: Chethan T N <chethan.tumkur.narayan@intel.com>
---
 drivers/bluetooth/btusb.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index f73a27ea28cc..844b4145ff76 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -1741,6 +1741,15 @@ static int btusb_setup_intel(struct hci_dev *hdev)
 	int disable_patch, err;
 	struct intel_version ver;
 
+	/* Observed race condition during controller recovery mechanism
+	 * resulting the controller not responding to the reset command.
+	 *
+	 * To avoid such race condition need a delay of 2ms soon after the
+	 * USB re-enumeration and before sending the Reset command which shall
+	 * allow controller to completely recover and process the Reset command.
+	 */
+	mdelay(2);
+
 	BT_DBG("%s", hdev->name);
 
 	/* The controller has a bug with the first HCI command sent to it
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] Bluetooth: btusb: Avoid race condition during controller recovery
  2018-05-31  9:50 Amit K Bag
@ 2018-06-05 14:05 ` Marcel Holtmann
  2018-06-05 14:07 ` Marcel Holtmann
  1 sibling, 0 replies; 7+ messages in thread
From: Marcel Holtmann @ 2018-06-05 14:05 UTC (permalink / raw)
  To: Amit K Bag
  Cc: BlueZ development, Sukumar Ghorai, chethan.tumkur.narayan,
	ravishankar.srivatsa

Hi Amit,

> Observed race condition during controller recovery mechanism
> resulting the controller not responding to the reset command.
> 
> To avoid such race condition need a delay of 2ms soon after the
> USB re-enumeration and before sending the Reset command which shall
> allow controller to completely recover and process the Reset command.
> 
> Change-Id: Ifbc387d4377bc79081244d444d45ba6effc95f23
> Signed-off-by: Chethan T N <chethan.tumkur.narayan@intel.com>
> ---
> drivers/bluetooth/btusb.c | 9 +++++++++
> 1 file changed, 9 insertions(+)
> 
> diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
> index f73a27ea28cc..844b4145ff76 100644
> --- a/drivers/bluetooth/btusb.c
> +++ b/drivers/bluetooth/btusb.c
> @@ -1741,6 +1741,15 @@ static int btusb_setup_intel(struct hci_dev *hdev)
> 	int disable_patch, err;
> 	struct intel_version ver;
> 
> +	/* Observed race condition during controller recovery mechanism
> +	 * resulting the controller not responding to the reset command.
> +	 *
> +	 * To avoid such race condition need a delay of 2ms soon after the
> +	 * USB re-enumeration and before sending the Reset command which shall
> +	 * allow controller to completely recover and process the Reset command.
> +	 */
> +	mdelay(2);
> +
> 	BT_DBG("%s", hdev->name);

can you leave the BT_DBG() at the top and move the mdelay + comment after it.

Regards

Marcel


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] Bluetooth: btusb: Avoid race condition during controller recovery
  2018-05-31  9:50 Amit K Bag
  2018-06-05 14:05 ` Marcel Holtmann
@ 2018-06-05 14:07 ` Marcel Holtmann
  1 sibling, 0 replies; 7+ messages in thread
From: Marcel Holtmann @ 2018-06-05 14:07 UTC (permalink / raw)
  To: Amit K Bag
  Cc: linux-bluetooth, sukumar.ghorai, chethan.tumkur.narayan,
	ravishankar.srivatsa

Hi Amit,

> Observed race condition during controller recovery mechanism
> resulting the controller not responding to the reset command.
> 
> To avoid such race condition need a delay of 2ms soon after the
> USB re-enumeration and before sending the Reset command which shall
> allow controller to completely recover and process the Reset command.
> 
> Change-Id: Ifbc387d4377bc79081244d444d45ba6effc95f23
> Signed-off-by: Chethan T N <chethan.tumkur.narayan@intel.com>

oh, and no Change-Id please and you also need to add your Signed-off-by here.

Regards

Marcel


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH] Bluetooth: btusb: Avoid race condition during controller recovery
@ 2018-06-06  6:03 Amit K Bag
  2018-06-06  6:23 ` Bag, Amit K
  0 siblings, 1 reply; 7+ messages in thread
From: Amit K Bag @ 2018-06-06  6:03 UTC (permalink / raw)
  To: linux-bluetooth
  Cc: sukumar.ghorai, chethan.tumkur.narayan, ravishankar.srivatsa,
	Amit K Bag

From: Chethan T N <chethan.tumkur.narayan@intel.com>

Observed race condition during controller recovery mechanism
resulting the controller not responding to the reset command.

To avoid such race condition need a delay of 2ms soon after the
USB re-enumeration and before sending the Reset command which shall
allow controller to completely recover and process the Reset command.

BUG=b:64035404
TEST=Magic tethering, P0 and P1 santiy test cases, kernel-boot log

Signed-off-by: Chethan T N <chethan.tumkur.narayan@intel.com>
Signed-off-by: Amit K Bag <amit.k.bag@intel.com>
---
 drivers/bluetooth/btusb.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index f73a27ea28cc..c7fce9c11889 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -1743,6 +1743,15 @@ static int btusb_setup_intel(struct hci_dev *hdev)
 
 	BT_DBG("%s", hdev->name);
 
+	/* Observed race condition during controller recovery mechanism
+	 * resulting the controller not responding to the reset command.
+	 *
+	 * To avoid such race condition need a delay of 2ms soon after the
+	 * USB re-enumeration and before sending the Reset command which shall
+	 * allow controller to completely recover and process the Reset command.
+	 */
+	mdelay(2);
+
 	/* The controller has a bug with the first HCI command sent to it
 	 * returning number of completed commands as zero. This would stall the
 	 * command processing in the Bluetooth core.
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH] Bluetooth: btusb: Avoid race condition during controller recovery
@ 2018-06-06  6:22 Amit K Bag
  2018-06-06  9:57 ` Luiz Augusto von Dentz
  0 siblings, 1 reply; 7+ messages in thread
From: Amit K Bag @ 2018-06-06  6:22 UTC (permalink / raw)
  To: linux-bluetooth
  Cc: sukumar.ghorai, chethan.tumkur.narayan, ravishankar.srivatsa,
	Amit K Bag

From: Chethan T N <chethan.tumkur.narayan@intel.com>

Observed race condition during controller recovery mechanism
resulting the controller not responding to the reset command.

To avoid such race condition need a delay of 2ms soon after the
USB re-enumeration and before sending the Reset command which shall
allow controller to completely recover and process the Reset command.

BUG=b:64035404
TEST=Magic tethering, P0 and P1 santiy test cases, kernel-boot log

Signed-off-by: Chethan T N <chethan.tumkur.narayan@intel.com>
Signed-off-by: Amit K Bag <amit.k.bag@intel.com>
---
 drivers/bluetooth/btusb.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index f73a27ea28cc..2303ac037240 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -1743,6 +1743,15 @@ static int btusb_setup_intel(struct hci_dev *hdev)
 
 	BT_DBG("%s", hdev->name);
 
+	/* Observed race condition during controller recovery mechanism
+	 * resulting the controller not responding to the reset command.
+	 *
+	 * To avoid such race condition need a delay of 2ms soon after the
+	 * USB re-enumeration and before sending the Reset command which shall
+	 * allow controller to completely recover and process the Reset command.
+	 */
+	mdelay(5);
+
 	/* The controller has a bug with the first HCI command sent to it
 	 * returning number of completed commands as zero. This would stall the
 	 * command processing in the Bluetooth core.
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* RE: [PATCH] Bluetooth: btusb: Avoid race condition during controller recovery
  2018-06-06  6:03 [PATCH] Bluetooth: btusb: Avoid race condition during controller recovery Amit K Bag
@ 2018-06-06  6:23 ` Bag, Amit K
  0 siblings, 0 replies; 7+ messages in thread
From: Bag, Amit K @ 2018-06-06  6:23 UTC (permalink / raw)
  To: linux-bluetooth@vger.kernel.org
  Cc: Ghorai, Sukumar, Tumkur Narayan, Chethan, Srivatsa, Ravishankar

Hello Marcel,

> Observed race condition during controller recovery mechanism resulting the controller not responding to the reset command.
>
> To avoid such race condition need a delay of 2ms soon after the USB re-enumeration and before sending the Reset command which shall allow controller to completely recover and process the Reset command.
>
> BUG=b:64035404
> TEST=Magic tethering, P0 and P1 santiy test cases, kernel-boot log
>
> Signed-off-by: Chethan T N <chethan.tumkur.narayan@intel.com>
> Signed-off-by: Amit K Bag <amit.k.bag@intel.com>
> ---
 > drivers/bluetooth/btusb.c | 9 +++++++++
 > 1 file changed, 9 insertions(+)
> 
> diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index f73a27ea28cc..c7fce9c11889 100644
> --- a/drivers/bluetooth/btusb.c
> +++ b/drivers/bluetooth/btusb.c
> @@ -1743,6 +1743,15 @@ static int btusb_setup_intel(struct hci_dev *hdev)
> 
> 	BT_DBG("%s", hdev->name);
 >
> +	/* Observed race condition during controller recovery mechanism
> +	 * resulting the controller not responding to the reset command.
> +	 *
> +	 * To avoid such race condition need a delay of 2ms soon after the
> +	 * USB re-enumeration and before sending the Reset command which shall
> +	 * allow controller to completely recover and process the Reset command.
> +	 */
> +	mdelay(2);
> +

I will provide a new patch. Please ignore this patch. 

Thanks & Regards,
Amit Bag

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] Bluetooth: btusb: Avoid race condition during controller recovery
  2018-06-06  6:22 Amit K Bag
@ 2018-06-06  9:57 ` Luiz Augusto von Dentz
  0 siblings, 0 replies; 7+ messages in thread
From: Luiz Augusto von Dentz @ 2018-06-06  9:57 UTC (permalink / raw)
  To: Amit K Bag
  Cc: linux-bluetooth@vger.kernel.org, sukumar.ghorai,
	chethan.tumkur.narayan, ravishankar.srivatsa

Hi Amit,

On Wed, Jun 6, 2018 at 9:22 AM, Amit K Bag <amit.k.bag@intel.com> wrote:
> From: Chethan T N <chethan.tumkur.narayan@intel.com>
>
> Observed race condition during controller recovery mechanism
> resulting the controller not responding to the reset command.
>
> To avoid such race condition need a delay of 2ms soon after the
> USB re-enumeration and before sending the Reset command which shall
> allow controller to completely recover and process the Reset command.
>
> BUG=b:64035404
> TEST=Magic tethering, P0 and P1 santiy test cases, kernel-boot log
>
> Signed-off-by: Chethan T N <chethan.tumkur.narayan@intel.com>
> Signed-off-by: Amit K Bag <amit.k.bag@intel.com>
> ---
>  drivers/bluetooth/btusb.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
>
> diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
> index f73a27ea28cc..2303ac037240 100644
> --- a/drivers/bluetooth/btusb.c
> +++ b/drivers/bluetooth/btusb.c
> @@ -1743,6 +1743,15 @@ static int btusb_setup_intel(struct hci_dev *hdev)
>
>         BT_DBG("%s", hdev->name);
>
> +       /* Observed race condition during controller recovery mechanism
> +        * resulting the controller not responding to the reset command.
> +        *
> +        * To avoid such race condition need a delay of 2ms soon after the
> +        * USB re-enumeration and before sending the Reset command which shall
> +        * allow controller to completely recover and process the Reset command.
> +        */
> +       mdelay(5);

Looks like the commit message and comment are not longer in sync with
the actual value here. Also perhaps this could be a parameter so any
hardware that has this problem just set how much delay it needs before
setup can be called.

>         /* The controller has a bug with the first HCI command sent to it
>          * returning number of completed commands as zero. This would stall the
>          * command processing in the Bluetooth core.
> --
> 2.7.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



-- 
Luiz Augusto von Dentz

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2018-06-06  9:57 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-06-06  6:03 [PATCH] Bluetooth: btusb: Avoid race condition during controller recovery Amit K Bag
2018-06-06  6:23 ` Bag, Amit K
  -- strict thread matches above, loose matches on Subject: below --
2018-06-06  6:22 Amit K Bag
2018-06-06  9:57 ` Luiz Augusto von Dentz
2018-05-31  9:50 Amit K Bag
2018-06-05 14:05 ` Marcel Holtmann
2018-06-05 14:07 ` Marcel Holtmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox