rt2x00: fix rmmod crash
PATCH 1/1 rt2x00: fix rmmod crash
Do not destroy workqueue, which still can be used by autowakeup_work, before ieee80211_unregister_hw() is called.
--- drivers/net/wireless/rt2x00/rt2x00dev.c | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-)
drivers/net/wireless/rt2x00/rt2x00dev.c +5 -1
@@ -1165,7 +1165,6 @@ void rt2x00lib_remove_dev(struct rt2x00_dev *rt2x00dev)cancel_work_sync (&rt2x00dev->rxdone_work);cancel_work_sync (&rt2x00dev->txdone_work); } -destroy_workqueue (rt2x00dev->workqueue);/* * Free the tx status fifo.
@@ -1198,6 +1197,11 @@ void rt2x00lib_remove_dev(struct rt2x00_dev *rt2x00dev)rt2x00lib_remove_hw (rt2x00dev);/* +* Now nobody use workqueue anymore. +*/ +destroy_workqueue (rt2x00dev->workqueue); + +/* * Free firmware image. */ rt2x00lib_free_firmware (rt2x00dev);
Signature · 1 line
1.7.4
Quoted 4 lines · Stanislaw Gruszka
Do not destroy workqueue, which still can be used by
autowakeup_work, beforeieee80211_unregister_hw()is called.Signed-off-by Stanislaw Gruszka <[email protected]>
Could you add some details of the crash here, e.g. the stack trace of when this occurs, so that we can understand what is exactly happening that is causing the crash, for our education.
Quoted 28 lines
--- drivers/net/wireless/rt2x00/rt2x00dev.c | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-)drivers/net/wireless/rt2x00/rt2x00dev.c +5
-1@@ -1165,7 +1165,6 @@ void rt2x00lib_remove_dev(struct rt2x00_dev *rt2x00dev)cancel_work_sync (&rt2x00dev->rxdone_work);cancel_work_sync (&rt2x00dev->txdone_work); } -destroy_workqueue (rt2x00dev->workqueue);/* * Free the tx status fifo. @@ -1198,6 +1197,11 @@ void rt2x00lib_remove_dev(struct rt2x00_dev *rt2x00dev)rt2x00lib_remove_hw (rt2x00dev);/* +* Now nobody use workqueue anymore. +*/ +destroy_workqueue (rt2x00dev->workqueue); + +/* * Free firmware image. */ rt2x00lib_free_firmware (rt2x00dev);
Signature · 2 lines
--- Gertjan
Quoted 8 lines · Gertjan van Wingerde
Quoted 4 lines · Stanislaw Gruszka
Do not destroy workqueue, which still can be used by
autowakeup_work, beforeieee80211_unregister_hw()is called.Signed-off-by Stanislaw Gruszka <[email protected]>Could you add some details of the crash here, e.g. the stack trace of when this occurs, so that we can understand what is exactly happening that is causing the crash, for our education.
Crash is in workqueue code in interrupt context, there is no indication about rt2x00 blame in the calltrace, but crash happen directly after rmmod rt73usb, here is a photo:
https://bugzilla.kernel.org/attachment.cgi?id=59992
Stanislaw
Gertjan van Wingerde
Acked-byQuoted 5 lines · Stanislaw Gruszka
Quoted 4 lines · Gertjan van Wingerde
Quoted 3 lines · Stanislaw Gruszka
Do not destroy workqueue, which still can be used by
autowakeup_work, beforeieee80211_unregister_hw()is called.
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
Signed-off-by Stanislaw Gruszka <[email protected]>Could you add some details of the crash here, e.g. the stack trace of when this occurs, so that we can understand what is exactly happening that is causing the crash, for our education.
Crash is in workqueue code in interrupt context, there is no indication about rt2x00 blame in the calltrace, but crash happen directly after rmmod rt73usb, here is a photo:
https://bugzilla.kernel.org/attachment.cgi?id=59992
OK. Thanks for the info.
Could you create a v2 of the patch that:
1. Includes a reference to the bugzilla entry that the patch is resolving.
2. Cc's the stable team.
In that v2 you can add my acked-by as follows:
Thanks for the patch.
---
Gertjan
Quoted 11 lines · Gertjan van Wingerde
Quoted 10 lines · Stanislaw Gruszka
Quoted 8 lines · Gertjan van Wingerde
Quoted 4 lines · Stanislaw Gruszka
Do not destroy workqueue, which still can be used by
autowakeup_work, beforeieee80211_unregister_hw()is called.Signed-off-by Stanislaw Gruszka <[email protected]>Could you add some details of the crash here, e.g. the stack trace of when this occurs, so that we can understand what is exactly happening that is causing the crash, for our education.
Quoted 8 lines
Quoted 3 lines
Crash is in workqueue code in interrupt context, there is no indication about rt2x00 blame in the calltrace, but crash happen directly after rmmod rt73usb, here is a photo:
https://bugzilla.kernel.org/attachment.cgi?id=59992OK. Thanks for the info.
Could you create a v2 of the patch that:
1. Includes a reference to the bugzilla entry that the patch is resolving.
It does not solve the bugzilla,
https://bugzilla.kernel.org/show_bug.cgi?id=32132
I put image there, because of temporally lack of opportunity to put it in some better place. Sorry.
Quoted 1 line
2. Cc's the stable team.
It's not stable fix, this bug was introduced currently by
commit 1c0bcf89d85cc97a0d9ce4cd909351a81fa4fdde
Author: Ivo van Doorn <[email protected]> Date: Sat Apr 30 17:18:18 2011 +0200
rt2x00: Add autowake support for USB hardware
Thanks
Stanislaw
Quoted 18 lines · Stanislaw Gruszka
Quoted 17 lines · Gertjan van Wingerde
Quoted 5 lines · Stanislaw Gruszka
Quoted 4 lines · Gertjan van Wingerde
Quoted 3 lines · Stanislaw Gruszka
Do not destroy workqueue, which still can be used by
autowakeup_work, beforeieee80211_unregister_hw()is called.Quoted 8 lines
Quoted 4 lines
Quoted 1 line
Signed-off-by Stanislaw Gruszka <[email protected]>Could you add some details of the crash here, e.g. the stack trace of when this occurs, so that we can understand what is exactly happening that is causing the crash, for our education.
Crash is in workqueue code in interrupt context, there is no indication about rt2x00 blame in the calltrace, but crash happen directly after rmmod rt73usb, here is a photo:
https://bugzilla.kernel.org/attachment.cgi?id=59992OK. Thanks for the info.
Quoted 7 lines
Quoted 2 lines
Could you create a v2 of the patch that:
1. Includes a reference to the bugzilla entry that the patch is resolving.It does not solve the bugzilla,
https://bugzilla.kernel.org/show_bug.cgi?id=32132
I put image there, because of temporally lack of opportunity to put it in some better place. Sorry.
Ah, OK. That got me confused.
Quoted 11 lines
Quoted 2 lines
2. Cc's the stable team.
It's not stable fix, this bug was introduced currently by
commit
1c0bcf89d85cc97a0d9ce4cd909351a81fa4fdde
Author: Ivo van Doorn <[email protected]>
Date: Sat Apr 30 17:18:18 2011 +0200rt2x00: Add autowake support for USB hardware
I cannot check it right now, but that patch is not yet included in wireless-2.6, which
you indicate (in the email subject) as being the target for this patch. Which tree do you want this patch to be applied to?
---
Gertjan
Quoted 6 lines · Gertjan van Wingerde
Quoted 6 lines
It's not stable fix, this bug was introduced currently by
commit
1c0bcf89d85cc97a0d9ce4cd909351a81fa4fdde
Author: Ivo van Doorn <[email protected]>
Date: Sat Apr 30 17:18:18 2011 +0200
Quoted 7 lines
Quoted 2 lines
rt2x00: Add autowake support for USB hardware
I cannot check it right now, but that patch is not yet included in wireless-2.6, which
you indicate (in the email subject) as being the target for this patch. Which tree do you want this patch to be applied to?
Oh, indeed. But it is in current Linus' tree, patch is targeted there.
Stanislaw
Quoted 10 lines · Stanislaw Gruszka
Quoted 9 lines · Gertjan van Wingerde
Quoted 8 lines
It's not stable fix, this bug was introduced currently by
commit
1c0bcf89d85cc97a0d9ce4cd909351a81fa4fdde
Author: Ivo van Doorn <[email protected]>
Date: Sat Apr 30 17:18:18 2011 +0200rt2x00: Add autowake support for USB hardware
Quoted 7 lines
Quoted 4 lines
I cannot check it right now, but that patch is not yet included in wireless-2.6, which
you indicate (in the email subject) as being the target for this patch. Which tree do you want this patch to be applied to?Oh, indeed. But it is in current Linus' tree, patch is targeted there.
OK. Everything is clear now.
Personally I am okay with your patch; however, I would like for Ivo to comment, as it was his patch
that caused the issues in the first place.
---
Gertjan
Hi,
Quoted 2 lines · Stanislaw Gruszka
Do not destroy workqueue, which still can be used by
autowakeup_work, beforeieee80211_unregister_hw()is called.
Well isn't the bug then that autowakeup_work isn't cancelled using cancel_work_sync
like the other workqueue tasks?
I rather add the call to cancel_work_sync then moving the killing of the workqueue.
The position where the workqueue is destroyed should be the place where we cancel
all scheduled work, that way we can assume no rt2x00-related threads ater this position.
Ivo
Quoted 33 lines
Signed-off-by Stanislaw Gruszka <[email protected]>---
drivers/net/wireless/rt2x00/rt2x00dev.c | 6 +++++-1 files changed, 5 insertions(+), 1 deletions(-)drivers/net/wireless/rt2x00/rt2x00dev.c +5
-2@@ -1165,7 +1165,6 @@ void rt2x00lib_remove_dev(struct rt2x00_dev *rt2x00dev) cancel_work_sync(&rt2x00dev->rxdone_work); cancel_work_sync(&rt2x00dev->txdone_work); } - destroy_workqueue(rt2x00dev->workqueue); /** Free the tx status fifo. @@ -1198,6 +1197,11 @@ void rt2x00lib_remove_dev(struct rt2x00_dev *rt2x00dev) rt2x00lib_remove_hw(rt2x00dev); /* + * Now nobody use workqueue anymore. + */ + destroy_workqueue(rt2x00dev->workqueue); + + /* * Free firmware image. */ rt2x00lib_free_firmware(rt2x00dev); --1.7.4
Hello
Quoted 8 lines · Ivo Van Doorn
Quoted 2 lines · Stanislaw Gruszka
Do not destroy workqueue, which still can be used by
autowakeup_work, beforeieee80211_unregister_hw()is called.Well isn't the bug then that
autowakeup_workisn't cancelled usingcancel_work_sync
like the other workqueue tasks?
Quoted 6 lines
I rather add the call to
cancel_work_syncthen moving the killing of the workqueue.
The position where the workqueue is destroyed should be the place where we cancel
all scheduled work, that way we can assume no rt2x00-related threads ater this position.
rt2x00lib_config() could be running simultaneously to rt2x00lib_remove_dev() and queue just canceled autowake_work again into (just destroyed) workqueue. Other solution to fix, would be use ieee80211_queue_work() instead of custom workqueue, is that better?
Stanislaw
Hi,
Quoted 11 lines
Quoted 10 lines
Well isn't the bug then that
autowakeup_workisn't cancelled usingcancel_work_sync
like the other workqueue tasks?I rather add the call to
cancel_work_syncthen moving the killing of the workqueue.
The position where the workqueue is destroyed should be the place where we cancel
all scheduled work, that way we can assume no rt2x00-related threads ater this position.
Quoted 4 lines
rt2x00lib_config()could be running simultaneously tort2x00lib_remove_dev()and queue just canceledautowake_workagain into (just destroyed) workqueue. Other solution to fix, would be useieee80211_queue_work()instead of custom workqueue, is that better?
Well 3 things are needed then,
1) Don't schedule autowake_work when DEVICE_PRESENT flag is not set
2) The handler for autowake_work should exit immediately when DEVICE_PRESENT flag is not set
3) add a cancel_work_sync for the autowake_work inside remove_dev
That should effictively prevent the entire work structure from running while the driver
is being rmmodded, or the device is being unplugged.
Ivo