Skip to contentSkip to conversation

wl1251: beacon filter support and more

PATCH In review Kalle Valo 2 participants 19 messages Nov 17, 2009

Subsystems (2)
lore
Share & tools
lore

Kalle Valo

author
#0 lore raw

cover wl1251: beacon filter support and more

Hi John,

here is a set of patches for wl1251. New features are EEPROM NVS support (from David-John Willis) and beacon filtering, but there are also some serious fixes and optimisations.

These patches are not urgent.

---

David-John Willis (1):
wl1251: add NVS in EEPROM support

Janne Ylalehto (2):
wl1251: Filter out unwanted events
wl1251: Add IRQ looping support

Juuso Oikarinen (5):
wl1251: Fix regression in IRQ loop handling
wl1251: Implement delayed entry into ELP mode
wl1251: Configure beacon filtering on if PSM used
wl1251: Enable beacon filtering with the stack
wl1251: Add connection monitoring configuration

Kalle Valo (3):
wl1251: remove depcreated qual usage
wl1251: mask aid bits 14 and 15 in ps-poll template
wl1251: allocate space for firmware with vmalloc()

Vidhya Govindan (5):
wl1251: Send null data packet with "TODS" bit set
wl1251: Increase the beacon loss timeout value and handle regain event
wl1251: Set the correct dtim period to the firmware
wl1251: Add acx command to set tbtt and dtim period
wl1251: fix deadlock with ieee80211 beacon filter calls

 drivers/net/wireless/wl12xx/wl1251.h       |    5 +
 drivers/net/wireless/wl12xx/wl1251_acx.c   |   68 +++++++++++-
 drivers/net/wireless/wl12xx/wl1251_acx.h   |   36 ++++++
 drivers/net/wireless/wl12xx/wl1251_boot.c  |   55 +++++++---
 drivers/net/wireless/wl12xx/wl1251_event.c |   18 +++
 drivers/net/wireless/wl12xx/wl1251_init.c  |    8 +
 drivers/net/wireless/wl12xx/wl1251_main.c  |  162 ++++++++++++++++------------
 drivers/net/wireless/wl12xx/wl1251_ps.c    |   44 +++++++-
 drivers/net/wireless/wl12xx/wl1251_ps.h    |    1 
 drivers/net/wireless/wl12xx/wl1251_reg.h   |    6 +
 drivers/net/wireless/wl12xx/wl1251_rx.c    |    4 -
 drivers/net/wireless/wl12xx/wl1251_spi.c   |    2 
 include/linux/spi/wl12xx.h                 |    1 
 13 files changed, 314 insertions(+), 96 deletions(-)
author
#1 lore raw

PATCH 1/16 wl1251: Add connection monitoring configuration

From: Juuso Oikarinen <[email protected]>

Add configuration for connection monitor (number of allowed beacons, and timeout after last received beacon.)

---

 drivers/net/wireless/wl12xx/wl1251_acx.c  |   29 +++++++++++++++++++++++++++++
 drivers/net/wireless/wl12xx/wl1251_acx.h  |   11 +++++++++++
 drivers/net/wireless/wl12xx/wl1251_init.c |    5 +++++
 3 files changed, 45 insertions(+), 0 deletions(-)
drivers/net/wireless/wl12xx/wl1251_acx.c +29 -0
index 10b26c4..4a9c708 100644
@@ -550,6 +550,35 @@ out:
 	return ret;
 }
 
+int wl1251_acx_conn_monit_params(struct wl1251 *wl)
+{
+	struct acx_conn_monit_params *acx;
+	int ret;
+
+	wl1251_debug(DEBUG_ACX, "acx connection monitor parameters");
+
+	acx = kzalloc(sizeof(*acx), GFP_KERNEL);
+	if (!acx) {
+		ret = -ENOMEM;
+		goto out;
+	}
+
+	acx->synch_fail_thold = SYNCH_FAIL_DEFAULT_THRESHOLD;
+	acx->bss_lose_timeout = NO_BEACON_DEFAULT_TIMEOUT;
+
+	ret = wl1251_cmd_configure(wl, ACX_CONN_MONIT_PARAMS,
+				   acx, sizeof(*acx));
+	if (ret < 0) {
+		wl1251_warning("failed to set connection monitor "
+			       "parameters: %d", ret);
+		goto out;
+	}
+
+out:
+	kfree(acx);
+	return ret;
+}
+
 int wl1251_acx_sg_enable(struct wl1251 *wl)
 {
 	struct acx_bt_wlan_coex *pta;
drivers/net/wireless/wl12xx/wl1251_acx.h +11 -0
index cafb914..926789c 100644
@@ -458,6 +458,16 @@ struct acx_beacon_filter_ie_table {
 	u8 pad[3];
 } __attribute__ ((packed));
 
+#define SYNCH_FAIL_DEFAULT_THRESHOLD    5     /* number of beacons */
+#define NO_BEACON_DEFAULT_TIMEOUT       (100) /* TU */
+
+struct acx_conn_monit_params {
+	struct acx_header header;
+
+	u32 synch_fail_thold; /* number of beacons missed */
+	u32 bss_lose_timeout; /* number of TU's from synch fail */
+};
+
 enum {
 	SG_ENABLE = 0,
 	SG_DISABLE,
@@ -1275,6 +1285,7 @@ int wl1251_acx_service_period_timeout(struct wl1251 *wl);
 int wl1251_acx_rts_threshold(struct wl1251 *wl, u16 rts_threshold);
 int wl1251_acx_beacon_filter_opt(struct wl1251 *wl);
 int wl1251_acx_beacon_filter_table(struct wl1251 *wl);
+int wl1251_acx_conn_monit_params(struct wl1251 *wl);
 int wl1251_acx_sg_enable(struct wl1251 *wl);
 int wl1251_acx_sg_cfg(struct wl1251 *wl);
 int wl1251_acx_cca_threshold(struct wl1251 *wl);
drivers/net/wireless/wl12xx/wl1251_init.c +5 -0
index b2ee4f4..035ab11 100644
@@ -364,6 +364,11 @@ int wl1251_hw_init(struct wl1251 *wl)
 	if (ret < 0)
 		goto out_free_data_path;
 
+	/* Initialize connection monitoring thresholds */
+	ret = wl1251_acx_conn_monit_params(wl);
+	if (ret < 0)
+		goto out_free_data_path;
+
 	/* Beacon filtering */
 	ret = wl1251_hw_init_beacon_filter(wl);
 	if (ret < 0)
author
#2 lore raw

PATCH 2/16 wl1251: Enable beacon filtering with the stack

In reply to Kalle Valo

From: Juuso Oikarinen <[email protected]>

Enable beacon filtering with the mac80211 stack.

---

 drivers/net/wireless/wl12xx/wl1251.h       |    2 ++
 drivers/net/wireless/wl12xx/wl1251_event.c |    7 +++++++
 drivers/net/wireless/wl12xx/wl1251_main.c  |   12 ++++++++++++
 3 files changed, 21 insertions(+), 0 deletions(-)
drivers/net/wireless/wl12xx/wl1251.h +2 -0
index 998e4b6..fc2871c 100644
@@ -374,6 +374,8 @@ struct wl1251 {
 	u8 buffer_busyword[WL1251_BUSY_WORD_LEN];
 	struct wl1251_rx_descriptor *rx_descriptor;
 
+	struct ieee80211_vif *vif;
+
 	u32 chip_id;
 	char fw_ver[21];
 };
drivers/net/wireless/wl12xx/wl1251_event.c +7 -0
index 00076c4..18c301d 100644
@@ -79,6 +79,13 @@ static int wl1251_event_process(struct wl1251 *wl, struct event_mailbox *mbox)
 		}
 	}
 
