Skip to contentSkip to conversation

2.6.39-rc2 regression: X201s fails to resume b77dcf8460ae57d4eb9fd3633eb4f97b8fb20716

DISCUSSION Applied Keith Packard 7 participants 23 messages Apr 6, 2011 – May 3, 2011

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

-rc2 was causing resume failures on my X201s -- the video mode would get reset, but the system would then lock up. I bisected the failure down to:

commit b77dcf8460ae57d4eb9fd3633eb4f97b8fb20716

Author: Thomas Gleixner <[email protected]>
Date:   Thu Mar 24 20:16:42 2011 +0100

Bluetooth: Fix warning with hci_cmd_timer

Reverting this on top of -rc2 makes resume reliable again.

Signature · 1 line
[email protected]
#1 lore raw
Quoted 10 lines · Keith Packard

-rc2 was causing resume failures on my X201s -- the video mode would get reset, but the system would then lock up. I bisected the failure down to:

commit b77dcf8460ae57d4eb9fd3633eb4f97b8fb20716

Author: Thomas Gleixner <[email protected]>
Date:   Thu Mar 24 20:16:42 2011 +0100

Bluetooth: Fix warning with hci_cmd_timer

Reverting this on top of -rc2 makes resume reliable again.

Huch. I really have a hard time to connect this. Can you revert the two hunks seperately?

Thanks,

tglx

#2 lore raw
Quoted 8 lines · Thomas Gleixner
Quoted 7 lines · Keith Packard

-rc2 was causing resume failures on my X201s -- the video mode would get reset, but the system would then lock up. I bisected the failure down to:

commit b77dcf8460ae57d4eb9fd3633eb4f97b8fb20716

Author: Thomas Gleixner <[email protected]>
Date:   Thu Mar 24 20:16:42 2011 +0100
Quoted 6 lines
Quoted 3 lines

Bluetooth: Fix warning with hci_cmd_timer

Reverting this on top of -rc2 makes resume reliable again.

Huch. I really have a hard time to connect this. Can you revert the two hunks seperately?

Keith confirmed that reverting the second hunk fixes the problem. Heck, so that timer is rearmed somewhere in the teardown path?

Can the bluetooth folks please have a look at that ASAP? The obvious fast fix for Linus tree is to revert the second hunk for now, but this needs to be fixed proper.

Thanks,

tglx

#3 lore raw
Quoted 3 lines · Thomas Gleixner

Can the bluetooth folks please have a look at that ASAP? The obvious fast fix for Linus tree is to revert the second hunk for now, but this needs to be fixed proper.

Who will submit this patch? I'd rather have your name on it so that people come complain at you...

Signature · 1 line
[email protected]
#4 lore raw

Hi Keith,

Quoted 8 lines · Keith Packard
Quoted 3 lines · Thomas Gleixner

Can the bluetooth folks please have a look at that ASAP? The obvious fast fix for Linus tree is to revert the second hunk for now, but this needs to be fixed proper.

Who will submit this patch? I'd rather have your name on it so that people come complain at you...

I took a shot at it and just sent a patch (also attached for convenience) that should solve the problem.

Quoted 3 lines
Signature · 2 lines
-- 
[email protected]

Cheers,

Signature · 1 line
Vinicius
Quoted 1 line

From 1a617e2dde807ae932531ddd9b451011f236546c Mon Sep 17 00:00:00 2001

From: Vinicius Costa Gomes <[email protected]>
Date: Fri, 8 Apr 2011 20:33:17 -0300
Subject: [PATCH] Bluetooth: Fix keeping the command timer running

In the teardown path the reset command is sent to the controller, this event causes the command timer to be reactivated.

Now we remove the timer after the reset command is sent.

---
 net/bluetooth/hci_core.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
net/bluetooth/hci_core.c +3 -3
index a80bc1c..7467eaa 100644
@@ -586,9 +586,6 @@ static int hci_dev_do_close(struct hci_dev *hdev)
 	hci_req_cancel(hdev, ENODEV);
 	hci_req_lock(hdev);
 
