linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: silexcommon@gmail.com
To: ath10k@lists.infradead.org
Cc: linux-wireless@vger.kernel.org,
	Alagu Sankar <alagusankar@silex-india.com>
Subject: [PATCH 10/11] ath10k_sdio: enable firmware crash dump
Date: Sat, 30 Sep 2017 23:07:47 +0530	[thread overview]
Message-ID: <1506793068-27445-11-git-send-email-alagusankar@silex-india.com> (raw)
In-Reply-To: <1506793068-27445-1-git-send-email-alagusankar@silex-india.com>

From: Alagu Sankar <alagusankar@silex-india.com>

Handle firmware crash and gracefully restart the sdio driver on firmware
failures.  The caldata prefetch is disabled for sdio as the data read in
prefetch is resulting in errors, when enabled.

Signed-off-by: Alagu Sankar <alagusankar@silex-india.com>
---
 drivers/net/wireless/ath/ath10k/debug.c |  3 ++
 drivers/net/wireless/ath/ath10k/sdio.c  | 86 +++++++++++++++++++++++++++++++++
 2 files changed, 89 insertions(+)

diff --git a/drivers/net/wireless/ath/ath10k/debug.c b/drivers/net/wireless/ath/ath10k/debug.c
index eed4e9c..3a1982f 100644
--- a/drivers/net/wireless/ath/ath10k/debug.c
+++ b/drivers/net/wireless/ath/ath10k/debug.c
@@ -1255,6 +1255,9 @@ static int ath10k_debug_cal_data_fetch(struct ath10k *ar)
 	if (WARN_ON(ar->hw_params.cal_data_len > ATH10K_DEBUG_CAL_DATA_LEN))
 		return -EINVAL;
 
+	if (ar->hif.bus == ATH10K_BUS_SDIO)
+		return -EINVAL;
+
 	hi_addr = host_interest_item_address(HI_ITEM(hi_board_data));
 
 	ret = ath10k_hif_diag_read(ar, hi_addr, &addr, sizeof(addr));
diff --git a/drivers/net/wireless/ath/ath10k/sdio.c b/drivers/net/wireless/ath/ath10k/sdio.c
index 45df9db..11fbf6e 100644
--- a/drivers/net/wireless/ath/ath10k/sdio.c
+++ b/drivers/net/wireless/ath/ath10k/sdio.c
@@ -28,6 +28,7 @@
 #include "core.h"
 #include "bmi.h"
 #include "debug.h"
+#include "coredump.h"
 #include "hif.h"
 #include "htc.h"
 #include "targaddrs.h"
@@ -37,6 +38,8 @@
 #define ATH10K_SDIO_DMA_BUF_SIZE	(32 * 1024)
 #define ATH10K_SDIO_VSG_BUF_SIZE	(32 * 1024)
 