+	if (vector & SYNCHRONIZATION_TIMEOUT_EVENT_ID && wl->psm) {
+		wl1251_debug(DEBUG_EVENT, "SYNCHRONIZATION_TIMEOUT_EVENT");
+
+		/* indicate to the stack, that beacons have been lost */
+		ieee80211_beacon_loss(wl->vif);
+	}
+
 	return 0;
 }
 
drivers/net/wireless/wl12xx/wl1251_main.c +12 -0
index d03a07e..601c430 100644
@@ -509,6 +509,12 @@ static int wl1251_op_add_interface(struct ieee80211_hw *hw,
 		     conf->type, conf->mac_addr);
 
 	mutex_lock(&wl->mutex);
+	if (wl->vif) {
+		ret = -EBUSY;
+		goto out;
+	}
+
+	wl->vif = conf->vif;
 
 	switch (conf->type) {
 	case NL80211_IFTYPE_STATION:
@@ -538,7 +544,12 @@ out:
 static void wl1251_op_remove_interface(struct ieee80211_hw *hw,
 					 struct ieee80211_if_init_conf *conf)
 {
+	struct wl1251 *wl = hw->priv;
+
+	mutex_lock(&wl->mutex);
 	wl1251_debug(DEBUG_MAC80211, "mac80211 remove interface");
+	wl->vif = NULL;
+	mutex_unlock(&wl->mutex);
 }
 
 static int wl1251_build_null_data(struct wl1251 *wl)
@@ -1372,6 +1383,7 @@ struct ieee80211_hw *wl1251_alloc_hw(void)
 	wl->power_level = WL1251_DEFAULT_POWER_LEVEL;
 	wl->beacon_int = WL1251_DEFAULT_BEACON_INT;
 	wl->dtim_period = WL1251_DEFAULT_DTIM_PERIOD;
+	wl->vif = NULL;
 
 	for (i = 0; i < FW_TX_CMPLT_BLOCK_SIZE; i++)
 		wl->tx_frames[i] = NULL;
author
#3 lore raw

PATCH 3/16 wl1251: Configure beacon filtering on if PSM used

In reply to Kalle Valo

From: Juuso Oikarinen <[email protected]>

Enable beacon filtering when PSM is enabled

---

 drivers/net/wireless/wl12xx/wl1251_acx.c  |   11 +++++++----
 drivers/net/wireless/wl12xx/wl1251_acx.h  |    7 ++++++-
 drivers/net/wireless/wl12xx/wl1251_init.c |    3 ++-
 drivers/net/wireless/wl12xx/wl1251_main.c |    3 ++-
 drivers/net/wireless/wl12xx/wl1251_ps.c   |   10 ++++++++++
 5 files changed, 27 insertions(+), 7 deletions(-)
drivers/net/wireless/wl12xx/wl1251_acx.c +7 -4
index 4a9c708..50633e0 100644
@@ -494,7 +494,7 @@ out:
 	return ret;
 }
 
-int wl1251_acx_beacon_filter_opt(struct wl1251 *wl)
+int wl1251_acx_beacon_filter_opt(struct wl1251 *wl, bool enable_filter)
 {
 	struct acx_beacon_filter_option *beacon_filter;
 	int ret;
@@ -507,7 +507,7 @@ int wl1251_acx_beacon_filter_opt(struct wl1251 *wl)
 		goto out;
 	}
 
