Skip to contentSkip to conversation

mac80211: cancel scan in ieee80211_restart_hw

PATCH In review John W. Linville 2 participants 12 messages Aug 30, 2010 – Sep 2, 2010 mac80211

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mac80211: cancel scan in ieee80211_restart_hw

This function exists to clean-up after a hardware error or something similar. The restart is accomplished using the same infrastructure used to resume after a suspend. The suspend path cancels running scans, so it seems appropriate to do that here as well.

---
 net/mac80211/main.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
net/mac80211/main.c +3 -1
index 93194f6..8b43d85 100644
@@ -305,7 +305,9 @@ void ieee80211_restart_hw(struct ieee80211_hw *hw)
 
 	trace_api_restart_hw(local);
 
-	/* use this reason, __ieee80211_resume will unblock it */
+	ieee80211_scan_cancel(local);
+
+	/* use this reason, ieee80211_reconfig will unblock it */
 	ieee80211_stop_queues_by_reason(hw,
 		IEEE80211_QUEUE_STOP_REASON_SUSPEND);
 
Signature · 1 line
1.7.2.2
maintainer
#1 lore raw

net/mac80211/main.c void ieee80211_restart_hw(struct ieee80211_hw *hw) · line 310

Quoted 9 lines · John W. Linville

This function exists to clean-up after a hardware error or something similar. The restart is accomplished using the same infrastructure used to resume after a suspend. The suspend path cancels running scans, so it seems appropriate to do that here as well.

net/mac80211/main.c +3 -1
-	/* use this reason, __ieee80211_resume will unblock it */
+	ieee80211_scan_cancel(local);
+
+	/* use this reason, ieee80211_reconfig will unblock it */

Hmm, yes .. but how will this interact with hw scan?

johannes

#2 lore raw
Quoted 6 lines · Johannes Berg
Quoted 4 lines · John W. Linville

This function exists to clean-up after a hardware error or something similar. The restart is accomplished using the same infrastructure used to resume after a suspend. The suspend path cancels running scans, so it seems appropriate to do that here as well.

Quoted 6 lines

net/mac80211/main.c void ieee80211_restart_hw(struct ieee80211_hw *hw) · line 310

Quoted 4 lines
net/mac80211/main.c +3 -1
-	/* use this reason, __ieee80211_resume will unblock it */
+	ieee80211_scan_cancel(local);
+
+	/* use this reason, ieee80211_reconfig will unblock it */

Hmm, yes .. but how will this interact with hw scan?

You tell me -- I would think that calling ieee80211_restart_hw would effectively abandon all hope of a hardware scan completing. Should the caller call ieee80211_scan_completed(..., 1)? Or should we do that (or equivalent) here too?

John

Signature · 2 lines
John W. Linville		Someday the world will need a hero, and you
[email protected]			might be all we have.  Be ready.
maintainer
#3 lore raw
Quoted 11 lines · John W. Linville
Quoted 6 lines

net/mac80211/main.c void ieee80211_restart_hw(struct ieee80211_hw *hw) · line 310

Quoted 4 lines
net/mac80211/main.c +3 -1
-	/* use this reason, __ieee80211_resume will unblock it */
+	ieee80211_scan_cancel(local);
+
+	/* use this reason, ieee80211_reconfig will unblock it */

Hmm, yes .. but how will this interact with hw scan?

You tell me -- I would think that calling ieee80211_restart_hw would effectively abandon all hope of a hardware scan completing. Should the caller call ieee80211_scan_completed(..., 1)? Or should we do that (or equivalent) here too?

Yeah, I guess the caller probably should since it may have internal state that needs resetting for scans as well. Maybe we should WARN_ON(scan in progress) here for the hw scan case, and do what you're proposing only for SW scan?

johannes

#4 lore raw

PATCH 1/1 mac80211: cancel scan in ieee80211_restart_hw if software scan pending

This function exists to clean-up after a hardware error or something similar. The restart is accomplished using the same infrastructure used to resume after a suspend. The suspend path cancels running scans, so it seems appropriate to do that here as well for software-based scans. If a hardware-based scan is pending, issue a warning message since this indicates that the drivers has failed to clean-up after itself.

