alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
From: Richard Fitzgerald <rf@opensource.wolfsonmicro.com>
To: Mark Brown <broonie@kernel.org>
Cc: patches@opensource.wolfsonmicro.com,
	linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org,
	lgirdwood@gmail.com
Subject: Re: [PATCH v7 1/4] ASoC: arizona: Export functions to control subsystem DVFS
Date: Mon, 1 Jun 2015 17:22:51 +0100	[thread overview]
Message-ID: <20150601162241.GA13681@opensource.wolfsonmicro.com> (raw)
In-Reply-To: <20150601161047.GC14071@sirena.org.uk>

On Mon, Jun 01, 2015 at 05:10:47PM +0100, Mark Brown wrote:
> On Mon, Jun 01, 2015 at 02:04:48PM +0100, Richard Fitzgerald wrote:
> 
> > +int arizona_dvfs_down(struct snd_soc_codec *codec, unsigned int flags)
> > +{
> > +	struct arizona_priv *priv = snd_soc_codec_get_drvdata(codec);
> > +	unsigned int old_reqs = priv->dvfs_reqs;
> > +	int ret = 0;
> > +
> > +	mutex_lock(&priv->dvfs_lock);
> > +
> > +	priv->dvfs_reqs &= ~flags;
> > +
> > +	if (!priv->dvfs_cached && old_reqs && !priv->dvfs_reqs)
> > +		ret = arizona_dvfs_disable(codec);
> 
> What is the lock intended to protect here?  We read old_reqs outside the
> lock so it's possible that dvfs_reqs could change between us reading
> old_reqs and the locked section - I would have expected to see all the
> reads and updates to be in the locked section but perhaps it doesn't
> protect what I think it protects (all the DVFS-related variables).
> 

Damn, I didn't notice that assignment when I added the mutex lock.

> > +	case SND_SOC_DAPM_PRE_PMD:
> > +		/* We must ensure DVFS is disabled before the codec goes into
> > +		 * suspend so that we are never in an illegal state of DVFS
> > +		 * enabled without enough DCVDD
> > +		 */
> > +		priv->dvfs_cached = true;
> > +
> > +		if (priv->dvfs_reqs)
> > +			ret = arizona_dvfs_disable(codec);
> 
> Are you sure that the function shouldn't check for requests?  It seems
> like every caller is repeating the same check.

Sorry, I don't understand your comment here. When SYSCLK is disabled
we need to disable DVFS so that the codec can't go into suspend in the
illegal state of DVFS enabled but insifficient DCVDD. However, if
dvfs_reqs==0 DVFS is already disabled so we can save some time.

  reply	other threads:[~2015-06-01 16:22 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-01 13:04 [PATCH v7 1/4] ASoC: arizona: Export functions to control subsystem DVFS Richard Fitzgerald
2015-06-01 13:04 ` [PATCH v7 2/4] ASoC: wm_adsp: Move DVFS control into codec driver Richard Fitzgerald
2015-06-01 13:04 ` [PATCH v7 3/4] ASoC: arizona: Add DVFS handling for sample rate control Richard Fitzgerald
2015-06-01 13:04 ` [PATCH v7 4/4] regulator: arizona-ldo1: Do not control DVFS clocking from regulator Richard Fitzgerald
2015-06-01 16:10 ` [PATCH v7 1/4] ASoC: arizona: Export functions to control subsystem DVFS Mark Brown
2015-06-01 16:22   ` Richard Fitzgerald [this message]
2015-06-01 16:36     ` Mark Brown
2015-06-02 10:32       ` Richard Fitzgerald

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=20150601162241.GA13681@opensource.wolfsonmicro.com \
    --to=rf@opensource.wolfsonmicro.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=patches@opensource.wolfsonmicro.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).