-	beacon_filter->enable = 0;
+	beacon_filter->enable = enable_filter;
 	beacon_filter->max_num_beacons = 0;
 
 	ret = wl1251_cmd_configure(wl, ACX_BEACON_FILTER_OPT,
@@ -525,6 +525,7 @@ out:
 int wl1251_acx_beacon_filter_table(struct wl1251 *wl)
 {
 	struct acx_beacon_filter_ie_table *ie_table;
+	int idx = 0;
 	int ret;
 
 	wl1251_debug(DEBUG_ACX, "acx beacon filter table");
@@ -535,8 +536,10 @@ int wl1251_acx_beacon_filter_table(struct wl1251 *wl)
 		goto out;
 	}
 
-	ie_table->num_ie = 0;
-	memset(ie_table->table, 0, BEACON_FILTER_TABLE_MAX_SIZE);
+	/* configure default beacon pass-through rules */
+	ie_table->num_ie = 1;
+	ie_table->table[idx++] = BEACON_FILTER_IE_ID_CHANNEL_SWITCH_ANN;
+	ie_table->table[idx++] = BEACON_RULE_PASS_ON_APPEARANCE;
 
 	ret = wl1251_cmd_configure(wl, ACX_BEACON_FILTER_TABLE,
 				   ie_table, sizeof(*ie_table));
drivers/net/wireless/wl12xx/wl1251_acx.h +6 -1
index 926789c..ce1c995 100644
@@ -450,6 +450,11 @@ struct acx_beacon_filter_option {
 			   (BEACON_FILTER_TABLE_MAX_VENDOR_SPECIFIC_IE_NUM * \
 			    BEACON_FILTER_TABLE_EXTRA_VENDOR_SPECIFIC_IE_SIZE))
 
+#define BEACON_RULE_PASS_ON_CHANGE                     BIT(0)
+#define BEACON_RULE_PASS_ON_APPEARANCE                 BIT(1)
+
+#define BEACON_FILTER_IE_ID_CHANNEL_SWITCH_ANN         (37)
+
 struct acx_beacon_filter_ie_table {
 	struct acx_header header;
 
@@ -1283,7 +1288,7 @@ int wl1251_acx_slot(struct wl1251 *wl, enum acx_slot_type slot_time);
 int wl1251_acx_group_address_tbl(struct wl1251 *wl);
 int wl1251_acx_service_period_timeout(struct wl1251 *wl);
 int wl1251_acx_rts_threshold(struct wl1251 *wl, u16 rts_threshold);
-int wl1251_acx_beacon_filter_opt(struct wl1251 *wl);
+int wl1251_acx_beacon_filter_opt(struct wl1251 *wl, bool enable_filter);
 int wl1251_acx_beacon_filter_table(struct wl1251 *wl);
 int wl1251_acx_conn_monit_params(struct wl1251 *wl);
 int wl1251_acx_sg_enable(struct wl1251 *wl);
drivers/net/wireless/wl12xx/wl1251_init.c +2 -1
index 035ab11..5cb5733 100644
@@ -147,7 +147,8 @@ int wl1251_hw_init_beacon_filter(struct wl1251 *wl)
 {
 	int ret;
 
-	ret = wl1251_acx_beacon_filter_opt(wl);
+	/* disable beacon filtering at this stage */
+	ret = wl1251_acx_beacon_filter_opt(wl, false);
 	if (ret < 0)
 		return ret;
 
drivers/net/wireless/wl12xx/wl1251_main.c +2 -1
index 601c430..900e6e2 100644
@@ -1323,7 +1323,8 @@ int wl1251_init_ieee80211(struct wl1251 *wl)
 
 	wl->hw->flags = IEEE80211_HW_SIGNAL_DBM |
 		IEEE80211_HW_NOISE_DBM |
-		IEEE80211_HW_SUPPORTS_PS;
+		IEEE80211_HW_SUPPORTS_PS |
+		IEEE80211_HW_BEACON_FILTER;
 
 	wl->hw->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION);
 	wl->hw->wiphy->max_scan_ssids = 1;
drivers/net/wireless/wl12xx/wl1251_ps.c +10 -0
index c53e287..c3e348a 100644
@@ -119,6 +119,11 @@ int wl1251_ps_set_mode(struct wl1251 *wl, enum wl1251_cmd_ps_mode mode)
 	case STATION_POWER_SAVE_MODE:
 		wl1251_debug(DEBUG_PSM, "entering psm");
 
+		/* enable beacon filtering */
+		ret = wl1251_acx_beacon_filter_opt(wl, true);
+		if (ret < 0)
+			return ret;
+
 		ret = wl1251_acx_wake_up_conditions(wl,
 						    WAKE_UP_EVENT_DTIM_BITMAP,
 						    wl->listen_int);
@@ -142,6 +147,11 @@ int wl1251_ps_set_mode(struct wl1251 *wl, enum wl1251_cmd_ps_mode mode)
 		if (ret < 0)
 			return ret;
 
+		/* disable beacon filtering */
+		ret = wl1251_acx_beacon_filter_opt(wl, false);
+		if (ret < 0)
+			return ret;
+
 		ret = wl1251_acx_wake_up_conditions(wl,
 						    WAKE_UP_EVENT_DTIM_BITMAP,
 						    wl->listen_int);
author
#4 lore raw

PATCH 4/16 wl1251: Implement delayed entry into ELP mode

In reply to Kalle Valo

From: Juuso Oikarinen <[email protected]>

Implement (slightly) delayed entry into ELP. This will cure several problems:
- It works around a firmware race condition if ELP is entered too fast after commands (resulting in ELP timeout -traces)
- It will reduce the number of sleep-wake cycles between already scheduled events such as interrupts and tx, hence improving performance (less delay in switching between RX and TX)

---

 drivers/net/wireless/wl12xx/wl1251.h      |    2 ++
 drivers/net/wireless/wl12xx/wl1251_main.c |    1 +
 drivers/net/wireless/wl12xx/wl1251_ps.c   |   34 +++++++++++++++++++++++++----
 drivers/net/wireless/wl12xx/wl1251_ps.h   |    1 +
 4 files changed, 33 insertions(+), 5 deletions(-)
drivers/net/wireless/wl12xx/wl1251.h +2 -0
index fc2871c..a839466 100644
@@ -354,6 +354,8 @@ struct wl1251 {
 	/* is firmware in elp mode */
 	bool elp;
 
+	struct delayed_work elp_work;
+
 	/* we can be in psm, but not in elp, we have to differentiate */
 	bool psm;
 
drivers/net/wireless/wl12xx/wl1251_main.c +1 -0
index 900e6e2..b5e3bdb 100644
@@ -1367,6 +1367,7 @@ struct ieee80211_hw *wl1251_alloc_hw(void)
 	skb_queue_head_init(&wl->tx_queue);
 
 	INIT_WORK(&wl->filter_work, wl1251_filter_work);
+	INIT_DELAYED_WORK(&wl->elp_work, wl1251_elp_work);
 	wl->channel = WL1251_DEFAULT_CHANNEL;
 	wl->scanning = false;
 	wl->default_key = 0;
drivers/net/wireless/wl12xx/wl1251_ps.c +29 -5
index c3e348a..9931b19 100644
@@ -28,17 +28,41 @@
 
 #define WL1251_WAKEUP_TIMEOUT 2000
 
-/* Routines to toggle sleep mode while in ELP */
-void wl1251_ps_elp_sleep(struct wl1251 *wl)
+void wl1251_elp_work(struct work_struct *work)
 {
+	struct delayed_work *dwork;
+	struct wl1251 *wl;
+
+	dwork = container_of(work, struct delayed_work, work);
+	wl = container_of(dwork, struct wl1251, elp_work);
+
+	wl1251_debug(DEBUG_PSM, "elp work");
+
+	mutex_lock(&wl->mutex);
+
 	if (wl->elp || !wl->psm)
-		return;
+		goto out;
 
 	wl1251_debug(DEBUG_PSM, "chip to elp");
-
 	wl1251_write32(wl, HW_ACCESS_ELP_CTRL_REG_ADDR, ELPCTRL_SLEEP);
-
 	wl->elp = true;
+
+out:
+	mutex_unlock(&wl->mutex);
+}
+
+#define ELP_ENTRY_DELAY  5
+
+/* Routines to toggle sleep mode while in ELP */
+void wl1251_ps_elp_sleep(struct wl1251 *wl)
+{
+	unsigned long delay;
+
+	if (wl->psm) {
+		cancel_delayed_work(&wl->elp_work);
+		delay = msecs_to_jiffies(ELP_ENTRY_DELAY);
+		ieee80211_queue_delayed_work(wl->hw, &wl->elp_work, delay);
+	}
 }
 
 int wl1251_ps_elp_wakeup(struct wl1251 *wl)
drivers/net/wireless/wl12xx/wl1251_ps.h +1 -0
index db036fe..c688ac5 100644
@@ -31,6 +31,7 @@
 int wl1251_ps_set_mode(struct wl1251 *wl, enum wl1251_cmd_ps_mode mode);
 void wl1251_ps_elp_sleep(struct wl1251 *wl);
 int wl1251_ps_elp_wakeup(struct wl1251 *wl);
+void wl1251_elp_work(struct work_struct *work);
 
 
 #endif /* __WL1251_PS_H__ */
author
#5 lore raw

PATCH 5/16 wl1251: allocate space for firmware with vmalloc()

In reply to Kalle Valo

From: Kalle Valo <[email protected]>

Earlier firmware was stored to a memory area allocated with kmalloc() but finding a a contiguous area of memory long enough for the firmware is very difficult in certain cases. better to allocate the memory for firmware with vmalloc() instead and use a small buffer for DMA transfers.

Thanks to Eero Tamminen for the idea.

---

 drivers/net/wireless/wl12xx/wl1251_boot.c |   27 ++++++++++++++++++++++-----
 drivers/net/wireless/wl12xx/wl1251_main.c |    5 +++--
 2 files changed, 25 insertions(+), 7 deletions(-)
drivers/net/wireless/wl12xx/wl1251_boot.c +22 -5
index 452d748..8febf27 100644
@@ -314,8 +314,8 @@ int wl1251_boot_run_firmware(struct wl1251 *wl)
 static int wl1251_boot_upload_firmware(struct wl1251 *wl)
 {
 	int addr, chunk_num, partition_limit;
-	size_t fw_data_len;
-	u8 *p;
+	size_t fw_data_len, len;
+	u8 *p, *buf;
 
 	/* whal_FwCtrl_LoadFwImageSm() */
 
@@ -334,6 +334,12 @@ static int wl1251_boot_upload_firmware(struct wl1251 *wl)
 		return -EIO;
 	}
 
+	buf = kmalloc(CHUNK_SIZE, GFP_KERNEL);
+	if (!buf) {
+		wl1251_error("allocation for firmware upload chunk failed");
+		return -ENOMEM;
+	}
+
 	wl1251_set_partition(wl, WL1251_PART_DOWN_MEM_START,
 			     WL1251_PART_DOWN_MEM_SIZE,
 			     WL1251_PART_DOWN_REG_START,
@@ -364,7 +370,11 @@ static int wl1251_boot_upload_firmware(struct wl1251 *wl)
 		p = wl->fw + FW_HDR_SIZE + chunk_num * CHUNK_SIZE;
 		wl1251_debug(DEBUG_BOOT, "uploading fw chunk 0x%p to 0x%x",
 			     p, addr);
-		wl1251_mem_write(wl, addr, p, CHUNK_SIZE);
+
+		/* need to copy the chunk for dma */
+		len = CHUNK_SIZE;
+		memcpy(buf, p, len);
+		wl1251_mem_write(wl, addr, buf, len);
 
 		chunk_num++;
 	}
@@ -372,9 +382,16 @@ static int wl1251_boot_upload_firmware(struct wl1251 *wl)
 	/* 10.4 upload the last chunk */
 	addr = WL1251_PART_DOWN_MEM_START + chunk_num * CHUNK_SIZE;
 	p = wl->fw + FW_HDR_SIZE + chunk_num * CHUNK_SIZE;
+
+	/* need to copy the chunk for dma */
+	len = fw_data_len % CHUNK_SIZE;
+	memcpy(buf, p, len);
+
 	wl1251_debug(DEBUG_BOOT, "uploading fw last chunk (%zu B) 0x%p to 0x%x",
-		     fw_data_len % CHUNK_SIZE, p, addr);
-	wl1251_mem_write(wl, addr, p, fw_data_len % CHUNK_SIZE);
+		     len, p, addr);
+	wl1251_mem_write(wl, addr, buf, len);
+
+	kfree(buf);
 
 	return 0;
 }
drivers/net/wireless/wl12xx/wl1251_main.c +3 -2
index b5e3bdb..1f4c238 100644
@@ -28,6 +28,7 @@
 #include <linux/irq.h>
 #include <linux/crc32.h>
 #include <linux/etherdevice.h>
+#include <linux/vmalloc.h>
 
 #include "wl1251.h"
 #include "wl12xx_80211.h"
@@ -83,7 +84,7 @@ static int wl1251_fetch_firmware(struct wl1251 *wl)
 	}
 
 	wl->fw_len = fw->size;
