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

Commit ccff8359 authored by Deepak Katragadda's avatar Deepak Katragadda
Browse files

msm: pil: Move sending NMI to QDSP from the pil-q6v5-lpass driver



The SCM call to send NMI to QDSP is made from the audio
driver instead of from the pil-q6v5-lpass driver.

The audio driver uses the panic notifier and the
'before_shutdown' subsystem notification to make the call.
This is crucial in moving the pil-q6v5-lpass driver to use
the generic PIL driver functionality.

CRs-Fixed: 625452

Change-Id: I468e0364a77f06175b5bd646215b369ba8007393
Signed-off-by: default avatarDeepak Katragadda <dkatraga@codeaurora.org>
parent ff3d16fc
Loading
Loading
Loading
Loading
+0 −16
Original line number Diff line number Diff line
@@ -29,7 +29,6 @@
#include <soc/qcom/subsystem_restart.h>
#include <soc/qcom/subsystem_notif.h>
#include <soc/qcom/ramdump.h>
#include <soc/qcom/scm.h>

#include <soc/qcom/smem.h>

@@ -291,15 +290,6 @@ static irqreturn_t adsp_err_fatal_intr_handler (int irq, void *dev_id)
	return IRQ_HANDLED;
}

#define SCM_Q6_NMI_CMD 0x1

static void send_q6_nmi(void)
{
	/* Send NMI to QDSP6 via an SCM call. */
	scm_call_atomic1(SCM_SVC_UTIL, SCM_Q6_NMI_CMD, 0x1);
	pr_debug("%s: Q6 NMI was sent.\n", __func__);
}

/*
 * The "status" file where a static variable is read from and written to.
 */
@@ -334,11 +324,6 @@ static int adsp_shutdown(const struct subsys_desc *subsys, bool force_stop)
{
	struct lpass_data *drv = subsys_to_lpass(subsys);

	if (force_stop) {
		send_q6_nmi();
		/* The write needs to go through before the q6 is shutdown. */
		mb();
	}
	pil_shutdown(&drv->q6->desc);

	pr_debug("ADSP is Down\n");
@@ -373,7 +358,6 @@ static void adsp_crash_shutdown(const struct subsys_desc *subsys)

	drv->crash_shutdown = 1;
	gpio_set_value(subsys->force_stop_gpio, 1);
	send_q6_nmi();
}

static irqreturn_t adsp_wdog_bite_irq(int irq, void *dev_id)
+29 −0
Original line number Diff line number Diff line
@@ -28,12 +28,15 @@
#include <linux/slab.h>
#include <soc/qcom/subsystem_restart.h>
#include <soc/qcom/subsystem_notif.h>
#include <soc/qcom/scm.h>
#include <sound/apr_audio-v2.h>
#include <soc/qcom/smd.h>
#include <linux/qdsp6v2/apr.h>
#include <linux/qdsp6v2/apr_tal.h>
#include <linux/qdsp6v2/dsp_debug.h>

#define SCM_Q6_NMI_CMD 0x1

static struct apr_q6 q6;
static struct apr_client client[APR_DEST_MAX][APR_CLIENT_MAX];

@@ -761,10 +764,13 @@ static struct notifier_block mnb = {
	.notifier_call = modem_notifier_cb,
};

static bool powered_on;

static int lpass_notifier_cb(struct notifier_block *this, unsigned long code,
			     void *_cmd)
{
	static int boot_count = 2;
	struct notif_data *data = (struct notif_data *)_cmd;

	if (boot_count) {
		boot_count--;
@@ -776,8 +782,16 @@ static int lpass_notifier_cb(struct notifier_block *this, unsigned long code,
		pr_debug("L-Notify: Shutdown started\n");
		apr_set_q6_state(APR_SUBSYS_DOWN);
		dispatch_event(code, APR_DEST_QDSP6);
		if (data && data->crashed) {
			/* Send NMI to QDSP6 via an SCM call. */
			scm_call_atomic1(SCM_SVC_UTIL, SCM_Q6_NMI_CMD, 0x1);
			/* The write should go through before q6 is shutdown */
			mb();
			pr_debug("L-Notify: Q6 NMI was sent.\n");
		}
		break;
	case SUBSYS_AFTER_SHUTDOWN:
		powered_on = false;
		pr_debug("L-Notify: Shutdown Completed\n");
		break;
	case SUBSYS_BEFORE_POWERUP:
@@ -787,6 +801,7 @@ static int lpass_notifier_cb(struct notifier_block *this, unsigned long code,
		if (apr_cmpxchg_q6_state(APR_SUBSYS_DOWN,
				APR_SUBSYS_LOADED) == APR_SUBSYS_DOWN)
			wake_up(&dsp_wait);
		powered_on = true;
		pr_debug("L-Notify: Bootup Completed\n");
		break;
	default:
@@ -800,6 +815,18 @@ static struct notifier_block lnb = {
	.notifier_call = lpass_notifier_cb,
};

static int panic_handler(struct notifier_block *this,
				unsigned long event, void *ptr)
{
	if (powered_on)
		/* Send NMI to QDSP6 via an SCM call. */
		scm_call_atomic1(SCM_SVC_UTIL, SCM_Q6_NMI_CMD, 0x1);
	return NOTIFY_DONE;
}

static struct notifier_block panic_nb = {
	.notifier_call  = panic_handler,
};

static int __init apr_init(void)
{
@@ -818,6 +845,8 @@ static int __init apr_init(void)
	apr_reset_workqueue = create_singlethread_workqueue("apr_driver");
	if (!apr_reset_workqueue)
		return -ENOMEM;
	atomic_notifier_chain_register(&panic_notifier_list, &panic_nb);

	return 0;
}
device_initcall(apr_init);