From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> To: Liam Girdwood <lgirdwood@gmail.com>, Mark Brown <broonie@kernel.org>, Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com> Cc: Biju Das <biju.das.jz@bp.renesas.com>, Pavel Machek <pavel@denx.de>, Cezary Rojewski <cezary.rojewski@intel.com>, linux-renesas-soc@vger.kernel.org, Prabhakar <prabhakar.csengg@gmail.com>, Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 5/5] ASoC: sh: rz-ssi: Add rz_ssi_set_substream() helper function Date: Sat, 15 Jan 2022 01:23:03 +0000 [thread overview] Message-ID: <20220115012303.29651-6-prabhakar.mahadev-lad.rj@bp.renesas.com> (raw) In-Reply-To: <20220115012303.29651-1-prabhakar.mahadev-lad.rj@bp.renesas.com> A copy of substream pointer is stored in priv structure during rz_ssi_dai_trigger() callback ie in SNDRV_PCM_TRIGGER_START case and the pointer is assigned to NULL in case of SNDRV_PCM_TRIGGER_STOP. The driver used the locks only in rz_ssi_stream_is_valid() and assigned the local substream pointer to NULL in rz_ssi_dai_trigger() callback but never locked it while making a local copy. This patch adds the rz_ssi_set_substream() helper function to set the substream pointer with locks acquired and replaces the instances of setting the local substream pointer with the rz_ssi_set_substream() function. Reported-by: Pavel Machek <pavel@denx.de> Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> Reviewed-by: Biju Das <biju.das.jz@bp.renesas.com> --- v1->v2 * Dropped rz_ssi_get_substream() helper. --- sound/soc/sh/rz-ssi.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/sound/soc/sh/rz-ssi.c b/sound/soc/sh/rz-ssi.c index 2da43eecfb3e..07fdbcfa5b63 100644 --- a/sound/soc/sh/rz-ssi.c +++ b/sound/soc/sh/rz-ssi.c @@ -188,6 +188,17 @@ static inline bool rz_ssi_is_dma_enabled(struct rz_ssi_priv *ssi) return (ssi->playback.dma_ch && (ssi->dma_rt || ssi->capture.dma_ch)); } +static void rz_ssi_set_substream(struct rz_ssi_stream *strm, + struct snd_pcm_substream *substream) +{ + struct rz_ssi_priv *ssi = strm->priv; + unsigned long flags; + + spin_lock_irqsave(&ssi->lock, flags); + strm->substream = substream; + spin_unlock_irqrestore(&ssi->lock, flags); +} + static bool rz_ssi_stream_is_valid(struct rz_ssi_priv *ssi, struct rz_ssi_stream *strm) { @@ -206,7 +217,7 @@ static void rz_ssi_stream_init(struct rz_ssi_stream *strm, { struct snd_pcm_runtime *runtime = substream->runtime; - strm->substream = substream; + rz_ssi_set_substream(strm, substream); strm->sample_width = samples_to_bytes(runtime, 1); strm->dma_buffer_pos = 0; strm->period_counter = 0; @@ -224,11 +235,8 @@ static void rz_ssi_stream_quit(struct rz_ssi_priv *ssi, struct rz_ssi_stream *strm) { struct snd_soc_dai *dai = rz_ssi_get_dai(strm->substream); - unsigned long flags; - spin_lock_irqsave(&ssi->lock, flags); - strm->substream = NULL; - spin_unlock_irqrestore(&ssi->lock, flags); + rz_ssi_set_substream(strm, NULL); if (strm->oerr_num > 0) dev_info(dai->dev, "overrun = %d\n", strm->oerr_num); -- 2.17.1
WARNING: multiple messages have this Message-ID (diff)
From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> To: Liam Girdwood <lgirdwood@gmail.com>, Mark Brown <broonie@kernel.org>, Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com> Cc: Cezary Rojewski <cezary.rojewski@intel.com>, alsa-devel@alsa-project.org, Pavel Machek <pavel@denx.de>, Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>, linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Prabhakar <prabhakar.csengg@gmail.com>, Biju Das <biju.das.jz@bp.renesas.com> Subject: [PATCH v2 5/5] ASoC: sh: rz-ssi: Add rz_ssi_set_substream() helper function Date: Sat, 15 Jan 2022 01:23:03 +0000 [thread overview] Message-ID: <20220115012303.29651-6-prabhakar.mahadev-lad.rj@bp.renesas.com> (raw) In-Reply-To: <20220115012303.29651-1-prabhakar.mahadev-lad.rj@bp.renesas.com> A copy of substream pointer is stored in priv structure during rz_ssi_dai_trigger() callback ie in SNDRV_PCM_TRIGGER_START case and the pointer is assigned to NULL in case of SNDRV_PCM_TRIGGER_STOP. The driver used the locks only in rz_ssi_stream_is_valid() and assigned the local substream pointer to NULL in rz_ssi_dai_trigger() callback but never locked it while making a local copy. This patch adds the rz_ssi_set_substream() helper function to set the substream pointer with locks acquired and replaces the instances of setting the local substream pointer with the rz_ssi_set_substream() function. Reported-by: Pavel Machek <pavel@denx.de> Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> Reviewed-by: Biju Das <biju.das.jz@bp.renesas.com> --- v1->v2 * Dropped rz_ssi_get_substream() helper. --- sound/soc/sh/rz-ssi.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/sound/soc/sh/rz-ssi.c b/sound/soc/sh/rz-ssi.c index 2da43eecfb3e..07fdbcfa5b63 100644 --- a/sound/soc/sh/rz-ssi.c +++ b/sound/soc/sh/rz-ssi.c @@ -188,6 +188,17 @@ static inline bool rz_ssi_is_dma_enabled(struct rz_ssi_priv *ssi) return (ssi->playback.dma_ch && (ssi->dma_rt || ssi->capture.dma_ch)); } +static void rz_ssi_set_substream(struct rz_ssi_stream *strm, + struct snd_pcm_substream *substream) +{ + struct rz_ssi_priv *ssi = strm->priv; + unsigned long flags; + + spin_lock_irqsave(&ssi->lock, flags); + strm->substream = substream; + spin_unlock_irqrestore(&ssi->lock, flags); +} + static bool rz_ssi_stream_is_valid(struct rz_ssi_priv *ssi, struct rz_ssi_stream *strm) { @@ -206,7 +217,7 @@ static void rz_ssi_stream_init(struct rz_ssi_stream *strm, { struct snd_pcm_runtime *runtime = substream->runtime; - strm->substream = substream; + rz_ssi_set_substream(strm, substream); strm->sample_width = samples_to_bytes(runtime, 1); strm->dma_buffer_pos = 0; strm->period_counter = 0; @@ -224,11 +235,8 @@ static void rz_ssi_stream_quit(struct rz_ssi_priv *ssi, struct rz_ssi_stream *strm) { struct snd_soc_dai *dai = rz_ssi_get_dai(strm->substream); - unsigned long flags; - spin_lock_irqsave(&ssi->lock, flags); - strm->substream = NULL; - spin_unlock_irqrestore(&ssi->lock, flags); + rz_ssi_set_substream(strm, NULL); if (strm->oerr_num > 0) dev_info(dai->dev, "overrun = %d\n", strm->oerr_num); -- 2.17.1
next prev parent reply other threads:[~2022-01-15 1:23 UTC|newest] Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-01-15 1:22 [PATCH v2 0/5] ASoC: sh: rz-ssi: Code cleanup and fixes Lad Prabhakar 2022-01-15 1:22 ` [PATCH v2 1/5] ASoC: sh: rz-ssi: Drop calling rz_ssi_pio_recv() recursively Lad Prabhakar 2022-01-15 1:22 ` Lad Prabhakar 2022-01-19 13:35 ` Cezary Rojewski 2022-01-19 13:35 ` Cezary Rojewski 2022-01-25 10:22 ` Mark Brown 2022-01-25 10:22 ` Mark Brown 2022-01-15 1:23 ` [PATCH v2 2/5] ASoC: sh: rz-ssi: Make the data structures available before registering the handlers Lad Prabhakar 2022-01-15 1:23 ` Lad Prabhakar 2022-01-15 1:23 ` [PATCH v2 3/5] ASoC: sh: rz-ssi: Drop ssi parameter from rz_ssi_stream_init() Lad Prabhakar 2022-01-15 1:23 ` Lad Prabhakar 2022-01-15 1:23 ` [PATCH v2 4/5] ASoC: sh: rz-ssi: Change return type of rz_ssi_stream_is_valid() to bool Lad Prabhakar 2022-01-15 1:23 ` Lad Prabhakar 2022-01-15 1:23 ` Lad Prabhakar [this message] 2022-01-15 1:23 ` [PATCH v2 5/5] ASoC: sh: rz-ssi: Add rz_ssi_set_substream() helper function Lad Prabhakar 2022-01-19 14:11 ` [PATCH v2 0/5] ASoC: sh: rz-ssi: Code cleanup and fixes Cezary Rojewski 2022-01-19 15:05 ` Lad, Prabhakar 2022-01-25 10:20 ` Mark Brown 2022-01-25 12:25 ` Lad, Prabhakar 2022-01-25 12:30 ` Mark Brown 2022-01-25 13:16 ` Lad, Prabhakar
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20220115012303.29651-6-prabhakar.mahadev-lad.rj@bp.renesas.com \ --to=prabhakar.mahadev-lad.rj@bp.renesas.com \ --cc=alsa-devel@alsa-project.org \ --cc=biju.das.jz@bp.renesas.com \ --cc=broonie@kernel.org \ --cc=cezary.rojewski@intel.com \ --cc=lgirdwood@gmail.com \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-renesas-soc@vger.kernel.org \ --cc=pavel@denx.de \ --cc=perex@perex.cz \ --cc=prabhakar.csengg@gmail.com \ --cc=tiwai@suse.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.