Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 81e002d2 authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

Merge "dsp: add support to crash device when send APR CMD to ADSP timed out"

parents 49ed1e3b d7ea6283
Loading
Loading
Loading
Loading
+30 −1
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (c) 2013-2020, Linux Foundation. All rights reserved.
 * Copyright (c) 2013-2021, Linux Foundation. All rights reserved.
 */
#include <linux/fs.h>
#include <linux/mutex.h>
@@ -63,6 +63,12 @@ struct lsm_common {
	struct cal_type_data	*cal_data[LSM_MAX_CAL_IDX];

	struct mutex apr_lock;

#ifdef CONFIG_DEBUG_FS
	/* Debugfs related */
	struct dentry *entry;
	bool panic_on_timeout;
#endif
};

static struct lsm_common lsm_common;
@@ -508,6 +514,13 @@ static int q6lsm_apr_send_pkt(struct lsm_client *client, void *handle,
				__func__, msg_hdr->opcode, msg_hdr->pkt_size);
			/* ret = 0 means wait timed out */
			ret = -ETIMEDOUT;
#ifdef CONFIG_DEBUG_FS
			/*
			 * If panic_on_timeout flag is explicitly set through the debugfs,
			 * then trigger a device crash here to aid debugging.
			 */
			BUG_ON(lsm_common.panic_on_timeout);
#endif
		}
	} else {
		ret = 0;
@@ -3071,10 +3084,26 @@ int __init q6lsm_init(void)
	if (q6lsm_init_cal_data())
		pr_err("%s: could not init cal data!\n", __func__);

#ifdef CONFIG_DEBUG_FS
	lsm_common.entry = debugfs_create_dir("q6lsm_apr", NULL);
	if (!IS_ERR_OR_NULL(lsm_common.entry)) {
		if (IS_ERR(debugfs_create_bool("panic_on_timeout", 0644,
					       lsm_common.entry,
					       &lsm_common.panic_on_timeout)))
			lsm_common.panic_on_timeout = false;
		else
			pr_info("%s: panic_on_timeout debugfs flag is created\n", __func__);
	}
#endif
	return 0;
}

void q6lsm_exit(void)
{
	lsm_delete_cal_data();

#ifdef CONFIG_DEBUG_FS
	debugfs_remove_recursive(lsm_common.entry);
	lsm_common.entry = NULL;
#endif
}