misc brcmfmac fixes (M1/T2 series spin-off)
Subsystems (5)
v4 cover misc brcmfmac fixes (M1/T2 series spin-off)
Hi everyone,
This series contains just the fixes / misc improvements from the previously submitted series:
brcmfmac: Support Apple T2 and M1 platforms
Patches 8-9 aren't strictly bugfixes but rather just general improvements; they can be safely skipped, although patch 8 will be a dependency of the subsequent series to avoid a compile warning.
Changes since v3:
- Sprinkled Cc: stable tags on all the commits that fix real bugs
- Added review tags
- Removed error message on alloc failure path in #7
Hector Martin (9):
brcmfmac: pcie: Release firmwares in the brcmf_pcie_setup error path
brcmfmac: firmware: Allocate space for default boardrev in nvram
brcmfmac: firmware: Do not crash on a NULL board_type
brcmfmac: pcie: Declare missing firmware files in pcie.c
brcmfmac: pcie: Replace brcmf_pcie_copy_mem_todev with memcpy_toio
brcmfmac: pcie: Fix crashes due to early IRQs
brcmfmac: of: Use devm_kstrdup for board_type & check for errors
brcmfmac: fwil: Constify iovar name arguments
brcmfmac: pcie: Read the console on init and shutdown
.../broadcom/brcm80211/brcmfmac/firmware.c | 5 ++ .../broadcom/brcm80211/brcmfmac/fwil.c | 34 ++++---- .../broadcom/brcm80211/brcmfmac/fwil.h | 28 +++---- .../wireless/broadcom/brcm80211/brcmfmac/of.c | 7 +- .../broadcom/brcm80211/brcmfmac/pcie.c | 77 ++++++++----------- .../broadcom/brcm80211/brcmfmac/sdio.c | 1 - 6 files changed, 71 insertions(+), 81 deletions(-)
Signature · 1 line
2.33.0
PATCH v4 1/9 brcmfmac: pcie: Release firmwares in the brcmf_pcie_setup error path
This avoids leaking memory if brcmf_chip_get_raminfo fails. Note that the CLM blob is released in the device remove path.
--- drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c +2 -0
@@ -1777,6 +1777,8 @@ static void brcmf_pcie_setup(struct device *dev, int ret, ret =brcmf_chip_get_raminfo (devinfo->ci);if (ret) {brcmf_err (bus,"Failed to get RAM info\n" ); +release_firmware (fw); +brcmf_fw_nvram_free (nvram); goto fail; }
Signature · 1 line
2.33.0
Re: [PATCH v4 1/9] brcmfmac: pcie: Release firmwares in the brcmf_pcie_setup error path
Quoted 3 lines · Hector Martin
This avoids leaking memory if
brcmf_chip_get_raminfofails. Note that the CLM blob is released in the device remove path.
Quoted 25 lines
Fixes 82f93cf46d60 ("brcmfmac: get chip's default RAM info during PCIe setup")Reviewed-by Linus Walleij <[email protected]>Reviewed-by Arend van Spriel <[email protected]>Signed-off-by Hector Martin <[email protected]>--- drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c | 2 ++ 1 file changed, 2 insertions(+)drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c +2
-1@@ -1777,6 +1777,8 @@ static void brcmf_pcie_setup(struct device *dev, int ret, ret =brcmf_chip_get_raminfo (devinfo->ci);if (ret) {brcmf_err (bus,"Failed to get RAM info\n" ); +release_firmware (fw); +brcmf_fw_nvram_free (nvram); goto fail; } --2.33.0
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v4 1/9] brcmfmac: pcie: Release firmwares in the brcmf_pcie_setup error path
In reply to Hector MartinQuoted 9 lines · Hector Martin
This avoids leaking memory if
brcmf_chip_get_raminfofails. Note that the CLM blob is released in the device remove path.Fixes 82f93cf46d60 ("brcmfmac: get chip's default RAM info during PCIe setup")Reviewed-by Linus Walleij <[email protected]>Reviewed-by Arend van Spriel <[email protected]>Signed-off-by Hector Martin <[email protected]>Reviewed-by Andy Shevchenko <[email protected]>
8 patches applied to wireless-next.git, thanks.
5e90f0f3ead0 brcmfmac: pcie: Release firmwares in the brcmf_pcie_setup error path d19d8e3ba256 brcmfmac: firmware: Allocate space for default boardrev in nvram 6d766d8cb505 brcmfmac: pcie: Declare missing firmware files in pcie.c 9466987f2467 brcmfmac: pcie: Replace brcmf_pcie_copy_mem_todev with memcpy_toio b50255c83b91 brcmfmac: pcie: Fix crashes due to early IRQs 9cf6d7f2c554 brcmfmac: of: Use devm_kstrdup for board_type & check for errors e7191182adc5 brcmfmac: fwil: Constify iovar name arguments b4bb8469e90e brcmfmac: pcie: Read the console on init and shutdown
Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/patch/[email protected]/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
PATCH v4 2/9 brcmfmac: firmware: Allocate space for default boardrev in nvram
In reply to Hector MartinIf boardrev is missing from the NVRAM we add a default one, but this might need more space in the output buffer than was allocated. Ensure we have enough padding for this in the buffer.
--- drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c +2 -0
@@ -207,6 +207,8 @@ static int brcmf_init_nvram_parser(struct nvram_parser *nvp, size =BRCMF_FW_MAX_NVRAM_SIZE ; else size = data_len; +/* Add space for properties we may add */ + size +=strlen (BRCMF_FW_DEFAULT_BOARDREV ) +1 ;/* Alloc for extra 0 byte + roundup by 4 + length field */ size +=1 +3 +sizeof (u32); nvp->nvram =kzalloc (size,GFP_KERNEL );
Signature · 1 line
2.33.0
Re: [PATCH v4 2/9] brcmfmac: firmware: Allocate space for default boardrev in nvram
Quoted 4 lines · Hector Martin
If boardrev is missing from the NVRAM we add a default one, but this might need more space in the output buffer than was allocated. Ensure we have enough padding for this in the buffer.
Quoted 24 lines
Fixes 46f2b38a91b0 ("brcmfmac: insert default boardrev in nvram data if missing")Reviewed-by Arend van Spriel <[email protected]>Signed-off-by Hector Martin <[email protected]>--- drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c | 2 ++ 1 file changed, 2 insertions(+)drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c +2
-1@@ -207,6 +207,8 @@ static int brcmf_init_nvram_parser(struct nvram_parser *nvp, size =BRCMF_FW_MAX_NVRAM_SIZE ; else size = data_len; +/* Add space for properties we may add */ + size +=strlen (BRCMF_FW_DEFAULT_BOARDREV ) +1 ;/* Alloc for extra 0 byte + roundup by 4 + length field */ size +=1 +3 +sizeof (u32); nvp->nvram =kzalloc (size,GFP_KERNEL ); --2.33.0
Signature · 2 lines
With Best Regards, Andy Shevchenko
PATCH v4 3/9 brcmfmac: firmware: Do not crash on a NULL board_type
In reply to Hector MartinThis unbreaks support for USB devices, which do not have a board_type to create an alt_path out of and thus were running into a NULL dereference.
--- drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c +3 -0
@@ -599,6 +599,9 @@ static char *brcm_alt_fw_path(const char *path, const char *board_type)char alt_path[BRCMF_FW_NAME_LEN ];char suffix[5 ]; +if (!board_type) +return NULL ; +strscpy (alt_path, path,BRCMF_FW_NAME_LEN );/* At least one character + suffix */ if (strlen (alt_path) <5 )
Signature · 1 line
2.33.0
Re: [PATCH v4 3/9] brcmfmac: firmware: Do not crash on a NULL board_type
Quoted 4 lines · Hector Martin
This unbreaks support for USB devices, which do not have a
board_typeto create analt_pathout of and thus were running into a NULL dereference.
...
drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c static char *brcm_alt_fw_path(const char *path, const char *board_type) · line 603
Quoted 6 lines
drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c +2
-0@@ -599,6 +599,9 @@ static char *brcm_alt_fw_path(const char *path, const char *board_type)char alt_path[BRCMF_FW_NAME_LEN ];char suffix[5 ]; +if (!board_type) +return NULL ;
I still think it's better to have both callers do the same thing.
Now it will be the double check in one case,
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v4 3/9] brcmfmac: firmware: Do not crash on a NULL board_type
Quoted 13 lines · Andy Shevchenko
Quoted 4 lines · Hector Martin
This unbreaks support for USB devices, which do not have a
board_typeto create analt_pathout of and thus were running into a NULL dereference....
Quoted 5 lines
drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c +0
-0@@ -599,6 +599,9 @@ static char *brcm_alt_fw_path(const char *path, const char *board_type) char alt_path[BRCMF_FW_NAME_LEN];char suffix[5 ];
Quoted 6 lines
drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c static char *brcm_alt_fw_path(const char *path, const char *board_type) · line 603
Quoted 2 lines
drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c +2
-0+if (!board_type) +return NULL ;I still think it's better to have both callers do the same thing.
Now it will be the double check in one case,
I already applied a similar patch:
https://git.kernel.org/wireless/wireless/c/665408f4c3a5
Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/list/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
Re: [PATCH v4 3/9] brcmfmac: firmware: Do not crash on a NULL board_type
Quoted 20 lines · Kalle Valo
Quoted 18 lines · Andy Shevchenko
Quoted 4 lines · Hector Martin
This unbreaks support for USB devices, which do not have a
board_typeto create analt_pathout of and thus were running into a NULL dereference....
drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c static char *brcm_alt_fw_path(const char *path, · line 604
Quoted 7 lines
drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c +2
-0@@ -599,6 +599,9 @@ static char *brcm_alt_fw_path(const char *path, const char *board_type) char alt_path[BRCMF_FW_NAME_LEN];char suffix[5 ]; +if (!board_type) +return NULL ;I still think it's better to have both callers do the same thing.
Quoted 6 lines
Quoted 1 line
Now it will be the double check in one case,
I already applied a similar patch:
Feel free to drop this one from the series then, if everything else looks good.
Signature · 2 lines
Hector Martin ([email protected]) Public Key: https://mrcn.st/pub
Re: [PATCH v4 3/9] brcmfmac: firmware: Do not crash on a NULL board_type
Quoted 23 lines · Hector Martin
Quoted 22 lines · Kalle Valo
Quoted 19 lines · Andy Shevchenko
Quoted 4 lines · Hector Martin
This unbreaks support for USB devices, which do not have a
board_typeto create analt_pathout of and thus were running into a NULL dereference....
drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c static char *brcm_alt_fw_path(const char *path, · line 604
Quoted 7 lines
drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c +2
-0@@ -599,6 +599,9 @@ static char *brcm_alt_fw_path(const char *path, const char *board_type) char alt_path[BRCMF_FW_NAME_LEN];char suffix[5 ]; +if (!board_type) +return NULL ;I still think it's better to have both callers do the same thing.
Now it will be the double check in one case,
Quoted 7 lines
Quoted 4 lines
I already applied a similar patch:
Feel free to drop this one from the series then, if everything else looks good.
Yes, I'll drop this patch 3.
Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/list/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
Re: [PATCH v4 3/9] brcmfmac: firmware: Do not crash on a NULL board_type
In reply to Kalle ValoQuoted 2 lines · Kalle Valo
Quoted 1 line · Andy Shevchenko
On Mon, Jan 31, 2022 at 6:07 PM Hector Martin <[email protected]> wrote:
...
Quoted 10 lines
Quoted 6 lines
drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c static char *brcm_alt_fw_path(const char *path, const char *board_type) · line 603
Quoted 2 lines
drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c +2
-0+if (!board_type) +return NULL ;I still think it's better to have both callers do the same thing.
Now it will be the double check in one case,
I already applied a similar patch:
"Similar" means that it took into account the concern I expressed here :-) I would have done slightly differently, but the main idea is the same. Thank you!
Signature · 2 lines
With Best Regards, Andy Shevchenko
PATCH v4 4/9 brcmfmac: pcie: Declare missing firmware files in pcie.c
In reply to Hector MartinMove one of the declarations from sdio.c to pcie.c, since it makes no sense in the former (SDIO support is optional), and add missing ones.
--- drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c | 7 +++++++ drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c | 1 - 2 files changed, 7 insertions(+), 1 deletion(-)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c +7 -0
@@ -59,6 +59,13 @@ BRCMF_FW_DEF(4366B, "brcmfmac4366b-pcie"); BRCMF_FW_DEF(4366C, "brcmfmac4366c-pcie");BRCMF_FW_DEF (4371 ,"brcmfmac4371-pcie" ); +/* firmware config files */ +MODULE_FIRMWARE (BRCMF_FW_DEFAULT_PATH "brcmfmac*-pcie.txt" ); +MODULE_FIRMWARE (BRCMF_FW_DEFAULT_PATH "brcmfmac*-pcie.*.txt" ); + +/* per-board firmware binaries */ +MODULE_FIRMWARE (BRCMF_FW_DEFAULT_PATH "brcmfmac*-pcie.*.bin" ); +static const struct brcmf_firmware_mapping brcmf_pcie_fwnames[] = {BRCMF_FW_ENTRY (BRCM_CC_43602_CHIP_ID ,0xFFFFFFFF ,43602 ), BRCMF_FW_ENTRY(BRCM_CC_43465_CHIP_ID, 0xFFFFFFF0, 4366C),
drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c +0 -1
@@ -629,7 +629,6 @@ BRCMF_FW_CLM_DEF(43752, "brcmfmac43752-sdio");/* firmware config files */ MODULE_FIRMWARE (BRCMF_FW_DEFAULT_PATH "brcmfmac*-sdio.*.txt" ); -MODULE_FIRMWARE (BRCMF_FW_DEFAULT_PATH "brcmfmac*-pcie.*.txt" );/* per-board firmware binaries */ MODULE_FIRMWARE (BRCMF_FW_DEFAULT_PATH "brcmfmac*-sdio.*.bin" );
Signature · 1 line
2.33.0
PATCH v4 5/9 brcmfmac: pcie: Replace brcmf_pcie_copy_mem_todev with memcpy_toio
In reply to Hector MartinThe alignment check was wrong (e.g. & 4 instead of & 3), and the logic was also inefficient if the length was not a multiple of 4, since it would needlessly fall back to copying the entire buffer bytewise.
We already have a perfectly good memcpy_toio function, so just call that instead of rolling our own copy logic here. brcmf_pcie_init_ringbuffers was already using it anyway.
--- .../broadcom/brcm80211/brcmfmac/pcie.c | 48 ++----------------- 1 file changed, 4 insertions(+), 44 deletions(-)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c +4 -44
@@ -12,6 +12,7 @@#include <linux/interrupt.h> #include <linux/bcma/bcma.h> #include <linux/sched.h> +#include <linux/io.h> #include <asm/unaligned.h> #include <soc.h>
@@ -454,47 +455,6 @@ brcmf_pcie_write_ram32(struct brcmf_pciedev_info *devinfo, u32 mem_offset, } -static void -brcmf_pcie_copy_mem_todev (struct brcmf_pciedev_info *devinfo,u32 mem_offset, -void *srcaddr,u32 len) -{ -void __iomem *address = devinfo->tcm + mem_offset; -__le32 *src32; -__le16 *src16; -u8 *src8; - -if (((ulong )address &4 ) || ((ulong )srcaddr &4 ) || (len &4 )) { -if (((ulong )address &2 ) || ((ulong )srcaddr &2 ) || (len &2 )) { - src8 = (u8 *)srcaddr; -while (len) { -iowrite8 (*src8, address); - address++; - src8++; - len--; - } - }else { - len = len /2 ; - src16 = (__le16 *)srcaddr; -while (len) { -iowrite16 (le16_to_cpu (*src16), address); - address +=2 ; - src16++; - len--; - } - } - }else { - len = len /4 ; - src32 = (__le32 *)srcaddr; -while (len) { -iowrite32 (le32_to_cpu (*src32), address); - address +=4 ; - src32++; - len--; - } - } -} - -static void brcmf_pcie_copy_dev_tomem (struct brcmf_pciedev_info *devinfo,u32 mem_offset,void *dstaddr,u32 len)
@@ -1570,8 +1530,8 @@ static int brcmf_pcie_download_fw_nvram(struct brcmf_pciedev_info *devinfo,return err;brcmf_dbg (PCIE ,"Download FW %s\n" , devinfo->fw_name); -brcmf_pcie_copy_mem_todev (devinfo, devinfo->ci->rambase, - (void *)fw->data, fw->size); +memcpy_toio (devinfo->tcm + devinfo->ci->rambase, + (void *)fw->data, fw->size); resetintr =get_unaligned_le32 (fw->data);release_firmware (fw);
@@ -1585,7 +1545,7 @@ static int brcmf_pcie_download_fw_nvram(struct brcmf_pciedev_info *devinfo,brcmf_dbg (PCIE ,"Download NVRAM %s\n" , devinfo->nvram_name); address = devinfo->ci->rambase + devinfo->ci->ramsize - nvram_len; -brcmf_pcie_copy_mem_todev (devinfo, address, nvram, nvram_len); +memcpy_toio (devinfo->tcm + address, nvram, nvram_len);brcmf_fw_nvram_free (nvram); }else { brcmf_dbg(PCIE, "No matching NVRAM file found %s\n",
Signature · 1 line
2.33.0
PATCH v4 6/9 brcmfmac: pcie: Fix crashes due to early IRQs
In reply to Hector MartinThe driver was enabling IRQs before the message processing was initialized. This could cause IRQs to come in too early and crash the driver. Instead, move the IRQ enable and hostready to a bus preinit function, at which point everything is properly initialized.
--- .../wireless/broadcom/brcm80211/brcmfmac/pcie.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c +13 -3
@@ -1315,6 +1315,18 @@ static void brcmf_pcie_down(struct device *dev) { } +static int brcmf_pcie_preinit (struct device *dev) +{ +struct brcmf_bus *bus_if =dev_get_drvdata (dev); +struct brcmf_pciedev *buspub = bus_if->bus_priv.pcie; + +brcmf_dbg (PCIE ,"Enter\n" ); + +brcmf_pcie_intr_enable (buspub->devinfo); +brcmf_pcie_hostready (buspub->devinfo); + +return 0 ; +}static int brcmf_pcie_tx (struct device *dev,struct sk_buff *skb) {
@@ -1423,6 +1435,7 @@ static int brcmf_pcie_reset(struct device *dev) }static const struct brcmf_bus_ops brcmf_pcie_bus_ops = { + .preinit = brcmf_pcie_preinit, .txdata = brcmf_pcie_tx, .stop = brcmf_pcie_down, .txctl = brcmf_pcie_tx_ctlpkt,
@@ -1795,9 +1808,6 @@ static void brcmf_pcie_setup(struct device *dev, int ret,init_waitqueue_head (&devinfo->mbdata_resp_wait); -brcmf_pcie_intr_enable (devinfo); -brcmf_pcie_hostready (devinfo); - ret =brcmf_attach (&devinfo->pdev->dev);if (ret) goto fail;
Signature · 1 line
2.33.0
Re: [PATCH v4 6/9] brcmfmac: pcie: Fix crashes due to early IRQs
Quoted 5 lines · Hector Martin
The driver was enabling IRQs before the message processing was initialized. This could cause IRQs to come in too early and crash the driver. Instead, move the IRQ enable and hostready to a bus preinit function, at which point everything is properly initialized.
Quoted 53 lines
Fixes 9e37f045d5e7 ("brcmfmac: Adding PCIe bus layer support.")Reviewed-by Linus Walleij <[email protected]>Reviewed-by Arend van Spriel <[email protected]>Signed-off-by Hector Martin <[email protected]>--- .../wireless/broadcom/brcm80211/brcmfmac/pcie.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c +13
-4@@ -1315,6 +1315,18 @@ static void brcmf_pcie_down(struct device *dev) { } +static int brcmf_pcie_preinit (struct device *dev) +{ +struct brcmf_bus *bus_if =dev_get_drvdata (dev); +struct brcmf_pciedev *buspub = bus_if->bus_priv.pcie; + +brcmf_dbg (PCIE ,"Enter\n" ); + +brcmf_pcie_intr_enable (buspub->devinfo); +brcmf_pcie_hostready (buspub->devinfo); + +return 0 ; +}static int brcmf_pcie_tx (struct device *dev,struct sk_buff *skb) {@@ -1423,6 +1435,7 @@ static int brcmf_pcie_reset(struct device *dev) }static const struct brcmf_bus_ops brcmf_pcie_bus_ops = { + .preinit = brcmf_pcie_preinit, .txdata = brcmf_pcie_tx, .stop = brcmf_pcie_down, .txctl = brcmf_pcie_tx_ctlpkt,@@ -1795,9 +1808,6 @@ static void brcmf_pcie_setup(struct device *dev, int ret,init_waitqueue_head (&devinfo->mbdata_resp_wait); -brcmf_pcie_intr_enable (devinfo); -brcmf_pcie_hostready (devinfo); - ret =brcmf_attach (&devinfo->pdev->dev);if (ret) goto fail; --2.33.0
Signature · 2 lines
With Best Regards, Andy Shevchenko
PATCH v4 7/9 brcmfmac: of: Use devm_kstrdup for board_type & check for errors
In reply to Hector MartinThis was missing a NULL check, and we can collapse the strlen/alloc/copy into a devm_kstrdup().
--- drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.c +5 -2
@@ -79,8 +79,11 @@ void brcmf_of_probe(struct device *dev, enum brcmf_bus_type bus_type,/* get rid of '/' in the compatible string to be able to find the FW */ len =strlen (tmp) +1 ; - board_type =devm_kzalloc (dev, len,GFP_KERNEL ); -strscpy (board_type, tmp, len); + board_type =devm_kstrdup (dev, tmp,GFP_KERNEL ); +if (!board_type) { +of_node_put (root); +return ; + }for (i =0 ; i < board_type[i]; i++) {if (board_type[i] =='/' ) board_type[i] ='-' ;
Signature · 1 line
2.33.0
Re: [PATCH v4 7/9] brcmfmac: of: Use devm_kstrdup for board_type & check for errors
Quoted 3 lines · Hector Martin
This was missing a NULL check, and we can collapse the strlen/alloc/copy into a
devm_kstrdup().
...
drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.c void brcmf_of_probe(struct device *dev, enum brcmf_bus_type bus_type, · line 82
Quoted 5 lines
/* get rid of '/' in the compatible string to be able to find the FW */ len = strlen(tmp) + 1;drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.c +1
-2- board_type = devm_kzalloc(dev, len, >GFP_KERNEL); -strscpy (board_type, tmp, len); + board_type =devm_kstrdup (dev, tmp,GFP_KERNEL );
Also len can be dropped, since it is now unused.
--
Best regards,
Piotr Masłowski
PATCH v4 8/9 brcmfmac: fwil: Constify iovar name arguments
In reply to Hector MartinMake all the iovar name arguments const char * instead of just char *.
--- .../broadcom/brcm80211/brcmfmac/fwil.c | 34 +++++++++---------- .../broadcom/brcm80211/brcmfmac/fwil.h | 28 +++++++-------- 2 files changed, 31 insertions(+), 31 deletions(-)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwil.c +17 -17
@@ -192,7 +192,7 @@ brcmf_fil_cmd_int_get(struct brcmf_if *ifp, u32 cmd, u32 *data) }static u32 -brcmf_create_iovar (char *name,const char *data,u32 datalen, +brcmf_create_iovar (const char *name,const char *data,u32 datalen,char *buf,u32 buflen) {u32 len;
@@ -213,7 +213,7 @@ brcmf_create_iovar(char *name, const char *data, u32 datalen,s32 -brcmf_fil_iovar_data_set (struct brcmf_if *ifp,char *name,const void *data, +brcmf_fil_iovar_data_set (struct brcmf_if *ifp,const char *name,const void *data,u32 len) {struct brcmf_pub *drvr = ifp->drvr;
@@ -241,7 +241,7 @@ brcmf_fil_iovar_data_set(struct brcmf_if *ifp, char *name, const void *data, }s32 -brcmf_fil_iovar_data_get (struct brcmf_if *ifp,char *name,void *data, +brcmf_fil_iovar_data_get (struct brcmf_if *ifp,const char *name,void *data,u32 len) {struct brcmf_pub *drvr = ifp->drvr;
@@ -272,7 +272,7 @@ brcmf_fil_iovar_data_get(struct brcmf_if *ifp, char *name, void *data, }s32 -brcmf_fil_iovar_int_set (struct brcmf_if *ifp,char *name,u32 data) +brcmf_fil_iovar_int_set (struct brcmf_if *ifp,const char *name,u32 data) {__le32 data_le =cpu_to_le32 (data);
@@ -280,7 +280,7 @@ brcmf_fil_iovar_int_set(struct brcmf_if *ifp, char *name, u32 data) }s32 -brcmf_fil_iovar_int_get (struct brcmf_if *ifp,char *name,u32 *data) +brcmf_fil_iovar_int_get (struct brcmf_if *ifp,const char *name,u32 *data) {__le32 data_le =cpu_to_le32 (*data);s32 err;
@@ -292,7 +292,7 @@ brcmf_fil_iovar_int_get(struct brcmf_if *ifp, char *name, u32 *data) }static u32 -brcmf_create_bsscfg (s32 bsscfgidx,char *name,char *data,u32 datalen, +brcmf_create_bsscfg (s32 bsscfgidx,const char *name,char *data,u32 datalen,char *buf,u32 buflen) {const s8 *prefix ="bsscfg:" ;
@@ -337,7 +337,7 @@ brcmf_create_bsscfg(s32 bsscfgidx, char *name, char *data, u32 datalen, }s32 -brcmf_fil_bsscfg_data_set (struct brcmf_if *ifp,char *name, +brcmf_fil_bsscfg_data_set (struct brcmf_if *ifp,const char *name,void *data,u32 len) {struct brcmf_pub *drvr = ifp->drvr;
@@ -366,7 +366,7 @@ brcmf_fil_bsscfg_data_set(struct brcmf_if *ifp, char *name, }s32 -brcmf_fil_bsscfg_data_get (struct brcmf_if *ifp,char *name, +brcmf_fil_bsscfg_data_get (struct brcmf_if *ifp,const char *name,void *data,u32 len) {struct brcmf_pub *drvr = ifp->drvr;
@@ -396,7 +396,7 @@ brcmf_fil_bsscfg_data_get(struct brcmf_if *ifp, char *name, }s32 -brcmf_fil_bsscfg_int_set (struct brcmf_if *ifp,char *name,u32 data) +brcmf_fil_bsscfg_int_set (struct brcmf_if *ifp,const char *name,u32 data) {__le32 data_le =cpu_to_le32 (data);
@@ -405,7 +405,7 @@ brcmf_fil_bsscfg_int_set(struct brcmf_if *ifp, char *name, u32 data) }s32 -brcmf_fil_bsscfg_int_get (struct brcmf_if *ifp,char *name,u32 *data) +brcmf_fil_bsscfg_int_get (struct brcmf_if *ifp,const char *name,u32 *data) {__le32 data_le =cpu_to_le32 (*data);s32 err;
@@ -417,7 +417,7 @@ brcmf_fil_bsscfg_int_get(struct brcmf_if *ifp, char *name, u32 *data)return err; } -static u32 brcmf_create_xtlv (char *name,u16 id,char *data,u32 len, +static u32 brcmf_create_xtlv (const char *name,u16 id,char *data,u32 len,char *buf,u32 buflen) {u32 iolen;
@@ -438,7 +438,7 @@ static u32 brcmf_create_xtlv(char *name, u16 id, char *data, u32 len,return iolen; } -s32 brcmf_fil_xtlv_data_set (struct brcmf_if *ifp,char *name,u16 id, +s32 brcmf_fil_xtlv_data_set (struct brcmf_if *ifp,const char *name,u16 id,void *data,u32 len) {struct brcmf_pub *drvr = ifp->drvr;
@@ -466,7 +466,7 @@ s32 brcmf_fil_xtlv_data_set(struct brcmf_if *ifp, char *name, u16 id,return err; } -s32 brcmf_fil_xtlv_data_get (struct brcmf_if *ifp,char *name,u16 id, +s32 brcmf_fil_xtlv_data_get (struct brcmf_if *ifp,const char *name,u16 id,void *data,u32 len) {struct brcmf_pub *drvr = ifp->drvr;
@@ -495,7 +495,7 @@ s32 brcmf_fil_xtlv_data_get(struct brcmf_if *ifp, char *name, u16 id,return err; } -s32 brcmf_fil_xtlv_int_set (struct brcmf_if *ifp,char *name,u16 id,u32 data) +s32 brcmf_fil_xtlv_int_set (struct brcmf_if *ifp,const char *name,u16 id,u32 data) {__le32 data_le =cpu_to_le32 (data);
@@ -503,7 +503,7 @@ s32 brcmf_fil_xtlv_int_set(struct brcmf_if *ifp, char *name, u16 id, u32 data) sizeof(data_le)); } -s32 brcmf_fil_xtlv_int_get (struct brcmf_if *ifp,char *name,u16 id,u32 *data) +s32 brcmf_fil_xtlv_int_get (struct brcmf_if *ifp,const char *name,u16 id,u32 *data) {__le32 data_le =cpu_to_le32 (*data);s32 err;
@@ -514,12 +514,12 @@ s32 brcmf_fil_xtlv_int_get(struct brcmf_if *ifp, char *name, u16 id, u32 *data)return err; } -s32 brcmf_fil_xtlv_int8_get (struct brcmf_if *ifp,char *name,u16 id,u8 *data) +s32 brcmf_fil_xtlv_int8_get (struct brcmf_if *ifp,const char *name,u16 id,u8 *data) {return brcmf_fil_xtlv_data_get (ifp, name, id, data,sizeof (*data)); } -s32 brcmf_fil_xtlv_int16_get (struct brcmf_if *ifp,char *name,u16 id,u16 *data) +s32 brcmf_fil_xtlv_int16_get (struct brcmf_if *ifp,const char *name,u16 id,u16 *data) {__le16 data_le =cpu_to_le16 (*data);s32 err;
drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwil.h +14 -14
@@ -84,26 +84,26 @@ s32 brcmf_fil_cmd_data_get(struct brcmf_if *ifp, u32 cmd, void *data, u32 len);s32 brcmf_fil_cmd_int_set (struct brcmf_if *ifp,u32 cmd,u32 data);s32 brcmf_fil_cmd_int_get (struct brcmf_if *ifp,u32 cmd,u32 *data); -s32 brcmf_fil_iovar_data_set (struct brcmf_if *ifp,char *name,const void *data, +s32 brcmf_fil_iovar_data_set (struct brcmf_if *ifp,const char *name,const void *data,u32 len); -s32 brcmf_fil_iovar_data_get (struct brcmf_if *ifp,char *name,void *data, +s32 brcmf_fil_iovar_data_get (struct brcmf_if *ifp,const char *name,void *data,u32 len); -s32 brcmf_fil_iovar_int_set (struct brcmf_if *ifp,char *name,u32 data); -s32 brcmf_fil_iovar_int_get (struct brcmf_if *ifp,char *name,u32 *data); +s32 brcmf_fil_iovar_int_set (struct brcmf_if *ifp,const char *name,u32 data); +s32 brcmf_fil_iovar_int_get (struct brcmf_if *ifp,const char *name,u32 *data); -s32 brcmf_fil_bsscfg_data_set (struct brcmf_if *ifp,char *name,void *data, +s32 brcmf_fil_bsscfg_data_set (struct brcmf_if *ifp,const char *name,void *data,u32 len); -s32 brcmf_fil_bsscfg_data_get (struct brcmf_if *ifp,char *name,void *data, +s32 brcmf_fil_bsscfg_data_get (struct brcmf_if *ifp,const char *name,void *data,u32 len); -s32 brcmf_fil_bsscfg_int_set (struct brcmf_if *ifp,char *name,u32 data); -s32 brcmf_fil_bsscfg_int_get (struct brcmf_if *ifp,char *name,u32 *data); -s32 brcmf_fil_xtlv_data_set (struct brcmf_if *ifp,char *name,u16 id, +s32 brcmf_fil_bsscfg_int_set (struct brcmf_if *ifp,const char *name,u32 data); +s32 brcmf_fil_bsscfg_int_get (struct brcmf_if *ifp,const char *name,u32 *data); +s32 brcmf_fil_xtlv_data_set (struct brcmf_if *ifp,const char *name,u16 id,void *data,u32 len); -s32 brcmf_fil_xtlv_data_get (struct brcmf_if *ifp,char *name,u16 id, +s32 brcmf_fil_xtlv_data_get (struct brcmf_if *ifp,const char *name,u16 id,void *data,u32 len); -s32 brcmf_fil_xtlv_int_set (struct brcmf_if *ifp,char *name,u16 id,u32 data); -s32 brcmf_fil_xtlv_int_get (struct brcmf_if *ifp,char *name,u16 id,u32 *data); -s32 brcmf_fil_xtlv_int8_get (struct brcmf_if *ifp,char *name,u16 id,u8 *data); -s32 brcmf_fil_xtlv_int16_get (struct brcmf_if *ifp,char *name,u16 id,u16 *data); +s32 brcmf_fil_xtlv_int_set (struct brcmf_if *ifp,const char *name,u16 id,u32 data); +s32 brcmf_fil_xtlv_int_get (struct brcmf_if *ifp,const char *name,u16 id,u32 *data); +s32 brcmf_fil_xtlv_int8_get (struct brcmf_if *ifp,const char *name,u16 id,u8 *data); +s32 brcmf_fil_xtlv_int16_get (struct brcmf_if *ifp,const char *name,u16 id,u16 *data);#endif /* _fwil_h_ */
Signature · 1 line
2.33.0
PATCH v4 9/9 brcmfmac: pcie: Read the console on init and shutdown
In reply to Hector MartinThis allows us to get console messages if the firmware crashed during early init, or if an operation failed and we're about to shut down.
--- drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c +4 -0
@@ -744,6 +744,8 @@ static void brcmf_pcie_bus_console_read(struct brcmf_pciedev_info *devinfo,return ; console = &devinfo->shared.console; +if (!console->base_addr) +return ; addr = console->base_addr +BRCMF_CONSOLE_WRITEIDX_OFFSET ; newidx =brcmf_pcie_read_tcm32 (devinfo, addr);while (newidx != console->read_idx) {
@@ -1520,6 +1522,7 @@ brcmf_pcie_init_share_ram_info(struct brcmf_pciedev_info *devinfo, shared->max_rxbufpost, shared->rx_dataoffset);brcmf_pcie_bus_console_init (devinfo); +brcmf_pcie_bus_console_read (devinfo, false);return 0 ; }
@@ -1959,6 +1962,7 @@ brcmf_pcie_remove(struct pci_dev *pdev)return ; devinfo = bus->bus_priv.pcie->devinfo; +brcmf_pcie_bus_console_read (devinfo, false); devinfo->state =BRCMFMAC_PCIE_STATE_DOWN ;if (devinfo->ci)
Signature · 1 line
2.33.0
Re: [PATCH v4 9/9] brcmfmac: pcie: Read the console on init and shutdown
Quoted 3 lines · Hector Martin
This allows us to get console messages if the firmware crashed during early init, or if an operation failed and we're about to shut down.
fails
Quoted 39 lines
Reviewed-by Linus Walleij <[email protected]>Reviewed-by Arend van Spriel <[email protected]>Signed-off-by Hector Martin <[email protected]>--- drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c +4
-1@@ -744,6 +744,8 @@ static void brcmf_pcie_bus_console_read(struct brcmf_pciedev_info *devinfo,return ; console = &devinfo->shared.console; +if (!console->base_addr) +return ; addr = console->base_addr +BRCMF_CONSOLE_WRITEIDX_OFFSET ; newidx =brcmf_pcie_read_tcm32 (devinfo, addr);while (newidx != console->read_idx) {@@ -1520,6 +1522,7 @@ brcmf_pcie_init_share_ram_info(struct brcmf_pciedev_info *devinfo, shared->max_rxbufpost, shared->rx_dataoffset);brcmf_pcie_bus_console_init (devinfo); +brcmf_pcie_bus_console_read (devinfo, false);return 0 ; }@@ -1959,6 +1962,7 @@ brcmf_pcie_remove(struct pci_dev *pdev)return ; devinfo = bus->bus_priv.pcie->devinfo; +brcmf_pcie_bus_console_read (devinfo, false); devinfo->state =BRCMFMAC_PCIE_STATE_DOWN ;if (devinfo->ci) --2.33.0
Signature · 2 lines
With Best Regards, Andy Shevchenko