From 231d6678806c19a9a57d4e6c3380f7b0168ca618 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rafa=C5=82=20Mi=C5=82ecki?= Date: Sat, 16 Apr 2016 08:47:12 +0000 Subject: [PATCH] mac80211: backport brcmfmac workaround for missing boardrev MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Rafał Miłecki SVN-Revision: 49173 --- ...default-boardrev-in-nvram-data-if-mi.patch | 114 ++++++++++++++++++ ...-register-wiphy-s-during-module_init.patch | 14 +-- 2 files changed, 121 insertions(+), 7 deletions(-) create mode 100644 package/kernel/mac80211/patches/345-brcmfmac-insert-default-boardrev-in-nvram-data-if-mi.patch diff --git a/package/kernel/mac80211/patches/345-brcmfmac-insert-default-boardrev-in-nvram-data-if-mi.patch b/package/kernel/mac80211/patches/345-brcmfmac-insert-default-boardrev-in-nvram-data-if-mi.patch new file mode 100644 index 0000000000..f293401ca8 --- /dev/null +++ b/package/kernel/mac80211/patches/345-brcmfmac-insert-default-boardrev-in-nvram-data-if-mi.patch @@ -0,0 +1,114 @@ +From: Hante Meuleman +Date: Mon, 11 Apr 2016 11:35:23 +0200 +Subject: [PATCH] brcmfmac: insert default boardrev in nvram data if + missing + +Some nvram files/stores come without the boardrev information, +but firmware requires this to be set. When not found in nvram then +add a default boardrev string to the nvram data. + +Reported-by: Rafal Milecki +Reviewed-by: Arend Van Spriel +Reviewed-by: Franky (Zhenhui) Lin +Reviewed-by: Pieter-Paul Giesberts +Signed-off-by: Hante Meuleman +Signed-off-by: Arend van Spriel +Signed-off-by: Kalle Valo +--- + +--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c ++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c +@@ -29,6 +29,7 @@ + #define BRCMF_FW_MAX_NVRAM_SIZE 64000 + #define BRCMF_FW_NVRAM_DEVPATH_LEN 19 /* devpath0=pcie/1/4/ */ + #define BRCMF_FW_NVRAM_PCIEDEV_LEN 10 /* pcie/1/4/ + \0 */ ++#define BRCMF_FW_DEFAULT_BOARDREV "boardrev=0xff" + + enum nvram_parser_state { + IDLE, +@@ -51,6 +52,7 @@ enum nvram_parser_state { + * @entry: start position of key,value entry. + * @multi_dev_v1: detect pcie multi device v1 (compressed). + * @multi_dev_v2: detect pcie multi device v2. ++ * @boardrev_found: nvram contains boardrev information. + */ + struct nvram_parser { + enum nvram_parser_state state; +@@ -63,6 +65,7 @@ struct nvram_parser { + u32 entry; + bool multi_dev_v1; + bool multi_dev_v2; ++ bool boardrev_found; + }; + + /** +@@ -125,6 +128,8 @@ static enum nvram_parser_state brcmf_nvr + nvp->multi_dev_v1 = true; + if (strncmp(&nvp->data[nvp->entry], "pcie/", 5) == 0) + nvp->multi_dev_v2 = true; ++ if (strncmp(&nvp->data[nvp->entry], "boardrev", 8) == 0) ++ nvp->boardrev_found = true; + } else if (!is_nvram_char(c) || c == ' ') { + brcmf_dbg(INFO, "warning: ln=%d:col=%d: '=' expected, skip invalid key entry\n", + nvp->line, nvp->column); +@@ -284,6 +289,8 @@ static void brcmf_fw_strip_multi_v1(stru + while (i < nvp->nvram_len) { + if ((nvp->nvram[i] - '0' == id) && (nvp->nvram[i + 1] == ':')) { + i += 2; ++ if (strncmp(&nvp->nvram[i], "boardrev", 8) == 0) ++ nvp->boardrev_found = true; + while (nvp->nvram[i] != 0) { + nvram[j] = nvp->nvram[i]; + i++; +@@ -335,6 +342,8 @@ static void brcmf_fw_strip_multi_v2(stru + while (i < nvp->nvram_len - len) { + if (strncmp(&nvp->nvram[i], prefix, len) == 0) { + i += len; ++ if (strncmp(&nvp->nvram[i], "boardrev", 8) == 0) ++ nvp->boardrev_found = true; + while (nvp->nvram[i] != 0) { + nvram[j] = nvp->nvram[i]; + i++; +@@ -356,6 +365,18 @@ fail: + nvp->nvram_len = 0; + } + ++static void brcmf_fw_add_defaults(struct nvram_parser *nvp) ++{ ++ if (nvp->boardrev_found) ++ return; ++ ++ memcpy(&nvp->nvram[nvp->nvram_len], &BRCMF_FW_DEFAULT_BOARDREV, ++ strlen(BRCMF_FW_DEFAULT_BOARDREV)); ++ nvp->nvram_len += strlen(BRCMF_FW_DEFAULT_BOARDREV); ++ nvp->nvram[nvp->nvram_len] = '\0'; ++ nvp->nvram_len++; ++} ++ + /* brcmf_nvram_strip :Takes a buffer of "=\n" lines read from a fil + * and ending in a NUL. Removes carriage returns, empty lines, comment lines, + * and converts newlines to NULs. Shortens buffer as needed and pads with NULs. +@@ -377,16 +398,21 @@ static void *brcmf_fw_nvram_strip(const + if (nvp.state == END) + break; + } +- if (nvp.multi_dev_v1) ++ if (nvp.multi_dev_v1) { ++ nvp.boardrev_found = false; + brcmf_fw_strip_multi_v1(&nvp, domain_nr, bus_nr); +- else if (nvp.multi_dev_v2) ++ } else if (nvp.multi_dev_v2) { ++ nvp.boardrev_found = false; + brcmf_fw_strip_multi_v2(&nvp, domain_nr, bus_nr); ++ } + + if (nvp.nvram_len == 0) { + kfree(nvp.nvram); + return NULL; + } + ++ brcmf_fw_add_defaults(&nvp); ++ + pad = nvp.nvram_len; + *new_length = roundup(nvp.nvram_len + 1, 4); + while (pad != *new_length) { diff --git a/package/kernel/mac80211/patches/861-brcmfmac-register-wiphy-s-during-module_init.patch b/package/kernel/mac80211/patches/861-brcmfmac-register-wiphy-s-during-module_init.patch index 95d93ae1f6..00181f647b 100644 --- a/package/kernel/mac80211/patches/861-brcmfmac-register-wiphy-s-during-module_init.patch +++ b/package/kernel/mac80211/patches/861-brcmfmac-register-wiphy-s-during-module_init.patch @@ -23,7 +23,7 @@ Signed-off-by: Rafał Miłecki } --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c -@@ -418,6 +418,7 @@ struct brcmf_fw { +@@ -444,6 +444,7 @@ struct brcmf_fw { u16 bus_nr; void (*done)(struct device *dev, const struct firmware *fw, void *nvram_image, u32 nvram_len); @@ -31,7 +31,7 @@ Signed-off-by: Rafał Miłecki }; static void brcmf_fw_request_nvram_done(const struct firmware *fw, void *ctx) -@@ -452,6 +453,8 @@ static void brcmf_fw_request_nvram_done( +@@ -478,6 +479,8 @@ static void brcmf_fw_request_nvram_done( goto fail; fwctx->done(fwctx->dev, fwctx->code, nvram, nvram_length); @@ -40,7 +40,7 @@ Signed-off-by: Rafał Miłecki kfree(fwctx); return; -@@ -459,6 +462,8 @@ fail: +@@ -485,6 +488,8 @@ fail: brcmf_dbg(TRACE, "failed: dev=%s\n", dev_name(fwctx->dev)); release_firmware(fwctx->code); device_release_driver(fwctx->dev); @@ -49,7 +49,7 @@ Signed-off-by: Rafał Miłecki kfree(fwctx); } -@@ -474,6 +479,8 @@ static void brcmf_fw_request_code_done(c +@@ -500,6 +505,8 @@ static void brcmf_fw_request_code_done(c /* only requested code so done here */ if (!(fwctx->flags & BRCMF_FW_REQUEST_NVRAM)) { fwctx->done(fwctx->dev, fw, NULL, 0); @@ -58,7 +58,7 @@ Signed-off-by: Rafał Miłecki kfree(fwctx); return; } -@@ -491,6 +498,8 @@ static void brcmf_fw_request_code_done(c +@@ -517,6 +524,8 @@ static void brcmf_fw_request_code_done(c fail: brcmf_dbg(TRACE, "failed: dev=%s\n", dev_name(fwctx->dev)); device_release_driver(fwctx->dev); @@ -67,7 +67,7 @@ Signed-off-by: Rafał Miłecki kfree(fwctx); } -@@ -502,6 +511,8 @@ int brcmf_fw_get_firmwares_pcie(struct d +@@ -528,6 +537,8 @@ int brcmf_fw_get_firmwares_pcie(struct d u16 domain_nr, u16 bus_nr) { struct brcmf_fw *fwctx; @@ -76,7 +76,7 @@ Signed-off-by: Rafał Miłecki brcmf_dbg(TRACE, "enter: dev=%s\n", dev_name(dev)); if (!fw_cb || !code) -@@ -522,9 +533,17 @@ int brcmf_fw_get_firmwares_pcie(struct d +@@ -548,9 +559,17 @@ int brcmf_fw_get_firmwares_pcie(struct d fwctx->domain_nr = domain_nr; fwctx->bus_nr = bus_nr; -- 2.30.2