-	wl->fw = kmalloc(wl->fw_len, GFP_KERNEL);
+	wl->fw = vmalloc(wl->fw_len);
 
 	if (!wl->fw) {
 		wl1251_error("could not allocate memory for the firmware");
@@ -1427,7 +1428,7 @@ int wl1251_free_hw(struct wl1251 *wl)
 
 	kfree(wl->target_mem_map);
 	kfree(wl->data_path);
-	kfree(wl->fw);
+	vfree(wl->fw);
 	wl->fw = NULL;
 	kfree(wl->nvs);
 	wl->nvs = NULL;
author
#6 lore raw

PATCH 6/16 wl1251: fix deadlock with ieee80211 beacon filter calls

In reply to Kalle Valo

From: Vidhya Govindan <[email protected]>

Lockdep shows that there is a deadlock when calling ieee80211_rssi_changed() under wl->mutex. Fix it by releasing mutex before calling mac80211 functions. This patch is based on Work-In-Progress patch sent by Kalle Valo.

---

 drivers/net/wireless/wl12xx/wl1251_event.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
drivers/net/wireless/wl12xx/wl1251_event.c +3 -0
index 18c301d..f42121c 100644
@@ -81,9 +81,12 @@ static int wl1251_event_process(struct wl1251 *wl, struct event_mailbox *mbox)
 
 	if (vector & SYNCHRONIZATION_TIMEOUT_EVENT_ID && wl->psm) {
 		wl1251_debug(DEBUG_EVENT, "SYNCHRONIZATION_TIMEOUT_EVENT");
+		/* need to unlock mutex to avoid deadlocking with rtnl */
+		mutex_unlock(&wl->mutex);
 
 		/* indicate to the stack, that beacons have been lost */
 		ieee80211_beacon_loss(wl->vif);
+		mutex_lock(&wl->mutex);
 	}
 
 	return 0;
maintainer
#7 lore raw

Re: [PATCH 06/16] wl1251: fix deadlock with ieee80211 beacon filter calls

Quoted 6 lines · Kalle Valo

From: Vidhya Govindan <[email protected]>

Lockdep shows that there is a deadlock when calling ieee80211_rssi_changed() under wl->mutex. Fix it by releasing mutex before calling mac80211 functions. This patch is based on Work-In-Progress patch sent by Kalle Valo.

drivers/net/wireless/wl12xx/wl1251_event.c static int wl1251_event_process(struct wl1251 *wl, struct event_mailbox *mbox) · line 89

Quoted 8 lines
drivers/net/wireless/wl12xx/wl1251_event.c +3 -0
 	if (vector & SYNCHRONIZATION_TIMEOUT_EVENT_ID && wl->psm) {
 		wl1251_debug(DEBUG_EVENT, "SYNCHRONIZATION_TIMEOUT_EVENT");
+		/* need to unlock mutex to avoid deadlocking with rtnl */
+		mutex_unlock(&wl->mutex);
 
 		/* indicate to the stack, that beacons have been lost */
 		ieee80211_beacon_loss(wl->vif);
+		mutex_lock(&wl->mutex);

That can't be true, ieee80211_beacon_loss() only calls ieee80211_queue_work().

johannes

author
#8 lore raw

Re: [PATCH 06/16] wl1251: fix deadlock with ieee80211 beacon filter calls

Quoted 12 lines · Johannes Berg
Quoted 11 lines · Kalle Valo

From: Vidhya Govindan <[email protected]>

Lockdep shows that there is a deadlock when calling ieee80211_rssi_changed() under wl->mutex. Fix it by releasing mutex before calling mac80211 functions. This patch is based on Work-In-Progress patch sent by Kalle Valo.

drivers/net/wireless/wl12xx/wl1251_event.c +2 -0
 	if (vector & SYNCHRONIZATION_TIMEOUT_EVENT_ID && wl->psm) {
 		wl1251_debug(DEBUG_EVENT, "SYNCHRONIZATION_TIMEOUT_EVENT");
+		/* need to unlock mutex to avoid deadlocking with rtnl */
+		mutex_unlock(&wl->mutex);
Quoted 6 lines

drivers/net/wireless/wl12xx/wl1251_event.c static int wl1251_event_process(struct wl1251 *wl, struct event_mailbox *mbox) · line 89

Quoted 3 lines
drivers/net/wireless/wl12xx/wl1251_event.c +1 -0
 		/* indicate to the stack, that beacons have been lost */
 		ieee80211_beacon_loss(wl->vif);
+		mutex_lock(&wl->mutex);

That can't be true, ieee80211_beacon_loss() only calls ieee80211_queue_work().

You are correct, of course. The problem was in our internal and heavily patched 2.6.28 tree, but not in wireless-testing. I should have checked this when I was rebasing the patches. Johannes, thank you for noticing this!

John, can you drop this patch or do you want me to resend the patch set? Based on stgit there might some problems with patch 10 after dropping this patch, but at least stgit was able to handle it automatically.

Signature · 1 line
Kalle Valo
author
#9 lore raw

PATCH 7/16 wl1251: mask aid bits 14 and 15 in ps-poll template

In reply to Kalle Valo

From: Kalle Valo <[email protected]>

In ps-poll template aid bits 14 and 15 were not masked as required by the standard. Mask them so that aid is sent in correct format.

---

 drivers/net/wireless/wl12xx/wl1251_main.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
drivers/net/wireless/wl12xx/wl1251_main.c +4 -1
index 1f4c238..41f5ad4 100644
@@ -580,7 +580,10 @@ static int wl1251_build_ps_poll(struct wl1251 *wl, u16 aid)
 
 	memcpy(template.bssid, wl->bssid, ETH_ALEN);
 	memcpy(template.ta, wl->mac_addr, ETH_ALEN);
-	template.aid = aid;
+
+	/* aid in PS-Poll has its two MSBs each set to 1 */
+	template.aid = cpu_to_le16(1 << 15 | 1 << 14 | aid);
+
 	template.fc = cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_PSPOLL);
 
 	return wl1251_cmd_template_set(wl, CMD_PS_POLL, &template,
author
#10 lore raw

PATCH 8/16 wl1251: Add acx command to set tbtt and dtim period

In reply to Kalle Valo

From: Vidhya Govindan <[email protected]>

The dtim period obtained from the mac80211 is not set to the firmware. This patch implements the acx command to set correct tbtt and dtim value to the firmware.

---

 drivers/net/wireless/wl12xx/wl1251_acx.c |   28 ++++++++++++++++++++++++++++
 drivers/net/wireless/wl12xx/wl1251_acx.h |   18 ++++++++++++++++++
 2 files changed, 46 insertions(+), 0 deletions(-)
drivers/net/wireless/wl12xx/wl1251_acx.c +28 -0
index 50633e0..acfa086 100644
@@ -948,3 +948,31 @@ out:
 	kfree(mem_conf);
 	return ret;
 }
+
+int wl1251_acx_wr_tbtt_and_dtim(struct wl1251 *wl, u16 tbtt, u8 dtim)
+{
+	struct wl1251_acx_wr_tbtt_and_dtim *acx;
+	int ret;
+
+	wl1251_debug(DEBUG_ACX, "acx tbtt and dtim");
+
+	acx = kzalloc(sizeof(*acx), GFP_KERNEL);
+	if (!acx) {
+		ret = -ENOMEM;
+		goto out;
+	}
+
+	acx->tbtt = tbtt;
+	acx->dtim = dtim;
+
+	ret = wl1251_cmd_configure(wl, ACX_WR_TBTT_AND_DTIM,
+				   acx, sizeof(*acx));
+	if (ret < 0) {
+		wl1251_warning("failed to set tbtt and dtim: %d", ret);
+		goto out;
+	}
+
+out:
+	kfree(acx);
+	return ret;
+}
drivers/net/wireless/wl12xx/wl1251_acx.h +18 -0
index ce1c995..44a4b04 100644
@@ -1149,6 +1149,23 @@ struct wl1251_acx_mem_map {
 	u32 num_rx_mem_blocks;
 } __attribute__ ((packed));
 
+
+struct wl1251_acx_wr_tbtt_and_dtim {
+
+	struct acx_header header;
+
+	/* Time in TUs between two consecutive beacons */
+	u16 tbtt;
+
+	/*
+	 * DTIM period
+	 * For BSS: Number of TBTTs in a DTIM period (range: 1-10)
+	 * For IBSS: value shall be set to 1
+	*/
+	u8  dtim;
+	u8  padding;
+} __attribute__ ((packed));
+
 /*************************************************************************
 
     Host Interrupt Register (WiLink -> Host)
@@ -1304,5 +1321,6 @@ int wl1251_acx_statistics(struct wl1251 *wl, struct acx_statistics *stats);
 int wl1251_acx_tsf_info(struct wl1251 *wl, u64 *mactime);
 int wl1251_acx_rate_policies(struct wl1251 *wl);
 int wl1251_acx_mem_cfg(struct wl1251 *wl);
+int wl1251_acx_wr_tbtt_and_dtim(struct wl1251 *wl, u16 tbtt, u8 dtim);
 
 #endif /* __WL1251_ACX_H__ */
author
#11 lore raw

PATCH 9/16 wl1251: Set the correct dtim period to the firmware

In reply to Kalle Valo

From: Vidhya Govindan <[email protected]>

This patch sets the dtim period obtained from the mac80211 to firmware.

---

 drivers/net/wireless/wl12xx/wl1251_main.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireless/wl12xx/wl1251_main.c +2 -2
index 41f5ad4..cc32ba6 100644
@@ -1105,8 +1105,8 @@ static void wl1251_op_bss_info_changed(struct ieee80211_hw *hw,
 			wl->beacon_int = bss_conf->beacon_int;
 			wl->dtim_period = bss_conf->dtim_period;
 
-			/* FIXME: call join */
-
+			ret = wl1251_acx_wr_tbtt_and_dtim(wl, wl->beacon_int,
+							  wl->dtim_period);
 			wl->aid = bss_conf->aid;
 
 			ret = wl1251_build_ps_poll(wl, wl->aid);
author
#12 lore raw

PATCH 10/16 wl1251: Increase the beacon loss timeout value and handle regain event

In reply to Kalle Valo

From: Vidhya Govindan <[email protected]>

This patch increases the number of beacons to be missed before generating SYNC TIMEOUT event. It increases the beacon timeout period to 500 microseconds, which gives enough time for the firmware to receive probe response or beacon. Also handled the regain event from firmware once it receives a probe response or beacon.

---

 drivers/net/wireless/wl12xx/wl1251_acx.h   |    4 ++--
 drivers/net/wireless/wl12xx/wl1251_event.c |    8 ++++++++
 2 files changed, 10 insertions(+), 2 deletions(-)
drivers/net/wireless/wl12xx/wl1251_acx.h +2 -2
index 44a4b04..6523714 100644
@@ -463,8 +463,8 @@ struct acx_beacon_filter_ie_table {
 	u8 pad[3];
 } __attribute__ ((packed));
 
-#define SYNCH_FAIL_DEFAULT_THRESHOLD    5     /* number of beacons */
-#define NO_BEACON_DEFAULT_TIMEOUT       (100) /* TU */
+#define SYNCH_FAIL_DEFAULT_THRESHOLD    10     /* number of beacons */
+#define NO_BEACON_DEFAULT_TIMEOUT       (500) /* in microseconds */
 
 struct acx_conn_monit_params {
 	struct acx_header header;
drivers/net/wireless/wl12xx/wl1251_event.c +8 -0
index f42121c..9d488c6 100644
@@ -89,6 +89,14 @@ static int wl1251_event_process(struct wl1251 *wl, struct event_mailbox *mbox)
 		mutex_lock(&wl->mutex);
 	}
 
+	if (vector & REGAINED_BSS_EVENT_ID) {
+		if (wl->psm_requested) {
+			ret = wl1251_ps_set_mode(wl, STATION_POWER_SAVE_MODE);
+			if (ret < 0)
+				return ret;
+		}
+	}
+
 	return 0;
 }
 
author
#13 lore raw

PATCH 11/16 wl1251: Add IRQ looping support

In reply to Kalle Valo

From: Janne Ylalehto <[email protected]>

Add support for IRQ looping. Helps in the case that we have e.g. multiple packets coming from the network when we wake up from the ELP.

---

 drivers/net/wireless/wl12xx/wl1251_main.c |  127 +++++++++++++++--------------
 1 files changed, 67 insertions(+), 60 deletions(-)
drivers/net/wireless/wl12xx/wl1251_main.c +67 -60
index cc32ba6..dad010d 100644
@@ -212,9 +212,10 @@ out:
 	return ret;
 }
 
+#define WL1251_IRQ_LOOP_COUNT 10
 static void wl1251_irq_work(struct work_struct *work)
 {
-	u32 intr;
+	u32 intr, ctr = WL1251_IRQ_LOOP_COUNT;
 	struct wl1251 *wl =
 		container_of(work, struct wl1251, irq_work);
 	int ret;
@@ -235,78 +236,84 @@ static void wl1251_irq_work(struct work_struct *work)
 	intr = wl1251_reg_read32(wl, ACX_REG_INTERRUPT_CLEAR);
 	wl1251_debug(DEBUG_IRQ, "intr: 0x%x", intr);
 
-	if (wl->data_path) {
-		wl->rx_counter =
-			wl1251_mem_read32(wl, wl->data_path->rx_control_addr);
-
-		/* We handle a frmware bug here */
-		switch ((wl->rx_counter - wl->rx_handled) & 0xf) {
-		case 0:
-			wl1251_debug(DEBUG_IRQ, "RX: FW and host in sync");
-			intr &= ~WL1251_ACX_INTR_RX0_DATA;
-			intr &= ~WL1251_ACX_INTR_RX1_DATA;
-			break;
-		case 1:
-			wl1251_debug(DEBUG_IRQ, "RX: FW +1");
-			intr |= WL1251_ACX_INTR_RX0_DATA;
-			intr &= ~WL1251_ACX_INTR_RX1_DATA;
-			break;
-		case 2:
-			wl1251_debug(DEBUG_IRQ, "RX: FW +2");
-			intr |= WL1251_ACX_INTR_RX0_DATA;
-			intr |= WL1251_ACX_INTR_RX1_DATA;
-			break;
-		default:
-			wl1251_warning("RX: FW and host out of sync: %d",
-				       wl->rx_counter - wl->rx_handled);
-			break;
-		}
-
-		wl->rx_handled = wl->rx_counter;
+	do {
+		if (wl->data_path) {
+			wl->rx_counter = wl1251_mem_read32(
+				wl, wl->data_path->rx_control_addr);
+
+			/* We handle a frmware bug here */
+			switch ((wl->rx_counter - wl->rx_handled) & 0xf) {
+			case 0:
+				wl1251_debug(DEBUG_IRQ,
+					     "RX: FW and host in sync");
+				intr &= ~WL1251_ACX_INTR_RX0_DATA;
+				intr &= ~WL1251_ACX_INTR_RX1_DATA;
+				break;
+			case 1:
+				wl1251_debug(DEBUG_IRQ, "RX: FW +1");
+				intr |= WL1251_ACX_INTR_RX0_DATA;
+				intr &= ~WL1251_ACX_INTR_RX1_DATA;
+				break;
+			case 2:
+				wl1251_debug(DEBUG_IRQ, "RX: FW +2");
+				intr |= WL1251_ACX_INTR_RX0_DATA;
+				intr |= WL1251_ACX_INTR_RX1_DATA;
+				break;
+			default:
+				wl1251_warning(
+					"RX: FW and host out of sync: %d",
+					wl->rx_counter - wl->rx_handled);
+				break;
+			}
 
+			wl->rx_handled = wl->rx_counter;
 
-		wl1251_debug(DEBUG_IRQ, "RX counter: %d", wl->rx_counter);
-	}
+			wl1251_debug(DEBUG_IRQ, "RX counter: %d",
+				     wl->rx_counter);
+		}
 
-	intr &= wl->intr_mask;
+		intr &= wl->intr_mask;
 
-	if (intr == 0) {
-		wl1251_debug(DEBUG_IRQ, "INTR is 0");
-		wl1251_reg_write32(wl, ACX_REG_INTERRUPT_MASK,
-				   ~(wl->intr_mask));
+		if (intr == 0) {
+			wl1251_debug(DEBUG_IRQ, "INTR is 0");
+			goto out_sleep;
+		}
 
-		goto out_sleep;
-	}
+		if (intr & WL1251_ACX_INTR_RX0_DATA) {
+			wl1251_debug(DEBUG_IRQ, "WL1251_ACX_INTR_RX0_DATA");
+			wl1251_rx(wl);
+		}
 
-	if (intr & WL1251_ACX_INTR_RX0_DATA) {
-		wl1251_debug(DEBUG_IRQ, "WL1251_ACX_INTR_RX0_DATA");
-		wl1251_rx(wl);
-	}
+		if (intr & WL1251_ACX_INTR_RX1_DATA) {
+			wl1251_debug(DEBUG_IRQ, "WL1251_ACX_INTR_RX1_DATA");
+			wl1251_rx(wl);
+		}
 
-	if (intr & WL1251_ACX_INTR_RX1_DATA) {
-		wl1251_debug(DEBUG_IRQ, "WL1251_ACX_INTR_RX1_DATA");
-		wl1251_rx(wl);
-	}
+		if (intr & WL1251_ACX_INTR_TX_RESULT) {
+			wl1251_debug(DEBUG_IRQ, "WL1251_ACX_INTR_TX_RESULT");
+			wl1251_tx_complete(wl);
+		}
 
-	if (intr & WL1251_ACX_INTR_TX_RESULT) {
-		wl1251_debug(DEBUG_IRQ, "WL1251_ACX_INTR_TX_RESULT");
-		wl1251_tx_complete(wl);
-	}
+		if (intr & (WL1251_ACX_INTR_EVENT_A |
+			    WL1251_ACX_INTR_EVENT_B)) {
+			wl1251_debug(DEBUG_IRQ, "WL1251_ACX_INTR_EVENT (0x%x)",
+				     intr);
+			if (intr & WL1251_ACX_INTR_EVENT_A)
+				wl1251_event_handle(wl, 0);
+			else
+				wl1251_event_handle(wl, 1);
+		}
 
-	if (intr & (WL1251_ACX_INTR_EVENT_A | WL1251_ACX_INTR_EVENT_B)) {
-		wl1251_debug(DEBUG_IRQ, "WL1251_ACX_INTR_EVENT (0x%x)", intr);
-		if (intr & WL1251_ACX_INTR_EVENT_A)
-			wl1251_event_handle(wl, 0);
-		else
-			wl1251_event_handle(wl, 1);
-	}
+		if (intr & WL1251_ACX_INTR_INIT_COMPLETE)
+			wl1251_debug(DEBUG_IRQ,
+				     "WL1251_ACX_INTR_INIT_COMPLETE");
 
-	if (intr & WL1251_ACX_INTR_INIT_COMPLETE)
-		wl1251_debug(DEBUG_IRQ, "WL1251_ACX_INTR_INIT_COMPLETE");
+		intr = wl1251_reg_read32(wl, ACX_REG_INTERRUPT_CLEAR);
 
-	wl1251_reg_write32(wl, ACX_REG_INTERRUPT_MASK, ~(wl->intr_mask));
+	} while (intr && --ctr);
 
 out_sleep:
+	wl1251_reg_write32(wl, ACX_REG_INTERRUPT_MASK, ~(wl->intr_mask));
 	wl1251_ps_elp_sleep(wl);
 
 out:
author
#14 lore raw

PATCH 12/16 wl1251: Filter out unwanted events

In reply to Kalle Valo

From: Janne Ylalehto <[email protected]>

Filter out unwanted events to reduce wakeups.

---

 drivers/net/wireless/wl12xx/wl1251_boot.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
drivers/net/wireless/wl12xx/wl1251_boot.c +6 -2
index 8febf27..5094f24 100644
@@ -296,8 +296,12 @@ int wl1251_boot_run_firmware(struct wl1251 *wl)
 		WL1251_ACX_INTR_INIT_COMPLETE;
 	wl1251_boot_target_enable_interrupts(wl);
 
-	/* unmask all mbox events  */
-	wl->event_mask = 0xffffffff;
+	wl->event_mask = SCAN_COMPLETE_EVENT_ID | BSS_LOSE_EVENT_ID |
+		SYNCHRONIZATION_TIMEOUT_EVENT_ID |
+		ROAMING_TRIGGER_LOW_RSSI_EVENT_ID |
+		ROAMING_TRIGGER_REGAINED_RSSI_EVENT_ID |
+		REGAINED_BSS_EVENT_ID | BT_PTA_SENSE_EVENT_ID |
+		BT_PTA_PREDICTION_EVENT_ID;
 
 	ret = wl1251_event_unmask(wl);
 	if (ret < 0) {
author
#15 lore raw

PATCH 13/16 wl1251: Fix regression in IRQ loop handling

In reply to Kalle Valo

From: Juuso Oikarinen <[email protected]>

In some cases, the IRQ loop handler could acknowledge an interrupt to the chipset, but not service it.

---

 drivers/net/wireless/wl12xx/wl1251_main.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
drivers/net/wireless/wl12xx/wl1251_main.c +4 -2
index dad010d..2e1c10f 100644
@@ -308,9 +308,11 @@ static void wl1251_irq_work(struct work_struct *work)
 			wl1251_debug(DEBUG_IRQ,
 				     "WL1251_ACX_INTR_INIT_COMPLETE");
 
-		intr = wl1251_reg_read32(wl, ACX_REG_INTERRUPT_CLEAR);
+		if (--ctr == 0)
+			break;
 
-	} while (intr && --ctr);
+		intr = wl1251_reg_read32(wl, ACX_REG_INTERRUPT_CLEAR);
+	} while (intr);
 
 out_sleep:
 	wl1251_reg_write32(wl, ACX_REG_INTERRUPT_MASK, ~(wl->intr_mask));
author
#16 lore raw

PATCH 14/16 wl1251: Send null data packet with "TODS" bit set

In reply to Kalle Valo

From: Vidhya Govindan <[email protected]>

According to IEEE80211 standard all the data packets have to be sent with TODS bit set. This patch fixes the null data packet format which was sent without TODS bit set. This should fix many problems associated with power save. Janne Ylalehto also found this fix in the same time as mine, for a different bug he was working on.

---

 drivers/net/wireless/wl12xx/wl1251_main.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
drivers/net/wireless/wl12xx/wl1251_main.c +2 -1
index 2e1c10f..ff4be7b 100644
@@ -576,7 +576,8 @@ static int wl1251_build_null_data(struct wl1251 *wl)
 
 	memcpy(template.header.sa, wl->mac_addr, ETH_ALEN);
 	template.header.frame_ctl = cpu_to_le16(IEEE80211_FTYPE_DATA |
-						IEEE80211_STYPE_NULLFUNC);
+						IEEE80211_STYPE_NULLFUNC |
+						IEEE80211_FCTL_TODS);
 
 	return wl1251_cmd_template_set(wl, CMD_NULL_DATA, &template,
 				       sizeof(template));
