349-v5.2-brcmfmac-print-firmware-messages-after-a-firmware-cr.patch 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. From 47dd82e3d25e85a7c7c4e4b0eac9d297d1e5e2d4 Mon Sep 17 00:00:00 2001
  2. From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
  3. Date: Sun, 28 Apr 2019 23:38:26 +0200
  4. Subject: [PATCH] brcmfmac: print firmware messages after a firmware crash
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. Normally firmware messages are printed with debugging enabled only. It's
  9. a good idea as firmware may print a lot of messages that normal users
  10. don't need to care about.
  11. However, on firmware crash, it may be very helpful to log all recent
  12. messages. There is almost always a backtrace available as well as rought
  13. info on the latest actions/state.
  14. Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
  15. Reviewed-by: Arend van Spriel <arend.vanspriel@broadcom.com>
  16. Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
  17. ---
  18. .../broadcom/brcm80211/brcmfmac/pcie.c | 24 ++++++++++++++-----
  19. 1 file changed, 18 insertions(+), 6 deletions(-)
  20. --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
  21. +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
  22. @@ -760,15 +760,22 @@ static void brcmf_pcie_bus_console_init(
  23. console->base_addr, console->buf_addr, console->bufsize);
  24. }
  25. -
  26. -static void brcmf_pcie_bus_console_read(struct brcmf_pciedev_info *devinfo)
  27. +/**
  28. + * brcmf_pcie_bus_console_read - reads firmware messages
  29. + *
  30. + * @error: specifies if error has occurred (prints messages unconditionally)
  31. + */
  32. +static void brcmf_pcie_bus_console_read(struct brcmf_pciedev_info *devinfo,
  33. + bool error)
  34. {
  35. + struct pci_dev *pdev = devinfo->pdev;
  36. + struct brcmf_bus *bus = dev_get_drvdata(&pdev->dev);
  37. struct brcmf_pcie_console *console;
  38. u32 addr;
  39. u8 ch;
  40. u32 newidx;
  41. - if (!BRCMF_FWCON_ON())
  42. + if (!error && !BRCMF_FWCON_ON())
  43. return;
  44. console = &devinfo->shared.console;
  45. @@ -792,7 +799,10 @@ static void brcmf_pcie_bus_console_read(
  46. }
  47. if (ch == '\n') {
  48. console->log_str[console->log_idx] = 0;
  49. - pr_debug("CONSOLE: %s", console->log_str);
  50. + if (error)
  51. + brcmf_err(bus, "CONSOLE: %s", console->log_str);
  52. + else
  53. + pr_debug("CONSOLE: %s", console->log_str);
  54. console->log_idx = 0;
  55. }
  56. }
  57. @@ -847,7 +857,7 @@ static irqreturn_t brcmf_pcie_isr_thread
  58. &devinfo->pdev->dev);
  59. }
  60. }
  61. - brcmf_pcie_bus_console_read(devinfo);
  62. + brcmf_pcie_bus_console_read(devinfo, false);
  63. if (devinfo->state == BRCMFMAC_PCIE_STATE_UP)
  64. brcmf_pcie_intr_enable(devinfo);
  65. devinfo->in_irq = false;
  66. @@ -1398,6 +1408,8 @@ static int brcmf_pcie_reset(struct devic
  67. u16 bus_nr;
  68. int err;
  69. + brcmf_pcie_bus_console_read(devinfo, true);
  70. +
  71. brcmf_detach(dev);
  72. brcmf_pcie_release_irq(devinfo);
  73. @@ -1799,7 +1811,7 @@ static void brcmf_pcie_setup(struct devi
  74. if (brcmf_pcie_attach_bus(devinfo) == 0)
  75. return;
  76. - brcmf_pcie_bus_console_read(devinfo);
  77. + brcmf_pcie_bus_console_read(devinfo, false);
  78. fail:
  79. device_release_driver(dev);