aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorJohannes Berg <johannes.berg@intel.com>2011-06-27 09:06:42 -0400
committerWey-Yi Guy <wey-yi.w.guy@intel.com>2011-07-01 10:46:21 -0400
commit98a648e10a3c4eb30f8043281345506e17ace007 (patch)
tree0e1f04eb63b342018635f0bb38860e13cedaaa7d /drivers
parent9a4ba833a2d0016cf836827e136f0c219834bd41 (diff)
iwlagn: verify mutex held for sync commands
Emmanuel noticed that there's no explicit checking that prevents the driver from attempting to issue multiple synchronous commands at the same time and wrote a patch to check. However, his patch warns only if a collision actually happened, an unlikely thing since the driver mutex should be held for synchronous command submissions. So instead of checking that a collision happened add a check that the mutex is held which ensures that collisions can't happen. Signed-off-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-dev.h1
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-hcmd.c13
2 files changed, 3 insertions, 11 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h
index 8ec04f20c96a..ae2ecc24b91e 100644
--- a/drivers/net/wireless/iwlwifi/iwl-dev.h
+++ b/drivers/net/wireless/iwlwifi/iwl-dev.h
@@ -1301,7 +1301,6 @@ struct iwl_priv {
1301 1301
1302 /* command queue number */ 1302 /* command queue number */
1303 u8 cmd_queue; 1303 u8 cmd_queue;
1304 u8 last_sync_cmd_id;
1305 1304
1306 /* max number of station keys */ 1305 /* max number of station keys */
1307 u8 sta_key_max_num; 1306 u8 sta_key_max_num;
diff --git a/drivers/net/wireless/iwlwifi/iwl-hcmd.c b/drivers/net/wireless/iwlwifi/iwl-hcmd.c
index e3e5fb614178..107b38e2ee93 100644
--- a/drivers/net/wireless/iwlwifi/iwl-hcmd.c
+++ b/drivers/net/wireless/iwlwifi/iwl-hcmd.c
@@ -171,6 +171,8 @@ int iwl_send_cmd_sync(struct iwl_priv *priv, struct iwl_host_cmd *cmd)
171 int cmd_idx; 171 int cmd_idx;
172 int ret; 172 int ret;
173 173
174 lockdep_assert_held(&priv->mutex);
175
174 if (WARN_ON(cmd->flags & CMD_ASYNC)) 176 if (WARN_ON(cmd->flags & CMD_ASYNC))
175 return -EINVAL; 177 return -EINVAL;
176 178
@@ -181,16 +183,7 @@ int iwl_send_cmd_sync(struct iwl_priv *priv, struct iwl_host_cmd *cmd)
181 IWL_DEBUG_INFO(priv, "Attempting to send sync command %s\n", 183 IWL_DEBUG_INFO(priv, "Attempting to send sync command %s\n",
182 get_cmd_string(cmd->id)); 184 get_cmd_string(cmd->id));
183 185
184 if (test_and_set_bit(STATUS_HCMD_ACTIVE, &priv->status)) { 186 set_bit(STATUS_HCMD_ACTIVE, &priv->status);
185 IWL_ERR(priv, "STATUS_HCMD_ACTIVE already set while sending %s"
186 ". Previous SYNC cmdn is %s\n",
187 get_cmd_string(cmd->id),
188 get_cmd_string(priv->last_sync_cmd_id));
189 WARN_ON(1);
190 } else {
191 priv->last_sync_cmd_id = cmd->id;
192 }
193
194 IWL_DEBUG_INFO(priv, "Setting HCMD_ACTIVE for command %s\n", 187 IWL_DEBUG_INFO(priv, "Setting HCMD_ACTIVE for command %s\n",
195 get_cmd_string(cmd->id)); 188 get_cmd_string(cmd->id));
196 189