brcmfmac: print firmware messages after a firmware crash
PATCH 1/1 brcmfmac: print firmware messages after a firmware crash
From: Rafał Miłecki <[email protected]>
Normally firmware messages are printed with debugging enabled only. It's a good idea as firmware may print a lot of messages that normal users don't need to care about.
However, on firmware crash, it may be very helpful to log all recent messages. There is almost always a backtrace available as well as rought info on the latest actions/state.
--- .../broadcom/brcm80211/brcmfmac/pcie.c | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c +18 -6
@@ -764,15 +764,22 @@ static void brcmf_pcie_bus_console_init(struct brcmf_pciedev_info *devinfo) console->base_addr, console->buf_addr, console->bufsize); } - -static void brcmf_pcie_bus_console_read (struct brcmf_pciedev_info *devinfo) +/** +* brcmf_pcie_bus_console_read - reads firmware messages +* +* @error: specifies if error has occurred (prints messages unconditionally) +*/ +static void brcmf_pcie_bus_console_read (struct brcmf_pciedev_info *devinfo, +int error) { +struct pci_dev *pdev = devinfo->pdev; +struct brcmf_bus *bus =dev_get_drvdata (&pdev->dev);struct brcmf_pcie_console *console;u32 addr;u8 ch;u32 newidx; -if (!BRCMF_FWCON_ON ()) +if (!error && !BRCMF_FWCON_ON ())return ; console = &devinfo->shared.console;
@@ -796,7 +803,10 @@ static void brcmf_pcie_bus_console_read(struct brcmf_pciedev_info *devinfo) }if (ch =='\n' ) { console->log_str[console->log_idx] =0 ; -pr_debug ("CONSOLE: %s" , console->log_str); +if (error) +brcmf_err (bus,"CONSOLE: %s" , console->log_str); +else +pr_debug ("CONSOLE: %s" , console->log_str); console->log_idx =0 ; } }
@@ -857,7 +867,7 @@ static irqreturn_t brcmf_pcie_isr_thread(int irq, void *arg) &devinfo->pdev->dev); } } -brcmf_pcie_bus_console_read (devinfo); +brcmf_pcie_bus_console_read (devinfo, false);if (devinfo->state ==BRCMFMAC_PCIE_STATE_UP )brcmf_pcie_intr_enable (devinfo); devinfo->in_irq = false;
@@ -1426,6 +1436,8 @@ static int brcmf_pcie_reset(struct device *dev)struct brcmf_fw_request *fwreq;int err; +brcmf_pcie_bus_console_read (devinfo, true); +brcmf_detach (dev);brcmf_pcie_release_irq (devinfo);
@@ -1824,7 +1836,7 @@ static void brcmf_pcie_setup(struct device *dev, int ret,if (brcmf_attach (&devinfo->pdev->dev, devinfo->settings) ==0 )return ; -brcmf_pcie_bus_console_read (devinfo); +brcmf_pcie_bus_console_read (devinfo, false); fail:device_release_driver (dev);
Signature · 1 line
2.21.0
Quoted 9 lines · Rafał Miłecki
From: Rafał Miłecki <[email protected]>
Normally firmware messages are printed with debugging enabled only. It's a good idea as firmware may print a lot of messages that normal users don't need to care about.
However, on firmware crash, it may be very helpful to log all recent messages. There is almost always a backtrace available as well as rought info on the latest actions/state.
nice... there is one minor nit below, but other than that...
Quoted 12 lines
Signed-off-by Rafał Miłecki <[email protected]>--- .../broadcom/brcm80211/brcmfmac/pcie.c | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-)drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c +0
-0@@ -764,15 +764,22 @@ static void brcmf_pcie_bus_console_init(struct brcmf_pciedev_info *devinfo) console->base_addr, console->buf_addr, console->bufsize); }
drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c static void brcmf_pcie_bus_console_init(struct brcmf_pciedev_info *devinfo) · line 773
Quoted 10 lines
drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c +7
-2- -static void brcmf_pcie_bus_console_read (struct brcmf_pciedev_info *devinfo) +/** +* brcmf_pcie_bus_console_read - reads firmware messages +* +* @error: specifies if error has occurred (prints messages unconditionally) +*/ +static void brcmf_pcie_bus_console_read (struct brcmf_pciedev_info *devinfo, +int error)
Given how it is called I would say 'bool error' makes a bit more sense.
Gr. AvS
Quoted 34 lines · Arend Van Spriel
Quoted 9 lines · Rafał Miłecki
From: Rafał Miłecki <[email protected]>
Normally firmware messages are printed with debugging enabled only. It's a good idea as firmware may print a lot of messages that normal users don't need to care about.
However, on firmware crash, it may be very helpful to log all recent messages. There is almost always a backtrace available as well as rought info on the latest actions/state.
nice... there is one minor nit below, but other than that...
Reviewed-by Arend van Spriel <[email protected]>Quoted 20 lines
Signed-off-by Rafał Miłecki <[email protected]>--- .../broadcom/brcm80211/brcmfmac/pcie.c | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-)drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c +3
-1@@ -764,15 +764,22 @@ static void brcmf_pcie_bus_console_init(struct brcmf_pciedev_info *devinfo) console->base_addr, console->buf_addr, console->bufsize); } - -static void brcmf_pcie_bus_console_read(struct brcmf_pciedev_info *devinfo) +/** +* brcmf_pcie_bus_console_read - reads firmware messages +*
Quoted 8 lines
drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c static void brcmf_pcie_bus_console_init(struct · line 777
Quoted 6 lines
drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c +4
-0+* @error: specifies if error has occurred (prints messages unconditionally) +*/ +static void brcmf_pcie_bus_console_read (struct brcmf_pciedev_info *devinfo, +int error)Given how it is called I would say 'bool error' makes a bit more sense.
I even call that function passing "true" or "false" as argument. Nice catch!
PATCH v2 1/1 brcmfmac: print firmware messages after a firmware crash
In reply to Rafał MiłeckiFrom: Rafał Miłecki <[email protected]>
Normally firmware messages are printed with debugging enabled only. It's a good idea as firmware may print a lot of messages that normal users don't need to care about.
However, on firmware crash, it may be very helpful to log all recent messages. There is almost always a backtrace available as well as rought info on the latest actions/state.
---
V2: Use "bool" for brcmf_pcie_bus_console_read() error argument
--- .../broadcom/brcm80211/brcmfmac/pcie.c | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c +18 -6
@@ -764,15 +764,22 @@ static void brcmf_pcie_bus_console_init(struct brcmf_pciedev_info *devinfo) console->base_addr, console->buf_addr, console->bufsize); } - -static void brcmf_pcie_bus_console_read (struct brcmf_pciedev_info *devinfo) +/** +* brcmf_pcie_bus_console_read - reads firmware messages +* +* @error: specifies if error has occurred (prints messages unconditionally) +*/ +static void brcmf_pcie_bus_console_read (struct brcmf_pciedev_info *devinfo, +bool error) { +struct pci_dev *pdev = devinfo->pdev; +struct brcmf_bus *bus =dev_get_drvdata (&pdev->dev);struct brcmf_pcie_console *console;u32 addr;u8 ch;u32 newidx; -if (!BRCMF_FWCON_ON ()) +if (!error && !BRCMF_FWCON_ON ())return ; console = &devinfo->shared.console;
@@ -796,7 +803,10 @@ static void brcmf_pcie_bus_console_read(struct brcmf_pciedev_info *devinfo) }if (ch =='\n' ) { console->log_str[console->log_idx] =0 ; -pr_debug ("CONSOLE: %s" , console->log_str); +if (error) +brcmf_err (bus,"CONSOLE: %s" , console->log_str); +else +pr_debug ("CONSOLE: %s" , console->log_str); console->log_idx =0 ; } }
@@ -857,7 +867,7 @@ static irqreturn_t brcmf_pcie_isr_thread(int irq, void *arg) &devinfo->pdev->dev); } } -brcmf_pcie_bus_console_read (devinfo); +brcmf_pcie_bus_console_read (devinfo, false);if (devinfo->state ==BRCMFMAC_PCIE_STATE_UP )brcmf_pcie_intr_enable (devinfo); devinfo->in_irq = false;
@@ -1426,6 +1436,8 @@ static int brcmf_pcie_reset(struct device *dev)struct brcmf_fw_request *fwreq;int err; +brcmf_pcie_bus_console_read (devinfo, true); +brcmf_detach (dev);brcmf_pcie_release_irq (devinfo);
@@ -1824,7 +1836,7 @@ static void brcmf_pcie_setup(struct device *dev, int ret,if (brcmf_attach (&devinfo->pdev->dev, devinfo->settings) ==0 )return ; -brcmf_pcie_bus_console_read (devinfo); +brcmf_pcie_bus_console_read (devinfo, false); fail:device_release_driver (dev);
Signature · 1 line
2.21.0
Quoted 6 lines · Rafał Miłecki
From: Rafał Miłecki <[email protected]>
Normally firmware messages are printed with debugging enabled only. It's a good idea as firmware may print a lot of messages that normal users don't need to care about.
Quoted 6 lines
However, on firmware crash, it may be very helpful to log all recent messages. There is almost always a backtrace available as well as rought info on the latest actions/state.
Signed-off-by Rafał Miłecki <[email protected]>Reviewed-by Arend van Spriel <[email protected]>
Patch applied to wireless-drivers-next.git, thanks.
47dd82e3d25e brcmfmac: print firmware messages after a firmware crash
Signature · 3 lines
https://patchwork.kernel.org/patch/10921071/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches