Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions drivers/soundwire/intel.c
Original file line number Diff line number Diff line change
Expand Up @@ -954,9 +954,15 @@ static int intel_component_dais_suspend(struct snd_soc_component *component)
struct sdw_cdns_dai_runtime *dai_runtime;

dai_runtime = cdns->dai_runtime_array[dai->id];
if (!dai_runtime)
continue;

if (dai_runtime)
dai_runtime->suspended = true;
/* the stream is kept running during the system suspend */
if (dai_runtime->stream &&
dai_runtime->stream->state == SDW_STREAM_ENABLED)
continue;

dai_runtime->suspended = true;
}

return 0;
Expand Down
1 change: 1 addition & 0 deletions drivers/soundwire/intel.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ struct sdw_intel {
struct sdw_intel_link_res *link_res;
bool startup_done;
struct sdw_intel_bpt bpt_ctx;
bool suspend_bus_retained;
#ifdef CONFIG_DEBUG_FS
struct dentry *debugfs;
#endif
Expand Down
10 changes: 8 additions & 2 deletions drivers/soundwire/intel_ace2x.c
Original file line number Diff line number Diff line change
Expand Up @@ -953,9 +953,15 @@ static int intel_component_dais_suspend(struct snd_soc_component *component)
struct sdw_cdns_dai_runtime *dai_runtime;

dai_runtime = cdns->dai_runtime_array[dai->id];
if (!dai_runtime)
continue;

if (dai_runtime)
dai_runtime->suspended = true;
/* the stream is kept running during the system suspend */
if (dai_runtime->stream &&
dai_runtime->stream->state == SDW_STREAM_ENABLED)
continue;

dai_runtime->suspended = true;
}

return 0;
Expand Down
21 changes: 21 additions & 0 deletions drivers/soundwire/intel_auxdevice.c
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,20 @@ static int __maybe_unused intel_suspend(struct device *dev)
return 0;
}

/*
* The sound card is suspended before the SoundWire links and the
* streams which are not kept running are disabled by then: a stream
* is only enabled while it is running and the card's suspend disables
* all the running streams except the ones kept running during the
* system suspend. Do not stop the bus under an enabled stream.
*/
sdw->suspend_bus_retained = sdw_bus_has_enabled_stream(bus);
if (sdw->suspend_bus_retained) {
dev_dbg(dev, "SoundWire master %d is kept active during system suspend\n",
bus->link_id);
return 0;
}

/* Prevent runtime PM from racing with the code below. */
pm_runtime_disable(dev);

Expand Down Expand Up @@ -737,6 +751,13 @@ static int __maybe_unused intel_resume(struct device *dev)
return 0;
}

if (sdw->suspend_bus_retained) {
sdw->suspend_bus_retained = false;
dev_dbg(dev, "SoundWire master %d remained active during system suspend\n",
bus->link_id);
return 0;
}

ret = sdw_intel_link_power_up(sdw);
if (ret) {
dev_err(dev, "%s failed: %d\n", __func__, ret);
Expand Down
21 changes: 21 additions & 0 deletions drivers/soundwire/stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -1690,6 +1690,27 @@ int sdw_enable_stream(struct sdw_stream_runtime *stream)
}
EXPORT_SYMBOL(sdw_enable_stream);

/**
* sdw_bus_has_enabled_stream() - Check if the bus carries an enabled stream
*
* @bus: SDW bus instance
*
* Return: true if at least one stream on the bus is in ENABLED state
*/
bool sdw_bus_has_enabled_stream(struct sdw_bus *bus)
{
struct sdw_master_runtime *m_rt;

guard(mutex)(&bus->bus_lock);
list_for_each_entry(m_rt, &bus->m_rt_list, bus_node) {
if (m_rt->stream->state == SDW_STREAM_ENABLED)
return true;
}

return false;
}
EXPORT_SYMBOL(sdw_bus_has_enabled_stream);

static int _sdw_disable_stream(struct sdw_stream_runtime *stream)
{
struct sdw_master_runtime *m_rt;
Expand Down
1 change: 1 addition & 0 deletions include/linux/soundwire/sdw.h
Original file line number Diff line number Diff line change
Expand Up @@ -1084,6 +1084,7 @@ int sdw_stream_remove_master(struct sdw_bus *bus,
int sdw_startup_stream(void *sdw_substream);
int sdw_prepare_stream(struct sdw_stream_runtime *stream);
int sdw_enable_stream(struct sdw_stream_runtime *stream);
bool sdw_bus_has_enabled_stream(struct sdw_bus *bus);
int sdw_disable_stream(struct sdw_stream_runtime *stream);
int sdw_deprepare_stream(struct sdw_stream_runtime *stream);
void sdw_shutdown_stream(void *sdw_substream);
Expand Down
1 change: 1 addition & 0 deletions sound/soc/sof/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,7 @@ int snd_sof_device_probe(struct device *dev, struct snd_sof_pdata *plat_data)
INIT_LIST_HEAD(&sdev->dai_list);
INIT_LIST_HEAD(&sdev->dai_link_list);
INIT_LIST_HEAD(&sdev->route_list);
INIT_LIST_HEAD(&sdev->ignore_suspend_widget_list);
INIT_LIST_HEAD(&sdev->ipc_client_list);
INIT_LIST_HEAD(&sdev->ipc_rx_handler_list);
INIT_LIST_HEAD(&sdev->fw_state_handler_list);
Expand Down
49 changes: 1 addition & 48 deletions sound/soc/sof/intel/hda-dai.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,6 @@ hda_link_dma_cleanup(struct snd_pcm_substream *substream,
if (!hlink)
return -EINVAL;

hda_stream = hstream_to_sof_hda_stream(hext_stream);
hda_stream->suspend_ignored = false;

if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
stream_tag = hdac_stream(hext_stream)->stream_tag;
snd_hdac_ext_bus_link_clear_stream_id(hlink, stream_tag);
Expand All @@ -160,6 +157,7 @@ hda_link_dma_cleanup(struct snd_pcm_substream *substream,
hext_stream->link_prepared = 0;

/* free the host DMA channel reserved by hostless streams */
hda_stream = hstream_to_sof_hda_stream(hext_stream);
hda_stream->host_reserved = 0;

return 0;
Expand Down Expand Up @@ -282,32 +280,6 @@ static int __maybe_unused hda_dai_hw_params(struct snd_pcm_substream *substream,
return hda_dai_hw_params_data(substream, params, dai, &data, flags);
}

static bool hda_dai_has_wov_fe(struct snd_sof_dev *sdev, struct snd_pcm_substream *substream)
{
struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
struct snd_soc_dpcm *dpcm;
struct snd_sof_pcm *spcm;

if (substream->stream != SNDRV_PCM_STREAM_CAPTURE)
return false;

/*
* Only retain the BE for a connected WoV capture FE that is running
* or has already ignored its suspend trigger. An idle WoV FE may
* still be connected to the BE.
*/
for_each_dpcm_fe(rtd, SNDRV_PCM_STREAM_CAPTURE, dpcm) {
spcm = snd_sof_find_spcm_dai(sdev->component, dpcm->fe);
if (spcm && spcm->stream[SNDRV_PCM_STREAM_CAPTURE].d0i3_compatible &&
spcm->stream[SNDRV_PCM_STREAM_CAPTURE].dsp_max_burst_size_in_ms <= 1 &&
(dpcm->fe->dpcm[SNDRV_PCM_STREAM_CAPTURE].state == SND_SOC_DPCM_STATE_START ||
spcm->stream[SNDRV_PCM_STREAM_CAPTURE].suspend_ignored))
return true;
}

return false;
}

/*
* In contrast to IPC3, the dai trigger in IPC4 mixes pipeline state changes
* (over IPC channel) and DMA state change (direct host register changes).
Expand All @@ -317,7 +289,6 @@ static int __maybe_unused hda_dai_trigger(struct snd_pcm_substream *substream, i
{
const struct hda_dai_widget_dma_ops *ops = hda_dai_get_ops(substream, dai);
struct hdac_ext_stream *hext_stream;
struct sof_intel_hda_stream *hda_stream;
struct snd_sof_dev *sdev;
int ret;

Expand All @@ -334,24 +305,6 @@ static int __maybe_unused hda_dai_trigger(struct snd_pcm_substream *substream, i
hext_stream = ops->get_hext_stream(sdev, dai, substream);
if (!hext_stream)
return -EINVAL;
hda_stream = hstream_to_sof_hda_stream(hext_stream);

if (cmd == SNDRV_PCM_TRIGGER_RESUME && hda_stream->suspend_ignored) {
hda_stream->suspend_ignored = false;
return 0;
}

/*
* Set the suspend_ignored flag for BE which is used with
* D0I3-compatible streams used for WoV to keep the firmware pipeline
* running.
*/
if (cmd == SNDRV_PCM_TRIGGER_SUSPEND &&
sdev->system_suspend_target == SOF_SUSPEND_S0IX &&
hda_dai_has_wov_fe(sdev, substream)) {
hda_stream->suspend_ignored = true;
return 0;
}

if (ops->pre_trigger) {
ret = ops->pre_trigger(sdev, dai, substream, cmd);
Expand Down
4 changes: 2 additions & 2 deletions sound/soc/sof/intel/hda-dsp.c
Original file line number Diff line number Diff line change
Expand Up @@ -793,8 +793,8 @@ EXPORT_SYMBOL_NS(hda_dsp_set_power_state_ipc4, "SND_SOC_SOF_INTEL_HDA_COMMON");
* +----------------------------+ +----------------+
*
* S0IX suspend: The DSP is in D0I3 if any D0I3-compatible streams
* ignored the suspend trigger. Otherwise the DSP
* is in D3.
* are kept running during the suspend. Otherwise the
* DSP is in D3.
*/

static int hda_suspend(struct snd_sof_dev *sdev, bool runtime_suspend)
Expand Down
14 changes: 0 additions & 14 deletions sound/soc/sof/intel/hda-pcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -352,20 +352,6 @@ int hda_dsp_pcm_open(struct snd_sof_dev *sdev,
spcm->stream[substream->stream].d0i3_compatible)
flags |= SOF_HDA_STREAM_DMI_L1_COMPATIBLE;

/*
* Set the RESUME supported flag for WoV streams. The core will ignore
* the trigger but applications must not try to restart the WoV stream
* due to not supported RESUME.
* WoV streams can be indetified by:
* They are capture streams and
* They have the d0i3_compatible flag set and
* They don't use Deep Buffer
*/
if (direction == SNDRV_PCM_STREAM_CAPTURE &&
spcm->stream[substream->stream].d0i3_compatible &&
spcm->stream[substream->stream].dsp_max_burst_size_in_ms <= 1)
runtime->hw.info |= SNDRV_PCM_INFO_RESUME;

dsp_stream = hda_dsp_stream_get(sdev, direction, flags);
if (!dsp_stream) {
dev_err(sdev->dev, "error: no stream available\n");
Expand Down
1 change: 0 additions & 1 deletion sound/soc/sof/intel/hda.h
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,6 @@ struct sof_intel_hda_stream {
struct hdac_ext_stream hext_stream;
struct sof_intel_stream sof_intel_stream;
int host_reserved; /* reserve host DMA channel */
bool suspend_ignored;
u32 flags;
struct completion ioc;
};
Expand Down
Loading
Loading