[Bug 455] Fix frequent channel change generates firmware fatal error. Because of the frequent channel change, it is possible that when we are try to associate with channel 1 (authenticated but not associated). Another channel change comes at this time, then the driver will issue disassociate command to the firmware which will cause the fatal error. It seems that the association/disassociation procedure should not be interrupted. The patch attached adds test on STATUS_ASSOCIATING | STATUS_DISASSOCIATING in ipw_send_cmd(), when ensures that commands will not be sent to firmware when we are in these two status. Signed-off-by: Hong Liu Signed-off-by: Zhu Yi -- diff -Nurp ipw2200-1.0.6-orig/ipw2200.c ipw2200-1.0.6/ipw2200.c --- ipw2200-1.0.6-orig/ipw2200.c 2005-04-12 17:03:02.000000000 +0800 +++ ipw2200-1.0.6/ipw2200.c 2005-04-13 13:42:03.496914912 +0800 @@ -1592,6 +1592,18 @@ static int ipw_send_cmd(struct ipw_priv return -1; } + if (priv->status & STATUS_ASSOCIATING) { + IPW_DEBUG_HC("abandon a command while associating\n"); + spin_unlock_irqrestore(&priv->lock, flags); + return -1; + } + + if (priv->status & STATUS_DISASSOCIATING) { + IPW_DEBUG_HC("abandon a command while disassociating\n"); + spin_unlock_irqrestore(&priv->lock, flags); + return -1; + } + priv->status |= STATUS_HCMD_ACTIVE; IPW_DEBUG_HC("Sending %s command (#%d), %d bytes\n", @@ -3385,14 +3397,17 @@ static void ipw_send_disassociate(struct return; } + if (priv->status & STATUS_ASSOCIATING) { + IPW_DEBUG_ASSOC("Disassociating while associating.\n"); + queue_work(priv->workqueue, &priv->disassociate); + return; + } + IPW_DEBUG_ASSOC("Disassocation attempt from " MAC_FMT " " "on channel %d.\n", MAC_ARG(priv->assoc_request.bssid), priv->assoc_request.channel); - priv->status &= ~(STATUS_ASSOCIATING | STATUS_ASSOCIATED); - priv->status |= STATUS_DISASSOCIATING; - if (quiet) priv->assoc_request.assoc_type = HC_DISASSOC_QUIET; else @@ -3404,6 +3419,9 @@ static void ipw_send_disassociate(struct return; } + priv->status &= ~(STATUS_ASSOCIATING | STATUS_ASSOCIATED); + priv->status |= STATUS_DISASSOCIATING; + } static int ipw_disassociate(void *data) @@ -6093,8 +6111,6 @@ static int ipw_associate_network(struct */ priv->channel = network->channel; memcpy(priv->bssid, network->bssid, ETH_ALEN); - priv->status |= STATUS_ASSOCIATING; - priv->status &= ~STATUS_SECURITY_UPDATED; priv->assoc_network = network; @@ -6104,6 +6120,9 @@ static int ipw_associate_network(struct return err; } + priv->status |= STATUS_ASSOCIATING; + priv->status &= ~STATUS_SECURITY_UPDATED; + IPW_DEBUG(IPW_DL_STATE, "associating: '%s' " MAC_FMT " \n", escape_essid(priv->essid, priv->essid_len), MAC_ARG(priv->bssid));