Blob Blame History Raw
From 9f369f7e4660d05b5318aa413db199a70dfb2c4f Mon Sep 17 00:00:00 2001
From: Marcin Rajwa <marcin.rajwa@linux.intel.com>
Date: Fri, 15 May 2020 16:59:53 +0300
Subject: [PATCH] ASoC: SOF: inform DSP that driver is going to be removed
Git-commit: 9f369f7e4660d05b5318aa413db199a70dfb2c4f
Patch-mainline: v5.8-rc1
References: jsc#SLE-16518

This patch invokes the DSP power down notifier to inform
DSP that driver is going to be removed.
The module removal entails DSP power down, disabling of
IRQs and more. Therefore it is highly recommended to inform
the DSP about this upcoming event.

Due to hardware limitations on some Intel platforms it is necessary
to power gate all LPSRAM banks that were enabled prior to controller
reset. Otherwise, an attempt to write LPSRAM control registers may
have no effect.

Signed-off-by: Marcin Rajwa <marcin.rajwa@linux.intel.com>
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://lore.kernel.org/r/20200515135958.17511-4-kai.vehmanen@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Acked-by: Takashi Iwai <tiwai@suse.de>

---
 sound/soc/sof/core.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/sound/soc/sof/core.c b/sound/soc/sof/core.c
index ef9be4f45e27..339c4930b0c0 100644
--- a/sound/soc/sof/core.c
+++ b/sound/soc/sof/core.c
@@ -343,6 +343,12 @@ int snd_sof_device_remove(struct device *dev)
 {
 	struct snd_sof_dev *sdev = dev_get_drvdata(dev);
 	struct snd_sof_pdata *pdata = sdev->pdata;
+	int ret;
+
+	ret = snd_sof_dsp_power_down_notify(sdev);
+	if (ret < 0)
+		dev_warn(dev, "error: %d failed to prepare DSP for device removal",
+			 ret);
 
 	if (IS_ENABLED(CONFIG_SND_SOC_SOF_PROBE_WORK_QUEUE))
 		cancel_work_sync(&sdev->probe_work);
-- 
2.16.4