diff mbox

ath10k: Support firmware crash-by-assert.

Message ID 1409238957-30625-1-git-send-email-greearb@candelatech.com (mailing list archive)
State Not Applicable, archived
Headers show

Commit Message

Ben Greear Aug. 28, 2014, 3:15 p.m. UTC
From: Ben Greear <greearb@candelatech.com>

10.1 firmware does not have an official way to
cause assert on purpose, but it can be done with
carefully crafted WMI command.  This is a different
kind of crash from the 'hard' crash, which is
a bad memory dereference.

Different crashes decode in different manners, so
this will help the crash-report testing as well as
offer better ways to test firmware failure and
recovery.

Signed-off-by: Ben Greear <greearb@candelatech.com>
---
 drivers/net/wireless/ath/ath10k/debug.c |  8 +++++++-
 drivers/net/wireless/ath/ath10k/wmi.c   | 20 ++++++++++++++++++++
 drivers/net/wireless/ath/ath10k/wmi.h   |  1 +
 3 files changed, 28 insertions(+), 1 deletion(-)

Comments

Kalle Valo Sept. 10, 2014, 3:53 p.m. UTC | #1
greearb@candelatech.com writes:

> From: Ben Greear <greearb@candelatech.com>
>
> 10.1 firmware does not have an official way to
> cause assert on purpose, but it can be done with
> carefully crafted WMI command.  This is a different
> kind of crash from the 'hard' crash, which is
> a bad memory dereference.
>
> Different crashes decode in different manners, so
> this will help the crash-report testing as well as
> offer better ways to test firmware failure and
> recovery.
>
> Signed-off-by: Ben Greear <greearb@candelatech.com>

[...]

> --- a/drivers/net/wireless/ath/ath10k/wmi.c
> +++ b/drivers/net/wireless/ath/ath10k/wmi.c
> @@ -3725,6 +3725,26 @@ int ath10k_wmi_vdev_install_key(struct ath10k *ar,
>  				   ar->wmi.cmd->vdev_install_key_cmdid);
>  }
>  
> +int ath10k_wmi_vdev_assert(struct ath10k *ar, u32 crashme)
> +{
> +	struct wmi_vdev_install_key_cmd *cmd;
> +	struct sk_buff *skb;
> +
> +	skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd) + 16);
> +	if (!skb)
> +		return -ENOMEM;
> +
> +	cmd = (struct wmi_vdev_install_key_cmd *)skb->data;
> +	memset(cmd, 0, sizeof(*cmd));
> +	cmd->vdev_id = __cpu_to_le32(crashme);
> +
> +	ath10k_info(ar,
> +		    "simulating firmware ASSERT with bad install_key vdev-id: 0x%x\n",
> +		    cmd->vdev_id);

cmd->vdev_id is in little endian here.

> +	return ath10k_wmi_cmd_send(ar, skb,
> +				   ar->wmi.cmd->vdev_install_key_cmdid);
> +}

As this is not a real WMI command, I would actually prefer to have this
in debug.c. With my patch "ath10k: make ath10k_wmi_cmd_send() public"
that's possible now.

I can do the changes and will send v2 shortly. Just need to test it
first.
diff mbox

Patch

diff --git a/drivers/net/wireless/ath/ath10k/debug.c b/drivers/net/wireless/ath/ath10k/debug.c
index 8da3d57..01ff6fb 100644
--- a/drivers/net/wireless/ath/ath10k/debug.c
+++ b/drivers/net/wireless/ath/ath10k/debug.c
@@ -580,7 +580,10 @@  static ssize_t ath10k_read_simulate_fw_crash(struct file *file,
 			   " WMI_FORCE_FW_HANG_ASSERT to firmware if FW"
 			   " supports that command.\n `hard` - this will send"
 			   " to firmware command with illegal parameters"
-			   " causing firmware crash.\n";
+			   " causing firmware crash.\n"
+			   "`assert` - this will send special illegal parameter"
+			   " to firmware to cause assert failure"
+			   " and crash.\n";
 
 	return simple_read_from_buffer(user_buf, count, ppos, buf, strlen(buf));
 }
@@ -629,6 +632,9 @@  static ssize_t ath10k_write_simulate_fw_crash(struct file *file,
 		 */
 		ret = ath10k_wmi_vdev_set_param(ar, 0x7fff,
 					ar->wmi.vdev_param->rts_threshold, 0);
+	} else if (!strcmp(buf, "assert")) {
+		/* This is a clean assert crash. */
+		ret = ath10k_wmi_vdev_assert(ar, 0x7ffe);
 	} else {
 		ret = -EINVAL;
 		goto exit;
diff --git a/drivers/net/wireless/ath/ath10k/wmi.c b/drivers/net/wireless/ath/ath10k/wmi.c
index 5d96926..ac32b22 100644
--- a/drivers/net/wireless/ath/ath10k/wmi.c
+++ b/drivers/net/wireless/ath/ath10k/wmi.c
@@ -3725,6 +3725,26 @@  int ath10k_wmi_vdev_install_key(struct ath10k *ar,
 				   ar->wmi.cmd->vdev_install_key_cmdid);
 }
 
+int ath10k_wmi_vdev_assert(struct ath10k *ar, u32 crashme)
+{
+	struct wmi_vdev_install_key_cmd *cmd;
+	struct sk_buff *skb;
+
+	skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd) + 16);
+	if (!skb)
+		return -ENOMEM;
+
+	cmd = (struct wmi_vdev_install_key_cmd *)skb->data;
+	memset(cmd, 0, sizeof(*cmd));
+	cmd->vdev_id = __cpu_to_le32(crashme);
+
+	ath10k_info(ar,
+		    "simulating firmware ASSERT with bad install_key vdev-id: 0x%x\n",
+		    cmd->vdev_id);
+	return ath10k_wmi_cmd_send(ar, skb,
+				   ar->wmi.cmd->vdev_install_key_cmdid);
+}
+
 int ath10k_wmi_vdev_spectral_conf(struct ath10k *ar,
 				  const struct wmi_vdev_spectral_conf_arg *arg)
 {
diff --git a/drivers/net/wireless/ath/ath10k/wmi.h b/drivers/net/wireless/ath/ath10k/wmi.h
index eae0105..45836cc 100644
--- a/drivers/net/wireless/ath/ath10k/wmi.h
+++ b/drivers/net/wireless/ath/ath10k/wmi.h
@@ -4774,6 +4774,7 @@  int ath10k_wmi_vdev_set_param(struct ath10k *ar, u32 vdev_id,
 			      u32 param_id, u32 param_value);
 int ath10k_wmi_vdev_install_key(struct ath10k *ar,
 				const struct wmi_vdev_install_key_arg *arg);
+int ath10k_wmi_vdev_assert(struct ath10k *ar, u32 crashme);
 int ath10k_wmi_vdev_spectral_conf(struct ath10k *ar,
 				  const struct wmi_vdev_spectral_conf_arg *arg);
 int ath10k_wmi_vdev_spectral_enable(struct ath10k *ar, u32 vdev_id, u32 trigger,