zd1211 config operation problem
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?
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
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
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
@@ -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;
Johannes Berg
maintainernet/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
Johannes Berg
maintainerQuoted 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
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
Johannes Berg
maintainerQuoted 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
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.
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
Johannes Berg
maintainerQuoted 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 (inieee80211_sta.c) cannot run if the device is down.
Good point. I guess the patch is fine then.
johannes