---
 net/mac80211/main.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)
net/mac80211/main.c +7 -1
index 93194f6..a06b6ee 100644
@@ -305,7 +305,13 @@ void ieee80211_restart_hw(struct ieee80211_hw *hw)
 
 	trace_api_restart_hw(local);
 
-	/* use this reason, __ieee80211_resume will unblock it */
+	WARN(test_bit(SCAN_HW_SCANNING, &local->scanning),
+		"%s called with hardware scan in progress\n", __func__);
+
+	if (unlikely(test_bit(SCAN_SW_SCANNING, &local->scanning)))
+		ieee80211_scan_cancel(local);
+
+	/* use this reason, ieee80211_reconfig will unblock it */
 	ieee80211_stop_queues_by_reason(hw,
 		IEEE80211_QUEUE_STOP_REASON_SUSPEND);
 
Signature · 1 line
1.7.2.2
maintainer
#5 lore raw

Re: [PATCH] mac80211: cancel scan in ieee80211_restart_hw if software scan pending

Quoted 6 lines · John W. Linville

This function exists to clean-up after a hardware error or something similar. The restart is accomplished using the same infrastructure used to resume after a suspend. The suspend path cancels running scans, so it seems appropriate to do that here as well for software-based scans. If a hardware-based scan is pending, issue a warning message since this indicates that the drivers has failed to clean-up after itself.

Makes sense.

I guess unrelated to this, I wonder if we should warn in the suspend case as well, rather than doing it unconditionally. Hmm.

johannes

#6 lore raw

Re: [PATCH] mac80211: cancel scan in ieee80211_restart_hw if software scan pending

Quoted 8 lines · Johannes Berg
Quoted 6 lines · John W. Linville

This function exists to clean-up after a hardware error or something similar. The restart is accomplished using the same infrastructure used to resume after a suspend. The suspend path cancels running scans, so it seems appropriate to do that here as well for software-based scans. If a hardware-based scan is pending, issue a warning message since this indicates that the drivers has failed to clean-up after itself.

Quoted 4 lines

Makes sense.

I guess unrelated to this, I wonder if we should warn in the suspend case as well, rather than doing it unconditionally. Hmm.

Maybe so, but I'm not sure what path we would hook for that. Doesn't wiphy_suspend run before the hardware bus suspend functions? How would the driver now in advance to cancel the hardware scan?

John

Signature · 2 lines
John W. Linville		Someday the world will need a hero, and you
[email protected]			might be all we have.  Be ready.
maintainer
#7 lore raw

Re: [PATCH] mac80211: cancel scan in ieee80211_restart_hw if software scan pending

Quoted 9 lines · John W. Linville
Quoted 8 lines · Johannes Berg
Quoted 6 lines · John W. Linville

This function exists to clean-up after a hardware error or something similar. The restart is accomplished using the same infrastructure used to resume after a suspend. The suspend path cancels running scans, so it seems appropriate to do that here as well for software-based scans. If a hardware-based scan is pending, issue a warning message since this indicates that the drivers has failed to clean-up after itself.

Quoted 8 lines
Quoted 4 lines

Makes sense.

I guess unrelated to this, I wonder if we should warn in the suspend case as well, rather than doing it unconditionally. Hmm.

Maybe so, but I'm not sure what path we would hook for that. Doesn't wiphy_suspend run before the hardware bus suspend functions? How would the driver now in advance to cancel the hardware scan?

Good point! I was just thinking that if we do a mac80211 cancel only, then the scan request struct pointer that we gave to the driver earlier suddenly becomes invalid.

johannes

#11 lore raw

Re: [PATCH] mac80211: cancel scan in ieee80211_restart_hw if software scan pending

In reply to John W. Linville
Quoted 9 lines · John W. Linville
Quoted 8 lines · Johannes Berg
Quoted 6 lines · John W. Linville

This function exists to clean-up after a hardware error or something similar. The restart is accomplished using the same infrastructure used to resume after a suspend. The suspend path cancels running scans, so it seems appropriate to do that here as well for software-based scans. If a hardware-based scan is pending, issue a warning message since this indicates that the drivers has failed to clean-up after itself.

Quoted 8 lines
Quoted 4 lines

