Skip to content

Commit

Permalink
ath10k-ct: Add restart_failed debugfs file.
Browse files Browse the repository at this point in the history
So user-space can detect hung firmware/driver/HW and know it needs
to reboot to recover.

Signed-off-by: Ben Greear <greearb@candelatech.com>
  • Loading branch information
greearb committed Nov 1, 2021
1 parent e6a7d5b commit 3d3450c
Show file tree
Hide file tree
Showing 16 changed files with 141 additions and 1 deletion.
5 changes: 5 additions & 0 deletions ath10k-5.10/core.c
Expand Up @@ -2819,6 +2819,8 @@ static void ath10k_core_restart(struct work_struct *work)

mutex_lock(&ar->conf_mutex);

ar->restart_failed = 0; /* assume good things */

switch (ar->state) {
case ATH10K_STATE_ON:
ar->state = ATH10K_STATE_RESTARTING;
Expand All @@ -2831,6 +2833,7 @@ static void ath10k_core_restart(struct work_struct *work)
* or if the crash happens during FW probing
*/
ath10k_warn(ar, "cannot restart a device that hasn't been started\n");
ar->restart_failed = 1;
break;
case ATH10K_STATE_RESTARTING:
/* hw restart might be requested from multiple places */
Expand All @@ -2840,9 +2843,11 @@ static void ath10k_core_restart(struct work_struct *work)
fallthrough;
case ATH10K_STATE_WEDGED:
ath10k_warn(ar, "device is wedged, will not restart\n");
ar->restart_failed = 2;
break;
case ATH10K_STATE_UTF:
ath10k_warn(ar, "firmware restart in UTF mode not supported\n");
ar->restart_failed = 3;
break;
}

