]> git.openfabrics.org - ~emulex/infiniband.git/commitdiff
iwlagn: verify mutex held for sync commands
authorJohannes Berg <johannes.berg@intel.com>
Mon, 27 Jun 2011 13:06:42 +0000 (06:06 -0700)
committerWey-Yi Guy <wey-yi.w.guy@intel.com>
Fri, 1 Jul 2011 14:46:21 +0000 (07:46 -0700)
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>
drivers/net/wireless/iwlwifi/iwl-dev.h
drivers/net/wireless/iwlwifi/iwl-hcmd.c

index 8ec04f20c96aed61a553fcef62b2f1997b8142b8..ae2ecc24b91e5c587cd840199eca613a8fddf4c3 100644 (file)
@@ -1301,7 +1301,6 @@ struct iwl_priv {
 
        /* command queue number */
        u8 cmd_queue;
-       u8 last_sync_cmd_id;
 
        /* max number of station keys */
        u8 sta_key_max_num;
index e3e5fb614178070b086c73bd3a9656ef0d977cce..107b38e2ee93cff3f8647333d1a2983253abdf22 100644 (file)
@@ -171,6 +171,8 @@ int iwl_send_cmd_sync(struct iwl_priv *priv, struct iwl_host_cmd *cmd)
        int cmd_idx;
        int ret;
 
+       lockdep_assert_held(&priv->mutex);
+
        if (WARN_ON(cmd->flags & CMD_ASYNC))
                return -EINVAL;
 
@@ -181,16 +183,7 @@ int iwl_send_cmd_sync(struct iwl_priv *priv, struct iwl_host_cmd *cmd)
        IWL_DEBUG_INFO(priv, "Attempting to send sync command %s\n",
                        get_cmd_string(cmd->id));
 
-       if (test_and_set_bit(STATUS_HCMD_ACTIVE, &priv->status)) {
-               IWL_ERR(priv, "STATUS_HCMD_ACTIVE already set while sending %s"
-                             ". Previous SYNC cmdn is %s\n",
-                       get_cmd_string(cmd->id),
-                       get_cmd_string(priv->last_sync_cmd_id));
-               WARN_ON(1);
-       } else {
-               priv->last_sync_cmd_id = cmd->id;
-       }
-
+       set_bit(STATUS_HCMD_ACTIVE, &priv->status);
        IWL_DEBUG_INFO(priv, "Setting HCMD_ACTIVE for command %s\n",
                        get_cmd_string(cmd->id));