]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
ASoC: SOF: Intel: Split the set_power_op for IPC3 and IPC4
authorRanjani Sridharan <ranjani.sridharan@linux.intel.com>
Thu, 20 Apr 2023 10:47:14 +0000 (13:47 +0300)
committerMark Brown <broonie@kernel.org>
Thu, 20 Apr 2023 11:52:02 +0000 (12:52 +0100)
Suspending to S0iX with IPC3 requires the PM_GATE IPC to be sent again
to stop the DMA trace. But with IPC4, this is not needed as the trace is
stopped with the LARGE_CONFIG_SET IPC. Also, sending the MOD_D0IX IPC to
set the D0I3 state again when the DSP is in D0I3 already results in an
imbalance in PM runtime states in the firmware. So split the
set_power_state ops for IPC3 and IPC4 to avoid sending the MOD_D0IX IPC
when the DSP is already in D0I3 with IPC4.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Rander Wang <rander.wang@intel.com>
Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Link: https://lore.kernel.org/r/20230420104714.29573-1-peter.ujfalusi@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/sof/intel/apl.c
sound/soc/sof/intel/cnl.c
sound/soc/sof/intel/hda-common-ops.c
sound/soc/sof/intel/hda-dsp.c
sound/soc/sof/intel/hda.h
sound/soc/sof/intel/icl.c
sound/soc/sof/intel/mtl.c
sound/soc/sof/intel/tgl.c

index 0e7a7e4ad976bf86b56d32866ef3a163be9c655a..e1f25a8f0c3262bae0f266b38f0f20fa15925c0c 100644 (file)
@@ -48,6 +48,8 @@ int sof_apl_ops_init(struct snd_sof_dev *sdev)
 
                /* debug */
                sof_apl_ops.ipc_dump    = hda_ipc_dump;
+
+               sof_apl_ops.set_power_state = hda_dsp_set_power_state_ipc3;
        }
 
        if (sdev->pdata->ipc_type == SOF_INTEL_IPC4) {
@@ -73,6 +75,8 @@ int sof_apl_ops_init(struct snd_sof_dev *sdev)
 
                /* debug */
                sof_apl_ops.ipc_dump    = hda_ipc4_dump;
+
+               sof_apl_ops.set_power_state = hda_dsp_set_power_state_ipc4;
        }
 
        /* set DAI driver ops */
index a08a77fa946b6c7ca61a90fa883274c68d66bdce..a95222e53ecf30a3a344a7a76771835d0b42485e 100644 (file)
@@ -395,6 +395,8 @@ int sof_cnl_ops_init(struct snd_sof_dev *sdev)
 
                /* debug */
                sof_cnl_ops.ipc_dump    = cnl_ipc_dump;
+
+               sof_cnl_ops.set_power_state = hda_dsp_set_power_state_ipc3;
        }
 
        if (sdev->pdata->ipc_type == SOF_INTEL_IPC4) {
@@ -420,6 +422,8 @@ int sof_cnl_ops_init(struct snd_sof_dev *sdev)
 
                /* debug */
                sof_cnl_ops.ipc_dump    = cnl_ipc4_dump;
+
+               sof_cnl_ops.set_power_state = hda_dsp_set_power_state_ipc4;
        }
 
        /* set DAI driver ops */
