[OpenWrt-Devel] [PATCH] mwlwifi - dont break fw upload timing with log prints

Ian Kent raven at themaw.net
Thu Jan 15 23:27:03 EST 2015


The patch included here is needed if debug logging in mwlwifi
is enabled to a high enough level that the log prints are done
during time critical parts of firmware loading.

Enabling debug logging is, unfortuneatly, not as simple as defining
MWLDBG on the module make command line.

Something like this is also needed:

diff --git a/mwl_debug.c b/mwl_debug.c
index 821b0c0..f8644a8 100644
--- a/mwl_debug.c
+++ b/mwl_debug.c
@@ -41,7 +41,7 @@
 /* PRIVATE VARIABLES
 */

-static u32 dbg_levels = 0;
+static u32 dbg_levels = 0xffff;

 /* PUBLIC FUNCTION DEFINITION
 */

or dbg_levels set to some suitable integer that enables the logging
required. But that's another story.

This change is meant to avoid the firmware loading problem if anyone
does use the logging, and that's all.

Signed-off-by: Ian Kent <raven at themaw.net>
---
 ...nt-break-fw-upload-timing-with-log-prints.patch |   82 ++++++++++++++++++++
 1 file changed, 82 insertions(+)
 create mode 100644 package/kernel/mwlwifi/patches/002-dont-break-fw-upload-timing-with-log-prints.patch

diff --git a/package/kernel/mwlwifi/patches/002-dont-break-fw-upload-timing-with-log-prints.patch b/package/kernel/mwlwifi/patches/002-dont-break-fw-upload-timing-with-log-prints.patch
new file mode 100644
index 0000000..e112606
--- /dev/null
+++ b/package/kernel/mwlwifi/patches/002-dont-break-fw-upload-timing-with-log-prints.patch
@@ -0,0 +1,82 @@
+mwlwifi - dont break fw upload timing with log prints
+
+From: Ian Kent <raven at themaw.net>
+
+In the function mwl_fwdl_download_firmware() there's a comment that it
+takes ~1300 nSec for the register change that acknowledges each chunk
+of the firmware uploaded. But if you take too long to get to the check
+you can miss the event altogether.
+
+The Function mwl_fwdl_trig_pcicmd_bootcode() contains log prints that
+can take several miliseconds to complete and it is called from the above
+function to transfer a chunk of the firmware at a time. When logging is
+enabled it breaks the firware upload.
+
+So remove the function call that uploads the chunk (and contains log prints)
+and add its code in-line to avoid inadvertantly breaking the firmware upload
+by enabling logging.
+
+Signed-off-by: Ian Kent <raven at themaw.net>
+---
+ mwl_fwdl.c |   29 ++++++++++-------------------
+ 1 file changed, 10 insertions(+), 19 deletions(-)
+
+diff --git a/mwl_fwdl.c b/mwl_fwdl.c
+index 5f9ef91..46b61ed 100644
+--- a/mwl_fwdl.c
++++ b/mwl_fwdl.c
+@@ -40,7 +40,6 @@
+ */
+ 
+ static void mwl_fwdl_trig_pcicmd(struct mwl_priv *priv);
+-static void mwl_fwdl_trig_pcicmd_bootcode(struct mwl_priv *priv);
+ 
+ /* PUBLIC FUNCTION DEFINITION
+ */
+@@ -99,9 +98,12 @@ int mwl_fwdl_download_firmware(struct ieee80211_hw *hw)
+ 		*/
+ 		memcpy((char *)&priv->pcmd_buf[0], (fw->data + size_fw_downloaded), len);
+ 
+-		/* this function writes pdata to c10, then write 2 to c18
++		/* write pdata to c10, then write 2 to c18
+ 		*/
+-		mwl_fwdl_trig_pcicmd_bootcode(priv);
++		writel(priv->pphys_cmd_buf, priv->iobase1 + MACREG_REG_GEN_PTR);
++		writel(0x00, priv->iobase1 + MACREG_REG_INT_CODE);
++		writel(MACREG_H2ARIC_BIT_DOOR_BELL,
++		       priv->iobase1 + MACREG_REG_H2A_INTERRUPT_EVENTS);
+ 
+ 		curr_iteration = FW_MAX_NUM_CHECKS; /* this is arbitrary per your platform; we use 0xffff */
+ 
+@@ -110,6 +112,11 @@ int mwl_fwdl_download_firmware(struct ieee80211_hw *hw)
+ 		 * the write of event 2 to C1C == 2 is ~1300 nSec. Hence the checkings on host
+ 		 * has to consider how efficient your code can be to meet this timing, or you
+ 		 * can alternatively tweak this routines to fit your platform
++		 *
++		 * NOTE: not only does the register change take ~1300 nSec
++		 * but if you take too long to get to the check below, such
++		 * as issuing a printk() for logging, you can miss the event
++		 * altogether.
+ 		 */
+ 		do {
+ 
+@@ -201,19 +208,3 @@ static void mwl_fwdl_trig_pcicmd(struct mwl_priv *priv)
+ 
+ 	WLDBG_EXIT(DBG_LEVEL_1);
+ }
+-
+-static void mwl_fwdl_trig_pcicmd_bootcode(struct mwl_priv *priv)
+-{
+-	WLDBG_ENTER(DBG_LEVEL_1);
+-
+-	BUG_ON(!priv);
+-
+-	writel(priv->pphys_cmd_buf, priv->iobase1 + MACREG_REG_GEN_PTR);
+-
+-	writel(0x00, priv->iobase1 + MACREG_REG_INT_CODE);
+-
+-	writel(MACREG_H2ARIC_BIT_DOOR_BELL,
+-	       priv->iobase1 + MACREG_REG_H2A_INTERRUPT_EVENTS);
+-
+-	WLDBG_EXIT(DBG_LEVEL_1);
+-}
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list