wlan-ap-Telecominfraproject/feeds/wifi-ax/mac80211/patches/qca/031-ath11k-print-stats-on-crash.patch
John Crispin 528a778e38 open-converged-wireless: Import 21.02 based uCentral tree
Signed-off-by: John Crispin <john@phrozen.org>
2021-03-25 12:19:47 +01:00

141 lines
4.1 KiB
Diff

--- a/drivers/net/wireless/ath/ath11k/core.c
+++ b/drivers/net/wireless/ath/ath11k/core.c
@@ -570,6 +570,51 @@ err_firmware_stop:
return ret;
}
+#ifdef CONFIG_QCOM_QMI_HELPERS
+
+void ath11k_core_dump_bp_stats(struct ath11k_base *ab)
+{
+ int len = 0;
+ const int size = 4096;
+ char *buf;
+
+ buf = kzalloc(size, GFP_KERNEL);
+ if (!buf)
+ return;
+
+ len = ath11k_debug_dump_soc_ring_bp_stats(ab, buf, size - 1);
+
+ buf[len] = '\0';
+
+ ath11k_info(ab, "ATH11K Driver Stats\n%s\n", buf);
+
+ kfree(buf);
+}
+
+/* Print the driver stats and crash the system on receving this notification */
+int ath11k_core_ssr_notifier_cb(struct notifier_block *nb, unsigned long event,
+ void *data)
+{
+ struct ath11k_qmi *qmi = container_of(nb, struct ath11k_qmi, ssr_nb);
+
+ if (test_bit(ATH11K_FLAG_FW_RESTART_FOR_HOST, &qmi->ab->dev_flags)) {
+ return 0;
+ }
+ /* TODO: currently wcss uses "rproc" as its name, but since this might be
+ * changed to correspondig name, the name is not compared now. Print the stats
+ * only if the notification is received for the expected rproc */
+
+ ath11k_core_dump_bp_stats(qmi->ab);
+ ath11k_hal_dump_srng_stats(qmi->ab);
+ /* TODO Add more driver stats */
+
+ /* Crash the system once all the stats are dumped */
+ BUG_ON(1);
+
+ return 0;
+}
+#endif
+
int ath11k_core_qmi_firmware_ready(struct ath11k_base *ab)
{
int ret;
@@ -615,6 +660,16 @@ int ath11k_core_qmi_firmware_ready(struc
ath11k_err(ab, "failed to create pdev core: %d\n", ret);
goto err_core_stop;
}
+
+#ifdef CONFIG_QCOM_QMI_HELPERS
+ /* Register a notifier after mac registration
+ * to be called on fw crash
+ */
+ if (ab->hif.bus == ATH11K_BUS_AHB) {
+ ab->qmi.ssr_nb.notifier_call = ath11k_core_ssr_notifier_cb;
+ qcom_register_ssr_notifier(&ab->qmi.ssr_nb);
+ }
+#endif
ath11k_hif_irq_enable(ab);
mutex_unlock(&ab->core_lock);
@@ -864,6 +919,13 @@ void ath11k_core_deinit(struct ath11k_ba
{
mutex_lock(&ab->core_lock);
+#ifdef CONFIG_QCOM_QMI_HELPERS
+ /* Unregister the ssr notifier as we are not intersted
+ * in receving these notifications after mac is unregistered.
+ */
+ if (ab->hif.bus == ATH11K_BUS_AHB)
+ qcom_unregister_ssr_notifier(&ab->qmi.ssr_nb);
+#endif
ath11k_core_pdev_destroy(ab);
ath11k_core_stop(ab);
--- a/drivers/net/wireless/ath/ath11k/debug.c
+++ b/drivers/net/wireless/ath/ath11k/debug.c
@@ -803,7 +803,7 @@ static int ath11k_fill_bp_stats(struct a
return len;
}
-static ssize_t ath11k_debug_dump_soc_ring_bp_stats(struct ath11k_base *ab,
+ssize_t ath11k_debug_dump_soc_ring_bp_stats(struct ath11k_base *ab,
char *buf, int size)
{
struct ath11k_bp_stats *bp_stats;
--- a/drivers/net/wireless/ath/ath11k/debug.h
+++ b/drivers/net/wireless/ath/ath11k/debug.h
@@ -166,7 +166,8 @@ void ath11k_debug_fw_stats_process(struc
void ath11k_debug_fw_stats_init(struct ath11k *ar);
int ath11k_dbg_htt_stats_req(struct ath11k *ar);
-
+ssize_t ath11k_debug_dump_soc_ring_bp_stats(struct ath11k_base *ab,
+ char *buf, int size);
static inline bool ath11k_debug_is_pktlog_lite_mode_enabled(struct ath11k *ar)
{
return (ar->debug.pktlog_mode == ATH11K_PKTLOG_MODE_LITE);
@@ -297,6 +298,11 @@ ath11k_update_per_peer_stats_from_txcomp
struct hal_tx_status *ts)
{
}
+ssize_t ath11k_debug_dump_soc_ring_bp_stats(struct ath11k_base *ab,
+ char *buf, int size)
+{
+ return 0;
+}
#endif /* CPTCFG_MAC80211_DEBUGFS*/
--- a/drivers/net/wireless/ath/ath11k/qmi.h
+++ b/drivers/net/wireless/ath/ath11k/qmi.h
@@ -7,7 +7,9 @@
#define ATH11K_QMI_H
#include <linux/mutex.h>
+#include <linux/notifier.h>
#include <linux/soc/qcom/qmi.h>
+#include <linux/remoteproc/qcom_rproc.h>
#define ATH11K_HOST_VERSION_STRING "WIN"
#define ATH11K_QMI_WLANFW_TIMEOUT_MS 5000
@@ -118,6 +120,7 @@ struct ath11k_qmi {
struct workqueue_struct *event_wq;
struct list_head event_list;
spinlock_t event_lock; /* spinlock for qmi event list */
+ struct notifier_block ssr_nb;
struct ath11k_qmi_ce_cfg ce_cfg;
struct target_mem_chunk target_mem[ATH11K_QMI_WLANFW_MAX_NUM_MEM_SEG_V01];
u32 mem_seg_count;