+static int ath10k_sdio_hif_diag_read(struct ath10k *ar, u32 address, void *buf,
+				     size_t buf_len);
 static int ath10k_sdio_read(struct ath10k *ar, u32 addr, void *buf,
 			    u32 len, bool incr);
 static int ath10k_sdio_write(struct ath10k *ar, u32 addr, const void *buf,
@@ -810,6 +813,86 @@ static int ath10k_sdio_mbox_rxmsg_pending_handler(struct ath10k *ar,
 	return ret;
 }
 
+static int __ath10k_sdio_diag_read_hi(struct ath10k *ar, void *dest, u32 src,
+				      u32 len)
+{
+	u32 host_addr, addr;
+	int ret;
+
+	host_addr = host_interest_item_address(src);
+
+	ret = ath10k_sdio_hif_diag_read(ar, host_addr, &addr, sizeof(addr));
+	if (ret != 0) {
+		ath10k_warn(ar, "failed to get firmware hi address %d: %d\n",
+			    src, ret);
+		return ret;
+	}
+
+	ret = ath10k_sdio_hif_diag_read(ar, addr, dest, len);
+	if (ret != 0) {
+		ath10k_warn(ar, "failed to copy memory from %d (%d B): %d\n",
+			    addr, len, ret);
+		return ret;
+	}
+
+	return 0;
+}
+
+#define ath10k_sdio_diag_read_hi(ar, dest, src, len)		\
+	__ath10k_sdio_diag_read_hi(ar, dest, HI_ITEM(src), len)
+
+static void ath10k_sdio_dump_registers(struct ath10k *ar,
+				       struct ath10k_fw_crash_data *crash_data)
+{
+	__le32 reg_dump_values[REG_DUMP_COUNT_QCA988X] = {};
+	int i, ret;
+
+	ret = ath10k_sdio_diag_read_hi(ar, &reg_dump_values[0],
+				       hi_failure_state,
+				       sizeof(reg_dump_values));
+	if (ret) {
+		ath10k_err(ar, "failed to read firmware dump area: %d\n", ret);
+		return;
+	}
+
+	BUILD_BUG_ON(REG_DUMP_COUNT_QCA988X % 4);
+
+	ath10k_err(ar, "firmware register dump:\n");
+	for (i = 0; i < REG_DUMP_COUNT_QCA988X; i += 4)
+		ath10k_err(ar, "[%02d]: 0x%08X 0x%08X 0x%08X 0x%08X\n",
+			   i,
+			   __le32_to_cpu(reg_dump_values[i]),
+			   __le32_to_cpu(reg_dump_values[i + 1]),
+			   __le32_to_cpu(reg_dump_values[i + 2]),
+			   __le32_to_cpu(reg_dump_values[i + 3]));
+
+	if (!crash_data)
+		return;
+
+	for (i = 0; i < REG_DUMP_COUNT_QCA988X; i++)
+		crash_data->registers[i] = reg_dump_values[i];
+}
+
+static void ath10k_sdio_fw_crashed_dump(struct ath10k *ar)
+{
+	struct ath10k_fw_crash_data *crash_data;
+	char guid[UUID_STRING_LEN + 1];
+
+	ar->stats.fw_crash_counter++;
+	crash_data = ath10k_coredump_new(ar);
+
+	if (crash_data)
+		scnprintf(guid, sizeof(guid), "%pUl", &crash_data->guid);
+	else
+		scnprintf(guid, sizeof(guid), "n/a");
+
+	ath10k_err(ar, "firmware crashed! (guid %s)\n", guid);
+	ath10k_print_driver_info(ar);
+	ath10k_sdio_dump_registers(ar, crash_data);
+
+	queue_work(ar->workqueue, &ar->restart_work);
+}
+
 static int ath10k_sdio_mbox_proc_dbg_intr(struct ath10k *ar)
 {
 	u32 val;
@@ -933,6 +1016,9 @@ static int ath10k_sdio_mbox_proc_cpu_intr(struct ath10k *ar)
 		goto out;
 	}
 
+	if (cpu_int_status & 0x1)
+		ath10k_sdio_fw_crashed_dump(ar);
+
 out:
 	mutex_unlock(&irq_data->mtx);
 	return ret;
-- 
1.9.1

  parent reply	other threads:[~2017-09-30 17:38 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-30 17:37 [PATCH 00/11] SDIO support for ath10k silexcommon
2017-09-30 17:37 ` [PATCH 01/11] ath10k_sdio: sdio htt data transfer fixes silexcommon
2017-10-02  7:36   ` Arend van Spriel
2017-10-02  7:44     ` Alagu Sankar
2017-10-04  8:55     ` Kalle Valo
2017-09-30 17:37 ` [PATCH 02/11] ath10k_sdio: wb396 reference card fix silexcommon
2017-10-01 22:47   ` Steve deRosier
2017-10-02  7:02     ` Alagu Sankar
2017-10-02  9:06       ` Erik Stromdahl
2017-09-30 17:37 ` [PATCH 03/11] ath10k_sdio: DMA bounce buffers for read write silexcommon
2017-12-22 16:08   ` Kalle Valo
2017-12-25 12:26     ` Alagu Sankar
2017-12-25 16:11       ` Adrian Chadd
2017-12-27 18:49       ` Arend van Spriel
2017-12-27 19:26         ` Adrian Chadd
2018-01-08 12:58       ` Kalle Valo
2017-09-30 17:37 ` [PATCH 04/11] ath10k_sdio: reduce transmit msdu count silexcommon
2017-09-30 17:37 ` [PATCH 05/11] ath10k_sdio: use clean packet headers silexcommon
2017-09-30 17:37 ` [PATCH 06/11] ath10k_sdio: high latency fixes for beacon buffer silexcommon
2017-09-30 17:37 ` [PATCH 07/11] ath10k_sdio: fix rssi indication silexcommon
2017-09-30 17:37 ` [PATCH 08/11] ath10k_sdio: common read write silexcommon
2017-10-04  9:49   ` Kalle Valo
2017-10-05 10:09   ` [08/11] " Gary Bisson
2017-10-05 17:33     ` Alagu Sankar
2017-12-08 14:42       ` Gary Bisson
2017-09-30 17:37 ` [PATCH 09/11] ath10k_sdio: virtual scatter gather for receive silexcommon
2017-10-04 19:56   ` Erik Stromdahl
2017-09-30 17:37 ` silexcommon [this message]
2017-09-30 17:37 ` [PATCH 11/11] ath10k_sdio: hif start once addition silexcommon
2017-10-02  9:02 ` [PATCH 00/11] SDIO support for ath10k Erik Stromdahl
2017-10-04  6:22   ` Alagu Sankar
2017-10-04 15:53     ` Erik Stromdahl
2017-10-05 15:12 ` Gary Bisson
2017-10-05 17:24   ` Alagu Sankar
2017-10-06 11:16     ` Gary Bisson
2017-12-18 16:19       ` Gary Bisson
2017-12-22 16:21         ` Kalle Valo
2017-12-22 16:25 ` Kalle Valo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1506793068-27445-11-git-send-email-alagusankar@silex-india.com \
    --to=silexcommon@gmail.com \
    --cc=alagusankar@silex-india.com \
    --cc=ath10k@lists.infradead.org \
    --cc=linux-wireless@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).