All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vasily Khoruzhick <anarsoul@gmail.com>
To: Maxime Ripard <maxime.ripard@bootlin.com>
Cc: Linux-ALSA <alsa-devel@alsa-project.org>,
	Takashi Iwai <tiwai@suse.com>,
	Liam Girdwood <lgirdwood@gmail.com>,
	Marcus Cooper <codekipper@gmail.com>,
	Chen-Yu Tsai <wens@csie.org>, Mark Brown <broonie@kernel.org>,
	Yong Deng <yong.deng@magewell.com>,
	arm-linux <linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH v2] ASoC: sun4i-i2s: move code from startup/shutdown hooks into pm_runtime hooks
Date: Tue, 16 Oct 2018 20:08:41 -0700	[thread overview]
Message-ID: <CA+E=qVcK7mBbZ-C8FyAxUty_wQ_aOjo1b0+iU4E5CgG=yBCj=g@mail.gmail.com> (raw)
In-Reply-To: <20181016071626.m6jkoiixkvxks5ob@flea>

On Tue, Oct 16, 2018 at 12:16 AM Maxime Ripard
<maxime.ripard@bootlin.com> wrote:
>
> On Mon, Oct 15, 2018 at 08:11:41PM -0700, Vasily Khoruzhick wrote:
> > startup() and shutdown() hooks are called for both substreams,
> > so stopping either substream when another is running breaks the
> > latter.
> >
> > E.g. playback breaks if capture is stopped when playback is running.
> >
> > Move code from startup() and shutdown() to resume() and suspend()
> > hooks respectively to fix this issue
> >
> > Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com>
> > ---
> > v2: - rename from "ASoC: sun4i-i2s: don't try to start up
> >                  or shut down DAI if it's active"
> >     - move code from startup/shutdown hooks into pm_runtime
> >
> >  sound/soc/sunxi/sun4i-i2s.c | 61 +++++++++++++++----------------------
> >  1 file changed, 25 insertions(+), 36 deletions(-)
> >
> > diff --git a/sound/soc/sunxi/sun4i-i2s.c b/sound/soc/sunxi/sun4i-i2s.c
> > index a4aa931ebfae..daa6c08cffbc 100644
> > --- a/sound/soc/sunxi/sun4i-i2s.c
> > +++ b/sound/soc/sunxi/sun4i-i2s.c
> > @@ -644,40 +644,6 @@ static int sun4i_i2s_trigger(struct snd_pcm_substream *substream, int cmd,
> >       return 0;
> >  }
> >
> > -static int sun4i_i2s_startup(struct snd_pcm_substream *substream,
> > -                          struct snd_soc_dai *dai)
> > -{
> > -     struct sun4i_i2s *i2s = snd_soc_dai_get_drvdata(dai);
> > -
> > -     /* Enable the whole hardware block */
> > -     regmap_update_bits(i2s->regmap, SUN4I_I2S_CTRL_REG,
> > -                        SUN4I_I2S_CTRL_GL_EN, SUN4I_I2S_CTRL_GL_EN);
> > -
> > -     /* Enable the first output line */
> > -     regmap_update_bits(i2s->regmap, SUN4I_I2S_CTRL_REG,
> > -                        SUN4I_I2S_CTRL_SDO_EN_MASK,
> > -                        SUN4I_I2S_CTRL_SDO_EN(0));
> > -
> > -
> > -     return clk_prepare_enable(i2s->mod_clk);
> > -}
> > -
> > -static void sun4i_i2s_shutdown(struct snd_pcm_substream *substream,
> > -                            struct snd_soc_dai *dai)
> > -{
> > -     struct sun4i_i2s *i2s = snd_soc_dai_get_drvdata(dai);
> > -
> > -     clk_disable_unprepare(i2s->mod_clk);
> > -
> > -     /* Disable our output lines */
> > -     regmap_update_bits(i2s->regmap, SUN4I_I2S_CTRL_REG,
> > -                        SUN4I_I2S_CTRL_SDO_EN_MASK, 0);
> > -
> > -     /* Disable the whole hardware block */
> > -     regmap_update_bits(i2s->regmap, SUN4I_I2S_CTRL_REG,
> > -                        SUN4I_I2S_CTRL_GL_EN, 0);
> > -}
> > -
> >  static int sun4i_i2s_set_sysclk(struct snd_soc_dai *dai, int clk_id,
> >                               unsigned int freq, int dir)
> >  {
> > @@ -695,8 +661,6 @@ static const struct snd_soc_dai_ops sun4i_i2s_dai_ops = {
> >       .hw_params      = sun4i_i2s_hw_params,
> >       .set_fmt        = sun4i_i2s_set_fmt,
> >       .set_sysclk     = sun4i_i2s_set_sysclk,
> > -     .shutdown       = sun4i_i2s_shutdown,
> > -     .startup        = sun4i_i2s_startup,
> >       .trigger        = sun4i_i2s_trigger,
> >  };
> >
> > @@ -869,6 +833,21 @@ static int sun4i_i2s_runtime_resume(struct device *dev)
> >               goto err_disable_clk;
> >       }
> >
> > +     /* Enable the whole hardware block */
> > +     regmap_update_bits(i2s->regmap, SUN4I_I2S_CTRL_REG,
> > +                        SUN4I_I2S_CTRL_GL_EN, SUN4I_I2S_CTRL_GL_EN);
> > +
>
> So this is definitely needed
>
> > +     /* Enable the first output line */
> > +     regmap_update_bits(i2s->regmap, SUN4I_I2S_CTRL_REG,
> > +                        SUN4I_I2S_CTRL_SDO_EN_MASK,
> > +                        SUN4I_I2S_CTRL_SDO_EN(0));
> > +
> > +     ret = clk_prepare_enable(i2s->mod_clk);
> > +     if (ret) {
> > +             dev_err(dev, "Failed to enable module clock\n");
> > +             goto err_disable_clk;
> > +     }
>
> But we really don't want to enable the module clock before the
> playback / capture actually starts. And I'm guessing it would make
> more sense to keep the output enable configuration there as well,
> since it's likely that we will have support for it in the future, and
> we'll need additional information from ASoC when we'll do.

