aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorJuuso Oikarinen <juuso.oikarinen@nokia.com>2011-03-29 09:43:50 -0400
committerLuciano Coelho <coelho@ti.com>2011-04-19 09:49:15 -0400
commit13026decf7b74d0908df034dc6dc86c2caaec939 (patch)
tree8d5e0fa75e0de15dee632854aa20db3be41de4cf /drivers
parentc1b193eb6557279d037ab18c00ab628c6c78847f (diff)
wl12xx: Handle duplicate calling of remove interface
Because of the hardware recovery mechanism, its possible the __wl1271_op_remove_interface is called twice. Currently, this leads to a kernel crash even before a kernel WARNing can be issued. Fix this. Signed-off-by: Juuso Oikarinen <juuso.oikarinen@nokia.com> Signed-off-by: Luciano Coelho <coelho@ti.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/wireless/wl12xx/main.c29
-rw-r--r--drivers/net/wireless/wl12xx/wl12xx.h3
2 files changed, 28 insertions, 4 deletions
diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c
index 3f6517dda629..57d0af6cfa64 100644
--- a/drivers/net/wireless/wl12xx/main.c
+++ b/drivers/net/wireless/wl12xx/main.c
@@ -1304,6 +1304,16 @@ static int wl1271_op_add_interface(struct ieee80211_hw *hw,
1304 goto out; 1304 goto out;
1305 } 1305 }
1306 1306
1307 /*
1308 * in some very corner case HW recovery scenarios its possible to
1309 * get here before __wl1271_op_remove_interface is complete, so
1310 * opt out if that is the case.
1311 */
1312 if (test_bit(WL1271_FLAG_IF_INITIALIZED, &wl->flags)) {
1313 ret = -EBUSY;
1314 goto out;
1315 }
1316
1307 switch (vif->type) { 1317 switch (vif->type) {
1308 case NL80211_IFTYPE_STATION: 1318 case NL80211_IFTYPE_STATION:
1309 wl->bss_type = BSS_TYPE_STA_BSS; 1319 wl->bss_type = BSS_TYPE_STA_BSS;
@@ -1372,6 +1382,7 @@ power_off:
1372 1382
1373 wl->vif = vif; 1383 wl->vif = vif;
1374 wl->state = WL1271_STATE_ON; 1384 wl->state = WL1271_STATE_ON;
1385 set_bit(WL1271_FLAG_IF_INITIALIZED, &wl->flags);
1375 wl1271_info("firmware booted (%s)", wl->chip.fw_ver_str); 1386 wl1271_info("firmware booted (%s)", wl->chip.fw_ver_str);
1376 1387
1377 /* update hw/fw version info in wiphy struct */ 1388 /* update hw/fw version info in wiphy struct */
@@ -1409,14 +1420,16 @@ static void __wl1271_op_remove_interface(struct wl1271 *wl)
1409 1420
1410 wl1271_debug(DEBUG_MAC80211, "mac80211 remove interface"); 1421 wl1271_debug(DEBUG_MAC80211, "mac80211 remove interface");
1411 1422
1423 /* because of hardware recovery, we may get here twice */
1424 if (wl->state != WL1271_STATE_ON)
1425 return;
1426
1412 wl1271_info("down"); 1427 wl1271_info("down");
1413 1428
1414 mutex_lock(&wl_list_mutex); 1429 mutex_lock(&wl_list_mutex);
1415 list_del(&wl->list); 1430 list_del(&wl->list);
1416 mutex_unlock(&wl_list_mutex); 1431 mutex_unlock(&wl_list_mutex);
1417 1432
1418 WARN_ON(wl->state != WL1271_STATE_ON);
1419
1420 /* enable dyn ps just in case (if left on due to fw crash etc) */ 1433 /* enable dyn ps just in case (if left on due to fw crash etc) */
1421 if (wl->bss_type == BSS_TYPE_STA_BSS) 1434 if (wl->bss_type == BSS_TYPE_STA_BSS)
1422 ieee80211_enable_dyn_ps(wl->vif); 1435 ieee80211_enable_dyn_ps(wl->vif);
@@ -1428,6 +1441,10 @@ static void __wl1271_op_remove_interface(struct wl1271 *wl)
1428 ieee80211_scan_completed(wl->hw, true); 1441 ieee80211_scan_completed(wl->hw, true);
1429 } 1442 }
1430 1443
1444 /*
1445 * this must be before the cancel_work calls below, so that the work
1446 * functions don't perform further work.
1447 */
1431 wl->state = WL1271_STATE_OFF; 1448 wl->state = WL1271_STATE_OFF;
1432 1449
1433 mutex_unlock(&wl->mutex); 1450 mutex_unlock(&wl->mutex);
@@ -1464,7 +1481,6 @@ static void __wl1271_op_remove_interface(struct wl1271 *wl)
1464 wl->time_offset = 0; 1481 wl->time_offset = 0;
1465 wl->session_counter = 0; 1482 wl->session_counter = 0;
1466 wl->rate_set = CONF_TX_RATE_MASK_BASIC; 1483 wl->rate_set = CONF_TX_RATE_MASK_BASIC;
1467 wl->flags = 0;
1468 wl->vif = NULL; 1484 wl->vif = NULL;
1469 wl->filters = 0; 1485 wl->filters = 0;
1470 wl1271_free_ap_keys(wl); 1486 wl1271_free_ap_keys(wl);
@@ -1473,6 +1489,13 @@ static void __wl1271_op_remove_interface(struct wl1271 *wl)
1473 wl->ap_ps_map = 0; 1489 wl->ap_ps_map = 0;
1474 wl->block_size = 0; 1490 wl->block_size = 0;
1475 1491
1492 /*
1493 * this is performed after the cancel_work calls and the associated
1494 * mutex_lock, so that wl1271_op_add_interface does not accidentally
1495 * get executed before all these vars have been reset.
1496 */
1497 wl->flags = 0;
1498
1476 for (i = 0; i < NUM_TX_QUEUES; i++) 1499 for (i = 0; i < NUM_TX_QUEUES; i++)
1477 wl->tx_blocks_freed[i] = 0; 1500 wl->tx_blocks_freed[i] = 0;
1478 1501
diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h
index ba98e1853842..c12945958848 100644
--- a/drivers/net/wireless/wl12xx/wl12xx.h
+++ b/drivers/net/wireless/wl12xx/wl12xx.h
@@ -354,7 +354,8 @@ enum wl12xx_flags {
354 WL1271_FLAG_PSPOLL_FAILURE, 354 WL1271_FLAG_PSPOLL_FAILURE,
355 WL1271_FLAG_STA_STATE_SENT, 355 WL1271_FLAG_STA_STATE_SENT,
356 WL1271_FLAG_FW_TX_BUSY, 356 WL1271_FLAG_FW_TX_BUSY,
357 WL1271_FLAG_AP_STARTED 357 WL1271_FLAG_AP_STARTED,
358 WL1271_FLAG_IF_INITIALIZED,
358}; 359};
359 360
360struct wl1271_link { 361struct wl1271_link {