From: Rafał Miłecki Date: Tue, 8 Jan 2019 09:01:08 +0000 (+0100) Subject: mac80211: brcmfmac: backport firmware loading changes & fix memory bugs X-Git-Tag: v18.06.2~38 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=a8cc06c5371eca2ae8ab4511c7136d0ebd9ee3bc;p=oweals%2Fopenwrt.git mac80211: brcmfmac: backport firmware loading changes & fix memory bugs This pick most of brcmfmac changes backported into the master in commits 5932eb690f24 ("mac80211: brcmfmac: backport firmware loading cleanup") 3eab6b8275b2 ("mac80211: brcmfmac: backport NVRAM loading improvements") 529c95cc15dc ("mac80211: brcmfmac: fix use-after-free & possible NULL pointer dereference") It's more than would be normally backported into a stable branch but it seems required. Firmware loading cleanups are needed to allow fix memory bugs in a reliable way. Memory fixes are really important to avoid corrupting memory and risking a NULL pointer dereference. Hopefully this stuff has received enough testing in the master. Signed-off-by: Rafał Miłecki --- diff --git a/package/kernel/mac80211/patches/355-v5.0-0001-brcmfmac-Remove-firmware-loading-code-duplication.patch b/package/kernel/mac80211/patches/355-v5.0-0001-brcmfmac-Remove-firmware-loading-code-duplication.patch new file mode 100644 index 0000000000..eca15a516e --- /dev/null +++ b/package/kernel/mac80211/patches/355-v5.0-0001-brcmfmac-Remove-firmware-loading-code-duplication.patch @@ -0,0 +1,102 @@ +From a1a3b762163868ad07a4499a73df324f40d5ab0b Mon Sep 17 00:00:00 2001 +From: Hans de Goede +Date: Wed, 10 Oct 2018 13:00:58 +0200 +Subject: [PATCH] brcmfmac: Remove firmware-loading code duplication + +brcmf_fw_request_next_item and brcmf_fw_request_done both have identical +code to complete the fw-request depending on the item-type. + +This commit adds a new brcmf_fw_complete_request helper removing this code +duplication. + +Signed-off-by: Hans de Goede +Signed-off-by: Kalle Valo +--- + .../broadcom/brcm80211/brcmfmac/firmware.c | 62 +++++++++++----------- + 1 file changed, 31 insertions(+), 31 deletions(-) + +--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c ++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c +@@ -504,6 +504,34 @@ fail: + return -ENOENT; + } + ++static int brcmf_fw_complete_request(const struct firmware *fw, ++ struct brcmf_fw *fwctx) ++{ ++ struct brcmf_fw_item *cur = &fwctx->req->items[fwctx->curpos]; ++ int ret = 0; ++ ++ brcmf_dbg(TRACE, "firmware %s %sfound\n", cur->path, fw ? "" : "not "); ++ ++ switch (cur->type) { ++ case BRCMF_FW_TYPE_NVRAM: ++ ret = brcmf_fw_request_nvram_done(fw, fwctx); ++ break; ++ case BRCMF_FW_TYPE_BINARY: ++ if (fw) ++ cur->binary = fw; ++ else ++ ret = -ENOENT; ++ break; ++ default: ++ /* something fishy here so bail out early */ ++ brcmf_err("unknown fw type: %d\n", cur->type); ++ release_firmware(fw); ++ ret = -EINVAL; ++ } ++ ++ return (cur->flags & BRCMF_FW_REQF_OPTIONAL) ? 0 : ret; ++} ++ + static int brcmf_fw_request_next_item(struct brcmf_fw *fwctx, bool async) + { + struct brcmf_fw_item *cur; +@@ -525,15 +553,7 @@ static int brcmf_fw_request_next_item(st + if (ret < 0) { + brcmf_fw_request_done(NULL, fwctx); + } else if (!async && fw) { +- brcmf_dbg(TRACE, "firmware %s %sfound\n", cur->path, +- fw ? "" : "not "); +- if (cur->type == BRCMF_FW_TYPE_BINARY) +- cur->binary = fw; +- else if (cur->type == BRCMF_FW_TYPE_NVRAM) +- brcmf_fw_request_nvram_done(fw, fwctx); +- else +- release_firmware(fw); +- ++ brcmf_fw_complete_request(fw, fwctx); + return -EAGAIN; + } + return 0; +@@ -547,28 +567,8 @@ static void brcmf_fw_request_done(const + + cur = &fwctx->req->items[fwctx->curpos]; + +- brcmf_dbg(TRACE, "enter: firmware %s %sfound\n", cur->path, +- fw ? "" : "not "); +- +- if (!fw) +- ret = -ENOENT; +- +- switch (cur->type) { +- case BRCMF_FW_TYPE_NVRAM: +- ret = brcmf_fw_request_nvram_done(fw, fwctx); +- break; +- case BRCMF_FW_TYPE_BINARY: +- cur->binary = fw; +- break; +- default: +- /* something fishy here so bail out early */ +- brcmf_err("unknown fw type: %d\n", cur->type); +- release_firmware(fw); +- ret = -EINVAL; +- goto fail; +- } +- +- if (ret < 0 && !(cur->flags & BRCMF_FW_REQF_OPTIONAL)) ++ ret = brcmf_fw_complete_request(fw, fwctx); ++ if (ret < 0) + goto fail; + + do { diff --git a/package/kernel/mac80211/patches/355-v5.0-0002-brcmfmac-Remove-recursion-from-firmware-load-error-h.patch b/package/kernel/mac80211/patches/355-v5.0-0002-brcmfmac-Remove-recursion-from-firmware-load-error-h.patch new file mode 100644 index 0000000000..1a4a1ec348 --- /dev/null +++ b/package/kernel/mac80211/patches/355-v5.0-0002-brcmfmac-Remove-recursion-from-firmware-load-error-h.patch @@ -0,0 +1,127 @@ +From 5b587496dc63595b71265d986ce69728c2724370 Mon Sep 17 00:00:00 2001 +From: Hans de Goede +Date: Wed, 10 Oct 2018 13:00:59 +0200 +Subject: [PATCH] brcmfmac: Remove recursion from firmware load error handling + +Before this commit brcmf_fw_request_done would call +brcmf_fw_request_next_item to load the next item, which on an error would +call brcmf_fw_request_done, which if the error is recoverable (*) will +then continue calling brcmf_fw_request_next_item for the next item again +which on an error will call brcmf_fw_request_done again... + +This does not blow up because we only have a limited number of items so +we never recurse too deep. But the recursion is still quite ugly and +frankly is giving me a headache, so lets fix this. + +This commit fixes this by removing brcmf_fw_request_next_item and by +making brcmf_fw_get_firmwares and brcmf_fw_request_done directly call +firmware_request_nowait resp. firmware_request themselves. + +*) brcmf_fw_request_nvram_done fallback path succeeds or + BRCMF_FW_REQF_OPTIONAL is set + +Signed-off-by: Hans de Goede +Signed-off-by: Kalle Valo +--- + .../broadcom/brcm80211/brcmfmac/firmware.c | 65 +++++++--------------- + 1 file changed, 19 insertions(+), 46 deletions(-) + +--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c ++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c +@@ -532,33 +532,6 @@ static int brcmf_fw_complete_request(con + return (cur->flags & BRCMF_FW_REQF_OPTIONAL) ? 0 : ret; + } + +-static int brcmf_fw_request_next_item(struct brcmf_fw *fwctx, bool async) +-{ +- struct brcmf_fw_item *cur; +- const struct firmware *fw = NULL; +- int ret; +- +- cur = &fwctx->req->items[fwctx->curpos]; +- +- brcmf_dbg(TRACE, "%srequest for %s\n", async ? "async " : "", +- cur->path); +- +- if (async) +- ret = request_firmware_nowait(THIS_MODULE, true, cur->path, +- fwctx->dev, GFP_KERNEL, fwctx, +- brcmf_fw_request_done); +- else +- ret = request_firmware(&fw, cur->path, fwctx->dev); +- +- if (ret < 0) { +- brcmf_fw_request_done(NULL, fwctx); +- } else if (!async && fw) { +- brcmf_fw_complete_request(fw, fwctx); +- return -EAGAIN; +- } +- return 0; +-} +- + static void brcmf_fw_request_done(const struct firmware *fw, void *ctx) + { + struct brcmf_fw *fwctx = ctx; +@@ -568,26 +541,19 @@ static void brcmf_fw_request_done(const + cur = &fwctx->req->items[fwctx->curpos]; + + ret = brcmf_fw_complete_request(fw, fwctx); +- if (ret < 0) +- goto fail; + +- do { +- if (++fwctx->curpos == fwctx->req->n_items) { +- ret = 0; +- goto done; +- } +- +- ret = brcmf_fw_request_next_item(fwctx, false); +- } while (ret == -EAGAIN); +- +- return; +- +-fail: +- brcmf_dbg(TRACE, "failed err=%d: dev=%s, fw=%s\n", ret, +- dev_name(fwctx->dev), cur->path); +- brcmf_fw_free_request(fwctx->req); +- fwctx->req = NULL; +-done: ++ while (ret == 0 && ++fwctx->curpos < fwctx->req->n_items) { ++ cur = &fwctx->req->items[fwctx->curpos]; ++ request_firmware(&fw, cur->path, fwctx->dev); ++ ret = brcmf_fw_complete_request(fw, ctx); ++ } ++ ++ if (ret) { ++ brcmf_dbg(TRACE, "failed err=%d: dev=%s, fw=%s\n", ret, ++ dev_name(fwctx->dev), cur->path); ++ brcmf_fw_free_request(fwctx->req); ++ fwctx->req = NULL; ++ } + fwctx->done(fwctx->dev, ret, fwctx->req); + kfree(fwctx); + } +@@ -611,7 +577,9 @@ int brcmf_fw_get_firmwares(struct device + void (*fw_cb)(struct device *dev, int err, + struct brcmf_fw_request *req)) + { ++ struct brcmf_fw_item *first = &req->items[0]; + struct brcmf_fw *fwctx; ++ int ret; + + brcmf_dbg(TRACE, "enter: dev=%s\n", dev_name(dev)); + if (!fw_cb) +@@ -628,7 +596,12 @@ int brcmf_fw_get_firmwares(struct device + fwctx->req = req; + fwctx->done = fw_cb; + +- brcmf_fw_request_next_item(fwctx, true); ++ ret = request_firmware_nowait(THIS_MODULE, true, first->path, ++ fwctx->dev, GFP_KERNEL, fwctx, ++ brcmf_fw_request_done); ++ if (ret < 0) ++ brcmf_fw_request_done(NULL, fwctx); ++ + return 0; + } + diff --git a/package/kernel/mac80211/patches/355-v5.0-0003-brcmfmac-Add-support-for-first-trying-to-get-a-board.patch b/package/kernel/mac80211/patches/355-v5.0-0003-brcmfmac-Add-support-for-first-trying-to-get-a-board.patch new file mode 100644 index 0000000000..727dcbe85a --- /dev/null +++ b/package/kernel/mac80211/patches/355-v5.0-0003-brcmfmac-Add-support-for-first-trying-to-get-a-board.patch @@ -0,0 +1,77 @@ +From eae8e50669e15002b195177212a6e25afbe7cf4d Mon Sep 17 00:00:00 2001 +From: Hans de Goede +Date: Wed, 10 Oct 2018 13:01:00 +0200 +Subject: [PATCH] brcmfmac: Add support for first trying to get a board + specific nvram file + +The nvram files which some brcmfmac chips need are board-specific. To be +able to distribute these as part of linux-firmware, so that devices with +such a wifi chip will work OOTB, multiple (one per board) versions must +co-exist under /lib/firmware. + +This commit adds support for callers of the brcmfmac/firmware.c code to +pass in a board_type parameter through the request structure. + +If that parameter is set then the code will first try to load +chipmodel.board_type.txt before falling back to the old chipmodel.txt name. + +Signed-off-by: Hans de Goede +Signed-off-by: Kalle Valo +--- + .../broadcom/brcm80211/brcmfmac/firmware.c | 27 +++++++++++++++++++++- + .../broadcom/brcm80211/brcmfmac/firmware.h | 1 + + 2 files changed, 27 insertions(+), 1 deletion(-) + +--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c ++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c +@@ -532,6 +532,31 @@ static int brcmf_fw_complete_request(con + return (cur->flags & BRCMF_FW_REQF_OPTIONAL) ? 0 : ret; + } + ++static int brcmf_fw_request_firmware(const struct firmware **fw, ++ struct brcmf_fw *fwctx) ++{ ++ struct brcmf_fw_item *cur = &fwctx->req->items[fwctx->curpos]; ++ int ret; ++ ++ /* nvram files are board-specific, first try a board-specific path */ ++ if (cur->type == BRCMF_FW_TYPE_NVRAM && fwctx->req->board_type) { ++ char alt_path[BRCMF_FW_NAME_LEN]; ++ ++ strlcpy(alt_path, cur->path, BRCMF_FW_NAME_LEN); ++ /* strip .txt at the end */ ++ alt_path[strlen(alt_path) - 4] = 0; ++ strlcat(alt_path, ".", BRCMF_FW_NAME_LEN); ++ strlcat(alt_path, fwctx->req->board_type, BRCMF_FW_NAME_LEN); ++ strlcat(alt_path, ".txt", BRCMF_FW_NAME_LEN); ++ ++ ret = request_firmware(fw, alt_path, fwctx->dev); ++ if (ret == 0) ++ return ret; ++ } ++ ++ return request_firmware(fw, cur->path, fwctx->dev); ++} ++ + static void brcmf_fw_request_done(const struct firmware *fw, void *ctx) + { + struct brcmf_fw *fwctx = ctx; +@@ -544,7 +569,7 @@ static void brcmf_fw_request_done(const + + while (ret == 0 && ++fwctx->curpos < fwctx->req->n_items) { + cur = &fwctx->req->items[fwctx->curpos]; +- request_firmware(&fw, cur->path, fwctx->dev); ++ brcmf_fw_request_firmware(&fw, fwctx); + ret = brcmf_fw_complete_request(fw, ctx); + } + +--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.h ++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.h +@@ -70,6 +70,7 @@ struct brcmf_fw_request { + u16 domain_nr; + u16 bus_nr; + u32 n_items; ++ const char *board_type; + struct brcmf_fw_item items[0]; + }; + diff --git a/package/kernel/mac80211/patches/355-v5.0-0004-brcmfmac-Set-board_type-used-for-nvram-file-selectio.patch b/package/kernel/mac80211/patches/355-v5.0-0004-brcmfmac-Set-board_type-used-for-nvram-file-selectio.patch new file mode 100644 index 0000000000..a33ceaa21e --- /dev/null +++ b/package/kernel/mac80211/patches/355-v5.0-0004-brcmfmac-Set-board_type-used-for-nvram-file-selectio.patch @@ -0,0 +1,77 @@ +From 0ad4b55b2f29784f93875e6231bf57cd233624a2 Mon Sep 17 00:00:00 2001 +From: Hans de Goede +Date: Wed, 10 Oct 2018 13:01:01 +0200 +Subject: [PATCH] brcmfmac: Set board_type used for nvram file selection to + machine-compatible + +For of/devicetree using machines, set the board_type used for nvram file +selection to the first string listed in the top-level's node compatible +string, aka the machine-compatible as used by of_machine_is_compatible(). + +The board_type setting is used to load the board-specific nvram file with +a board-specific name so that we can ship files for each supported board +in linux-firmware. + +Signed-off-by: Hans de Goede +Signed-off-by: Kalle Valo +--- + drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.h | 1 + + drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.c | 11 ++++++++++- + drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c | 1 + + drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c | 1 + + 4 files changed, 13 insertions(+), 1 deletion(-) + +--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.h ++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.h +@@ -59,6 +59,7 @@ struct brcmf_mp_device { + bool iapp; + bool ignore_probe_fail; + struct brcmfmac_pd_cc *country_codes; ++ const char *board_type; + union { + struct brcmfmac_sdio_pd sdio; + } bus; +--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.c ++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.c +@@ -27,11 +27,20 @@ void brcmf_of_probe(struct device *dev, + struct brcmf_mp_device *settings) + { + struct brcmfmac_sdio_pd *sdio = &settings->bus.sdio; +- struct device_node *np = dev->of_node; ++ struct device_node *root, *np = dev->of_node; ++ struct property *prop; + int irq; + u32 irqf; + u32 val; + ++ /* Set board-type to the first string of the machine compatible prop */ ++ root = of_find_node_by_path("/"); ++ if (root) { ++ prop = of_find_property(root, "compatible", NULL); ++ settings->board_type = of_prop_next_string(prop, NULL); ++ of_node_put(root); ++ } ++ + if (!np || bus_type != BRCMF_BUSTYPE_SDIO || + !of_device_is_compatible(np, "brcm,bcm4329-fmac")) + return; +--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c ++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c +@@ -1785,6 +1785,7 @@ brcmf_pcie_prepare_fw_request(struct brc + fwreq->items[BRCMF_PCIE_FW_CODE].type = BRCMF_FW_TYPE_BINARY; + fwreq->items[BRCMF_PCIE_FW_NVRAM].type = BRCMF_FW_TYPE_NVRAM; + fwreq->items[BRCMF_PCIE_FW_NVRAM].flags = BRCMF_FW_REQF_OPTIONAL; ++ fwreq->board_type = devinfo->settings->board_type; + /* NVRAM reserves PCI domain 0 for Broadcom's SDK faked bus */ + fwreq->domain_nr = pci_domain_nr(devinfo->pdev->bus) + 1; + fwreq->bus_nr = devinfo->pdev->bus->number; +--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c ++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c +@@ -4174,6 +4174,7 @@ brcmf_sdio_prepare_fw_request(struct brc + + fwreq->items[BRCMF_SDIO_FW_CODE].type = BRCMF_FW_TYPE_BINARY; + fwreq->items[BRCMF_SDIO_FW_NVRAM].type = BRCMF_FW_TYPE_NVRAM; ++ fwreq->board_type = bus->sdiodev->settings->board_type; + + return fwreq; + } diff --git a/package/kernel/mac80211/patches/355-v5.0-0005-brcmfmac-Set-board_type-from-DMI-on-x86-based-machin.patch b/package/kernel/mac80211/patches/355-v5.0-0005-brcmfmac-Set-board_type-from-DMI-on-x86-based-machin.patch new file mode 100644 index 0000000000..25426e3f10 --- /dev/null +++ b/package/kernel/mac80211/patches/355-v5.0-0005-brcmfmac-Set-board_type-from-DMI-on-x86-based-machin.patch @@ -0,0 +1,179 @@ +From bd1e82bb420adf4ad7cd468d8a482cde622dd69d Mon Sep 17 00:00:00 2001 +From: Hans de Goede +Date: Wed, 10 Oct 2018 13:01:02 +0200 +Subject: [PATCH] brcmfmac: Set board_type from DMI on x86 based machines + +For x86 based machines, set the board_type used for nvram file selection +based on the DMI sys-vendor and product-name strings. + +Since on some models these strings are too generic, this commit also adds +a quirk table overriding the strings for models listed in that table. + +The board_type setting is used to load the board-specific nvram file with +a board-specific name so that we can ship files for each supported board +in linux-firmware. + +Signed-off-by: Hans de Goede +Signed-off-by: Kalle Valo +--- + .../wireless/broadcom/brcm80211/brcmfmac/Makefile | 2 + + .../wireless/broadcom/brcm80211/brcmfmac/common.c | 3 +- + .../wireless/broadcom/brcm80211/brcmfmac/common.h | 7 ++ + .../net/wireless/broadcom/brcm80211/brcmfmac/dmi.c | 116 +++++++++++++++++++++ + 4 files changed, 127 insertions(+), 1 deletion(-) + create mode 100644 drivers/net/wireless/broadcom/brcm80211/brcmfmac/dmi.c + +--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/Makefile ++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/Makefile +@@ -54,3 +54,5 @@ brcmfmac-$(CPTCFG_BRCM_TRACING) += \ + tracepoint.o + brcmfmac-$(CONFIG_OF) += \ + of.o ++brcmfmac-$(CONFIG_DMI) += \ ++ dmi.o +--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c ++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c +@@ -448,8 +448,9 @@ struct brcmf_mp_device *brcmf_get_module + } + } + if (!found) { +- /* No platform data for this device, try OF (Open Firwmare) */ ++ /* No platform data for this device, try OF and DMI data */ + brcmf_of_probe(dev, bus_type, settings); ++ brcmf_dmi_probe(settings, chip, chiprev); + } + return settings; + } +--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.h ++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.h +@@ -75,4 +75,11 @@ void brcmf_release_module_param(struct b + /* Sets dongle media info (drv_version, mac address). */ + int brcmf_c_preinit_dcmds(struct brcmf_if *ifp); + ++#ifdef CONFIG_DMI ++void brcmf_dmi_probe(struct brcmf_mp_device *settings, u32 chip, u32 chiprev); ++#else ++static inline void ++brcmf_dmi_probe(struct brcmf_mp_device *settings, u32 chip, u32 chiprev) {} ++#endif ++ + #endif /* BRCMFMAC_COMMON_H */ +--- /dev/null ++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/dmi.c +@@ -0,0 +1,116 @@ ++/* ++ * Copyright 2018 Hans de Goede ++ * ++ * Permission to use, copy, modify, and/or distribute this software for any ++ * purpose with or without fee is hereby granted, provided that the above ++ * copyright notice and this permission notice appear in all copies. ++ * ++ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES ++ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF ++ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY ++ * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES ++ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION ++ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN ++ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ++ */ ++ ++#include ++#include ++#include "core.h" ++#include "common.h" ++#include "brcm_hw_ids.h" ++ ++/* The DMI data never changes so we can use a static buf for this */ ++static char dmi_board_type[128]; ++ ++struct brcmf_dmi_data { ++ u32 chip; ++ u32 chiprev; ++ const char *board_type; ++}; ++ ++/* NOTE: Please keep all entries sorted alphabetically */ ++ ++static const struct brcmf_dmi_data gpd_win_pocket_data = { ++ BRCM_CC_4356_CHIP_ID, 2, "gpd-win-pocket" ++}; ++ ++static const struct brcmf_dmi_data jumper_ezpad_mini3_data = { ++ BRCM_CC_43430_CHIP_ID, 0, "jumper-ezpad-mini3" ++}; ++ ++static const struct brcmf_dmi_data meegopad_t08_data = { ++ BRCM_CC_43340_CHIP_ID, 2, "meegopad-t08" ++}; ++ ++static const struct dmi_system_id dmi_platform_data[] = { ++ { ++ /* Match for the GPDwin which unfortunately uses somewhat ++ * generic dmi strings, which is why we test for 4 strings. ++ * Comparing against 23 other byt/cht boards, board_vendor ++ * and board_name are unique to the GPDwin, where as only one ++ * other board has the same board_serial and 3 others have ++ * the same default product_name. Also the GPDwin is the ++ * only device to have both board_ and product_name not set. ++ */ ++ .matches = { ++ DMI_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"), ++ DMI_MATCH(DMI_BOARD_NAME, "Default string"), ++ DMI_MATCH(DMI_BOARD_SERIAL, "Default string"), ++ DMI_MATCH(DMI_PRODUCT_NAME, "Default string"), ++ }, ++ .driver_data = (void *)&gpd_win_pocket_data, ++ }, ++ { ++ /* Jumper EZpad mini3 */ ++ .matches = { ++ DMI_MATCH(DMI_SYS_VENDOR, "Insyde"), ++ DMI_MATCH(DMI_PRODUCT_NAME, "CherryTrail"), ++ /* jumperx.T87.KFBNEEA02 with the version-nr dropped */ ++ DMI_MATCH(DMI_BIOS_VERSION, "jumperx.T87.KFBNEEA"), ++ }, ++ .driver_data = (void *)&jumper_ezpad_mini3_data, ++ }, ++ { ++ /* Meegopad T08 */ ++ .matches = { ++ DMI_MATCH(DMI_SYS_VENDOR, "Default string"), ++ DMI_MATCH(DMI_PRODUCT_NAME, "Default string"), ++ DMI_MATCH(DMI_BOARD_NAME, "T3 MRD"), ++ DMI_MATCH(DMI_BOARD_VERSION, "V1.1"), ++ }, ++ .driver_data = (void *)&meegopad_t08_data, ++ }, ++ {} ++}; ++ ++void brcmf_dmi_probe(struct brcmf_mp_device *settings, u32 chip, u32 chiprev) ++{ ++ const struct dmi_system_id *match; ++ const struct brcmf_dmi_data *data; ++ const char *sys_vendor; ++ const char *product_name; ++ ++ /* Some models have DMI strings which are too generic, e.g. ++ * "Default string", we use a quirk table for these. ++ */ ++ for (match = dmi_first_match(dmi_platform_data); ++ match; ++ match = dmi_first_match(match + 1)) { ++ data = match->driver_data; ++ ++ if (data->chip == chip && data->chiprev == chiprev) { ++ settings->board_type = data->board_type; ++ return; ++ } ++ } ++ ++ /* Not found in the quirk-table, use sys_vendor-product_name */ ++ sys_vendor = dmi_get_system_info(DMI_SYS_VENDOR); ++ product_name = dmi_get_system_info(DMI_PRODUCT_NAME); ++ if (sys_vendor && product_name) { ++ snprintf(dmi_board_type, sizeof(dmi_board_type), "%s-%s", ++ sys_vendor, product_name); ++ settings->board_type = dmi_board_type; ++ } ++} diff --git a/package/kernel/mac80211/patches/355-v5.0-0006-brcmfmac-Cleanup-brcmf_fw_request_done.patch b/package/kernel/mac80211/patches/355-v5.0-0006-brcmfmac-Cleanup-brcmf_fw_request_done.patch new file mode 100644 index 0000000000..211e9e4a9f --- /dev/null +++ b/package/kernel/mac80211/patches/355-v5.0-0006-brcmfmac-Cleanup-brcmf_fw_request_done.patch @@ -0,0 +1,41 @@ +From 55e491edbf14b2da5419c2a319ea3b1d6368d9a2 Mon Sep 17 00:00:00 2001 +From: Hans de Goede +Date: Wed, 10 Oct 2018 13:01:03 +0200 +Subject: [PATCH] brcmfmac: Cleanup brcmf_fw_request_done() + +The "cur" variable is now only used for a debug print and we already +print the same info from brcmf_fw_complete_request(), so the debug print +does not provide any extra info and we can remove it. + +Signed-off-by: Hans de Goede +Signed-off-by: Kalle Valo +--- + drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c | 8 +------- + 1 file changed, 1 insertion(+), 7 deletions(-) + +--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c ++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c +@@ -560,22 +560,16 @@ static int brcmf_fw_request_firmware(con + static void brcmf_fw_request_done(const struct firmware *fw, void *ctx) + { + struct brcmf_fw *fwctx = ctx; +- struct brcmf_fw_item *cur; +- int ret = 0; +- +- cur = &fwctx->req->items[fwctx->curpos]; ++ int ret; + + ret = brcmf_fw_complete_request(fw, fwctx); + + while (ret == 0 && ++fwctx->curpos < fwctx->req->n_items) { +- cur = &fwctx->req->items[fwctx->curpos]; + brcmf_fw_request_firmware(&fw, fwctx); + ret = brcmf_fw_complete_request(fw, ctx); + } + + if (ret) { +- brcmf_dbg(TRACE, "failed err=%d: dev=%s, fw=%s\n", ret, +- dev_name(fwctx->dev), cur->path); + brcmf_fw_free_request(fwctx->req); + fwctx->req = NULL; + } diff --git a/package/kernel/mac80211/patches/860-brcmfmac-register-wiphy-s-during-module_init.patch b/package/kernel/mac80211/patches/860-brcmfmac-register-wiphy-s-during-module_init.patch index e70738322d..2e710d3d62 100644 --- a/package/kernel/mac80211/patches/860-brcmfmac-register-wiphy-s-during-module_init.patch +++ b/package/kernel/mac80211/patches/860-brcmfmac-register-wiphy-s-during-module_init.patch @@ -31,35 +31,37 @@ Signed-off-by: Rafał Miłecki }; static void brcmf_fw_request_done(const struct firmware *fw, void *ctx); -@@ -589,6 +590,8 @@ fail: - fwctx->req = NULL; - done: +@@ -574,6 +575,8 @@ static void brcmf_fw_request_done(const + fwctx->req = NULL; + } fwctx->done(fwctx->dev, ret, fwctx->req); + if (fwctx->completion) + complete(fwctx->completion); kfree(fwctx); } -@@ -612,6 +615,8 @@ int brcmf_fw_get_firmwares(struct device - struct brcmf_fw_request *req)) +@@ -598,6 +601,7 @@ int brcmf_fw_get_firmwares(struct device { + struct brcmf_fw_item *first = &req->items[0]; struct brcmf_fw *fwctx; + struct completion completion; -+ int err; + int ret; brcmf_dbg(TRACE, "enter: dev=%s\n", dev_name(dev)); - if (!fw_cb) -@@ -628,7 +633,14 @@ int brcmf_fw_get_firmwares(struct device +@@ -615,12 +619,17 @@ int brcmf_fw_get_firmwares(struct device fwctx->req = req; fwctx->done = fw_cb; + init_completion(&completion); + fwctx->completion = &completion; + - brcmf_fw_request_next_item(fwctx, true); -+ -+ wait_for_completion_timeout(fwctx->completion, msecs_to_jiffies(5000)); -+ fwctx->completion = NULL; + ret = request_firmware_nowait(THIS_MODULE, true, first->path, + fwctx->dev, GFP_KERNEL, fwctx, + brcmf_fw_request_done); + if (ret < 0) + brcmf_fw_request_done(NULL, fwctx); + ++ wait_for_completion_timeout(&completion, msecs_to_jiffies(5000)); + return 0; } diff --git a/package/kernel/mac80211/patches/863-brcmfmac-add-in-driver-tables-with-country-codes.patch b/package/kernel/mac80211/patches/863-brcmfmac-add-in-driver-tables-with-country-codes.patch index e7551c3a70..5bb7015810 100644 --- a/package/kernel/mac80211/patches/863-brcmfmac-add-in-driver-tables-with-country-codes.patch +++ b/package/kernel/mac80211/patches/863-brcmfmac-add-in-driver-tables-with-country-codes.patch @@ -49,9 +49,9 @@ Signed-off-by: Rafał Miłecki void brcmf_of_probe(struct device *dev, enum brcmf_bus_type bus_type, struct brcmf_mp_device *settings) { -@@ -32,6 +62,8 @@ void brcmf_of_probe(struct device *dev, - u32 irqf; - u32 val; +@@ -41,6 +71,8 @@ void brcmf_of_probe(struct device *dev, + of_node_put(root); + } + brcmf_of_probe_cc(dev, settings); +