wlan-ap-Telecominfraproject/feeds/ipq95xx/mac80211/patches/qca/831-ath12k-Add-API-to-print-q6-crash-dump.patch
John Crispin 144c5d00f4 ipq95xx/mac80211: update to ATH12.3-CS
Signed-off-by: John Crispin <john@phrozen.org>
2024-02-28 18:56:21 +01:00

145 lines
5.1 KiB
Diff

From 6b9299dc69d7605d99876ecc3ccbea2b3c387567 Mon Sep 17 00:00:00 2001
From: Narendhar Reddy <quic_nare@quicinc.com>
Date: Mon, 4 Sep 2023 16:29:35 +0530
Subject: [PATCH] ath12k: Add API to print q6 crash dump
Added the API to parse the q6 ramdump header from mhi and print
the ram dump info. This crash dump print will be called only for
pci interface.
Signed-off-by: Narendhar Reddy <quic_nare@quicinc.com>
---
drivers/net/wireless/ath/ath12k/coredump.c | 63 +++++++++++++++++++++-
drivers/net/wireless/ath/ath12k/coredump.h | 22 ++++++++
2 files changed, 84 insertions(+), 1 deletion(-)
diff --git a/drivers/net/wireless/ath/ath12k/coredump.c b/drivers/net/wireless/ath/ath12k/coredump.c
index 4fa4482..b4f9605 100644
--- a/drivers/net/wireless/ath/ath12k/coredump.c
+++ b/drivers/net/wireless/ath/ath12k/coredump.c
@@ -185,6 +185,66 @@ ath12k_coredump_get_dump_type(u32 mem_region_type)
return dump_type;
}
+
+static void ath12k_coredump_q6crash_reason(struct ath12k_base *ab)
+{
+ int i = 0;
+ uint64_t coredump_offset = 0;
+ struct ath12k_pci *ar_pci = (struct ath12k_pci *)ab->drv_priv;
+ struct mhi_controller *mhi_ctrl = ar_pci->mhi_ctrl;
+ struct mhi_buf *mhi_buf;
+ struct image_info *rddm_image;
+ struct ath12k_coredump_q6ramdump_header *ramdump_header;
+ struct ath12k_coredump_q6ramdump_entry *ramdump_table;
+ char *msg = NULL;
+ struct pci_dev *pci_dev = ar_pci->pdev;
+
+ rddm_image = mhi_ctrl->rddm_image;
+ mhi_buf = rddm_image->mhi_buf;
+
+ ath12k_info(ab, "CRASHED - [DID:DOMAIN:BUS:SLOT] - %x:%04u:%02u:%02u\n",
+ pci_dev->device, pci_dev->bus->domain_nr,
+ pci_dev->bus->number, PCI_SLOT(pci_dev->devfn));
+
+ /* Get RDDM header size */
+ ramdump_header = (struct ath12k_coredump_q6ramdump_header *)mhi_buf[0].buf;
+ ramdump_table = ramdump_header->ramdump_table;
+ coredump_offset = le32_to_cpu(ramdump_header->header_size);
+
+ /* Traverse ramdump table to get coredump offset */
+ while (i < MAX_RAMDUMP_TABLE_SIZE) {
+ if (!strncmp(ramdump_table->description, COREDUMP_DESC,
+ sizeof(COREDUMP_DESC)) ||
+ !strncmp(ramdump_table->description, Q6_SFR_DESC,
+ sizeof(Q6_SFR_DESC))) {
+ break;
+ }
+ coredump_offset += le64_to_cpu(ramdump_table->size);
+ ramdump_table++;
+ i++;
+ }
+
+ if (i == MAX_RAMDUMP_TABLE_SIZE) {
+ ath12k_warn(ab, "Cannot find '%s' entry in ramdump\n",
+ COREDUMP_DESC);
+ return;
+ }
+
+ /* Locate coredump data from the ramdump segments */
+ for (i = 0; i < rddm_image->entries; i++) {
+ if (coredump_offset < mhi_buf[i].len) {
+ msg = mhi_buf[i].buf + coredump_offset;
+ break;
+ }
+
+ coredump_offset -= mhi_buf[i].len;
+ }
+
+ if (msg && msg[0])
+ ath12k_err(ab, "Fatal error received from wcss!\n%s\n",
+ msg);
+}
+
void ath12k_coredump_download_rddm(struct ath12k_base *ab)
{
struct ath12k_pci *ar_pci = (struct ath12k_pci *)ab->drv_priv;
@@ -203,6 +263,7 @@ void ath12k_coredump_download_rddm(struct ath12k_base *ab)
state = true;
ath12k_mhi_coredump(mhi_ctrl, state);
+ ath12k_coredump_q6crash_reason(ab);
rddm_img = mhi_ctrl->rddm_image;
fw_img = mhi_ctrl->fbc_image;
@@ -448,4 +509,4 @@ send_resp:
ret = ath12k_qmi_m3_dump_upload_done_ind_send(ab, event_data->pdev_id, ret);
if (ret < 0)
ath12k_warn(ab, "qmi M3 dump upload done failed\n");
-}
+}
\ No newline at end of file
diff --git a/drivers/net/wireless/ath/ath12k/coredump.h b/drivers/net/wireless/ath/ath12k/coredump.h
index 6d2f87a..59546cd 100644
--- a/drivers/net/wireless/ath/ath12k/coredump.h
+++ b/drivers/net/wireless/ath/ath12k/coredump.h
@@ -9,6 +9,14 @@
#define ATH12K_FW_CRASH_DUMP_VERSION 1
#define ATH12K_FW_CRASH_DUMP_V2 2
+#define MAX_RAMDUMP_TABLE_SIZE 6
+#define COREDUMP_DESC "Q6-COREDUMP"
+#define Q6_SFR_DESC "Q6-SFR"
+
+#define DESC_STRING_SIZE 20
+#define FILE_NAME_STRING_SIZE 20
+
+
enum ath12k_fw_crash_dump_type {
ATH12K_FW_CRASH_PAGING_DATA,
ATH12K_FW_CRASH_RDDM_DATA,
@@ -81,6 +89,20 @@ struct ath12k_coredump_info {
struct ath12k_coredump_segment_info chip_seg_info[ATH12K_MAX_SOCS];
};
+struct ath12k_coredump_q6ramdump_entry {
+ __le64 base_address;
+ __le64 actual_phys_address;
+ __le64 size;
+ char description[DESC_STRING_SIZE];
+ char file_name[FILE_NAME_STRING_SIZE];
+};
+
+struct ath12k_coredump_q6ramdump_header {
+ __le32 version;
+ __le32 header_size;
+ struct ath12k_coredump_q6ramdump_entry ramdump_table[MAX_RAMDUMP_TABLE_SIZE];
+};
+
#ifdef CONFIG_WANT_DEV_COREDUMP
void ath12k_coredump_download_rddm(struct ath12k_base *ab);
void ath12k_coredump_build_inline(struct ath12k_base *ab,
--
2.17.1