-	/* Stop timer, it might be running */
-	del_timer_sync(&hdev->cmd_timer);
-
 	if (!test_and_clear_bit(HCI_UP, &hdev->flags)) {
 		hci_req_unlock(hdev);
 		return 0;
@@ -618,6 +615,9 @@ static int hci_dev_do_close(struct hci_dev *hdev)
 		clear_bit(HCI_INIT, &hdev->flags);
 	}
 
+	/* Stop timer, it might be running */
+	del_timer_sync(&hdev->cmd_timer);
+
 	/* Kill cmd task */
 	tasklet_kill(&hdev->cmd_task);
 
Signature · 1 line
1.7.4.3
author Tested-by
#5 lore raw
Quoted 2 lines · Vinicius Costa Gomes

I took a shot at it and just sent a patch (also attached for convenience) that should solve the problem.

Thanks much! I applied this to -rc2 and it appears to work fine in some brief testing (a dozen suspend/resume cycles)

Quoted 2 lines
Signature · 1 line
[email protected]
#6 lore raw
Quoted 5 lines · Keith Packard
Quoted 2 lines · Vinicius Costa Gomes

I took a shot at it and just sent a patch (also attached for convenience) that should solve the problem.

Quoted 7 lines

Thanks much! I applied this to -rc2 and it appears to work fine in some brief testing (a dozen suspend/resume cycles)

Quoted 2 lines

I applied the patch to bluetooth-2.6. Thank you all.

Signature · 2 lines
Gustavo F. Padovan
http://profusion.mobi
#7 lore raw
Quoted 10 lines · Gustavo F. Padovan
Quoted 8 lines · Keith Packard
Quoted 2 lines · Vinicius Costa Gomes

I took a shot at it and just sent a patch (also attached for convenience) that should solve the problem.

Thanks much! I applied this to -rc2 and it appears to work fine in some brief testing (a dozen suspend/resume cycles)

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

I applied the patch to bluetooth-2.6. Thank you all.

Sigh. Is actually anyone trying to read what I wrote ?

#8 lore raw
In reply to Vinicius Costa Gomes
Quoted 9 lines · Vinicius Costa Gomes

Hi Keith,

Quoted 6 lines · Keith Packard
Quoted 3 lines · Thomas Gleixner

Can the bluetooth folks please have a look at that ASAP? The obvious fast fix for Linus tree is to revert the second hunk for now, but this needs to be fixed proper.

Quoted 5 lines
Quoted 2 lines

Who will submit this patch? I'd rather have your name on it so that people come complain at you...

I took a shot at it and just sent a patch (also attached for convenience) that should solve the problem.

Aaarg. No. That patch reverts both hunks.

net/bluetooth/hci_core.c +0 -3
@@ -586,9 +586,6 @@ static int hci_dev_do_close(struct hci_dev *hdev)
 	hci_req_cancel(hdev, ENODEV);
 	hci_req_lock(hdev);
 
-	/* Stop timer, it might be running */
-	del_timer_sync(&hdev->cmd_timer);
-
 	if (!test_and_clear_bit(HCI_UP, &hdev->flags)) {
 		hci_req_unlock(hdev);
 		return 0;

As I said before you need that first hunk to stay for the case where there is no device up and you return via the !HCI_UP check. You just moved back to the state before as the stupid timer is active for whatever reason even when HCI_UP is not set.

@@ -618,6 +615,9 @@ static int hci_dev_do_close(struct hci_dev *hdev)
clear_bit(HCI_INIT, &hdev->flags);
}

+ /* Stop timer, it might be running */
+ del_timer_sync(&hdev->cmd_timer);
+
/* Kill cmd task */
tasklet_kill(&hdev->cmd_task);

maintainer
#9 lore raw

Hi Thomas,

Quoted 25 lines
Quoted 9 lines
Quoted 6 lines
Quoted 3 lines