Makes sense.

I guess unrelated to this, I wonder if we should warn in the suspend case as well, rather than doing it unconditionally. Hmm.

Maybe so, but I'm not sure what path we would hook for that. Doesn't wiphy_suspend run before the hardware bus suspend functions? How would the driver now in advance to cancel the hardware scan?

s/now/know/ -- English is hard...

Signature · 2 lines
John W. Linville		Someday the world will need a hero, and you
[email protected]			might be all we have.  Be ready.
#8 lore raw

PATCH 1/1 mac80211: only cancel software-based scans on suspend

In reply to Johannes Berg

Otherwise the hardware scan handler could access an invalid scan request structure. The driver should cancel any pending hardware scans during the suspend process anyway, so also add a warning if the hardware scan is still pending when the device resumes.

---
 net/mac80211/ieee80211_i.h |    6 ++++++
 net/mac80211/pm.c          |    3 ++-
 2 files changed, 8 insertions(+), 1 deletions(-)
net/mac80211/ieee80211_i.h +6 -0
index 16f7fb1..4e635e2 100644
@@ -1186,6 +1186,12 @@ int __ieee80211_suspend(struct ieee80211_hw *hw);
 
 static inline int __ieee80211_resume(struct ieee80211_hw *hw)
 {
+	struct ieee80211_local *local = hw_to_local(hw);
+
+	WARN(test_bit(SCAN_HW_SCANNING, &local->scanning),
+		"%s: resume with hardware scan still in progress\n",
+		wiphy_name(hw->wiphy));
+
 	return ieee80211_reconfig(hw_to_local(hw));
 }
 #else
net/mac80211/pm.c +2 -1
index d287fde..ce671df 100644
@@ -12,7 +12,8 @@ int __ieee80211_suspend(struct ieee80211_hw *hw)
 	struct ieee80211_sub_if_data *sdata;
 	struct sta_info *sta;
 
-	ieee80211_scan_cancel(local);
+	if (unlikely(test_bit(SCAN_SW_SCANNING, &local->scanning)))
+		ieee80211_scan_cancel(local);
 
 	ieee80211_stop_queues_by_reason(hw,
 			IEEE80211_QUEUE_STOP_REASON_SUSPEND);
Signature · 1 line
1.7.2.2
#9 lore raw

Re: [PATCH] mac80211: cancel scan in ieee80211_restart_hw if software scan pending

In reply to Johannes Berg
Quoted 15 lines · Johannes Berg
Quoted 14 lines · John W. Linville
Quoted 12 lines · Johannes Berg
Quoted 6 lines · John W. Linville

This function exists to clean-up after a hardware error or something similar. The restart is accomplished using the same infrastructure used to resume after a suspend. The suspend path cancels running scans, so it seems appropriate to do that here as well for software-based scans. If a hardware-based scan is pending, issue a warning message since this indicates that the drivers has failed to clean-up after itself.

Makes sense.

I guess unrelated to this, I wonder if we should warn in the suspend case as well, rather than doing it unconditionally. Hmm.

Quoted 7 lines
Quoted 3 lines

Maybe so, but I'm not sure what path we would hook for that. Doesn't wiphy_suspend run before the hardware bus suspend functions? How would the driver now in advance to cancel the hardware scan?

Good point! I was just thinking that if we do a mac80211 cancel only, then the scan request struct pointer that we gave to the driver earlier suddenly becomes invalid.

I see...how about we only cancel the software scans, then warn on resume if the hardware scan is still running?

John

Signature · 2 lines
John W. Linville		Someday the world will need a hero, and you
[email protected]			might be all we have.  Be ready.
maintainer
#10 lore raw

Re: [PATCH] mac80211: cancel scan in ieee80211_restart_hw if software scan pending

Quoted 6 lines · John W. Linville
Quoted 3 lines

Good point! I was just thinking that if we do a mac80211 cancel only, then the scan request struct pointer that we gave to the driver earlier suddenly becomes invalid.

I see...how about we only cancel the software scans, then warn on resume if the hardware scan is still running?

That seems reasonable, although the driver can only cancel it after mac80211 has already suspended, which is kinda odd (but should work fine)

johannes