mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
To: "Rhodes, David" <drhodes@opensource.cirrus.com>,
	Charles Keepax <ckeepax@opensource.cirrus.com>
Cc: James Schulman <james.schulman@cirrus.com>,
	David Rhodes <david.rhodes@cirrus.com>,
	Richard Fitzgerald <rf@opensource.cirrus.com>,
	Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
	Liam Girdwood <lgirdwood@gmail.com>,
	Mark Brown <broonie@kernel.org>,
	Stefan Binding <sbinding@opensource.cirrus.com>,
	alsa-devel@alsa-project.org, patches@opensource.cirrus.com,
	linux-kernel@vger.kernel.org, kernel@collabora.com
Subject: Re: [PATCH 4/9] ASoC: cs35l41: Fix broken shared boost activation
Date: Tue, 5 Sep 2023 23:05:28 +0300	[thread overview]
Message-ID: <1cd66d6d-6a39-41eb-8646-0a6e6f473e8d@collabora.com> (raw)
In-Reply-To: <c3328c1d-07f4-ae3f-88cd-b4b767a667b2@opensource.cirrus.com>

On 9/5/23 21:11, Rhodes, David wrote:
> On 9/5/23 5:29 AM, Charles Keepax wrote:
>> On Sun, Sep 03, 2023 at 12:06:16AM +0300, Cristian Ciocaltea wrote:
>>> Enabling the active/passive shared boosts involves writing the MDSYNC UP
>>> register sequence, which cannot be performed before receiving the PLL
>>> lock signal.
>>>
> 
>>
>> Thanks for looking at this apologies this was missed in the
>> initial review of the patch.
>>
> 
> Thanks Cristian, I agree with the intent of your patch.
> We do not expect that clocks are always available before the DAPM PMU
> event and shared boost should still be configured if they are not.
> 
>>> +int cs35l41_mdsync_up(struct regmap *regmap)
>>> +{
>>> +    struct reg_sequence cs35l41_mdsync_up_seq[] = {
>>> +        {CS35L41_PWR_CTRL3, 0},
>>> +        {CS35L41_PWR_CTRL1, 0x00000000, 3000},
>>> +        {CS35L41_PWR_CTRL1, 0x00000001, 3000},
>>> +    };
> 
> I don't know why PWR_CTRL1 is included in the up sequence here.
> This toggles GLOBAL_EN, which will cause the PLL to unlock and lock
> again. Doing this defeats the purpose of setting SYNC_EN in a separate
> operation, which is to only do so when the amp is powered on and has
> locked the PLL. GLOBAL_EN is set by the mdsync_down_seq, so all that is
> needed when the PLL is locked is to set SYNC_EN.

Unfortunately I had to rely on the existing implementation as I don't 
have access to the datasheet.

If I got it right, we should drop all write operations on PWR_CTRL1, 
and simply set the CS35L41_SYNC_EN_MASK bit in PWR_CTRL3.
 
>>
>> Is this now safe? By pulling this out into a worker thread, it is
>> no longer under the DAPM lock, which makes me worry this can race
>> with the other uses of PWR_CTRL3 which could theoretically change
>> state between when you read the reg and when you write it.

That's a good point, it should be fixed implicitly by replacing the 
read/write operations with a single regmap_update_bits() call, which 
is protected by regmap's internal lock.

> 
> The Class-H DAPM widget also uses the PWR_CTRL3 register.
> 
>>
>> One question I might also have would be does a worker thread make
>> more sense or would it be simpler to do the mdsync power up
>> directly in response to the PLL lock IRQ?
>>
> 
> I  agree with implementing this in the PLL lock IRQ.
> As I described above, all that would need to be done is to set SYNC_EN
> in the PLL Lock IRQ handler.

As a matter of fact I initially considered doing this in the IRQ handler, 
but I also wanted to understand the reasoning behind current solution. 
Therefore I searched the ML archive for any relevant review comments, 
and I came across [1] which raises some concerns regarding the PLL lock 
signal, e.g. lack of documentation regarding trigger time & frequency.

If going with the IRQ handler approach is still the recommended approach,
I will handle it in v2.

Thanks for reviewing,
Cristian

[1] https://lore.kernel.org/all/20230207114855.GC36097@ediswmail.ad.cirrus.com/

  reply	other threads:[~2023-09-05 20:05 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-02 21:06 [PATCH 0/9] Improve CS35l41 ALSA SoC audio driver Cristian Ciocaltea
2023-09-02 21:06 ` [PATCH 1/9] ASoC: cs35l41: Handle mdsync_down reg write errors Cristian Ciocaltea
2023-09-05  9:19   ` Charles Keepax
2023-09-02 21:06 ` [PATCH 2/9] ASoC: cs35l41: Handle mdsync_up " Cristian Ciocaltea
2023-09-05  9:23   ` Charles Keepax
2023-09-02 21:06 ` [PATCH 3/9] ASoC: cs35l41: Initialize completion object before requesting IRQ Cristian Ciocaltea
2023-09-05  9:23   ` Charles Keepax
2023-09-02 21:06 ` [PATCH 4/9] ASoC: cs35l41: Fix broken shared boost activation Cristian Ciocaltea
2023-09-05 10:29   ` Charles Keepax
2023-09-05 18:11     ` Rhodes, David
2023-09-05 20:05       ` Cristian Ciocaltea [this message]
2023-09-05 20:25         ` Rhodes, David
2023-09-02 21:06 ` [PATCH 5/9] ASoC: cs35l41: Rename pll_lock to pll_lock_done Cristian Ciocaltea
2023-09-05  9:35   ` Charles Keepax
2023-09-02 21:06 ` [PATCH 6/9] ASoC: cs35l41: Make use of dev_err_probe() Cristian Ciocaltea
2023-09-05  9:36   ` Charles Keepax
2023-09-02 21:06 ` [PATCH 7/9] ASoC: cs35l41: Verify PM runtime resume errors in IRQ handler Cristian Ciocaltea
2023-09-05  9:37   ` Charles Keepax
2023-09-02 21:06 ` [PATCH 8/9] ASoC: cs35l41: Use modern pm_ops Cristian Ciocaltea
2023-09-05  9:37   ` Charles Keepax
2023-09-02 21:06 ` [PATCH 9/9] ASoC: cs35l41: Use devm_pm_runtime_enable() Cristian Ciocaltea
2023-09-05  9:45   ` Charles Keepax
2023-09-05 19:15     ` Cristian Ciocaltea
2023-09-06 16:37       ` Charles Keepax
2023-09-06 19:55         ` Cristian Ciocaltea
2023-09-07  8:37           ` Charles Keepax

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=1cd66d6d-6a39-41eb-8646-0a6e6f473e8d@collabora.com \
    --to=cristian.ciocaltea@collabora.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=ckeepax@opensource.cirrus.com \
    --cc=david.rhodes@cirrus.com \
    --cc=drhodes@opensource.cirrus.com \
    --cc=james.schulman@cirrus.com \
    --cc=kernel@collabora.com \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=patches@opensource.cirrus.com \
    --cc=perex@perex.cz \
    --cc=rf@opensource.cirrus.com \
    --cc=sbinding@opensource.cirrus.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: 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

all inboxes | Powered by JetHome®