Commit 0351a9b8 authored by Pierre-Louis Bossart's avatar Pierre-Louis Bossart Committed by Mark Brown

ASoC: SOF: Intel: hda-dai: start removing the use of runtime->private_data in BE

The SOF HDAudio code stores the Host DMA hdac_stream structure in the
FE substream->runtime->private_data. The BE dailink also uses the
substream->runtime->private_data to allocate the link DMA stream tag.

This really works by accident: the DPCM core copies the FE runtime
information in the BE, which has the side-effect of sharing the
FE-specific private_data with the BE.

To avoid more uses of the private_data with potential issues such as
accessing stale information or use-after-free cases, this patch
removes most of the usages of this private_data at the BE level. We
can directly use the existing dma_data to access the relevant
information.

However the hw_params still uses the information, mainly to go back to
the 'bus' structure required for the link dma stream tag
allocation. This is safe in that the 'bus' is not stream or PCM
specific.

The next patch will completely remove this last use of private_data by
using the component_drvdata - which is how SOF passes a global context
around.
Signed-off-by: default avatarPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: default avatarRanjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: default avatarPéter Ujfalusi <peter.ujfalusi@linux.intel.com>
Link: https://lore.kernel.org/r/20221024165310.246183-7-pierre-louis.bossart@linux.intel.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 33ac4ca7
...@@ -138,12 +138,12 @@ hda_link_stream_assign(struct hdac_bus *bus, ...@@ -138,12 +138,12 @@ hda_link_stream_assign(struct hdac_bus *bus,
} }
static int hda_link_dma_cleanup(struct snd_pcm_substream *substream, static int hda_link_dma_cleanup(struct snd_pcm_substream *substream,
struct hdac_stream *hstream, struct hdac_ext_stream *hext_stream,
struct snd_soc_dai *cpu_dai, struct snd_soc_dai *cpu_dai,
struct snd_soc_dai *codec_dai, struct snd_soc_dai *codec_dai,
bool trigger_suspend_stop) bool trigger_suspend_stop)
{ {
struct hdac_ext_stream *hext_stream = snd_soc_dai_get_dma_data(cpu_dai, substream); struct hdac_stream *hstream = &hext_stream->hstream;
struct hdac_bus *bus = hstream->bus; struct hdac_bus *bus = hstream->bus;
struct sof_intel_hda_stream *hda_stream; struct sof_intel_hda_stream *hda_stream;
struct hdac_ext_link *hlink; struct hdac_ext_link *hlink;
...@@ -257,7 +257,6 @@ static int hda_link_dma_prepare(struct snd_pcm_substream *substream) ...@@ -257,7 +257,6 @@ static int hda_link_dma_prepare(struct snd_pcm_substream *substream)
static int hda_link_dma_trigger(struct snd_pcm_substream *substream, int cmd) static int hda_link_dma_trigger(struct snd_pcm_substream *substream, int cmd)
{ {
struct hdac_stream *hstream = substream->runtime->private_data;
struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0); struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0); struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
...@@ -274,7 +273,7 @@ static int hda_link_dma_trigger(struct snd_pcm_substream *substream, int cmd) ...@@ -274,7 +273,7 @@ static int hda_link_dma_trigger(struct snd_pcm_substream *substream, int cmd)
break; break;
case SNDRV_PCM_TRIGGER_SUSPEND: case SNDRV_PCM_TRIGGER_SUSPEND:
case SNDRV_PCM_TRIGGER_STOP: case SNDRV_PCM_TRIGGER_STOP:
ret = hda_link_dma_cleanup(substream, hstream, cpu_dai, codec_dai, true); ret = hda_link_dma_cleanup(substream, hext_stream, cpu_dai, codec_dai, true);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -291,7 +290,6 @@ static int hda_link_dma_trigger(struct snd_pcm_substream *substream, int cmd) ...@@ -291,7 +290,6 @@ static int hda_link_dma_trigger(struct snd_pcm_substream *substream, int cmd)
static int hda_link_dma_hw_free(struct snd_pcm_substream *substream) static int hda_link_dma_hw_free(struct snd_pcm_substream *substream)
{ {
struct hdac_stream *hstream = substream->runtime->private_data;
struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0); struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0); struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
...@@ -301,7 +299,7 @@ static int hda_link_dma_hw_free(struct snd_pcm_substream *substream) ...@@ -301,7 +299,7 @@ static int hda_link_dma_hw_free(struct snd_pcm_substream *substream)
if (!hext_stream) if (!hext_stream)
return 0; return 0;
return hda_link_dma_cleanup(substream, hstream, cpu_dai, codec_dai, false); return hda_link_dma_cleanup(substream, hext_stream, cpu_dai, codec_dai, false);
} }
static int hda_dai_widget_update(struct snd_soc_dapm_widget *w, static int hda_dai_widget_update(struct snd_soc_dapm_widget *w,
...@@ -458,14 +456,12 @@ static int ipc4_hda_dai_trigger(struct snd_pcm_substream *substream, ...@@ -458,14 +456,12 @@ static int ipc4_hda_dai_trigger(struct snd_pcm_substream *substream,
struct snd_sof_widget *swidget; struct snd_sof_widget *swidget;
struct snd_soc_dapm_widget *w; struct snd_soc_dapm_widget *w;
struct snd_soc_dai *codec_dai; struct snd_soc_dai *codec_dai;
struct hdac_stream *hstream;
struct snd_soc_dai *cpu_dai; struct snd_soc_dai *cpu_dai;
int ret; int ret;
dev_dbg(dai->dev, "cmd=%d dai %s direction %d\n", cmd, dev_dbg(dai->dev, "cmd=%d dai %s direction %d\n", cmd,
dai->name, substream->stream); dai->name, substream->stream);
hstream = substream->runtime->private_data;
rtd = asoc_substream_to_rtd(substream); rtd = asoc_substream_to_rtd(substream);
cpu_dai = asoc_rtd_to_cpu(rtd, 0); cpu_dai = asoc_rtd_to_cpu(rtd, 0);
codec_dai = asoc_rtd_to_codec(rtd, 0); codec_dai = asoc_rtd_to_codec(rtd, 0);
...@@ -500,7 +496,7 @@ static int ipc4_hda_dai_trigger(struct snd_pcm_substream *substream, ...@@ -500,7 +496,7 @@ static int ipc4_hda_dai_trigger(struct snd_pcm_substream *substream,
pipeline->state = SOF_IPC4_PIPE_RESET; pipeline->state = SOF_IPC4_PIPE_RESET;
ret = hda_link_dma_cleanup(substream, hstream, cpu_dai, codec_dai, false); ret = hda_link_dma_cleanup(substream, hext_stream, cpu_dai, codec_dai, false);
if (ret < 0) { if (ret < 0) {
dev_err(sdev->dev, "%s: failed to clean up link DMA\n", __func__); dev_err(sdev->dev, "%s: failed to clean up link DMA\n", __func__);
return ret; return ret;
...@@ -575,7 +571,8 @@ static int hda_dai_suspend(struct hdac_bus *bus) ...@@ -575,7 +571,8 @@ static int hda_dai_suspend(struct hdac_bus *bus)
cpu_dai = asoc_rtd_to_cpu(rtd, 0); cpu_dai = asoc_rtd_to_cpu(rtd, 0);
codec_dai = asoc_rtd_to_codec(rtd, 0); codec_dai = asoc_rtd_to_codec(rtd, 0);
ret = hda_link_dma_cleanup(hext_stream->link_substream, s, ret = hda_link_dma_cleanup(hext_stream->link_substream,
hext_stream,
cpu_dai, codec_dai, false); cpu_dai, codec_dai, false);
if (ret < 0) if (ret < 0)
return ret; return ret;
......
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