]> Git Repo - linux.git/commitdiff
ASoC: SOF: Intel: Enable d0i3 work for ipc4
authorRander Wang <[email protected]>
Tue, 14 Feb 2023 10:33:44 +0000 (12:33 +0200)
committerMark Brown <[email protected]>
Tue, 14 Feb 2023 13:25:14 +0000 (13:25 +0000)
Schedule a delayed work for d0i3 entry after every non-pm ipc msg.

Signed-off-by: Rander Wang <[email protected]>
Reviewed-by: Pierre-Louis Bossart <[email protected]>
Reviewed-by: Ranjani Sridharan <[email protected]>
Reviewed-by: Péter Ujfalusi <[email protected]>
Signed-off-by: Peter Ujfalusi <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Mark Brown <[email protected]>
sound/soc/sof/intel/cnl.c
sound/soc/sof/intel/hda-ipc.c
sound/soc/sof/intel/hda.h
sound/soc/sof/intel/mtl.c

index 6b075bbe5bfb831951580061e000ab79faff8be1..a08a77fa946b6c7ca61a90fa883274c68d66bdce 100644 (file)
@@ -280,6 +280,8 @@ int cnl_ipc4_send_msg(struct snd_sof_dev *sdev, struct snd_sof_ipc_msg *msg)
        snd_sof_dsp_write(sdev, HDA_DSP_BAR, CNL_DSP_REG_HIPCIDR,
                          msg_data->primary | CNL_DSP_REG_HIPCIDR_BUSY);
 
+       hda_dsp_ipc4_schedule_d0i3_work(hdev, msg);
+
        return 0;
 }
 
index d7e16e6b6f52c43c025ea0fd08452379669eb10f..df541b22b2d2b82e530b6f4e5b74f13ce725f005 100644 (file)
@@ -67,6 +67,32 @@ int hda_dsp_ipc_send_msg(struct snd_sof_dev *sdev, struct snd_sof_ipc_msg *msg)
        return 0;
 }
 
+static inline bool hda_dsp_ipc4_pm_msg(u32 primary)
+{
+       /* pm setting is only supported by module msg */
+       if (SOF_IPC4_MSG_IS_MODULE_MSG(primary) != SOF_IPC4_MODULE_MSG)
+               return false;
+
+       if (SOF_IPC4_MSG_TYPE_GET(primary) == SOF_IPC4_MOD_SET_DX ||
+           SOF_IPC4_MSG_TYPE_GET(primary) == SOF_IPC4_MOD_SET_D0IX)
+               return true;
+
+       return false;
+}
+
+void hda_dsp_ipc4_schedule_d0i3_work(struct sof_intel_hda_dev *hdev,
+                                    struct snd_sof_ipc_msg *msg)
+{
+       struct sof_ipc4_msg *msg_data = msg->msg_data;
+
+       /* Schedule a delayed work for d0i3 entry after sending non-pm ipc msg */
+       if (hda_dsp_ipc4_pm_msg(msg_data->primary))
+               return;
+
+       mod_delayed_work(system_wq, &hdev->d0i3_work,
+                        msecs_to_jiffies(SOF_HDA_D0I3_WORK_DELAY_MS));
+}
+
 int hda_dsp_ipc4_send_msg(struct snd_sof_dev *sdev, struct snd_sof_ipc_msg *msg)
 {
        struct sof_intel_hda_dev *hdev = sdev->pdata->hw_pdata;
@@ -88,6 +114,8 @@ int hda_dsp_ipc4_send_msg(struct snd_sof_dev *sdev, struct snd_sof_ipc_msg *msg)
        snd_sof_dsp_write(sdev, HDA_DSP_BAR, HDA_DSP_REG_HIPCI,
                          msg_data->primary | HDA_DSP_REG_HIPCI_BUSY);
 
+       hda_dsp_ipc4_schedule_d0i3_work(hdev, msg);
+
        return 0;
 }
 
index b3080b82ca253f1e64576720182c4ad19b0670d6..45f9d4248f14e9ba47d4f122e2ff658766de19f3 100644 (file)
@@ -919,6 +919,8 @@ irqreturn_t cnl_ipc4_irq_thread(int irq, void *context);
 int cnl_ipc4_send_msg(struct snd_sof_dev *sdev, struct snd_sof_ipc_msg *msg);
 irqreturn_t hda_dsp_ipc4_irq_thread(int irq, void *context);
 bool hda_ipc4_tx_is_busy(struct snd_sof_dev *sdev);
+void hda_dsp_ipc4_schedule_d0i3_work(struct sof_intel_hda_dev *hdev,
+                                    struct snd_sof_ipc_msg *msg);
 int hda_dsp_ipc4_send_msg(struct snd_sof_dev *sdev, struct snd_sof_ipc_msg *msg);
 void hda_ipc4_dump(struct snd_sof_dev *sdev);
 extern struct sdw_intel_ops sdw_callback;
index 67b8ccbc2e949ee8f99762777d73a8628bf98ebd..307faad2ecf4b994c6cef1fb4cf59bdbf00678d3 100644 (file)
@@ -110,6 +110,8 @@ static int mtl_ipc_send_msg(struct snd_sof_dev *sdev, struct snd_sof_ipc_msg *ms
        snd_sof_dsp_write(sdev, HDA_DSP_BAR, MTL_DSP_REG_HFIPCXIDR,
                          msg_data->primary | MTL_DSP_REG_HFIPCXIDR_BUSY);
 
+       hda_dsp_ipc4_schedule_d0i3_work(hdev, msg);
+
        return 0;
 }
 
This page took 0.0570889999999999 seconds and 4 git commands to generate.