340-v5.2-0002-brcmfmac-add-a-function-designated-for-handling-firm.patch 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. From a2ec87ddbf1637f854ffcfff9d12d392fa30758b Mon Sep 17 00:00:00 2001
  2. From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
  3. Date: Tue, 26 Feb 2019 14:11:18 +0100
  4. Subject: [PATCH] brcmfmac: add a function designated for handling firmware
  5. fails
  6. MIME-Version: 1.0
  7. Content-Type: text/plain; charset=UTF-8
  8. Content-Transfer-Encoding: 8bit
  9. This improves handling PCIe firmware halts by printing a clear error
  10. message and replaces a similar code in the SDIO bus support.
  11. It will also allow further improvements like trying to recover from a
  12. firmware crash.
  13. Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
  14. Reviewed-by: Arend van Spriel <arend.vanspriel@broadcom.com>
  15. Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
  16. ---
  17. drivers/net/wireless/broadcom/brcm80211/brcmfmac/bus.h | 2 ++
  18. .../net/wireless/broadcom/brcm80211/brcmfmac/core.c | 10 ++++++++++
  19. .../net/wireless/broadcom/brcm80211/brcmfmac/pcie.c | 2 +-
  20. .../net/wireless/broadcom/brcm80211/brcmfmac/sdio.c | 4 ++--
  21. 4 files changed, 15 insertions(+), 3 deletions(-)
  22. --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bus.h
  23. +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bus.h
  24. @@ -231,6 +231,8 @@ void brcmf_detach(struct device *dev);
  25. void brcmf_dev_reset(struct device *dev);
  26. /* Request from bus module to initiate a coredump */
  27. void brcmf_dev_coredump(struct device *dev);
  28. +/* Indication that firmware has halted or crashed */
  29. +void brcmf_fw_crashed(struct device *dev);
  30. /* Configure the "global" bus state used by upper layers */
  31. void brcmf_bus_change_state(struct brcmf_bus *bus, enum brcmf_bus_state state);
  32. --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
  33. +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
  34. @@ -1242,6 +1242,16 @@ void brcmf_dev_coredump(struct device *d
  35. brcmf_dbg(TRACE, "failed to create coredump\n");
  36. }
  37. +void brcmf_fw_crashed(struct device *dev)
  38. +{
  39. + struct brcmf_bus *bus_if = dev_get_drvdata(dev);
  40. + struct brcmf_pub *drvr = bus_if->drvr;
  41. +
  42. + bphy_err(drvr, "Firmware has halted or crashed\n");
  43. +
  44. + brcmf_dev_coredump(dev);
  45. +}
  46. +
  47. void brcmf_detach(struct device *dev)
  48. {
  49. s32 i;
  50. --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
  51. +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
  52. @@ -728,7 +728,7 @@ static void brcmf_pcie_handle_mb_data(st
  53. }
  54. if (dtoh_mb_data & BRCMF_D2H_DEV_FWHALT) {
  55. brcmf_dbg(PCIE, "D2H_MB_DATA: FW HALT\n");
  56. - brcmf_dev_coredump(&devinfo->pdev->dev);
  57. + brcmf_fw_crashed(&devinfo->pdev->dev);
  58. }
  59. }
  60. --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
  61. +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
  62. @@ -1098,8 +1098,8 @@ static u32 brcmf_sdio_hostmail(struct br
  63. /* dongle indicates the firmware has halted/crashed */
  64. if (hmb_data & HMB_DATA_FWHALT) {
  65. - brcmf_err("mailbox indicates firmware halted\n");
  66. - brcmf_dev_coredump(&sdiod->func[1]->dev);
  67. + brcmf_dbg(SDIO, "mailbox indicates firmware halted\n");
  68. + brcmf_fw_crashed(&sdiod->func[1]->dev);
  69. }
  70. /* Dongle recomposed rx frames, accept them again */