author
#17 lore raw

PATCH 15/16 wl1251: remove depcreated qual usage

In reply to Kalle Valo

From: Kalle Valo <[email protected]>

Fixes warnings:

drivers/net/wireless/wl12xx/wl1251_rx.c: In function 'wl1251_rx_status':
drivers/net/wireless/wl12xx/wl1251_rx.c:75:
warning: 'qual' is deprecated (declared at include/net/mac80211.h:555)
drivers/net/wireless/wl12xx/wl1251_rx.c:77:
warning: 'qual' is deprecated (declared at include/net/mac80211.h:555)
drivers/net/wireless/wl12xx/wl1251_rx.c:77:
warning: 'qual' is deprecated (declared at include/net/mac80211.h:555)
drivers/net/wireless/wl12xx/wl1251_rx.c:77:
warning: 'qual' is deprecated (declared at include/net/mac80211.h:555)
drivers/net/wireless/wl12xx/wl1251_rx.c:78:
warning: 'qual' is deprecated (declared at include/net/mac80211.h:555)
drivers/net/wireless/wl12xx/wl1251_rx.c:78:
warning: 'qual' is deprecated (declared at include/net/mac80211.h:555)
drivers/net/wireless/wl12xx/wl1251_rx.c:78:
warning: 'qual' is deprecated (declared at include/net/mac80211.h:555)