Should we go with v1 version of my patch then? I see no reason to
shuffle code around if we keep startup() and shutdown() hooks.

> Maxime
>
> --
> Maxime Ripard, Bootlin
> Embedded Linux and Kernel engineering
> https://bootlin.com

WARNING: multiple messages have this Message-ID (diff)
From: anarsoul@gmail.com (Vasily Khoruzhick)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2] ASoC: sun4i-i2s: move code from startup/shutdown hooks into pm_runtime hooks
Date: Tue, 16 Oct 2018 20:08:41 -0700	[thread overview]
Message-ID: <CA+E=qVcK7mBbZ-C8FyAxUty_wQ_aOjo1b0+iU4E5CgG=yBCj=g@mail.gmail.com> (raw)
In-Reply-To: <20181016071626.m6jkoiixkvxks5ob@flea>

On Tue, Oct 16, 2018 at 12:16 AM Maxime Ripard
<maxime.ripard@bootlin.com> wrote:
>
> On Mon, Oct 15, 2018 at 08:11:41PM -0700, Vasily Khoruzhick wrote:
> > startup() and shutdown() hooks are called for both substreams,
> > so stopping either substream when another is running breaks the
> > latter.
> >
> > E.g. playback breaks if capture is stopped when playback is running.
> >
> > Move code from startup() and shutdown() to resume() and suspend()
> > hooks respectively to fix this issue
> >
> > Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com>
> > ---
> > v2: - rename from "ASoC: sun4i-i2s: don't try to start up
> >                  or shut down DAI if it's active"
> >     - move code from startup/shutdown hooks into pm_runtime
> >
> >  sound/soc/sunxi/sun4i-i2s.c | 61 +++++++++++++++----------------------
> >  1 file changed, 25 insertions(+), 36 deletions(-)
> >
> > diff --git a/sound/soc/sunxi/sun4i-i2s.c b/sound/soc/sunxi/sun4i-i2s.c
> > index a4aa931ebfae..daa6c08cffbc 100644
> > --- a/sound/soc/sunxi/sun4i-i2s.c
> > +++ b/sound/soc/sunxi/sun4i-i2s.c
> > @@ -644,40 +644,6 @@ static int sun4i_i2s_trigger(struct snd_pcm_substream *substream, int cmd,
> >       return 0;
> >  }
> >
> > -static int sun4i_i2s_startup(struct snd_pcm_substream *substream,
> > -                          struct snd_soc_dai *dai)
> > -{
> > -     struct sun4i_i2s *i2s = snd_soc_dai_get_drvdata(dai);
> > -
> > -     /* Enable the whole hardware block */
> > -     regmap_update_bits(i2s->regmap, SUN4I_I2S_CTRL_REG,
> > -                        SUN4I_I2S_CTRL_GL_EN, SUN4I_I2S_CTRL_GL_EN);
> > -
> > -     /* Enable the first output line */
> > -     regmap_update_bits(i2s->regmap, SUN4I_I2S_CTRL_REG,
> > -                        SUN4I_I2S_CTRL_SDO_EN_MASK,
> > -                        SUN4I_I2S_CTRL_SDO_EN(0));
> > -
> > -
> > -     return clk_prepare_enable(i2s->mod_clk);
> > -}
> > -
> > -static void sun4i_i2s_shutdown(struct snd_pcm_substream *substream,
> > -                            struct snd_soc_dai *dai)
> > -{
> > -     struct sun4i_i2s *i2s = snd_soc_dai_get_drvdata(dai);
> > -
> > -     clk_disable_unprepare(i2s->mod_clk);
> > -
> > -     /* Disable our output lines */
> > -     regmap_update_bits(i2s->regmap, SUN4I_I2S_CTRL_REG,
> > -                        SUN4I_I2S_CTRL_SDO_EN_MASK, 0);
> > -
> > -     /* Disable the whole hardware block */
> > -     regmap_update_bits(i2s->regmap, SUN4I_I2S_CTRL_REG,
> > -                        SUN4I_I2S_CTRL_GL_EN, 0);
> > -}
> > -
> >  static int sun4i_i2s_set_sysclk(struct snd_soc_dai *dai, int clk_id,
> >                               unsigned int freq, int dir)
> >  {
> > @@ -695,8 +661,6 @@ static const struct snd_soc_dai_ops sun4i_i2s_dai_ops = {
> >       .hw_params      = sun4i_i2s_hw_params,
> >       .set_fmt        = sun4i_i2s_set_fmt,
> >       .set_sysclk     = sun4i_i2s_set_sysclk,
> > -     .shutdown       = sun4i_i2s_shutdown,
> > -     .startup        = sun4i_i2s_startup,
> >       .trigger        = sun4i_i2s_trigger,
> >  };
> >
> > @@ -869,6 +833,21 @@ static int sun4i_i2s_runtime_resume(struct device *dev)
> >               goto err_disable_clk;
> >       }
> >
> > +     /* Enable the whole hardware block */
> > +     regmap_update_bits(i2s->regmap, SUN4I_I2S_CTRL_REG,
> > +                        SUN4I_I2S_CTRL_GL_EN, SUN4I_I2S_CTRL_GL_EN);
> > +
>
> So this is definitely needed
>
> > +     /* Enable the first output line */
> > +     regmap_update_bits(i2s->regmap, SUN4I_I2S_CTRL_REG,
> > +                        SUN4I_I2S_CTRL_SDO_EN_MASK,
> > +                        SUN4I_I2S_CTRL_SDO_EN(0));
> > +
> > +     ret = clk_prepare_enable(i2s->mod_clk);
> > +     if (ret) {
> > +             dev_err(dev, "Failed to enable module clock\n");
> > +             goto err_disable_clk;
> > +     }
>
> But we really don't want to enable the module clock before the
> playback / capture actually starts. And I'm guessing it would make
> more sense to keep the output enable configuration there as well,
> since it's likely that we will have support for it in the future, and
> we'll need additional information from ASoC when we'll do.