index 397303b3ac9d5cfacb7719f3ff0e74cf9724ed9d..8e1cd0babd32c50e36741dc0e20556e6c0bdee3e 100644 (file)
@@ -89,7 +89,6 @@ struct snd_sof_dsp_ops sof_hda_common_ops = {
        .runtime_resume         = hda_dsp_runtime_resume,
        .runtime_idle           = hda_dsp_runtime_idle,
        .set_hw_params_upon_resume = hda_dsp_set_hw_params_upon_resume,
-       .set_power_state        = hda_dsp_set_power_state,
 
        /* ALSA HW info flags */
        .hw_info =      SNDRV_PCM_INFO_MMAP |
index 77df536cf901a195357cd14c395dd5dc60859dbe..44f39a520bb39cc44e068231a817846c77b8b0a9 100644 (file)
@@ -574,31 +574,11 @@ static void hda_dsp_state_log(struct snd_sof_dev *sdev)
  * is called again either because of a new IPC sent to the DSP or
  * during system suspend/resume.
  */
-int hda_dsp_set_power_state(struct snd_sof_dev *sdev,
-                           const struct sof_dsp_power_state *target_state)
+static int hda_dsp_set_power_state(struct snd_sof_dev *sdev,
+                                  const struct sof_dsp_power_state *target_state)
 {
        int ret = 0;
 
-       /*
-        * When the DSP is already in D0I3 and the target state is D0I3,
-        * it could be the case that the DSP is in D0I3 during S0
-        * and the system is suspending to S0Ix. Therefore,
-        * hda_dsp_set_D0_state() must be called to disable trace DMA
-        * by sending the PM_GATE IPC to the FW.
-        */
-       if (target_state->substate == SOF_HDA_DSP_PM_D0I3 &&
-           sdev->system_suspend_target == SOF_SUSPEND_S0IX)
-               goto set_state;
-
-       /*
-        * For all other cases, return without doing anything if
-        * the DSP is already in the target state.
-        */
-       if (target_state->state == sdev->dsp_power_state.state &&
-           target_state->substate == sdev->dsp_power_state.substate)
-               return 0;
-
-set_state:
        switch (target_state->state) {
        case SOF_DSP_PM_D0:
                ret = hda_dsp_set_D0_state(sdev, target_state);
@@ -630,6 +610,42 @@ set_state:
        return ret;
 }
 
+int hda_dsp_set_power_state_ipc3(struct snd_sof_dev *sdev,
+                                const struct sof_dsp_power_state *target_state)
+{
+       /*
+        * When the DSP is already in D0I3 and the target state is D0I3,
+        * it could be the case that the DSP is in D0I3 during S0
+        * and the system is suspending to S0Ix. Therefore,
+        * hda_dsp_set_D0_state() must be called to disable trace DMA
+        * by sending the PM_GATE IPC to the FW.
+        */
+       if (target_state->substate == SOF_HDA_DSP_PM_D0I3 &&
+           sdev->system_suspend_target == SOF_SUSPEND_S0IX)
+               return hda_dsp_set_power_state(sdev, target_state);
+
+       /*
+        * For all other cases, return without doing anything if
+        * the DSP is already in the target state.
+        */
+       if (target_state->state == sdev->dsp_power_state.state &&
+           target_state->substate == sdev->dsp_power_state.substate)
+               return 0;
+
+       return hda_dsp_set_power_state(sdev, target_state);
+}
+
+int hda_dsp_set_power_state_ipc4(struct snd_sof_dev *sdev,
+                                const struct sof_dsp_power_state *target_state)
+{
+       /* Return without doing anything if the DSP is already in the target state */
+       if (target_state->state == sdev->dsp_power_state.state &&
+           target_state->substate == sdev->dsp_power_state.substate)
+               return 0;
+
+       return hda_dsp_set_power_state(sdev, target_state);
+}
+
 /*
  * Audio DSP states may transform as below:-
  *
index 0e0cfa81a8f2193dcdec9c879303805f96bc62cf..c4befacde23e435fa054b73e46b184a64e1776eb 100644 (file)
@@ -584,8 +584,10 @@ void hda_dsp_ipc_int_enable(struct snd_sof_dev *sdev);
 void hda_dsp_ipc_int_disable(struct snd_sof_dev *sdev);
 bool hda_dsp_core_is_enabled(struct snd_sof_dev *sdev, unsigned int core_mask);
 
-int hda_dsp_set_power_state(struct snd_sof_dev *sdev,
-                           const struct sof_dsp_power_state *target_state);
+int hda_dsp_set_power_state_ipc3(struct snd_sof_dev *sdev,
+                                const struct sof_dsp_power_state *target_state);
+int hda_dsp_set_power_state_ipc4(struct snd_sof_dev *sdev,
+                                const struct sof_dsp_power_state *target_state);
 
 int hda_dsp_suspend(struct snd_sof_dev *sdev, u32 target_state);
 int hda_dsp_resume(struct snd_sof_dev *sdev);
index 435941a1692fba5957d05d0c96f9fd0dddfb26ba..0f249efc6a5a28de4d2ed2dcce980ed907becab3 100644 (file)
@@ -116,6 +116,8 @@ int sof_icl_ops_init(struct snd_sof_dev *sdev)
 
                /* debug */
                sof_icl_ops.ipc_dump    = cnl_ipc_dump;
+
+               sof_icl_ops.set_power_state = hda_dsp_set_power_state_ipc3;
        }
 
        if (sdev->pdata->ipc_type == SOF_INTEL_IPC4) {
@@ -141,6 +143,8 @@ int sof_icl_ops_init(struct snd_sof_dev *sdev)
 
                /* debug */
                sof_icl_ops.ipc_dump    = cnl_ipc4_dump;
+
+               sof_icl_ops.set_power_state = hda_dsp_set_power_state_ipc4;
        }
 
        /* debug */
index 9f969e07fc270ede9a8b27592f046555ffc3b879..46caf3ccde66e13d4130a85110168d2087e79935 100644 (file)
@@ -668,6 +668,8 @@ int sof_mtl_ops_init(struct snd_sof_dev *sdev)
        /* set DAI ops */
        hda_set_dai_drv_ops(sdev, &sof_mtl_ops);
 
+       sof_mtl_ops.set_power_state = hda_dsp_set_power_state_ipc4;
+
        return 0;
 };
 EXPORT_SYMBOL_NS(sof_mtl_ops_init, SND_SOC_SOF_INTEL_HDA_COMMON);
index 58ac3a46e6a7514c6144918ae587262fd7eb7a37..2713b7dc793124ccae5c95d8bb9540ae9b901804 100644 (file)
@@ -71,6 +71,8 @@ int sof_tgl_ops_init(struct snd_sof_dev *sdev)
 
                /* debug */
                sof_tgl_ops.ipc_dump    = cnl_ipc_dump;
+
+               sof_tgl_ops.set_power_state = hda_dsp_set_power_state_ipc3;
        }
 
        if (sdev->pdata->ipc_type == SOF_INTEL_IPC4) {
@@ -96,6 +98,8 @@ int sof_tgl_ops_init(struct snd_sof_dev *sdev)
 
                /* debug */
                sof_tgl_ops.ipc_dump    = cnl_ipc4_dump;
+
+               sof_tgl_ops.set_power_state = hda_dsp_set_power_state_ipc4;
        }
 
        /* set DAI driver ops */