---

 drivers/net/wireless/wl12xx/wl1251_rx.c |    4 ----
 1 files changed, 0 insertions(+), 4 deletions(-)
drivers/net/wireless/wl12xx/wl1251_rx.c +0 -4
index 601fe0d..f84cc89 100644
@@ -72,10 +72,6 @@ static void wl1251_rx_status(struct wl1251 *wl,
 	}
 
 	status->signal = desc->rssi;
-	status->qual = (desc->rssi - WL1251_RX_MIN_RSSI) * 100 /
-		(WL1251_RX_MAX_RSSI - WL1251_RX_MIN_RSSI);
-	status->qual = min(status->qual, 100);
-	status->qual = max(status->qual, 0);
 
 	/*
 	 * FIXME: guessing that snr needs to be divided by two, otherwise
author
#18 lore raw

PATCH 16/16 wl1251: add NVS in EEPROM support

In reply to Kalle Valo

From: David-John Willis <[email protected]>

wl1251 supports also that NVS is stored in a separate EEPROM, add support for that.

kvalo: use platform data instead Kconfig and use kernel style

---

 drivers/net/wireless/wl12xx/wl1251.h      |    1 +
 drivers/net/wireless/wl12xx/wl1251_boot.c |   20 +++++++++++++-------
 drivers/net/wireless/wl12xx/wl1251_reg.h  |    6 ++++++
 drivers/net/wireless/wl12xx/wl1251_spi.c  |    2 ++
 include/linux/spi/wl12xx.h                |    1 +
 5 files changed, 23 insertions(+), 7 deletions(-)
drivers/net/wireless/wl12xx/wl1251.h +1 -0
index a839466..054533f 100644
@@ -269,6 +269,7 @@ struct wl1251 {
 
 	void (*set_power)(bool enable);
 	int irq;
+	bool use_eeprom;
 
 	enum wl1251_state state;
 	struct mutex mutex;
drivers/net/wireless/wl12xx/wl1251_boot.c +13 -7
index 5094f24..2e733e7 100644
@@ -494,13 +494,19 @@ int wl1251_boot(struct wl1251 *wl)
 		goto out;
 
 	/* 2. start processing NVS file */