Can the bluetooth folks please have a look at that ASAP? The obvious fast fix for Linus tree is to revert the second hunk for now, but this needs to be fixed proper.

Who will submit this patch? I'd rather have your name on it so that people come complain at you...

I took a shot at it and just sent a patch (also attached for convenience) that should solve the problem.

Aaarg. No. That patch reverts both hunks.

net/bluetooth/hci_core.c +0 -3
@@ -586,9 +586,6 @@ static int hci_dev_do_close(struct hci_dev *hdev)
 	hci_req_cancel(hdev, ENODEV);
 	hci_req_lock(hdev);
 
-	/* Stop timer, it might be running */
-	del_timer_sync(&hdev->cmd_timer);
-
 	if (!test_and_clear_bit(HCI_UP, &hdev->flags)) {
 		hci_req_unlock(hdev);
 		return 0;
Quoted 4 lines

As I said before you need that first hunk to stay for the case where there is no device up and you return via the !HCI_UP check. You just moved back to the state before as the stupid timer is active for whatever reason even when HCI_UP is not set.

if I read this right then we have the case that we arm this timer for no real reason. A device in !HCI_UP should have nothing running. Certainly not the cmd_timer since it will never process any commands.

According to Gustavo, the problem is really in the hci_reset logic were we arm the timer even when shutting down the device.

Regards

Marcel

#10 lore raw
Quoted 36 lines · Marcel Holtmann

Hi Thomas,

Quoted 25 lines
Quoted 9 lines
Quoted 6 lines
Quoted 3 lines

Can the bluetooth folks please have a look at that ASAP? The obvious fast fix for Linus tree is to revert the second hunk for now, but this needs to be fixed proper.

Who will submit this patch? I'd rather have your name on it so that people come complain at you...

I took a shot at it and just sent a patch (also attached for convenience) that should solve the problem.

Aaarg. No. That patch reverts both hunks.

net/bluetooth/hci_core.c +0 -3
@@ -586,9 +586,6 @@ static int hci_dev_do_close(struct hci_dev *hdev)
 	hci_req_cancel(hdev, ENODEV);
 	hci_req_lock(hdev);
 
-	/* Stop timer, it might be running */
-	del_timer_sync(&hdev->cmd_timer);
-
 	if (!test_and_clear_bit(HCI_UP, &hdev->flags)) {
 		hci_req_unlock(hdev);
 		return 0;
Quoted 4 lines

As I said before you need that first hunk to stay for the case where there is no device up and you return via the !HCI_UP check. You just moved back to the state before as the stupid timer is active for whatever reason even when HCI_UP is not set.

if I read this right then we have the case that we arm this timer for no real reason. A device in !HCI_UP should have nothing running. Certainly not the cmd_timer since it will never process any commands.

Quoted 2 lines

According to Gustavo, the problem is really in the hci_reset logic were we arm the timer even when shutting down the device.

The reason why the original patch was sent is, that the timer was running when the thing went out via the !HCI_UP path, which caused the whole thing to explode in the first place. I had no time to figure out why, but moving the del_timer_sync above the
if (!test_and_clear_bit(HCI_UP, &hdev->flags)) solved it.

Thanks,

tglx

#11 lore raw
Quoted 38 lines · Thomas Gleixner
Quoted 36 lines · Marcel Holtmann

Hi Thomas,

Quoted 25 lines
Quoted 9 lines
Quoted 6 lines
Quoted 3 lines

Can the bluetooth folks please have a look at that ASAP? The obvious fast fix for Linus tree is to revert the second hunk for now, but this needs to be fixed proper.

Who will submit this patch? I'd rather have your name on it so that people come complain at you...

I took a shot at it and just sent a patch (also attached for convenience) that should solve the problem.

Aaarg. No. That patch reverts both hunks.

net/bluetooth/hci_core.c +0 -3
@@ -586,9 +586,6 @@ static int hci_dev_do_close(struct hci_dev *hdev)
 	hci_req_cancel(hdev, ENODEV);
 	hci_req_lock(hdev);
 
-	/* Stop timer, it might be running */
-	del_timer_sync(&hdev->cmd_timer);
-
 	if (!test_and_clear_bit(HCI_UP, &hdev->flags)) {
 		hci_req_unlock(hdev);
 		return 0;
Quoted 4 lines

As I said before you need that first hunk to stay for the case where there is no device up and you return via the !HCI_UP check. You just moved back to the state before as the stupid timer is active for whatever reason even when HCI_UP is not set.

if I read this right then we have the case that we arm this timer for no real reason. A device in !HCI_UP should have nothing running. Certainly not the cmd_timer since it will never process any commands.

Quoted 8 lines
Quoted 2 lines

According to Gustavo, the problem is really in the hci_reset logic were we arm the timer even when shutting down the device.

The reason why the original patch was sent is, that the timer was running when the thing went out via the !HCI_UP path, which caused the whole thing to explode in the first place. I had no time to figure out why, but moving the del_timer_sync above the
if (!test_and_clear_bit(HCI_UP, &hdev->flags)) solved it.

Oops. Hit send too fast.

Then it broke the resume on Keith machine and reverting just the hunk which disarms the timer in the

        if (hdev->sent_cmd) {

path made both scenarios working. So there are two problems:

1) Why do we need the del_timer_sync() above the !HCI_UP check

2) Why gets the timer rearmed after that

Thanks,

tglx

#12 lore raw
Quoted 50 lines · Thomas Gleixner
Quoted 38 lines · Thomas Gleixner
Quoted 36 lines · Marcel Holtmann

Hi Thomas,

Quoted 25 lines
Quoted 9 lines
Quoted 6 lines
Quoted 3 lines

Can the bluetooth folks please have a look at that ASAP? The obvious fast fix for Linus tree is to revert the second hunk for now, but this needs to be fixed proper.

Who will submit this patch? I'd rather have your name on it so that people come complain at you...

I took a shot at it and just sent a patch (also attached for convenience) that should solve the problem.

Aaarg. No. That patch reverts both hunks.

net/bluetooth/hci_core.c +0 -3
@@ -586,9 +586,6 @@ static int hci_dev_do_close(struct hci_dev *hdev)
 	hci_req_cancel(hdev, ENODEV);
 	hci_req_lock(hdev);
 
-	/* Stop timer, it might be running */
-	del_timer_sync(&hdev->cmd_timer);
-
 	if (!test_and_clear_bit(HCI_UP, &hdev->flags)) {
 		hci_req_unlock(hdev);
 		return 0;
Quoted 4 lines

As I said before you need that first hunk to stay for the case where there is no device up and you return via the !HCI_UP check. You just moved back to the state before as the stupid timer is active for whatever reason even when HCI_UP is not set.

if I read this right then we have the case that we arm this timer for no real reason. A device in !HCI_UP should have nothing running. Certainly not the cmd_timer since it will never process any commands.

Quoted 8 lines
Quoted 2 lines

According to Gustavo, the problem is really in the hci_reset logic were we arm the timer even when shutting down the device.

The reason why the original patch was sent is, that the timer was running when the thing went out via the !HCI_UP path, which caused the whole thing to explode in the first place. I had no time to figure out why, but moving the del_timer_sync above the
if (!test_and_clear_bit(HCI_UP, &hdev->flags)) solved it.

Oops. Hit send too fast.

Quoted 8 lines

Then it broke the resume on Keith machine and reverting just the hunk which disarms the timer in the

        if (hdev->sent_cmd) {

path made both scenarios working. So there are two problems:

1) Why do we need the del_timer_sync() above the !HCI_UP check

That is still a mysterious to me, the real bug the hiding here. I'm trying to track this down but no luck yet.

Quoted 2 lines

2) Why gets the timer rearmed after that

It is armed at each HCI command we send. In the close path we send out an HCI RESET command that rearms it.

Signature · 2 lines
Gustavo F. Padovan
http://profusion.mobi
#13 lore raw
Quoted 61 lines · Gustavo F. Padovan
Quoted 50 lines · Thomas Gleixner
Quoted 38 lines · Thomas Gleixner
Quoted 36 lines · Marcel Holtmann

Hi Thomas,

Quoted 25 lines
Quoted 9 lines
Quoted 6 lines
Quoted 3 lines

Can the bluetooth folks please have a look at that ASAP? The obvious fast fix for Linus tree is to revert the second hunk for now, but this needs to be fixed proper.

Who will submit this patch? I'd rather have your name on it so that people come complain at you...

I took a shot at it and just sent a patch (also attached for convenience) that should solve the problem.

Aaarg. No. That patch reverts both hunks.

net/bluetooth/hci_core.c +0 -3
@@ -586,9 +586,6 @@ static int hci_dev_do_close(struct hci_dev *hdev)
 	hci_req_cancel(hdev, ENODEV);
 	hci_req_lock(hdev);
 
-	/* Stop timer, it might be running */
-	del_timer_sync(&hdev->cmd_timer);
-
 	if (!test_and_clear_bit(HCI_UP, &hdev->flags)) {
 		hci_req_unlock(hdev);
 		return 0;
Quoted 4 lines

As I said before you need that first hunk to stay for the case where there is no device up and you return via the !HCI_UP check. You just moved back to the state before as the stupid timer is active for whatever reason even when HCI_UP is not set.

if I read this right then we have the case that we arm this timer for no real reason. A device in !HCI_UP should have nothing running. Certainly not the cmd_timer since it will never process any commands.

Quoted 8 lines
Quoted 2 lines

According to Gustavo, the problem is really in the hci_reset logic were we arm the timer even when shutting down the device.

The reason why the original patch was sent is, that the timer was running when the thing went out via the !HCI_UP path, which caused the whole thing to explode in the first place. I had no time to figure out why, but moving the del_timer_sync above the
if (!test_and_clear_bit(HCI_UP, &hdev->flags)) solved it.

Oops. Hit send too fast.

Quoted 8 lines

Then it broke the resume on Keith machine and reverting just the hunk which disarms the timer in the

        if (hdev->sent_cmd) {

path made both scenarios working. So there are two problems:

1) Why do we need the del_timer_sync() above the !HCI_UP check

Quoted 8 lines

That is still a mysterious to me, the real bug the hiding here. I'm trying to track this down but no luck yet.

Quoted 2 lines

2) Why gets the timer rearmed after that

It is armed at each HCI command we send. In the close path we send out an HCI RESET command that rearms it.

I applied v2 patch from Vinícius that fix all the symptoms. Now we have more time to find the real cause of this bug. However I still have no idea, I'm not able to reproduce it.

Signature · 2 lines
Gustavo F. Padovan
http://profusion.mobi
#14 lore raw
Quoted 8 lines · Gustavo F. Padovan
Quoted 3 lines · Gustavo F. Padovan

* Thomas Gleixner <[email protected]> [2011-04-12 00:19:32 +0200]:
It is armed at each HCI command we send. In the close path we send out an HCI RESET command that rearms it.

I applied v2 patch from Vinícius that fix all the symptoms. Now we have more time to find the real cause of this bug. However I still have no idea, I'm not able to reproduce it.

You might poke Ingo. He had a reproducer.

Thanks,

tglx

#15 lore raw
In reply to Vinicius Costa Gomes
Quoted 2 lines

I took a shot at it and just sent a patch (also attached for convenience) that should solve the problem.

Well its reverting too much but its also looking pretty bogus to me

- /* Stop timer, it might be running */
- del_timer_sync(&hdev->cmd_timer);
-
if (!test_and_clear_bit(HCI_UP, &hdev->flags)) {
hci_req_unlock(hdev);
return 0;

So you've now got a path where you leave the timer running and didn't before - not it appears one that is a good idea.

Certainly not the kind of change that should be considered for a regression fix for an rc kernel. It's far too big a behavioural change to be safe.

Alan

#16 lore raw

Hi Gustavo,

Quoted 12 lines · Alan Cox
Quoted 2 lines

I took a shot at it and just sent a patch (also attached for convenience) that should solve the problem.

Well its reverting too much but its also looking pretty bogus to me

-       /* Stop timer, it might be running */
-       del_timer_sync(&hdev->cmd_timer);
-
       if (!test_and_clear_bit(HCI_UP, &hdev->flags)) { hci_req_unlock(hdev);
               return 0;

Quoted 6 lines

So you've now got a path where you leave the timer running and didn't before - not it appears one that is a good idea.

Certainly not the kind of change that should be considered for a regression fix for an rc kernel. It's far too big a behavioural change to be safe.

Considering what was said and that this patch didn't hit your public tree yet, I guess that this patch should be ignored.

Will send a proper fix soon. Thanks all.

Quoted 3 lines

Alan

Cheers,

Signature · 1 line
Vinicius
#17 lore raw
Quoted 1 line · Vinicius Gomes

Will send a proper fix soon. Thanks all.

This is still broken in -rc4, I'd love to see a proper patch soon -- this will affect any machine with a bluetooth device.

Signature · 1 line
[email protected]
#18 lore raw

Hi Keith,

Quoted 6 lines · Keith Packard
Quoted 1 line · Vinicius Gomes

Will send a proper fix soon. Thanks all.

This is still broken in -rc4, I'd love to see a proper patch soon -- this will affect any machine with a bluetooth device.

Patch is on the way to mainline. It's currently on wireless-2.6. Next steps are net-2.6 -> linux-2.6.

Regards,

Signature · 2 lines
Gustavo F. Padovan
http://profusion.mobi
#19 lore raw
Quoted 2 lines · Gustavo F. Padovan

Patch is on the way to mainline. It's currently on wireless-2.6. Next steps are net-2.6 -> linux-2.6.

I didn't see it on linux-kernel, so I was a bit worried. I'd love to test it in place of the kludge that Vinicius sent me.

Signature · 1 line
[email protected]
#20 lore raw
Quoted 8 lines · Keith Packard
Quoted 2 lines · Gustavo F. Padovan

Patch is on the way to mainline. It's currently on wireless-2.6. Next steps are net-2.6 -> linux-2.6.

I didn't see it on linux-kernel, so I was a bit worried. I'd love to test it in place of the kludge that Vinicius sent me.

I usually don't cc linux-kernel in my pull-requests, maybe I should.

Signature · 2 lines
Gustavo F. Padovan
http://profusion.mobi
#21 lore raw
Quoted 5 lines · On Sat, 23 Apr 2011 13:37:59 -0300 "Gustavo F. Padovan"…
Quoted 3 lines · Keith Packard

On Thu, 21 Apr 2011 19:59:53 -0300, "Gustavo F. Padovan" <[email protected]> wrote:

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

Patch is on the way to mainline. It's currently on wireless-2.6. Next steps are net-2.6 -> linux-2.6.

I didn't see it on linux-kernel, so I was a bit worried. I'd love to test it in place of the kludge that Vinicius sent me.

I usually don't cc linux-kernel in my pull-requests, maybe I should.

Did this hit mainline already? I seem to suffer from this still with -rc5

Signature · 3 lines
Stefan Seyfried

"Dispatch war rocket Ajax to bring back his body!"
#22 lore raw
Quoted 2 lines · Stefan Seyfried

Did this hit mainline already? I seem to suffer from this still with -rc5

It's on master, but not in -rc5:

commit b79f44c16a4e2181b1d6423afe746745d5e949ff

Author: Vinicius Costa Gomes <[email protected]>
Date:   Mon Apr 11 18:46:55 2011 -0300

Bluetooth: Fix keeping the command timer running

In the teardown path the reset command is sent to the controller, this event causes the command timer to be reactivated.

So the timer is removed in two situations, when the adapter isn't marked as UP and when we know that some command has been sent.

I'll be testing this patch shortly.

Signature · 1 line
[email protected]