319-v4.12-0001-brcmfmac-always-print-error-when-PSM-s-watchdog-fire.patch 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. From f1ac3aa212af6dd0a36dc07a63f95f91be6f4935 Mon Sep 17 00:00:00 2001
  2. From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
  3. Date: Fri, 24 Feb 2017 17:32:46 +0100
  4. Subject: [PATCH] brcmfmac: always print error when PSM's watchdog fires
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. So far we were attaching BRCMF_E_PSM_WATCHDOG event listener in
  9. brcmf_debug_attach which gets compiled only with CONFIG_BRCMDBG. This
  10. event means something went wrong and firmware / hardware usually can't
  11. be expected to work (reliably).
  12. Such a problem is significant for user experience so I believe we should
  13. print an error unconditionally (even with debugging disabled). What can
  14. be indeed optional is dumping bus memory as this is clearly part of
  15. debugging process.
  16. In the future we may also try to extend this listener by trying to
  17. recover from the error or at least signal it to the cfg80211.
  18. Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
  19. Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
  20. ---
  21. .../wireless/broadcom/brcm80211/brcmfmac/core.c | 22 ++++++++++++++++++
  22. .../wireless/broadcom/brcm80211/brcmfmac/debug.c | 26 +++-------------------
  23. .../wireless/broadcom/brcm80211/brcmfmac/debug.h | 9 ++++++++
  24. 3 files changed, 34 insertions(+), 23 deletions(-)
  25. --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
  26. +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
  27. @@ -748,6 +748,24 @@ void brcmf_remove_interface(struct brcmf
  28. brcmf_del_if(ifp->drvr, ifp->bsscfgidx, rtnl_locked);
  29. }
  30. +static int brcmf_psm_watchdog_notify(struct brcmf_if *ifp,
  31. + const struct brcmf_event_msg *evtmsg,
  32. + void *data)
  33. +{
  34. + int err;
  35. +
  36. + brcmf_dbg(TRACE, "enter: bsscfgidx=%d\n", ifp->bsscfgidx);
  37. +
  38. + brcmf_err("PSM's watchdog has fired!\n");
  39. +
  40. + err = brcmf_debug_create_memdump(ifp->drvr->bus_if, data,
  41. + evtmsg->datalen);
  42. + if (err)
  43. + brcmf_err("Failed to get memory dump, %d\n", err);
  44. +
  45. + return err;
  46. +}
  47. +
  48. #ifdef CONFIG_INET
  49. #define ARPOL_MAX_ENTRIES 8
  50. static int brcmf_inetaddr_changed(struct notifier_block *nb,
  51. @@ -927,6 +945,10 @@ int brcmf_attach(struct device *dev, str
  52. goto fail;
  53. }
  54. + /* Attach to events important for core code */
  55. + brcmf_fweh_register(drvr, BRCMF_E_PSM_WATCHDOG,
  56. + brcmf_psm_watchdog_notify);
  57. +
  58. /* attach firmware event handler */
  59. brcmf_fweh_attach(drvr);
  60. --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.c
  61. +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.c
  62. @@ -27,8 +27,8 @@
  63. static struct dentry *root_folder;
  64. -static int brcmf_debug_create_memdump(struct brcmf_bus *bus, const void *data,
  65. - size_t len)
  66. +int brcmf_debug_create_memdump(struct brcmf_bus *bus, const void *data,
  67. + size_t len)
  68. {
  69. void *dump;
  70. size_t ramsize;
  71. @@ -54,24 +54,6 @@ static int brcmf_debug_create_memdump(st
  72. return 0;
  73. }
  74. -static int brcmf_debug_psm_watchdog_notify(struct brcmf_if *ifp,
  75. - const struct brcmf_event_msg *evtmsg,
  76. - void *data)
  77. -{
  78. - int err;
  79. -
  80. - brcmf_dbg(TRACE, "enter: bsscfgidx=%d\n", ifp->bsscfgidx);
  81. -
  82. - brcmf_err("PSM's watchdog has fired!\n");
  83. -
  84. - err = brcmf_debug_create_memdump(ifp->drvr->bus_if, data,
  85. - evtmsg->datalen);
  86. - if (err)
  87. - brcmf_err("Failed to get memory dump, %d\n", err);
  88. -
  89. - return err;
  90. -}
  91. -
  92. void brcmf_debugfs_init(void)
  93. {
  94. root_folder = debugfs_create_dir(KBUILD_MODNAME, NULL);
  95. @@ -99,9 +81,7 @@ int brcmf_debug_attach(struct brcmf_pub
  96. if (IS_ERR(drvr->dbgfs_dir))
  97. return PTR_ERR(drvr->dbgfs_dir);
  98. -
  99. - return brcmf_fweh_register(drvr, BRCMF_E_PSM_WATCHDOG,
  100. - brcmf_debug_psm_watchdog_notify);
  101. + return 0;
  102. }
  103. void brcmf_debug_detach(struct brcmf_pub *drvr)
  104. --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.h
  105. +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.h
  106. @@ -99,6 +99,7 @@ do { \
  107. extern int brcmf_msg_level;
  108. +struct brcmf_bus;
  109. struct brcmf_pub;
  110. #ifdef DEBUG
  111. void brcmf_debugfs_init(void);
  112. @@ -108,6 +109,8 @@ void brcmf_debug_detach(struct brcmf_pub
  113. struct dentry *brcmf_debugfs_get_devdir(struct brcmf_pub *drvr);
  114. int brcmf_debugfs_add_entry(struct brcmf_pub *drvr, const char *fn,
  115. int (*read_fn)(struct seq_file *seq, void *data));
  116. +int brcmf_debug_create_memdump(struct brcmf_bus *bus, const void *data,
  117. + size_t len);
  118. #else
  119. static inline void brcmf_debugfs_init(void)
  120. {
  121. @@ -128,6 +131,12 @@ int brcmf_debugfs_add_entry(struct brcmf
  122. {
  123. return 0;
  124. }
  125. +static inline
  126. +int brcmf_debug_create_memdump(struct brcmf_bus *bus, const void *data,
  127. + size_t len)
  128. +{
  129. + return 0;
  130. +}
  131. #endif
  132. #endif /* BRCMFMAC_DEBUG_H */