-	ret = wl1251_boot_upload_nvs(wl);
-	if (ret < 0)
-		goto out;
-
-	/* write firmware's last address (ie. it's length) to
-	 * ACX_EEPROMLESS_IND_REG */
-	wl1251_reg_write32(wl, ACX_EEPROMLESS_IND_REG, wl->fw_len);
+	if (wl->use_eeprom) {
+		wl1251_reg_write32(wl, ACX_REG_EE_START, START_EEPROM_MGR);
+		msleep(4000);
+		wl1251_reg_write32(wl, ACX_EEPROMLESS_IND_REG, USE_EEPROM);
+	} else {
+		ret = wl1251_boot_upload_nvs(wl);
+		if (ret < 0)
+			goto out;
+
+		/* write firmware's last address (ie. it's length) to
+		 * ACX_EEPROMLESS_IND_REG */
+		wl1251_reg_write32(wl, ACX_EEPROMLESS_IND_REG, wl->fw_len);
+	}
 
 	/* 6. read the EEPROM parameters */
 	tmp = wl1251_reg_read32(wl, SCR_PAD2);
drivers/net/wireless/wl12xx/wl1251_reg.h +6 -0
index 06e1bd9..0ca3b43 100644
@@ -370,6 +370,7 @@ enum wl12xx_acx_int_reg {
  EEPROM location specified in the EE_ADDR register.
  The Wlan hardware hardware clears this bit automatically.
 *===============================================*/
+#define EE_CTL                              (REGISTERS_BASE + 0x2000)
 #define ACX_EE_CTL_REG                      EE_CTL
 #define EE_WRITE                            0x00000001ul
 #define EE_READ                             0x00000002ul
@@ -380,6 +381,7 @@ enum wl12xx_acx_int_reg {
   This register specifies the address
   within the EEPROM from/to which to read/write data.
   ===============================================*/
+#define EE_ADDR                             (REGISTERS_BASE + 0x2008)
 #define ACX_EE_ADDR_REG                     EE_ADDR
 
 /*===============================================
@@ -389,8 +391,12 @@ enum wl12xx_acx_int_reg {
   data from the EEPROM or the write data
   to be written to the EEPROM.
   ===============================================*/
+#define EE_DATA                             (REGISTERS_BASE + 0x2004)
 #define ACX_EE_DATA_REG                     EE_DATA
 
+#define EEPROM_ACCESS_TO                    10000   /* timeout counter */
+#define START_EEPROM_MGR                    0x00000001
+
 /*===============================================
   EEPROM Base Address  - 32bit RW
   ------------------------------------------
drivers/net/wireless/wl12xx/wl1251_spi.c +2 -0
index 2cf8a21..9cc8c32 100644
@@ -270,6 +270,8 @@ static int __devinit wl1251_spi_probe(struct spi_device *spi)
 		return -ENODEV;
 	}
 
+	wl->use_eeprom = pdata->use_eeprom;
+
 	ret = request_irq(wl->irq, wl1251_irq, 0, DRIVER_NAME, wl);
 	if (ret < 0) {
 		wl1251_error("request_irq() failed: %d", ret);
include/linux/spi/wl12xx.h +1 -0
index 11430ca..aed64ed 100644
@@ -26,6 +26,7 @@
 
 struct wl12xx_platform_data {
 	void (*set_power)(bool enable);
+	bool use_eeprom;
 };
 
 #endif