Skip to contentSkip to conversation

zd1211 config operation problem

DISCUSSION Michael Buesch 4 participants 11 messages Sep 23, 2007 – Sep 24, 2007 mac80211

lore
Share & tools
lore
#0 lore raw

The zd1211 driver has a bug in the ieee80211 config callback. It currently unconditionally calls the set_channel() function, whether the device is running or not. This causes a failed bus access, if we set some config while the device is down. The driver must check if the device is running before setting any config on it (usb->initialized?).
I tried to fix this, but I failed to find the correct condition to check for.

I'm also wondering why we only set the channel in the config callback. Is the rest all unsupported by the device, like setting of TX power and so on?

#1 lore raw
Quoted 8 lines · Michael Buesch

The zd1211 driver has a bug in the ieee80211 config callback. It currently unconditionally calls the set_channel() function, whether the device is running or not. This causes a failed bus access, if we set some config while the device is down. The driver must check if the device is running before setting any config on it (usb->initialized?).
I tried to fix this, but I failed to find the correct condition to check for.

Thank you for highlighting this. My MAC address patch introduced a flag mac->open, which could be useful here. We would need to store the channel and set it, when the device is opened. One could ask why the MAC stack is not handling this.

Quoted 3 lines

I'm also wondering why we only set the channel in the config callback. Is the rest all unsupported by the device, like setting of TX power and so on?

We don't know how to do it; we are missing good documentation about the hardware registers. The different RFs will also be a factor.

Signature · 1 line
Uli Kunitz
#2 lore raw
In reply to Michael Buesch
Quoted 6 lines · Michael Buesch

The zd1211 driver has a bug in the ieee80211 config callback. It currently unconditionally calls the set_channel() function, whether the device is running or not. This causes a failed bus access, if we set some config while the device is down. The driver must check if the device is running before setting any config on it (usb->initialized?).

Hm, that sounds pretty terrible. mac80211 should check if the device was started before trying to run any configure callbacks.

-Michael Wu

#3 lore raw
Quoted 9 lines · Michael Wu
Quoted 6 lines · Michael Buesch

The zd1211 driver has a bug in the ieee80211 config callback. It currently unconditionally calls the set_channel() function, whether the device is running or not. This causes a failed bus access, if we set some config while the device is down. The driver must check if the device is running before setting any config on it (usb->initialized?).

Hm, that sounds pretty terrible. mac80211 should check if the device was started before trying to run any configure callbacks.

Something like that?

Subject: mac80211: Check open_count before calling config callback.

Also remove the check for ops->config!=NULL, as it can never be NULL.

net/mac80211/ieee80211.c +1 -1
Index: wireless-dev/net/mac80211/ieee80211.c
===================================================================
@@ -722,7 +722,7 @@ int ieee80211_hw_config(struct ieee80211
 	       local->hw.conf.phymode);
 #endif /* CONFIG_MAC80211_VERBOSE_DEBUG */
 
-	if (local->ops->config)
+	if (local->open_count)
 		ret = local->ops->config(local_to_hw(local), &local->hw.conf);
 
 	return ret;
maintainer
#4 lore raw

net/mac80211/ieee80211.c int ieee80211_hw_config(struct ieee80211 · line 726

Quoted 3 lines · Michael Buesch
net/mac80211/ieee80211.c +1 -1
-	if (local->ops->config)
+	if (local->open_count)
 		ret = local->ops->config(local_to_hw(local), &local->hw.conf);

Isn't this racy?

johannes

maintainer
#5 lore raw
Quoted 7 lines · Johannes Berg

net/mac80211/ieee80211.c int ieee80211_hw_config(struct ieee80211 · line 726

Quoted 3 lines · Michael Buesch
net/mac80211/ieee80211.c +1 -1
-	if (local->ops->config)
+	if (local->open_count)
 		ret = local->ops->config(local_to_hw(local), &local->hw.conf);

Isn't this racy?

Also, shouldn't we then call ->config when the first interface is brought up or something?

johannes

#9 lore raw
In reply to Johannes Berg
Quoted 6 lines · Johannes Berg

net/mac80211/ieee80211.c int ieee80211_hw_config(struct ieee80211 · line 726

Quoted 3 lines · Michael Buesch
net/mac80211/ieee80211.c +1 -1
-	if (local->ops->config)
+	if (local->open_count)
 		ret = local->ops->config(local_to_hw(local), &local->hw.conf);

Isn't this racy?

Shouldn't be. Some callers are holding rtnl (ieee80211_open, ieee80211_ioctl*). Other callers (in ieee80211_sta.c) cannot run if the device is down.

-Michael Wu

#6 lore raw
In reply to Johannes Berg
Quoted 3 lines · Johannes Berg

Also, shouldn't we then call ->config when the first interface is brought up or something?

I'm pretty sure that was done for all cases at some point. When did it get switched to being done for just monitor?

-Michael Wu

maintainer
#10 lore raw
In reply to Michael Wu
Quoted 10 lines · Michael Wu
Quoted 6 lines · Johannes Berg

net/mac80211/ieee80211.c int ieee80211_hw_config(struct ieee80211 · line 726

Quoted 3 lines · Michael Buesch
net/mac80211/ieee80211.c +1 -1
-	if (local->ops->config)
+	if (local->open_count)
 		ret = local->ops->config(local_to_hw(local), &local->hw.conf);

Isn't this racy?

Shouldn't be. Some callers are holding rtnl (ieee80211_open, ieee80211_ioctl*). Other callers (in ieee80211_sta.c) cannot run if the device is down.

Good point. I guess the patch is fine then.

johannes

maintainer
#7 lore raw
In reply to Michael Wu
Quoted 2 lines · Michael Wu

I'm pretty sure that was done for all cases at some point. When did it get switched to being done for just monitor?

Looks like an oversight in the filter flags patch. I'll take a look tomorrow.

johannes

#8 lore raw
In reply to Johannes Berg
Quoted 11 lines · Johannes Berg
Quoted 7 lines · Johannes Berg

net/mac80211/ieee80211.c int ieee80211_hw_config(struct ieee80211 · line 726

Quoted 3 lines · Michael Buesch
net/mac80211/ieee80211.c +1 -1
-	if (local->ops->config)
+	if (local->open_count)
 		ret = local->ops->config(local_to_hw(local), &local->hw.conf);

Isn't this racy?

Also, shouldn't we then call ->config when the first interface is brought up or something?

I don't know. You are the one who knows the code. ;) I'm just pointing at problems that I'm not able to fix, because I don't know the code.