ASoC: SOF: core: Unregister machine driver before IPC and debugfs
authorPeter Ujfalusi <peter.ujfalusi@linux.intel.com>
Tue, 2 Nov 2021 09:47:56 +0000 (11:47 +0200)
committerMark Brown <broonie@kernel.org>
Mon, 15 Nov 2021 19:25:27 +0000 (19:25 +0000)
To ensure clean unload of the machine driver, components and topology, do
the unregister before we free IPC and debugfs.

It is a possibility that part of the unregister we would have IPC
communication with the firmware.

Suggested-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://lore.kernel.org/r/20211102094756.9317-1-peter.ujfalusi@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/sof/core.c

index 9ec9ef8..40549cd 100644 (file)
@@ -362,6 +362,13 @@ int snd_sof_device_remove(struct device *dev)
        if (IS_ENABLED(CONFIG_SND_SOC_SOF_PROBE_WORK_QUEUE))
                cancel_work_sync(&sdev->probe_work);
 
+       /*
+        * Unregister machine driver. This will unbind the snd_card which
+        * will remove the component driver and unload the topology
+        * before freeing the snd_card.
+        */
+       snd_sof_machine_unregister(sdev, pdata);
+
        if (sdev->fw_state > SOF_FW_BOOT_NOT_STARTED) {
                snd_sof_free_trace(sdev);
                ret = snd_sof_dsp_power_down_notify(sdev);
@@ -374,13 +381,6 @@ int snd_sof_device_remove(struct device *dev)
        }
 
        /*
-        * Unregister machine driver. This will unbind the snd_card which
-        * will remove the component driver and unload the topology
-        * before freeing the snd_card.
-        */
-       snd_sof_machine_unregister(sdev, pdata);
-
-       /*
         * Unregistering the machine driver results in unloading the topology.
         * Some widgets, ex: scheduler, attempt to power down the core they are
         * scheduled on, when they are unloaded. Therefore, the DSP must be