public inbox for linux-sound@vger.kernel.org
 help / color / mirror / Atom feed
From: Charles Keepax <ckeepax@opensource.cirrus.com>
To: Pierre-Louis Bossart <pierre-louis.bossart@linux.dev>
Cc: Richard Fitzgerald <rf@opensource.cirrus.com>,
	broonie@kernel.org, vkoul@kernel.org,
	yung-chuan.liao@linux.intel.com, peter.ujfalusi@linux.intel.com,
	shumingf@realtek.com, lgirdwood@gmail.com,
	linux-sound@vger.kernel.org, patches@opensource.cirrus.com
Subject: Re: [PATCH 3/4] ASoC: SDCA: Add basic SDCA class driver
Date: Tue, 4 Nov 2025 17:14:31 +0000	[thread overview]
Message-ID: <aQo0d3UWKinyzTYT@opensource.cirrus.com> (raw)
In-Reply-To: <382ce438-5251-4d4d-af44-863197c77b94@linux.dev>

On Tue, Nov 04, 2025 at 05:13:39PM +0100, Pierre-Louis Bossart wrote:
> On 10/30/25 16:36, Richard Fitzgerald wrote:
> > On 30/10/2025 3:29 pm, Charles Keepax wrote:
> >> On Mon, Oct 27, 2025 at 04:02:54PM +0100, Pierre-Louis Bossart wrote:
> > 
> > SNIP
> > 
> >>>> +    pm_runtime_set_autosuspend_delay(dev, 250);
> >>>> +    pm_runtime_use_autosuspend(dev);
> >>>> +    pm_runtime_set_active(dev);
> >>>> +    pm_runtime_get_noresume(dev);
> >>>
> >>> This seems odd, I don't recall that we do something similar in existing codec drivers.
> >>> It'd be worth explaining the whole pm_runtime flow.
> >>
> >> I suspect that means those codec drivers are broken :-) at least
> >> if they actively use pm_runtime. The first two enable
> >> autosuspend, that is suspending the device after a short period
> >> of inactivity. set_active tells the PM runtime the device is
> >> already powered up, as it is. Finally, get_noresume takes a
> >> reference, this will stop it powering down immediately once the
> >> pm_runtime is enabled, it will waiting until we put the reference
> >> we are holding.
> >>
> > Other drivers definitely do that.
> > For example:
> > https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git/tree/sound/soc/codecs/rt722-sdca.c#n1544
> > 
> > (the other rt drivers are similar)
> 
> This rt722-sdca driver seems wrong, IIRC we aligned all
> drivers to do most of the inits in the driver probe, and then
> the only thing left to do when the device attaches is the
> set_active/get_noresume/put_autosuspend.
> 
> See the rt711 and rt1308 for reference, they have comments to
> explain why we used this code pattern.
> 
> https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git/tree/sound/soc/codecs/rt1308-sdw.c#n709

That is some scary stuff there, that is basically working around
the fact that with those drivers the soundcard is created before
the hardware is actually ready. But its one aspect of that and
there are likely many knock on effects/races hiding in there. At
some point we should probably revisit the whole enumeration
thing in soundwire it does cause a lot of scary code.

That said... the class driver doesn't have the same problem
however, because of the two layer nature of the auxiliary driver
stuff. The soundwire driver binds to the device and completes
probe, but it is the auxiliary drivers that are used in the
soundcard and those are only probed once the device itself has
enumerated in class_boot_work(). This means the sound card is
only created after the device has enumerated, so the same problem
isn't present and we can have a more normal PM runtime startup.

Thanks,
Charles

  reply	other threads:[~2025-11-04 17:15 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-25 13:33 [PATCH 0/4] Add SDCA class driver Charles Keepax
2025-09-25 13:33 ` [PATCH 1/4] ASoC: SDCA: Add helper to write initialization writes Charles Keepax
2025-10-13  5:43   ` Vinod Koul
2025-09-25 13:33 ` [PATCH 2/4] ASoC: SDCA: add function devices Charles Keepax
2025-09-25 13:33 ` [PATCH 3/4] ASoC: SDCA: Add basic SDCA class driver Charles Keepax
2025-10-27 15:02   ` Pierre-Louis Bossart
2025-10-30 15:29     ` Charles Keepax
2025-10-30 15:36       ` Richard Fitzgerald
2025-11-04 16:13         ` Pierre-Louis Bossart
2025-11-04 17:14           ` Charles Keepax [this message]
2025-12-09 12:47             ` Pierre-Louis Bossart
2025-12-10  9:55               ` Charles Keepax
2025-12-20 11:04                 ` Pierre-Louis Bossart
2026-01-06 12:58                   ` Charles Keepax
2026-01-06 17:10                     ` Pierre-Louis Bossart
2026-01-13 17:27                       ` Charles Keepax
2026-01-13 22:05                         ` Pierre-Louis Bossart
2026-01-14  9:58                           ` Charles Keepax
2025-09-25 13:33 ` [PATCH 4/4] ASoC: SDCA: Add basic SDCA function driver Charles Keepax
2025-10-27 15:24   ` Pierre-Louis Bossart
2025-10-30 15:44     ` 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=aQo0d3UWKinyzTYT@opensource.cirrus.com \
    --to=ckeepax@opensource.cirrus.com \
    --cc=broonie@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-sound@vger.kernel.org \
    --cc=patches@opensource.cirrus.com \
    --cc=peter.ujfalusi@linux.intel.com \
    --cc=pierre-louis.bossart@linux.dev \
    --cc=rf@opensource.cirrus.com \
    --cc=shumingf@realtek.com \
    --cc=vkoul@kernel.org \
    --cc=yung-chuan.liao@linux.intel.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