From: Mark Brown <broonie@kernel.org>
To: Richard Fitzgerald <rf@opensource.cirrus.com>
Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org,
patches@opensource.cirrus.com
Subject: Re: [PATCH] ASoC: cs42l42: Implement system suspend
Date: Wed, 1 Dec 2021 16:32:02 +0000 [thread overview]
Message-ID: <YaejghraYE6lD7FD@sirena.org.uk> (raw)
In-Reply-To: <20211201153648.17259-1-rf@opensource.cirrus.com>
[-- Attachment #1: Type: text/plain, Size: 2829 bytes --]
On Wed, Dec 01, 2021 at 03:36:48PM +0000, Richard Fitzgerald wrote:
> Add system suspend functions to handle clean power-down on suspend and
> restoring state on resume.
>
> The jack state could change during suspend. Plug->unplug and unplug->plug
> are straightforward because this looks no different from any other plug
> state change. However, the jack could be unplugged and a different type
This fiddling about with the jack detect feels like it should be at
least one separate change, possibly multiple changes - the reporting of
button states feels like it should be a good cleanup/fix separately for
example.
> of jack plugged, and on resume the plug state would not have changed.
> Some code changes are needed to the jack handling so that on resume a
> plugged state will be re-evaluated instead of filtered out. In this case
It would be helpful to elaborate on what these code changes might be.
> + /*
> + * PWR_CTL2 must be volatile so it can be used as a canary bit to
> + * detect a reset during system suspend.
> + */
> + case CS42L42_PWR_CTL2:
This feels a bit hackish - is the cost of doing the cache sync really so
expensive that it's worth the effort of trying to skip it?
> + if (cs42l42->suspended) {
> + mutex_unlock(&cs42l42->irq_lock);
> + return IRQ_NONE;
> + }
Given that you're using disable_irq() to force the interrupt off (which
is a bit rude but often the best one can do) how might we be getting an
interrupt while suspended? This seems to indicate an error condition.
> case CS42L42_PLUG_OMTP:
> snd_soc_jack_report(cs42l42->jack, SND_JACK_HEADSET,
> - SND_JACK_HEADSET);
> + SND_JACK_HEADSET |
> + SND_JACK_BTN_0 | SND_JACK_BTN_1 |
> + SND_JACK_BTN_2 | SND_JACK_BTN_3);
> break;
> case CS42L42_PLUG_HEADPHONE:
> snd_soc_jack_report(cs42l42->jack, SND_JACK_HEADPHONE,
> - SND_JACK_HEADPHONE);
> + SND_JACK_HEADSET |
> + SND_JACK_BTN_0 | SND_JACK_BTN_1 |
> + SND_JACK_BTN_2 | SND_JACK_BTN_3);
This unconditionally clears the button status - will something notice if
the buttons are pressed?
> + } else {
> + /*
> + * Only call regcache_mark_dirty() if cs42l42 reset, so
> + * regcache_sync() writes all non-default cached values.
> + * If it didn't reset we don't want to filter out syncing
> + * dirty cache entries that have default value.
> + * DISCHARGE_FILT==1 after suspend. If the cs42l42 reset
> + * it will now be 0.
> + */
Something needs to tell regmap that the cache is dirty otherwise it
won't sync anything, including the non-default register values? There's
currently an assumption coded in there that the cache is dirty because
the device was reset and everything has default values.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2021-12-01 16:32 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-01 15:36 [PATCH] ASoC: cs42l42: Implement system suspend Richard Fitzgerald
2021-12-01 16:32 ` Mark Brown [this message]
2021-12-01 18:04 ` Richard Fitzgerald
2021-12-01 22:08 ` Mark Brown
2021-12-02 9:53 ` Charles Keepax
2021-12-02 12:49 ` 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=YaejghraYE6lD7FD@sirena.org.uk \
--to=broonie@kernel.org \
--cc=alsa-devel@alsa-project.org \
--cc=linux-kernel@vger.kernel.org \
--cc=patches@opensource.cirrus.com \
--cc=rf@opensource.cirrus.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