Subject: Re: BCM4313 & brcmsmac & 3.12: only semi-working?

From: Arend van Spriel <[email-masked]>
Date: Wed, 19 Nov 2014 18:54:21 +0100

On 11/19/14 10:04, Michael Tokarev wrote:
> 18.11.2014 01:36, Maximilian Engelhardt wrote:
> []
>> I just wanted to ask if there is any progress on this issue since I haven't
>> heard anything for a month. Please let me know if you need any additional
>> information.
>
> I've no idea if there's any progress.  Meanwhile I've an easy way of
> testing of my brcm4313 card in a mini-itx board with mini-PCIe slot.
> It works rather nicely and the stalls are easy to trigger.
> Running 3.16 kernel right now, tried to d/load a file from the
> AP, -- boom, it stalled after 77Kb.
>
> Since the previous discussion apparently ended prematurely and no patches
> to try emerged, I don't have anything to try on it...

In our last email exchange I got the impression you switch to Intel 
board and did not want to keep replacing cards for testing. Nice to hear 
you have an alternative setup for this and I assume are willing to do 
some testing.

I submitted two patches upstream and additionally I have attached two 
other that are still under review. Could you try these patches and sent 
me the content of the two debugfs files 'macstat' and 'hardware' after a 
stall has occurred.

Regards,
Arend
From dbc69f9769b92f3ce115fabf880f767d6bd4c436 Mon Sep 17 00:00:00 2001
From: Arend van Spriel <[email-masked]>
Date: Thu, 13 Nov 2014 14:16:34 +0100
Subject: [PATCH 1/2] brcmutil: add helper function to format board revision

The board revision that is available in hardware can be translated
so it matches the labelling on the board. This is accomplished by
this helper function.

Reviewed-by: Hante Meuleman <[email-masked]>
Reviewed-by: Pieter-Paul Giesberts <[email-masked]>
Signed-off-by: Arend van Spriel <[email-masked]>
---
 drivers/net/wireless/brcm80211/brcmutil/utils.c      | 16 ++++++++++++++++
 drivers/net/wireless/brcm80211/include/brcmu_utils.h |  2 ++
 2 files changed, 18 insertions(+)

diff --git a/drivers/net/wireless/brcm80211/brcmutil/utils.c b/drivers/net/wireless/brcm80211/brcmutil/utils.c
index 0f7e1c7..1575a1d 100644
--- a/drivers/net/wireless/brcm80211/brcmutil/utils.c
+++ b/drivers/net/wireless/brcm80211/brcmutil/utils.c
@@ -292,4 +292,20 @@ void brcmu_dbg_hex_dump(const void *data, size_t size, const char *fmt, ...)
 	print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, data, size);
 }
 EXPORT_SYMBOL(brcmu_dbg_hex_dump);
+
+/* Produce a human-readable string for boardrev */
+char *brcmu_boardrev_str(u32 brev, char *buf)
+{
+	char c;
+
+	if (brev < 0x100) {
+		snprintf(buf, 8, "%d.%d", (brev & 0xf0) >> 4, brev & 0xf);
+	} else {
+		c = (brev & 0xf000) == 0x1000 ? 'P' : 'A';
+		snprintf(buf, 8, "%c%03x", c, brev & 0xfff);
+	}
+	return (buf);
+}
+EXPORT_SYMBOL(brcmu_boardrev_str);
+
 #endif				/* defined(DEBUG) */
diff --git a/drivers/net/wireless/brcm80211/include/brcmu_utils.h b/drivers/net/wireless/brcm80211/include/brcmu_utils.h
index 8ba445b..a043e29 100644
--- a/drivers/net/wireless/brcm80211/include/brcmu_utils.h
+++ b/drivers/net/wireless/brcm80211/include/brcmu_utils.h
@@ -218,4 +218,6 @@ void brcmu_dbg_hex_dump(const void *data, size_t size, const char *fmt, ...)
 }
 #endif
 
+char *brcmu_boardrev_str(u32 brev, char *buf);
+
 #endif				/* _BRCMU_UTILS_H_ */
-- 
1.9.1

From a197cf44ef058942928b48223fce9d3f112be9d0 Mon Sep 17 00:00:00 2001
From: Arend van Spriel <[email-masked]>
Date: Thu, 13 Nov 2014 14:19:49 +0100
Subject: [PATCH 2/2] brcmsmac: extend hardware info shown in debugfs

The hardware info now also include radio and phy information, which
can be helpful in debugging issues.

Reviewed-by: Hante Meuleman <[email-masked]>
Reviewed-by: Pieter-Paul Giesberts <[email-masked]>
Signed-off-by: Arend van Spriel <[email-masked]>
---
 drivers/net/wireless/brcm80211/brcmsmac/debug.c | 40 +++++++++++++++++--------
 1 file changed, 27 insertions(+), 13 deletions(-)

diff --git a/drivers/net/wireless/brcm80211/brcmsmac/debug.c b/drivers/net/wireless/brcm80211/brcmsmac/debug.c
index 19740c1..c9a8b93 100644
--- a/drivers/net/wireless/brcm80211/brcmsmac/debug.c
+++ b/drivers/net/wireless/brcm80211/brcmsmac/debug.c
@@ -30,6 +30,7 @@
 #include "main.h"
 #include "debug.h"
 #include "brcms_trace_events.h"
+#include "phy/phy_int.h"
 
 static struct dentry *root_folder;
 
@@ -74,20 +75,33 @@ static
 int brcms_debugfs_hardware_read(struct seq_file *s, void *data)
 {
 	struct brcms_pub *drvr = s->private;
+	struct brcms_hardware *hw = drvr->wlc->hw;
+	struct bcma_device *core = hw->d11core;
+	struct bcma_bus *bus = core->bus;
+	char boardrev[10];
 
-	seq_printf(s, "board vendor: %x\n"
-		   "board type: %x\n"
-		   "board revision: %x\n"
-		   "board flags: %x\n"
-		   "board flags2: %x\n"
-		   "firmware revision: %x\n",
-		   drvr->wlc->hw->d11core->bus->boardinfo.vendor,
-		   drvr->wlc->hw->d11core->bus->boardinfo.type,
-		   drvr->wlc->hw->boardrev,
-		   drvr->wlc->hw->boardflags,
-		   drvr->wlc->hw->boardflags2,
-		   drvr->wlc->ucode_rev);
-
+	seq_printf(s, "chipnum 0x%x\n"
+		   "chiprev 0x%x\n"
+		   "chippackage 0x%x\n"
+		   "corerev 0x%x\n"
+		   "boardid 0x%x\n"
+		   "boardvendor 0x%x\n"
+		   "boardrev %s\n"
+		   "boardflags 0x%x\n"
+		   "boardflags2 0x%x\n"
+		   "ucoderev 0x%x\n"
+		   "radiorev 0x%x\n"
+		   "phytype 0x%x\n"
+		   "phyrev 0x%x\n"
+		   "anarev 0x%x\n"
+		   "nvramrev %d\n",
+		   bus->chipinfo.id, bus->chipinfo.rev, bus->chipinfo.pkg,
+		   core->id.rev, bus->boardinfo.type, bus->boardinfo.vendor,
+		   brcmu_boardrev_str(hw->boardrev, boardrev),
+		   drvr->wlc->hw->boardflags, drvr->wlc->hw->boardflags2,
+		   drvr->wlc->ucode_rev, hw->band->radiorev,
+		   hw->band->phytype, hw->band->phyrev, hw->band->pi->ana_rev,
+		   hw->sromrev);
 	return 0;
 }
 
-- 
1.9.1