Should we go with v1 version of my patch then? I see no reason to
shuffle code around if we keep startup() and shutdown() hooks.

> Maxime
>
> --
> Maxime Ripard, Bootlin
> Embedded Linux and Kernel engineering
> https://bootlin.com

  reply	other threads:[~2018-10-17  3:09 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-16  3:11 [PATCH v2] ASoC: sun4i-i2s: move code from startup/shutdown hooks into pm_runtime hooks Vasily Khoruzhick
2018-10-16  3:11 ` Vasily Khoruzhick
2018-10-16  7:16 ` Maxime Ripard
2018-10-16  7:16   ` Maxime Ripard
2018-10-17  3:08   ` Vasily Khoruzhick [this message]
2018-10-17  3:08     ` Vasily Khoruzhick
2018-10-17  7:45     ` Maxime Ripard
2018-10-17  7:45       ` Maxime Ripard
2018-10-17 14:41       ` Vasily Khoruzhick
2018-10-17 14:41         ` Vasily Khoruzhick
2018-10-17 15:25         ` Maxime Ripard
2018-10-17 15:25           ` Maxime Ripard
2018-10-17 15:36           ` Vasily Khoruzhick
2018-10-17 15:36             ` Vasily Khoruzhick
2018-10-17 21:01             ` Maxime Ripard
2018-10-17 21:01               ` Maxime Ripard
2018-10-19 16:18               ` Vasily Khoruzhick
2018-10-19 16:18                 ` Vasily Khoruzhick
2018-10-21 14:02                 ` Mark Brown
2018-10-21 14:02                   ` Mark Brown

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='CA+E=qVcK7mBbZ-C8FyAxUty_wQ_aOjo1b0+iU4E5CgG=yBCj=g@mail.gmail.com' \
    --to=anarsoul@gmail.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=codekipper@gmail.com \
    --cc=lgirdwood@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=maxime.ripard@bootlin.com \
    --cc=tiwai@suse.com \
    --cc=wens@csie.org \
    --cc=yong.deng@magewell.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: link
Be 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.