Commit ae9db908 authored by Ranjani Sridharan's avatar Ranjani Sridharan Committed by Mark Brown

ASoC: SOF: Intel: hda: Do not re-enable L1 if disabled before suspend

We have a workaround in place to address a known issue with host DMA
running into xruns when capture streams are running. But when resuming
from Sx, we unconditionally re-enable DMI L1 without taking the
workaround into account and this could lead to xruns when a suspended
capture stream is restarted.

To fix this rename the flag l1_support_enabled to l1_disabled in struct
sof_intel_hda_dev to save the L1 disabled status which can be
set/cleared when we get/put a stream and use the flag to determine if DMI
L1 should enabled or not during the post_fw_run op.
Signed-off-by: default avatarRanjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: default avatarPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: default avatarBard Liao <yung-chuan.liao@linux.intel.com>
Reviewed-by: default avatarRander Wang <rander.wang@intel.com>
Signed-off-by: default avatarPeter Ujfalusi <peter.ujfalusi@linux.intel.com>
Link: https://lore.kernel.org/r/20230220075804.4829-2-peter.ujfalusi@linux.intel.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent fe15c26e
...@@ -158,16 +158,18 @@ void hda_dsp_ctrl_misc_clock_gating(struct snd_sof_dev *sdev, bool enable) ...@@ -158,16 +158,18 @@ void hda_dsp_ctrl_misc_clock_gating(struct snd_sof_dev *sdev, bool enable)
*/ */
int hda_dsp_ctrl_clock_power_gating(struct snd_sof_dev *sdev, bool enable) int hda_dsp_ctrl_clock_power_gating(struct snd_sof_dev *sdev, bool enable)
{ {
struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata;
u32 val; u32 val;
/* enable/disable audio dsp clock gating */ /* enable/disable audio dsp clock gating */
val = enable ? PCI_CGCTL_ADSPDCGE : 0; val = enable ? PCI_CGCTL_ADSPDCGE : 0;
snd_sof_pci_update_bits(sdev, PCI_CGCTL, PCI_CGCTL_ADSPDCGE, val); snd_sof_pci_update_bits(sdev, PCI_CGCTL, PCI_CGCTL_ADSPDCGE, val);
/* enable/disable DMI Link L1 support */ /* disable the DMI link when requested. But enable only if it wasn't disabled previously */
val = enable ? HDA_VS_INTEL_EM2_L1SEN : 0; val = enable ? HDA_VS_INTEL_EM2_L1SEN : 0;
snd_sof_dsp_update_bits(sdev, HDA_DSP_HDA_BAR, HDA_VS_INTEL_EM2, if (!enable || !hda->l1_disabled)
HDA_VS_INTEL_EM2_L1SEN, val); snd_sof_dsp_update_bits(sdev, HDA_DSP_HDA_BAR, HDA_VS_INTEL_EM2,
HDA_VS_INTEL_EM2_L1SEN, val);
/* enable/disable audio dsp power gating */ /* enable/disable audio dsp power gating */
val = enable ? 0 : PCI_PGCTL_ADSPPGD; val = enable ? 0 : PCI_PGCTL_ADSPPGD;
......
...@@ -776,7 +776,7 @@ int hda_dsp_resume(struct snd_sof_dev *sdev) ...@@ -776,7 +776,7 @@ int hda_dsp_resume(struct snd_sof_dev *sdev)
} }
/* restore L1SEN bit */ /* restore L1SEN bit */
if (hda->l1_support_changed) if (hda->l1_disabled)
snd_sof_dsp_update_bits(sdev, HDA_DSP_HDA_BAR, snd_sof_dsp_update_bits(sdev, HDA_DSP_HDA_BAR,
HDA_VS_INTEL_EM2, HDA_VS_INTEL_EM2,
HDA_VS_INTEL_EM2_L1SEN, 0); HDA_VS_INTEL_EM2_L1SEN, 0);
...@@ -868,11 +868,9 @@ int hda_dsp_suspend(struct snd_sof_dev *sdev, u32 target_state) ...@@ -868,11 +868,9 @@ int hda_dsp_suspend(struct snd_sof_dev *sdev, u32 target_state)
} }
/* enable L1SEN to make sure the system can enter S0Ix */ /* enable L1SEN to make sure the system can enter S0Ix */
hda->l1_support_changed = if (hda->l1_disabled)
snd_sof_dsp_update_bits(sdev, HDA_DSP_HDA_BAR, snd_sof_dsp_update_bits(sdev, HDA_DSP_HDA_BAR, HDA_VS_INTEL_EM2,
HDA_VS_INTEL_EM2, HDA_VS_INTEL_EM2_L1SEN, HDA_VS_INTEL_EM2_L1SEN);
HDA_VS_INTEL_EM2_L1SEN,
HDA_VS_INTEL_EM2_L1SEN);
/* stop the CORB/RIRB DMA if it is On */ /* stop the CORB/RIRB DMA if it is On */
hda_codec_suspend_cmd_io(sdev); hda_codec_suspend_cmd_io(sdev);
......
...@@ -182,6 +182,7 @@ int hda_dsp_stream_spib_config(struct snd_sof_dev *sdev, ...@@ -182,6 +182,7 @@ int hda_dsp_stream_spib_config(struct snd_sof_dev *sdev,
struct hdac_ext_stream * struct hdac_ext_stream *
hda_dsp_stream_get(struct snd_sof_dev *sdev, int direction, u32 flags) hda_dsp_stream_get(struct snd_sof_dev *sdev, int direction, u32 flags)
{ {
struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata;
struct hdac_bus *bus = sof_to_bus(sdev); struct hdac_bus *bus = sof_to_bus(sdev);
struct sof_intel_hda_stream *hda_stream; struct sof_intel_hda_stream *hda_stream;
struct hdac_ext_stream *hext_stream = NULL; struct hdac_ext_stream *hext_stream = NULL;
...@@ -222,10 +223,12 @@ hda_dsp_stream_get(struct snd_sof_dev *sdev, int direction, u32 flags) ...@@ -222,10 +223,12 @@ hda_dsp_stream_get(struct snd_sof_dev *sdev, int direction, u32 flags)
* Workaround to address a known issue with host DMA that results * Workaround to address a known issue with host DMA that results
* in xruns during pause/release in capture scenarios. * in xruns during pause/release in capture scenarios.
*/ */
if (!(flags & SOF_HDA_STREAM_DMI_L1_COMPATIBLE)) if (!(flags & SOF_HDA_STREAM_DMI_L1_COMPATIBLE)) {
snd_sof_dsp_update_bits(sdev, HDA_DSP_HDA_BAR, snd_sof_dsp_update_bits(sdev, HDA_DSP_HDA_BAR,
HDA_VS_INTEL_EM2, HDA_VS_INTEL_EM2,
HDA_VS_INTEL_EM2_L1SEN, 0); HDA_VS_INTEL_EM2_L1SEN, 0);
hda->l1_disabled = true;
}
return hext_stream; return hext_stream;
} }
...@@ -233,6 +236,7 @@ hda_dsp_stream_get(struct snd_sof_dev *sdev, int direction, u32 flags) ...@@ -233,6 +236,7 @@ hda_dsp_stream_get(struct snd_sof_dev *sdev, int direction, u32 flags)
/* free a stream */ /* free a stream */
int hda_dsp_stream_put(struct snd_sof_dev *sdev, int direction, int stream_tag) int hda_dsp_stream_put(struct snd_sof_dev *sdev, int direction, int stream_tag)
{ {
struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata;
struct hdac_bus *bus = sof_to_bus(sdev); struct hdac_bus *bus = sof_to_bus(sdev);
struct sof_intel_hda_stream *hda_stream; struct sof_intel_hda_stream *hda_stream;
struct hdac_ext_stream *hext_stream; struct hdac_ext_stream *hext_stream;
...@@ -264,9 +268,11 @@ int hda_dsp_stream_put(struct snd_sof_dev *sdev, int direction, int stream_tag) ...@@ -264,9 +268,11 @@ int hda_dsp_stream_put(struct snd_sof_dev *sdev, int direction, int stream_tag)
spin_unlock_irq(&bus->reg_lock); spin_unlock_irq(&bus->reg_lock);
/* Enable DMI L1 if permitted */ /* Enable DMI L1 if permitted */
if (dmi_l1_enable) if (dmi_l1_enable) {
snd_sof_dsp_update_bits(sdev, HDA_DSP_HDA_BAR, HDA_VS_INTEL_EM2, snd_sof_dsp_update_bits(sdev, HDA_DSP_HDA_BAR, HDA_VS_INTEL_EM2,
HDA_VS_INTEL_EM2_L1SEN, HDA_VS_INTEL_EM2_L1SEN); HDA_VS_INTEL_EM2_L1SEN, HDA_VS_INTEL_EM2_L1SEN);
hda->l1_disabled = false;
}
if (!found) { if (!found) {
dev_err(sdev->dev, "%s: stream_tag %d not opened!\n", dev_err(sdev->dev, "%s: stream_tag %d not opened!\n",
......
...@@ -502,7 +502,7 @@ struct sof_intel_hda_dev { ...@@ -502,7 +502,7 @@ struct sof_intel_hda_dev {
u32 stream_max; u32 stream_max;
/* PM related */ /* PM related */
bool l1_support_changed;/* during suspend, is L1SEN changed or not */ bool l1_disabled;/* is DMI link L1 disabled? */
/* DMIC device */ /* DMIC device */
struct platform_device *dmic_dev; struct platform_device *dmic_dev;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment