Skip to content

Commit 3e6b6ed

Browse files
RanderWangbroonie
authored andcommitted
ASoC: SOF: Intel: Enable d0i3 work for ipc4
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]>
1 parent 1c91e92 commit 3e6b6ed

File tree

4 files changed

+34
-0
lines changed

4 files changed

+34
-0
lines changed

sound/soc/sof/intel/cnl.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,8 @@ int cnl_ipc4_send_msg(struct snd_sof_dev *sdev, struct snd_sof_ipc_msg *msg)
280280
snd_sof_dsp_write(sdev, HDA_DSP_BAR, CNL_DSP_REG_HIPCIDR,
281281
msg_data->primary | CNL_DSP_REG_HIPCIDR_BUSY);
282282

283+
hda_dsp_ipc4_schedule_d0i3_work(hdev, msg);
284+
283285
return 0;
284286
}
285287

sound/soc/sof/intel/hda-ipc.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,32 @@ int hda_dsp_ipc_send_msg(struct snd_sof_dev *sdev, struct snd_sof_ipc_msg *msg)
6767
return 0;
6868
}
6969

70+
static inline bool hda_dsp_ipc4_pm_msg(u32 primary)
71+
{
72+
/* pm setting is only supported by module msg */
73+
if (SOF_IPC4_MSG_IS_MODULE_MSG(primary) != SOF_IPC4_MODULE_MSG)
74+
return false;
75+
76+
if (SOF_IPC4_MSG_TYPE_GET(primary) == SOF_IPC4_MOD_SET_DX ||
77+
SOF_IPC4_MSG_TYPE_GET(primary) == SOF_IPC4_MOD_SET_D0IX)
78+
return true;
79+
80+
return false;
81+
}
82+
83+
void hda_dsp_ipc4_schedule_d0i3_work(struct sof_intel_hda_dev *hdev,
84+
struct snd_sof_ipc_msg *msg)
85+
{
86+
struct sof_ipc4_msg *msg_data = msg->msg_data;
87+
88+
/* Schedule a delayed work for d0i3 entry after sending non-pm ipc msg */
89+
if (hda_dsp_ipc4_pm_msg(msg_data->primary))
90+
return;
91+
92+
mod_delayed_work(system_wq, &hdev->d0i3_work,
93+
msecs_to_jiffies(SOF_HDA_D0I3_WORK_DELAY_MS));
94+
}
95+
7096
int hda_dsp_ipc4_send_msg(struct snd_sof_dev *sdev, struct snd_sof_ipc_msg *msg)
7197
{
7298
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)
88114
snd_sof_dsp_write(sdev, HDA_DSP_BAR, HDA_DSP_REG_HIPCI,
89115
msg_data->primary | HDA_DSP_REG_HIPCI_BUSY);
90116

117+
hda_dsp_ipc4_schedule_d0i3_work(hdev, msg);
118+
91119
return 0;
92120
}
93121

sound/soc/sof/intel/hda.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -919,6 +919,8 @@ irqreturn_t cnl_ipc4_irq_thread(int irq, void *context);
919919
int cnl_ipc4_send_msg(struct snd_sof_dev *sdev, struct snd_sof_ipc_msg *msg);
920920
irqreturn_t hda_dsp_ipc4_irq_thread(int irq, void *context);
921921
bool hda_ipc4_tx_is_busy(struct snd_sof_dev *sdev);
922+
void hda_dsp_ipc4_schedule_d0i3_work(struct sof_intel_hda_dev *hdev,
923+
struct snd_sof_ipc_msg *msg);
922924
int hda_dsp_ipc4_send_msg(struct snd_sof_dev *sdev, struct snd_sof_ipc_msg *msg);
923925
void hda_ipc4_dump(struct snd_sof_dev *sdev);
924926
extern struct sdw_intel_ops sdw_callback;

sound/soc/sof/intel/mtl.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ static int mtl_ipc_send_msg(struct snd_sof_dev *sdev, struct snd_sof_ipc_msg *ms
110110
snd_sof_dsp_write(sdev, HDA_DSP_BAR, MTL_DSP_REG_HFIPCXIDR,
111111
msg_data->primary | MTL_DSP_REG_HFIPCXIDR_BUSY);
112112

113+
hda_dsp_ipc4_schedule_d0i3_work(hdev, msg);
114+
113115
return 0;
114116
}
115117

0 commit comments

Comments
 (0)