Skip to contentSkip to conversation

wlcore/wl18xx: fixes and HW deprecation

PATCH In review Luciano Coelho 1 participant 7 messages Jun 26, 2012 – Jun 27, 2012 TI wilink wireless drivers

lore
Share & tools
lore
#1 lore raw

PATCH 1/5 wl18xx: deprecate PG1 support

In reply to Luciano Coelho

The new PG2 version of the chip has a few differences in terms of FW API if compared to PG1. PG1 is just a sample that shouldn't be used in real life, so to avoid having to handle both separately, mark the PG1 version as deprecated and bail out during probe.

---
 drivers/net/wireless/ti/wl18xx/acx.h  |   34 +++++++++++--------------
 drivers/net/wireless/ti/wl18xx/main.c |   45 +++++----------------------------
 2 files changed, 22 insertions(+), 57 deletions(-)
drivers/net/wireless/ti/wl18xx/acx.h +15 -19
index ebbaf61..e2609a6 100644
@@ -32,25 +32,21 @@ enum {
 /* numbers of bits the length field takes (add 1 for the actual number) */
 #define WL18XX_HOST_IF_LEN_SIZE_FIELD 15
 
-#define WL18XX_ACX_EVENTS_VECTOR_PG1	(WL1271_ACX_INTR_WATCHDOG      | \
-					WL1271_ACX_INTR_INIT_COMPLETE | \
-					WL1271_ACX_INTR_EVENT_A       | \
-					WL1271_ACX_INTR_EVENT_B       | \
-					WL1271_ACX_INTR_CMD_COMPLETE  | \
-					WL1271_ACX_INTR_HW_AVAILABLE  | \
-					WL1271_ACX_INTR_DATA)
-
-#define WL18XX_ACX_EVENTS_VECTOR_PG2	(WL18XX_ACX_EVENTS_VECTOR_PG1 | \
-					WL1271_ACX_SW_INTR_WATCHDOG)
-
-#define WL18XX_INTR_MASK_PG1		(WL1271_ACX_INTR_WATCHDOG      | \
-					WL1271_ACX_INTR_EVENT_A       | \
-					WL1271_ACX_INTR_EVENT_B       | \
-					WL1271_ACX_INTR_HW_AVAILABLE  | \
-					WL1271_ACX_INTR_DATA)
-
-#define WL18XX_INTR_MASK_PG2		(WL18XX_INTR_MASK_PG1         | \
-					WL1271_ACX_SW_INTR_WATCHDOG)
+#define WL18XX_ACX_EVENTS_VECTOR	(WL1271_ACX_INTR_WATCHDOG	| \
+					 WL1271_ACX_INTR_INIT_COMPLETE	| \
+					 WL1271_ACX_INTR_EVENT_A	| \
+					 WL1271_ACX_INTR_EVENT_B	| \
+					 WL1271_ACX_INTR_CMD_COMPLETE	| \
+					 WL1271_ACX_INTR_HW_AVAILABLE	| \
+					 WL1271_ACX_INTR_DATA		| \
+					 WL1271_ACX_SW_INTR_WATCHDOG)
+
+#define WL18XX_INTR_MASK		(WL1271_ACX_INTR_WATCHDOG	| \
+					 WL1271_ACX_INTR_EVENT_A	| \
+					 WL1271_ACX_INTR_EVENT_B	| \
+					 WL1271_ACX_INTR_HW_AVAILABLE	| \
+					 WL1271_ACX_INTR_DATA		| \
+					 WL1271_ACX_SW_INTR_WATCHDOG)
 
 struct wl18xx_acx_host_config_bitmap {
 	struct acx_header header;
drivers/net/wireless/ti/wl18xx/main.c +7 -38

77 lines not on this page · raw message

Signature · 1 line
1.7.10
#2 lore raw

PATCH 2/5 wlcore: fix some failure cases in wlcore_probe()

In reply to Luciano Coelho

We need to release the IRQ if hw_info() or identify_chip() fails. And we need unregister the HW with mac80211 if there are any failures after it's registered.

---
 drivers/net/wireless/ti/wlcore/main.c |    9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/net/wireless/ti/wlcore/main.c +6 -3
index 372ccf2..c5a9ffe 100644
@@ -5520,12 +5520,12 @@ int __devinit wlcore_probe(struct wl1271 *wl, struct platform_device *pdev)
 	ret = wl12xx_get_hw_info(wl);
 	if (ret < 0) {
 		wl1271_error("couldn't get hw info");
-		goto out;
+		goto out_irq;
 	}
 
 	ret = wl->ops->identify_chip(wl);
 	if (ret < 0)
-		goto out;
+		goto out_irq;
 
 	ret = wl1271_init_ieee80211(wl);
 	if (ret)
@@ -5539,7 +5539,7 @@ int __devinit wlcore_probe(struct wl1271 *wl, struct platform_device *pdev)
 	ret = device_create_file(wl->dev, &dev_attr_bt_coex_state);
 	if (ret < 0) {
 		wl1271_error("failed to create sysfs file bt_coex_state");
-		goto out_irq;
+		goto out_unreg;
 	}
 
 	/* Create sysfs file to get HW PG version */
@@ -5564,6 +5564,9 @@ out_hw_pg_ver:
 out_bt_coex_state:
 	device_remove_file(wl->dev, &dev_attr_bt_coex_state);
 
+out_unreg:
+	wl1271_unregister_hw(wl);
+
 out_irq:
 	free_irq(wl->irq, wl);
 
Signature · 1 line
1.7.10
#0 lore raw

cover wlcore/wl18xx: fixes and HW deprecation

Hi,

Here are a few more patches for wlcore and wl18xx. Three patches by Eyal to fix a couple of bugs we found in the IO changes patchset and improve the recovery traces.

Also two patches of my own that deprecate an old HW version of the wl18xx chips (a sample PG1). The reason to deprecate this is that these chips will never be used outside TI and removing support for it avoids some blunt caused by workarounds and other things that were fixed in the hardware (PG2).

Please review.

Luca.

Eyal Shapira (3):
wlcore: fix broken TX due to wrong queuing of recovery
wlcore: queue recovery in case of bus errors during cmd_remove_peer
wlcore: print stack trace in every recovery

Luciano Coelho (2):
wl18xx: deprecate PG1 support
wlcore: fix some failure cases in wlcore_probe()

 drivers/net/wireless/ti/wl18xx/acx.h  |   34 +++++++++++--------------
 drivers/net/wireless/ti/wl18xx/main.c |   45 +++++----------------------------
 drivers/net/wireless/ti/wlcore/cmd.c  |   30 ++++++++++++++--------
 drivers/net/wireless/ti/wlcore/main.c |   11 +++++---
 drivers/net/wireless/ti/wlcore/tx.c   |   35 +++++++++++++++++--------
 5 files changed, 73 insertions(+), 82 deletions(-)
Signature · 1 line
1.7.10
#4 lore raw

PATCH 4/5 wlcore: queue recovery in case of bus errors during cmd_remove_peer

From: Eyal Shapira <[email protected]>

Following the addition of propagating errors from the bus ops there's a need to distinguish between bus errors (including timeout) and a legitimate timeout occuring in cmd_wait_for_event_or_timeout. In case of real bus errors we need to queue recovery even in cases where a timeout on a response from the FW to a command is acceptable.

---
 drivers/net/wireless/ti/wlcore/cmd.c |   29 +++++++++++++++++++----------
 1 file changed, 19 insertions(+), 10 deletions(-)
drivers/net/wireless/ti/wlcore/cmd.c +19 -10
index 84dd808..ef13938 100644
@@ -133,24 +133,27 @@ fail:
  * Poll the mailbox event field until any of the bits in the mask is set or a
  * timeout occurs (WL1271_EVENT_TIMEOUT in msecs)
  */
-static int wl1271_cmd_wait_for_event_or_timeout(struct wl1271 *wl, u32 mask)
+static int wl1271_cmd_wait_for_event_or_timeout(struct wl1271 *wl,
+						u32 mask, bool *timeout)
 {
 	u32 *events_vector;
 	u32 event;
-	unsigned long timeout;
+	unsigned long timeout_time;
 	int ret = 0;
 
+	*timeout = false;
+
 	events_vector = kmalloc(sizeof(*events_vector), GFP_KERNEL | GFP_DMA);
 	if (!events_vector)
 		return -ENOMEM;
 
-	timeout = jiffies + msecs_to_jiffies(WL1271_EVENT_TIMEOUT);
+	timeout_time = jiffies + msecs_to_jiffies(WL1271_EVENT_TIMEOUT);
 
 	do {
-		if (time_after(jiffies, timeout)) {
+		if (time_after(jiffies, timeout_time)) {
 			wl1271_debug(DEBUG_CMD, "timeout waiting for event %d",
 				     (int)mask);
-			ret = -ETIMEDOUT;
+			*timeout = true;
 			goto out;
 		}
 
@@ -180,9 +183,10 @@ out:
 static int wl1271_cmd_wait_for_event(struct wl1271 *wl, u32 mask)
 {
 	int ret;
+	bool timeout = false;
 
-	ret = wl1271_cmd_wait_for_event_or_timeout(wl, mask);
-	if (ret != 0) {
+	ret = wl1271_cmd_wait_for_event_or_timeout(wl, mask, &timeout);
+	if (ret != 0 || timeout) {
 		wl12xx_queue_recovery_work(wl);
 		return ret;
 	}
@@ -1435,6 +1439,7 @@ int wl12xx_cmd_remove_peer(struct wl1271 *wl, u8 hlid)
 {
 	struct wl12xx_cmd_remove_peer *cmd;
 	int ret;
+	bool timeout = false;
 
 	wl1271_debug(DEBUG_CMD, "cmd remove peer %d", (int)hlid);
 
@@ -1455,12 +1460,16 @@ int wl12xx_cmd_remove_peer(struct wl1271 *wl, u8 hlid)
 		goto out_free;
 	}
 
+	ret = wl1271_cmd_wait_for_event_or_timeout(wl,
+					   PEER_REMOVE_COMPLETE_EVENT_ID,
+					   &timeout);
 	/*
 	 * We are ok with a timeout here. The event is sometimes not sent
-	 * due to a firmware bug.
+	 * due to a firmware bug. In case of another error (like SDIO timeout)
+	 * queue a recovery.
 	 */
-	wl1271_cmd_wait_for_event_or_timeout(wl,
-					     PEER_REMOVE_COMPLETE_EVENT_ID);
+	if (ret)
+		wl12xx_queue_recovery_work(wl);
 
 out_free:
 	kfree(cmd);
Signature · 1 line
1.7.10
#5 lore raw

PATCH 5/5 wlcore: print stack trace in every recovery

In reply to Luciano Coelho

From: Eyal Shapira <[email protected]>

As recovery queuing can now occur from multiple code paths it's convenient to know what triggered it in all cases other than an intended recovery which is part of the switch between single role to multi role.

---
 drivers/net/wireless/ti/wlcore/cmd.c  |    1 -
 drivers/net/wireless/ti/wlcore/main.c |    2 ++
 2 files changed, 2 insertions(+), 1 deletion(-)
drivers/net/wireless/ti/wlcore/cmd.c +0 -1
index ef13938..56c7a23 100644
@@ -124,7 +124,6 @@ int wl1271_cmd_send(struct wl1271 *wl, u16 id, void *buf, size_t len,
 	return 0;
 
 fail:
-	WARN_ON(1);
 	wl12xx_queue_recovery_work(wl);
 	return ret;
 }
drivers/net/wireless/ti/wlcore/main.c +2 -0
index c5a9ffe..2240cca 100644
@@ -772,6 +772,8 @@ out:
 
 void wl12xx_queue_recovery_work(struct wl1271 *wl)
 {
+	WARN_ON(!test_bit(WL1271_FLAG_INTENDED_FW_RECOVERY, &wl->flags));
+
 	/* Avoid a recursive recovery */
 	if (!test_and_set_bit(WL1271_FLAG_RECOVERY_IN_PROGRESS, &wl->flags)) {
 		wlcore_disable_interrupts_nosync(wl);
Signature · 1 line
1.7.10
#3 lore raw

PATCH 3/5 wlcore: fix broken TX due to wrong queuing of recovery

In reply to Luciano Coelho

From: Eyal Shapira <[email protected]>

commit 14bba17b "wl12xx: Propagate errors from wl1271_raw_write32" breaks down TX in certain scenarios. wl1271_irq_locked() propagates errors from wl1271_tx_work_locked however it may return -EBUSY when the FW queues are full which is a legitimate case and not a a real error. In this case a recovery is triggered by wl1271_irq and this keeps repeating itself so TX is completely broken. Fix it by avoiding propagating return values as errors even if they aren't. Only bus (SDIO or SPI) ops failures would be progagated as only these should trigger recovery.

---
 drivers/net/wireless/ti/wlcore/tx.c |   35 ++++++++++++++++++++++++-----------
 1 file changed, 24 insertions(+), 11 deletions(-)
drivers/net/wireless/ti/wlcore/tx.c +24 -11
index b5211be..6a28aee 100644
@@ -352,8 +352,10 @@ static int wl1271_prepare_tx_frame(struct wl1271 *wl, struct wl12xx_vif *wlvif,
 	bool is_dummy;
 	bool is_gem = false;
 
-	if (!skb)
+	if (!skb) {
+		wl1271_error("discarding null skb");
 		return -EINVAL;
+	}
 
 	info = IEEE80211_SKB_CB(skb);
 
@@ -662,6 +664,16 @@ void wl12xx_rearm_rx_streaming(struct wl1271 *wl, unsigned long *active_hlids)
 	}
 }
 
+/*
+ * Returns failure values only in case of failed bus ops within this function.
+ * wl1271_prepare_tx_frame retvals won't be returned in order to avoid
+ * triggering recovery by higher layers when not necessary.
+ * In case a FW command fails within wl1271_prepare_tx_frame fails a recovery
+ * will be queued in wl1271_cmd_send. -EAGAIN/-EBUSY from prepare_tx_frame
+ * can occur and are legitimate so don't propagate. -EINVAL will emit a WARNING
+ * within prepare_tx_frame code but there's nothing we should do about those
+ * as well.
+ */
 int wlcore_tx_work_locked(struct wl1271 *wl)
 {
 	struct wl12xx_vif *wlvif;
@@ -671,9 +683,10 @@ int wlcore_tx_work_locked(struct wl1271 *wl)
 	bool sent_packets = false;
 	unsigned long active_hlids[BITS_TO_LONGS(WL12XX_MAX_LINKS)] = {0};
 	int ret = 0;
+	int bus_ret = 0;
 
 	if (unlikely(wl->state == WL1271_STATE_OFF))
-		return -EIO;
+		return 0;
 
 	while ((skb = wl1271_skb_dequeue(wl))) {
 		struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
@@ -694,9 +707,9 @@ int wlcore_tx_work_locked(struct wl1271 *wl)
 
 			buf_offset = wlcore_hw_pre_pkt_send(wl, buf_offset,
 							    last_len);
-			ret = wlcore_write_data(wl, REG_SLV_MEM_DATA,
-						wl->aggr_buf, buf_offset, true);
-			if (ret < 0)
+			bus_ret = wlcore_write_data(wl, REG_SLV_MEM_DATA,
+					     wl->aggr_buf, buf_offset, true);
+			if (bus_ret < 0)
 				goto out;
 
 			sent_packets = true;
@@ -734,9 +747,9 @@ int wlcore_tx_work_locked(struct wl1271 *wl)
 out_ack:
 	if (buf_offset) {
 		buf_offset = wlcore_hw_pre_pkt_send(wl, buf_offset, last_len);
-		ret = wlcore_write_data(wl, REG_SLV_MEM_DATA, wl->aggr_buf,
-					buf_offset, true);
-		if (ret < 0)
+		bus_ret = wlcore_write_data(wl, REG_SLV_MEM_DATA, wl->aggr_buf,
+					     buf_offset, true);
+		if (bus_ret < 0)
 			goto out;
 
 		sent_packets = true;
@@ -747,9 +760,9 @@ out_ack:
 		 * required for older hardware revisions
 		 */
 		if (wl->quirks & WLCORE_QUIRK_END_OF_TRANSACTION) {
-			ret = wlcore_write32(wl, WL12XX_HOST_WR_ACCESS,
+			bus_ret = wlcore_write32(wl, WL12XX_HOST_WR_ACCESS,
 					     wl->tx_packets_count);
-			if (ret < 0)
+			if (bus_ret < 0)
 				goto out;
 		}
 
@@ -758,7 +771,7 @@ out_ack:
 	wl12xx_rearm_rx_streaming(wl, active_hlids);
 
 out:
-	return ret;
+	return bus_ret;
 }
 
 void wl1271_tx_work(struct work_struct *work)
Signature · 1 line
1.7.10
#6 lore raw
In reply to Luciano Coelho
Quoted 6 lines · Luciano Coelho

Hi,

Here are a few more patches for wlcore and wl18xx. Three patches by Eyal to fix a couple of bugs we found in the IO changes patchset and improve the recovery traces.

Quoted 7 lines

Also two patches of my own that deprecate an old HW version of the wl18xx chips (a sample PG1). The reason to deprecate this is that these chips will never be used outside TI and removing support for it avoids some blunt caused by workarounds and other things that were fixed in the hardware (PG2).

Please review.

Applied and pushed the series.

--
Luca.