Expand Down
1 change: 1 addition & 0 deletions ath10k-5.10/core.h
Expand Up @@ -1494,6 +1494,7 @@ struct ath10k {
struct sk_buff_head wmi_mgmt_tx_queue;

enum ath10k_state state;
int restart_failed; /* 0: ok, 1: state-off 2: wedged */

struct work_struct register_work;
struct work_struct restart_work;
Expand Down
22 changes: 22 additions & 0 deletions ath10k-5.10/debug.c
Expand Up @@ -1787,6 +1787,25 @@ static const struct file_operations fops_chip_id = {
.llseek = default_llseek,
};

static ssize_t ath10k_read_restart_failed(struct file *file, char __user *user_buf,
size_t count, loff_t *ppos)
{
struct ath10k *ar = file->private_data;
size_t len;
char buf[50];

len = scnprintf(buf, sizeof(buf), "%d\n", ar->restart_failed);

return simple_read_from_buffer(user_buf, count, ppos, buf, len);
}

static const struct file_operations fops_restart_failed = {
.read = ath10k_read_restart_failed,
.open = simple_open,
.owner = THIS_MODULE,
.llseek = default_llseek,
};

static int ath10k_fw_crash_dump_open(struct inode *inode, struct file *file)
{
struct ath10k *ar = inode->i_private;
Expand Down Expand Up @@ -4465,6 +4484,9 @@ int ath10k_debug_register(struct ath10k *ar)
debugfs_create_file("chip_id", 0400, ar->debug.debugfs_phy, ar,
&fops_chip_id);

debugfs_create_file("restart_failed", 0400, ar->debug.debugfs_phy, ar,
&fops_restart_failed);

debugfs_create_file("htt_stats_mask", 0600, ar->debug.debugfs_phy, ar,
&fops_htt_stats_mask);

Expand Down
5 changes: 5 additions & 0 deletions ath10k-5.11/core.c
Expand Up @@ -2877,6 +2877,8 @@ static void ath10k_core_restart(struct work_struct *work)

mutex_lock(&ar->conf_mutex);

ar->restart_failed = 0; /* assume good things */

switch (ar->state) {
case ATH10K_STATE_ON:
ar->state = ATH10K_STATE_RESTARTING;
Expand All @@ -2889,6 +2891,7 @@ static void ath10k_core_restart(struct work_struct *work)
* or if the crash happens during FW probing
*/
ath10k_warn(ar, "cannot restart a device that hasn't been started\n");
ar->restart_failed = 1;
break;
case ATH10K_STATE_RESTARTING:
/* hw restart might be requested from multiple places */
Expand All @@ -2898,9 +2901,11 @@ static void ath10k_core_restart(struct work_struct *work)
fallthrough;
case ATH10K_STATE_WEDGED:
ath10k_warn(ar, "device is wedged, will not restart\n");
ar->restart_failed = 2;
break;
case ATH10K_STATE_UTF:
ath10k_warn(ar, "firmware restart in UTF mode not supported\n");
ar->restart_failed = 3;
break;
}

Expand Down
1 change: 1 addition & 0 deletions ath10k-5.11/core.h
Expand Up @@ -1508,6 +1508,7 @@ struct ath10k {
struct sk_buff_head wmi_mgmt_tx_queue;

enum ath10k_state state;
int restart_failed; /* 0: ok, 1: state-off 2: wedged */

struct work_struct register_work;
struct work_struct restart_work;
Expand Down
22 changes: 22 additions & 0 deletions ath10k-5.11/debug.c
Expand Up @@ -1787,6 +1787,25 @@ static const struct file_operations fops_chip_id = {
.llseek = default_llseek,
};

static ssize_t ath10k_read_restart_failed(struct file *file, char __user *user_buf,
size_t count, loff_t *ppos)
{
struct ath10k *ar = file->private_data;
size_t len;
char buf[50];

len = scnprintf(buf, sizeof(buf), "%d\n", ar->restart_failed);

return simple_read_from_buffer(user_buf, count, ppos, buf, len);
}

static const struct file_operations fops_restart_failed = {
.read = ath10k_read_restart_failed,
.open = simple_open,
.owner = THIS_MODULE,
.llseek = default_llseek,
};

static int ath10k_fw_crash_dump_open(struct inode *inode, struct file *file)
{
struct ath10k *ar = inode->i_private;
Expand Down Expand Up @@ -4483,6 +4502,9 @@ int ath10k_debug_register(struct ath10k *ar)
debugfs_create_file("chip_id", 0400, ar->debug.debugfs_phy, ar,
&fops_chip_id);

debugfs_create_file("restart_failed", 0400, ar->debug.debugfs_phy, ar,
&fops_restart_failed);

debugfs_create_file("htt_stats_mask", 0600, ar->debug.debugfs_phy, ar,
&fops_htt_stats_mask);

Expand Down
5 changes: 5 additions & 0 deletions ath10k-5.12/core.c
Expand Up @@ -2893,6 +2893,8 @@ static void ath10k_core_restart(struct work_struct *work)

mutex_lock(&ar->conf_mutex);

ar->restart_failed = 0; /* assume good things */

switch (ar->state) {
case ATH10K_STATE_ON:
ar->state = ATH10K_STATE_RESTARTING;
Expand All @@ -2905,6 +2907,7 @@ static void ath10k_core_restart(struct work_struct *work)
* or if the crash happens during FW probing
*/
ath10k_warn(ar, "cannot restart a device that hasn't been started\n");
ar->restart_failed = 1;
break;
case ATH10K_STATE_RESTARTING:
/* hw restart might be requested from multiple places */
Expand All @@ -2914,9 +2917,11 @@ static void ath10k_core_restart(struct work_struct *work)
fallthrough;
case ATH10K_STATE_WEDGED:
ath10k_warn(ar, "device is wedged, will not restart\n");
ar->restart_failed = 2;
break;
case ATH10K_STATE_UTF:
ath10k_warn(ar, "firmware restart in UTF mode not supported\n");
ar->restart_failed = 3;
break;
}

Expand Down
1 change: 1 addition & 0 deletions ath10k-5.12/core.h
Expand Up @@ -1507,6 +1507,7 @@ struct ath10k {
struct sk_buff_head wmi_mgmt_tx_queue;

enum ath10k_state state;
int restart_failed; /* 0: ok, 1: state-off 2: wedged */

struct work_struct register_work;
struct work_struct restart_work;
Expand Down
22 changes: 22 additions & 0 deletions ath10k-5.12/debug.c
Expand Up @@ -1787,6 +1787,25 @@ static const struct file_operations fops_chip_id = {
.llseek = default_llseek,
};

static ssize_t ath10k_read_restart_failed(struct file *file, char __user *user_buf,
size_t count, loff_t *ppos)
{
struct ath10k *ar = file->private_data;
size_t len;
char buf[50];

len = scnprintf(buf, sizeof(buf), "%d\n", ar->restart_failed);

return simple_read_from_buffer(user_buf, count, ppos, buf, len);
}

static const struct file_operations fops_restart_failed = {
.read = ath10k_read_restart_failed,
.open = simple_open,
.owner = THIS_MODULE,
.llseek = default_llseek,
};

static int ath10k_fw_crash_dump_open(struct inode *inode, struct file *file)
{
struct ath10k *ar = inode->i_private;
Expand Down Expand Up @@ -4483,6 +4502,9 @@ int ath10k_debug_register(struct ath10k *ar)
debugfs_create_file("chip_id", 0400, ar->debug.debugfs_phy, ar,
&fops_chip_id);

debugfs_create_file("restart_failed", 0400, ar->debug.debugfs_phy, ar,
&fops_restart_failed);

debugfs_create_file("htt_stats_mask", 0600, ar->debug.debugfs_phy, ar,
&fops_htt_stats_mask);

Expand Down
5 changes: 5 additions & 0 deletions ath10k-5.13/core.c
Expand Up @@ -2893,6 +2893,8 @@ static void ath10k_core_restart(struct work_struct *work)

mutex_lock(&ar->conf_mutex);

ar->restart_failed = 0; /* assume good things */

switch (ar->state) {
case ATH10K_STATE_ON:
ar->state = ATH10K_STATE_RESTARTING;
Expand All @@ -2905,6 +2907,7 @@ static void ath10k_core_restart(struct work_struct *work)
* or if the crash happens during FW probing
*/
ath10k_warn(ar, "cannot restart a device that hasn't been started\n");
ar->restart_failed = 1;
break;
case ATH10K_STATE_RESTARTING:
/* hw restart might be requested from multiple places */
Expand All @@ -2914,9 +2917,11 @@ static void ath10k_core_restart(struct work_struct *work)
fallthrough;
case ATH10K_STATE_WEDGED:
ath10k_warn(ar, "device is wedged, will not restart\n");
ar->restart_failed = 2;
break;
case ATH10K_STATE_UTF:
ath10k_warn(ar, "firmware restart in UTF mode not supported\n");
ar->restart_failed = 3;
break;
}

Expand Down
1 change: 1 addition & 0 deletions ath10k-5.13/core.h
Expand Up @@ -1507,6 +1507,7 @@ struct ath10k {
struct sk_buff_head wmi_mgmt_tx_queue;

enum ath10k_state state;
int restart_failed; /* 0: ok, 1: state-off 2: wedged */

struct work_struct register_work;
struct work_struct restart_work;
Expand Down
22 changes: 22 additions & 0 deletions ath10k-5.13/debug.c
Expand Up @@ -1787,6 +1787,25 @@ static const struct file_operations fops_chip_id = {
.llseek = default_llseek,
};

static ssize_t ath10k_read_restart_failed(struct file *file, char __user *user_buf,
size_t count, loff_t *ppos)
{
struct ath10k *ar = file->private_data;
size_t len;
char buf[50];

len = scnprintf(buf, sizeof(buf), "%d\n", ar->restart_failed);

return simple_read_from_buffer(user_buf, count, ppos, buf, len);
}

static const struct file_operations fops_restart_failed = {
.read = ath10k_read_restart_failed,
.open = simple_open,
.owner = THIS_MODULE,
.llseek = default_llseek,
};

static int ath10k_fw_crash_dump_open(struct inode *inode, struct file *file)
{
struct ath10k *ar = inode->i_private;
Expand Down Expand Up @@ -4483,6 +4502,9 @@ int ath10k_debug_register(struct ath10k *ar)
debugfs_create_file("chip_id", 0400, ar->debug.debugfs_phy, ar,
&fops_chip_id);

debugfs_create_file("restart_failed", 0400, ar->debug.debugfs_phy, ar,
&fops_restart_failed);

debugfs_create_file("htt_stats_mask", 0600, ar->debug.debugfs_phy, ar,
&fops_htt_stats_mask);

Expand Down
2 changes: 1 addition & 1 deletion ath10k-5.15/Kconfig
Expand Up @@ -44,7 +44,7 @@ config ATH10K_SNOC
tristate "Qualcomm ath10k SNOC support"
depends on ATH10K
depends on ARCH_QCOM || COMPILE_TEST
depends on QCOM_SCM || !QCOM_SCM #if QCOM_SCM=m this can't be =y
select QCOM_SCM
select QCOM_QMI_HELPERS
help
This module adds support for integrated WCN3990 chip connected
Expand Down
5 changes: 5 additions & 0 deletions ath10k-5.15/core.c
Expand Up @@ -2894,6 +2894,8 @@ static void ath10k_core_restart(struct work_struct *work)

mutex_lock(&ar->conf_mutex);

ar->restart_failed = 0; /* assume good things */

switch (ar->state) {
case ATH10K_STATE_ON:
ar->state = ATH10K_STATE_RESTARTING;
Expand All @@ -2906,6 +2908,7 @@ static void ath10k_core_restart(struct work_struct *work)
* or if the crash happens during FW probing
*/
ath10k_warn(ar, "cannot restart a device that hasn't been started\n");
ar->restart_failed = 1;
break;
case ATH10K_STATE_RESTARTING:
/* hw restart might be requested from multiple places */
Expand All @@ -2915,9 +2918,11 @@ static void ath10k_core_restart(struct work_struct *work)
fallthrough;
case ATH10K_STATE_WEDGED:
ath10k_warn(ar, "device is wedged, will not restart\n");
ar->restart_failed = 2;
break;
case ATH10K_STATE_UTF:
ath10k_warn(ar, "firmware restart in UTF mode not supported\n");
ar->restart_failed = 3;
break;
}

Expand Down
1 change: 1 addition & 0 deletions ath10k-5.15/core.h
Expand Up @@ -1507,6 +1507,7 @@ struct ath10k {
struct sk_buff_head wmi_mgmt_tx_queue;

enum ath10k_state state;
int restart_failed; /* 0: ok, 1: state-off 2: wedged */

struct work_struct register_work;
struct work_struct restart_work;
Expand Down
22 changes: 22 additions & 0 deletions ath10k-5.15/debug.c
Expand Up @@ -1787,6 +1787,25 @@ static const struct file_operations fops_chip_id = {
.llseek = default_llseek,
};

static ssize_t ath10k_read_restart_failed(struct file *file, char __user *user_buf,
size_t count, loff_t *ppos)
{
struct ath10k *ar = file->private_data;
size_t len;
char buf[50];

len = scnprintf(buf, sizeof(buf), "%d\n", ar->restart_failed);

return simple_read_from_buffer(user_buf, count, ppos, buf, len);
}

static const struct file_operations fops_restart_failed = {
.read = ath10k_read_restart_failed,
.open = simple_open,
.owner = THIS_MODULE,
.llseek = default_llseek,
};

static int ath10k_fw_crash_dump_open(struct inode *inode, struct file *file)
{
struct ath10k *ar = inode->i_private;
Expand Down Expand Up @@ -4483,6 +4502,9 @@ int ath10k_debug_register(struct ath10k *ar)
debugfs_create_file("chip_id", 0400, ar->debug.debugfs_phy, ar,
&fops_chip_id);

debugfs_create_file("restart_failed", 0400, ar->debug.debugfs_phy, ar,
&fops_restart_failed);

debugfs_create_file("htt_stats_mask", 0600, ar->debug.debugfs_phy, ar,
&fops_htt_stats_mask);

Expand Down

0 comments on commit 3d3450c

Please sign in to comment.