349-v5.1-0005-brcmfmac-check-and-dump-trap-info-during-sdio-probe.patch 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. From 4ab2cf03da91785f2c34d79a302e53da06928bc1 Mon Sep 17 00:00:00 2001
  2. From: Arend van Spriel <[email protected]>
  3. Date: Thu, 14 Feb 2019 13:43:51 +0100
  4. Subject: [PATCH] brcmfmac: check and dump trap info during sdio probe
  5. When the firmware crashes during the probe sequence we provide little
  6. information on what really failed. This patch checks the sdpcm shared
  7. location and show the trap information if a firmware trap has happened.
  8. Reviewed-by: Hante Meuleman <[email protected]>
  9. Reviewed-by: Pieter-Paul Giesberts <[email protected]>
  10. Reviewed-by: Franky Lin <[email protected]>
  11. Signed-off-by: Arend van Spriel <[email protected]>
  12. Signed-off-by: Kalle Valo <[email protected]>
  13. ---
  14. .../broadcom/brcm80211/brcmfmac/sdio.c | 59 +++++++++++++------
  15. 1 file changed, 40 insertions(+), 19 deletions(-)
  16. --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
  17. +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
  18. @@ -2999,21 +2999,35 @@ static int brcmf_sdio_trap_info(struct s
  19. if (error < 0)
  20. return error;
  21. - seq_printf(seq,
  22. - "dongle trap info: type 0x%x @ epc 0x%08x\n"
  23. - " cpsr 0x%08x spsr 0x%08x sp 0x%08x\n"
  24. - " lr 0x%08x pc 0x%08x offset 0x%x\n"
  25. - " r0 0x%08x r1 0x%08x r2 0x%08x r3 0x%08x\n"
  26. - " r4 0x%08x r5 0x%08x r6 0x%08x r7 0x%08x\n",
  27. - le32_to_cpu(tr.type), le32_to_cpu(tr.epc),
  28. - le32_to_cpu(tr.cpsr), le32_to_cpu(tr.spsr),
  29. - le32_to_cpu(tr.r13), le32_to_cpu(tr.r14),
  30. - le32_to_cpu(tr.pc), sh->trap_addr,
  31. - le32_to_cpu(tr.r0), le32_to_cpu(tr.r1),
  32. - le32_to_cpu(tr.r2), le32_to_cpu(tr.r3),
  33. - le32_to_cpu(tr.r4), le32_to_cpu(tr.r5),
  34. - le32_to_cpu(tr.r6), le32_to_cpu(tr.r7));
  35. -
  36. + if (seq)
  37. + seq_printf(seq,
  38. + "dongle trap info: type 0x%x @ epc 0x%08x\n"
  39. + " cpsr 0x%08x spsr 0x%08x sp 0x%08x\n"
  40. + " lr 0x%08x pc 0x%08x offset 0x%x\n"
  41. + " r0 0x%08x r1 0x%08x r2 0x%08x r3 0x%08x\n"
  42. + " r4 0x%08x r5 0x%08x r6 0x%08x r7 0x%08x\n",
  43. + le32_to_cpu(tr.type), le32_to_cpu(tr.epc),
  44. + le32_to_cpu(tr.cpsr), le32_to_cpu(tr.spsr),
  45. + le32_to_cpu(tr.r13), le32_to_cpu(tr.r14),
  46. + le32_to_cpu(tr.pc), sh->trap_addr,
  47. + le32_to_cpu(tr.r0), le32_to_cpu(tr.r1),
  48. + le32_to_cpu(tr.r2), le32_to_cpu(tr.r3),
  49. + le32_to_cpu(tr.r4), le32_to_cpu(tr.r5),
  50. + le32_to_cpu(tr.r6), le32_to_cpu(tr.r7));
  51. + else
  52. + pr_debug("dongle trap info: type 0x%x @ epc 0x%08x\n"
  53. + " cpsr 0x%08x spsr 0x%08x sp 0x%08x\n"
  54. + " lr 0x%08x pc 0x%08x offset 0x%x\n"
  55. + " r0 0x%08x r1 0x%08x r2 0x%08x r3 0x%08x\n"
  56. + " r4 0x%08x r5 0x%08x r6 0x%08x r7 0x%08x\n",
  57. + le32_to_cpu(tr.type), le32_to_cpu(tr.epc),
  58. + le32_to_cpu(tr.cpsr), le32_to_cpu(tr.spsr),
  59. + le32_to_cpu(tr.r13), le32_to_cpu(tr.r14),
  60. + le32_to_cpu(tr.pc), sh->trap_addr,
  61. + le32_to_cpu(tr.r0), le32_to_cpu(tr.r1),
  62. + le32_to_cpu(tr.r2), le32_to_cpu(tr.r3),
  63. + le32_to_cpu(tr.r4), le32_to_cpu(tr.r5),
  64. + le32_to_cpu(tr.r6), le32_to_cpu(tr.r7));
  65. return 0;
  66. }
  67. @@ -3067,8 +3081,10 @@ static int brcmf_sdio_checkdied(struct b
  68. else if (sh.flags & SDPCM_SHARED_ASSERT)
  69. brcmf_err("assertion in dongle\n");
  70. - if (sh.flags & SDPCM_SHARED_TRAP)
  71. + if (sh.flags & SDPCM_SHARED_TRAP) {
  72. brcmf_err("firmware trap in dongle\n");
  73. + brcmf_sdio_trap_info(NULL, bus, &sh);
  74. + }
  75. return 0;
  76. }
  77. @@ -4199,7 +4215,7 @@ static void brcmf_sdio_firmware_callback
  78. } else {
  79. /* Disable F2 again */
  80. sdio_disable_func(sdiod->func2);
  81. - goto release;
  82. + goto checkdied;
  83. }
  84. if (brcmf_chip_sr_capable(bus->ci)) {
  85. @@ -4220,8 +4236,10 @@ static void brcmf_sdio_firmware_callback
  86. }
  87. /* If we didn't come up, turn off backplane clock */
  88. - if (err != 0)
  89. + if (err != 0) {
  90. brcmf_sdio_clkctl(bus, CLK_NONE, false);
  91. + goto checkdied;
  92. + }
  93. sdio_release_host(sdiod->func1);
  94. @@ -4235,12 +4253,15 @@ static void brcmf_sdio_firmware_callback
  95. err = brcmf_attach(sdiod->dev, sdiod->settings);
  96. if (err != 0) {
  97. brcmf_err("brcmf_attach failed\n");
  98. - goto fail;
  99. + sdio_claim_host(sdiod->func1);
  100. + goto checkdied;
  101. }
  102. /* ready */
  103. return;
  104. +checkdied:
  105. + brcmf_sdio_checkdied(bus);
  106. release:
  107. sdio_release_host(sdiod->func1);
  108. fail: