Re: [PATCH v3.5 2/2] iwlwifi: fix flow handler debug code

2012-09-26 Thread Greg KH
On Tue, Sep 11, 2012 at 08:11:12PM +0200, Johannes Berg wrote:
 From: Johannes Berg johannes.b...@intel.com
 
 Upstream commit 94543a8d4fb302817014981489f15cb3b92ec3c2.
 
 iwl_dbgfs_fh_reg_read() can cause crashes and/or
 BUG_ON in slub because the ifdefs are wrong, the
 code in iwl_dump_fh() should use DEBUGFS, not
 DEBUG to protect the buffer writing code.
 
 Also, while at it, clean up the arguments to the
 function, some code and make it generally safer.
 
 Cc: stable@vger.kernel.org
 Reported-by: Benjamin Herrenschmidt b...@kernel.crashing.org
 Signed-off-by: Johannes Berg johannes.b...@intel.com
 Signed-off-by: John W. Linville linvi...@tuxdriver.com
 ---
  drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h |2 +-
  drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c  |2 +-
  drivers/net/wireless/iwlwifi/iwl-trans-pcie.c |   30 
 +++--
  3 files changed, 18 insertions(+), 16 deletions(-)

Applied, thanks,

greg k-h
--
To unsubscribe from this list: send the line unsubscribe stable in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3.5 2/2] iwlwifi: fix flow handler debug code

2012-09-11 Thread Johannes Berg
From: Johannes Berg johannes.b...@intel.com

Upstream commit 94543a8d4fb302817014981489f15cb3b92ec3c2.

iwl_dbgfs_fh_reg_read() can cause crashes and/or
BUG_ON in slub because the ifdefs are wrong, the
code in iwl_dump_fh() should use DEBUGFS, not
DEBUG to protect the buffer writing code.

Also, while at it, clean up the arguments to the
function, some code and make it generally safer.

Cc: stable@vger.kernel.org
Reported-by: Benjamin Herrenschmidt b...@kernel.crashing.org
Signed-off-by: Johannes Berg johannes.b...@intel.com
Signed-off-by: John W. Linville linvi...@tuxdriver.com
---
 drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h |2 +-
 drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c  |2 +-
 drivers/net/wireless/iwlwifi/iwl-trans-pcie.c |   30 +++--
 3 files changed, 18 insertions(+), 16 deletions(-)

diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h 
b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h
index e959207..8215fad 100644
--- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h
+++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h
@@ -355,7 +355,7 @@ int iwl_queue_space(const struct iwl_queue *q);
 /*
 * Error handling
 **/
-int iwl_dump_fh(struct iwl_trans *trans, char **buf, bool display);
+int iwl_dump_fh(struct iwl_trans *trans, char **buf);
 void iwl_dump_csr(struct iwl_trans *trans);
 
 /*
diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c 
b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c
index 08517d3..5e18ff9 100644
--- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c
+++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c
@@ -559,7 +559,7 @@ static void iwl_irq_handle_error(struct iwl_trans *trans)
}
 
iwl_dump_csr(trans);
-   iwl_dump_fh(trans, NULL, false);
+   iwl_dump_fh(trans, NULL);
 
iwl_op_mode_nic_error(trans-op_mode);
 }
diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c 
b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c
index 79c6b91..0a68170 100644
--- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c
+++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c
@@ -1654,13 +1654,9 @@ static const char *get_fh_string(int cmd)
 #undef IWL_CMD
 }
 
-int iwl_dump_fh(struct iwl_trans *trans, char **buf, bool display)
+int iwl_dump_fh(struct iwl_trans *trans, char **buf)
 {
int i;
-#ifdef CONFIG_IWLWIFI_DEBUG
-   int pos = 0;
-   size_t bufsz = 0;
-#endif
static const u32 fh_tbl[] = {
FH_RSCSR_CHNL0_STTS_WPTR_REG,
FH_RSCSR_CHNL0_RBDCB_BASE_REG,
@@ -1672,29 +1668,35 @@ int iwl_dump_fh(struct iwl_trans *trans, char **buf, 
bool display)
FH_TSSR_TX_STATUS_REG,
FH_TSSR_TX_ERROR_REG
};
-#ifdef CONFIG_IWLWIFI_DEBUG
-   if (display) {
-   bufsz = ARRAY_SIZE(fh_tbl) * 48 + 40;
+
+#ifdef CONFIG_IWLWIFI_DEBUGFS
+   if (buf) {
+   int pos = 0;
+   size_t bufsz = ARRAY_SIZE(fh_tbl) * 48 + 40;
+
*buf = kmalloc(bufsz, GFP_KERNEL);
if (!*buf)
return -ENOMEM;
+
pos += scnprintf(*buf + pos, bufsz - pos,
FH register values:\n);
-   for (i = 0; i  ARRAY_SIZE(fh_tbl); i++) {
+
+   for (i = 0; i  ARRAY_SIZE(fh_tbl); i++)
pos += scnprintf(*buf + pos, bufsz - pos,
  %34s: 0X%08x\n,
get_fh_string(fh_tbl[i]),
iwl_read_direct32(trans, fh_tbl[i]));
-   }
+
return pos;
}
 #endif
+
IWL_ERR(trans, FH register values:\n);
-   for (i = 0; i   ARRAY_SIZE(fh_tbl); i++) {
+   for (i = 0; i   ARRAY_SIZE(fh_tbl); i++)
IWL_ERR(trans,   %34s: 0X%08x\n,
get_fh_string(fh_tbl[i]),
iwl_read_direct32(trans, fh_tbl[i]));
-   }
+
return 0;
 }
 
@@ -1989,11 +1991,11 @@ static ssize_t iwl_dbgfs_fh_reg_read(struct file *file,
 size_t count, loff_t *ppos)
 {
struct iwl_trans *trans = file-private_data;
-   char *buf;
+   char *buf = NULL;
int pos = 0;
ssize_t ret = -EFAULT;
 
-   ret = pos = iwl_dump_fh(trans, buf, true);
+   ret = pos = iwl_dump_fh(trans, buf);
if (buf) {
ret = simple_read_from_buffer(user_buf,
  count, ppos, buf, pos);
-- 
1.7.10.4

--
To unsubscribe from this list: send the line unsubscribe stable in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html