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

Commit 1f95a551 authored by Bhalchandra Gajare's avatar Bhalchandra Gajare Committed by Banajit Goswami
Browse files

ASoC: wcd-dsp-mgr: force crash upon collecting ramdumps



In case of WDSP fatal errors, subsystem restart is done to reset the
WDSP. Currently, the driver performs subsystem restart silently and
does not cause devie crash. Add debugfs property 'panic_on_error'
to indicate the driver to induce BUG_ON to aid debugging. The BUG_ON
is done only when the debugfs property is explicity set through
debugfs. If not set, the driver will continue without crashing. The
below command can be used to set the debugfs property.

echo Y > /sys/kernel/debug/wdsp_mgr/panic_on_error

CRs-fixed: 2029058
Change-Id: I1442cc59e1819c3b0abd4c4776f4b32ba63d59e2
Signed-off-by: default avatarBhalchandra Gajare <gajare@codeaurora.org>
parent 191ff2f4
Loading
Loading
Loading
Loading
+31 −0
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@
#include <linux/slab.h>
#include <linux/stringify.h>
#include <linux/of.h>
#include <linux/debugfs.h>
#include <linux/component.h>
#include <linux/dma-mapping.h>
#include <soc/qcom/ramdump.h>
@@ -182,6 +183,10 @@ struct wdsp_mgr_priv {
	struct work_struct ssr_work;
	u16 ready_status;
	struct completion ready_compl;

	/* Debugfs related */
	struct dentry *entry;
	bool panic_on_error;
};

static char *wdsp_get_ssr_type_string(enum wdsp_ssr_type type)
@@ -656,6 +661,12 @@ static void wdsp_collect_ramdumps(struct wdsp_mgr_priv *wdsp)
		goto err_read_dumps;
	}

	/*
	 * If panic_on_error flag is explicitly set through the debugfs,
	 * then cause a BUG here to aid debugging.
	 */
	BUG_ON(wdsp->panic_on_error);

	rd_seg.address = (unsigned long) wdsp->dump_data.rd_v_addr;
	rd_seg.size = img_section.size;
	rd_seg.v_address = wdsp->dump_data.rd_v_addr;
@@ -949,6 +960,22 @@ static int wdsp_mgr_compare_of(struct device *dev, void *data)
		 !strcmp(dev_name(dev), cmpnt->cdev_name)));
}

static void wdsp_mgr_debugfs_init(struct wdsp_mgr_priv *wdsp)
{
	wdsp->entry = debugfs_create_dir("wdsp_mgr", NULL);
	if (IS_ERR_OR_NULL(wdsp->entry))
		return;

	debugfs_create_bool("panic_on_error", 0644,
			    wdsp->entry, &wdsp->panic_on_error);
}

static void wdsp_mgr_debugfs_remove(struct wdsp_mgr_priv *wdsp)
{
	debugfs_remove_recursive(wdsp->entry);
	wdsp->entry = NULL;
}

static int wdsp_mgr_bind(struct device *dev)
{
	struct wdsp_mgr_priv *wdsp = dev_get_drvdata(dev);
@@ -978,6 +1005,8 @@ static int wdsp_mgr_bind(struct device *dev)
		}
	}

	wdsp_mgr_debugfs_init(wdsp);

	/* Schedule the work to download image if binding was successful. */
	if (!ret)
		schedule_work(&wdsp->load_fw_work);
@@ -993,6 +1022,8 @@ static void wdsp_mgr_unbind(struct device *dev)

	component_unbind_all(dev, wdsp->ops);

	wdsp_mgr_debugfs_remove(wdsp);

	if (wdsp->dump_data.rd_dev) {
		destroy_ramdump_device(wdsp->dump_data.rd_dev);
		wdsp->dump_data.rd_dev = NULL;