Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ASoC: soc-pcm.c: remove indirect runtime copy

substream->runtime will be attached when substream was opened
at snd_pcm_attach_substream(). When it uses DPCM,
FE substream->runtime is attached, but BE substream->runtime is not.
Thus, we are copying FE substream->runtime to BE.

But, we are copyig FE substream->runtime to FE dpcm->runtime first (A),
and copy it to BE dpcm->runtime (B), and copy it to
BE substream->runtime (C).

static int dpcm_fe_dai_open(...) {
...
(A) fe->dpcm[stream].runtime = fe_substream->runtime;
...
}

static int dpcm_be_connect(...) {
...
(B) be->dpcm[stream].runtime = fe->dpcm[stream].runtime;
...
}

int dpcm_be_dai_startup(...) {
...
(C) be_substream->runtime = be->dpcm[stream].runtime;
...
}

It is too roundabout and troublesome.
OTOH, it is directly copying fe_substream->runtime at dpcm_be_reparent()
without using be->dpcm[stream].runtime.

static void dpcm_be_reparent(...)
{
...
for_each_dpcm_fe(be, stream, dpcm) {
...
=> be_substream->runtime = fe_substream->runtime;
break;
}
}

This patch removes indirect copying.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87v8je64dh.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Kuninori Morimoto and committed by
Mark Brown
0d3a5178 5c5a7521

+4 -14
-1
include/sound/soc-dpcm.h
··· 91 91 struct list_head fe_clients; 92 92 93 93 int users; 94 - struct snd_pcm_runtime *runtime; 95 94 struct snd_pcm_hw_params hw_params; 96 95 97 96 /* state and update */
-7
sound/soc/soc-compress.c
··· 134 134 static int soc_compr_open_fe(struct snd_compr_stream *cstream) 135 135 { 136 136 struct snd_soc_pcm_runtime *fe = cstream->private_data; 137 - struct snd_pcm_substream *fe_substream = 138 - fe->pcm->streams[cstream->direction].substream; 139 137 struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(fe, 0); 140 138 struct snd_soc_dpcm *dpcm; 141 139 struct snd_soc_dapm_widget_list *list; ··· 141 143 int ret; 142 144 143 145 mutex_lock_nested(&fe->card->mutex, SND_SOC_CARD_CLASS_RUNTIME); 144 - fe->dpcm[stream].runtime = fe_substream->runtime; 145 146 146 147 ret = dpcm_path_get(fe, stream, &list); 147 148 if (ret < 0) ··· 150 153 151 154 /* calculate valid and active FE <-> BE dpcms */ 152 155 dpcm_process_paths(fe, stream, &list, 1); 153 - fe->dpcm[stream].runtime = fe_substream->runtime; 154 156 155 157 fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_FE; 156 158 ··· 160 164 dpcm->state = SND_SOC_DPCM_LINK_STATE_FREE; 161 165 162 166 dpcm_be_disconnect(fe, stream); 163 - fe->dpcm[stream].runtime = NULL; 164 167 goto out; 165 168 } 166 169 ··· 230 235 dpcm_be_disconnect(fe, stream); 231 236 232 237 mutex_unlock(&fe->card->pcm_mutex); 233 - 234 - fe->dpcm[stream].runtime = NULL; 235 238 236 239 snd_soc_link_compr_shutdown(cstream, 0); 237 240
+4 -6
sound/soc/soc-pcm.c
··· 1230 1230 1231 1231 dpcm->be = be; 1232 1232 dpcm->fe = fe; 1233 - be->dpcm[stream].runtime = fe->dpcm[stream].runtime; 1234 1233 dpcm->state = SND_SOC_DPCM_LINK_STATE_NEW; 1235 1234 snd_soc_dpcm_stream_lock_irq(fe, stream); 1236 1235 list_add(&dpcm->list_be, &fe->dpcm[stream].be_clients); ··· 1464 1465 struct snd_soc_dapm_widget_list *list = *list_; 1465 1466 struct snd_soc_pcm_runtime *be; 1466 1467 struct snd_soc_dapm_widget *widget; 1468 + struct snd_pcm_substream *fe_substream = snd_soc_dpcm_get_substream(fe, stream); 1467 1469 int i, new = 0, err; 1468 1470 1469 1471 /* don't connect if FE is not running */ 1470 - if (!fe->dpcm[stream].runtime && !fe->fe_compr) 1472 + if (!fe_substream->runtime && !fe->fe_compr) 1471 1473 return new; 1472 1474 1473 1475 /* Create any new FE <--> BE connections */ ··· 1590 1590 1591 1591 int dpcm_be_dai_startup(struct snd_soc_pcm_runtime *fe, int stream) 1592 1592 { 1593 + struct snd_pcm_substream *fe_substream = snd_soc_dpcm_get_substream(fe, stream); 1593 1594 struct snd_soc_pcm_runtime *be; 1594 1595 struct snd_soc_dpcm *dpcm; 1595 1596 int err, count = 0; ··· 1630 1629 dev_dbg(be->dev, "ASoC: open %s BE %s\n", 1631 1630 stream ? "capture" : "playback", be->dai_link->name); 1632 1631 1633 - be_substream->runtime = be->dpcm[stream].runtime; 1632 + be_substream->runtime = fe_substream->runtime; 1634 1633 err = __soc_pcm_open(be, be_substream); 1635 1634 if (err < 0) { 1636 1635 be->dpcm[stream].users--; ··· 2694 2693 dpcm->state = SND_SOC_DPCM_LINK_STATE_FREE; 2695 2694 2696 2695 dpcm_be_disconnect(fe, stream); 2697 - 2698 - fe->dpcm[stream].runtime = NULL; 2699 2696 } 2700 2697 2701 2698 static int dpcm_fe_dai_close(struct snd_pcm_substream *fe_substream) ··· 2718 2719 int stream = fe_substream->stream; 2719 2720 2720 2721 snd_soc_dpcm_mutex_lock(fe); 2721 - fe->dpcm[stream].runtime = fe_substream->runtime; 2722 2722 2723 2723 ret = dpcm_path_get(fe, stream, &list); 2724 2724 if (ret < 0)