mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Pierre-Louis Bossart <pierre-louis.bossart@linux.dev>
To: "Mukunda,Vijendar" <vijendar.mukunda@amd.com>, vkoul@kernel.org
Cc: yung-chuan.liao@linux.intel.com, Basavaraj.Hiregoudar@amd.com,
	Sunil-kumar.Dommati@amd.com, venkataprasad.potturu@amd.com,
	Syed.SabaKareem@amd.com, Mario.Limonciello@amd.com,
	Richard.Gong@amd.com, linux-sound@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/8] soundwire: amd: fix work drain ordering and pm_runtime guard in remove path
Date: Tue, 15 Sep 2026 13:24:49 +0200	[thread overview]
Message-ID: <aec77111-d07b-41b7-8d98-1519faa7f3f9@linux.dev> (raw)
In-Reply-To: <47708252-2867-4b3d-a997-ef153b6eeb05@amd.com>


> Thanks for the suggestion Pierre.  I considered moving pm_runtime_enable()
> into probe(), but I do not think that is safe given how the AMD SoundWire
> driver is structured.
> 
> The current placement in amd_sdw_manager_start() follows the same model
> used by the Intel SoundWire driver, where runtime PM is enabled only
> after the hardware has been powered up and fully initialized.
> 
> More importantly, pm_runtime_set_active() requires the hardware to be in
> a known operational state. For AMD, that is only true after
> acp_sdw_clk_init_ctrl(), acp_init_sdw_manager(),
> acp_enable_sdw_interrupts(), acp_enable_sdw_manager(), and
> acp_sdw_set_frameshape() have all completed successfully. Calling
> pm_runtime_set_active() from probe() would advertise the device as
> active before any of this initialization has occurred.
> 
> Enabling runtime PM in probe() would also create a race window between
> probe() and sdw_amd_startup(). During that window, the PM core could
> invoke the runtime suspend callback, which accesses SoundWire manager
> registers and performs clock-stop sequences. Since the hardware has not
> yet been initialized, those register accesses would occur on an
> uninitialized manager.
> 
> The failure path that motivated this change is also a real scenario.
> sdw_amd_startup() iterates over all manager instances. If one instance
> successfully completes startup and another fails later, the cleanup path
> must handle a mix of initialized and non-initialized managers. The
> pm_runtime_enabled() check added here ensures that
> pm_runtime_disable() is only called for instances that actually reached
> the point where runtime PM was enabled.
> 
> The probe/startup split is intentional and follows the existing
> SoundWire subsystem design. Hardware bring-up is deferred until startup,
> and runtime PM is enabled only after the manager is known to be fully
> operational. Since the runtime PM callbacks directly access hardware
> registers, allowing them to run before startup completes would be
> unsafe.
> 
> Finally, moving pm_runtime_enable() into probe() would separate it from
> pm_runtime_set_active(). The current ordering of
> pm_runtime_set_active() followed by pm_runtime_enable() is the standard
> runtime PM pattern and avoids additional synchronization requirements.
> 
> This design is not new. The placement of pm_runtime_enable() inside
> amd_sdw_manager_start() was introduced by commit 81ff58ff71ad
> ("soundwire: amd: add runtime pm ops for AMD SoundWire manager driver")
> and has been part of the upstream kernel since v6.4.
> 
> In summary, moving pm_runtime_enable() to probe() would expose runtime
> PM callbacks before the SoundWire manager is initialized, creating a
> real race between probe() and startup. Keeping it in
> amd_sdw_manager_start() satisfies the requirements of
> pm_runtime_set_active() and makes the pm_runtime_enabled() guard in the
> remove path both correct and necessary.
> 
> We will split the patch and push the pm_runtime guard change separately.

Sounds good, thanks for sharing the details.
My suggestion was based on what we did for SoundWire codecs, it may not
be 100% applicable on the host side - or it would create new problems.


  reply	other threads:[~2026-09-15 11:25 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-10 19:00 [PATCH 0/8] soundwire: amd: SoundWire manager driver bug fixes Vijendar Mukunda
2026-09-10 19:00 ` [PATCH 1/8] soundwire: amd: fix SDW command timeout return value handling Vijendar Mukunda
2026-09-11 17:48   ` Mario Limonciello
2026-09-12  8:49     ` Mukunda,Vijendar
2026-09-10 19:00 ` [PATCH 2/8] soundwire: amd: cache ping slave status to avoid spurious disconnect on timeout Vijendar Mukunda
2026-09-13 19:59   ` Pierre-Louis Bossart
2026-09-14  5:31     ` Mukunda,Vijendar
2026-09-10 19:00 ` [PATCH 3/8] soundwire: amd: fix work drain ordering and pm_runtime guard in remove path Vijendar Mukunda
2026-09-13 20:05   ` Pierre-Louis Bossart
2026-09-14  6:07     ` Mukunda,Vijendar
2026-09-14 17:30       ` Pierre-Louis Bossart
2026-09-15  4:42         ` Mukunda,Vijendar
2026-09-15 11:24           ` Pierre-Louis Bossart [this message]
2026-09-10 19:00 ` [PATCH 4/8] soundwire: amd: fix ctx leak when sdw_amd_startup() fails Vijendar Mukunda
2026-09-10 19:00 ` [PATCH 5/8] soundwire: amd: propagate amd_init_sdw_manager() error on resume Vijendar Mukunda
2026-09-10 19:00 ` [PATCH 6/8] soundwire: amd: drop amd_deinit_sdw_manager() in POWER_OFF suspend Vijendar Mukunda
2026-09-10 19:00 ` [PATCH 7/8] soundwire: amd: replace >= ACP70 with explicit switch/case in PM paths Vijendar Mukunda
2026-09-10 19:00 ` [PATCH 8/8] soundwire: amd: fix interrupt gate and work drain ordering in PM ops Vijendar Mukunda
2026-09-11 17:52 ` [PATCH 0/8] soundwire: amd: SoundWire manager driver bug fixes Mario Limonciello

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=aec77111-d07b-41b7-8d98-1519faa7f3f9@linux.dev \
    --to=pierre-louis.bossart@linux.dev \
    --cc=Basavaraj.Hiregoudar@amd.com \
    --cc=Mario.Limonciello@amd.com \
    --cc=Richard.Gong@amd.com \
    --cc=Sunil-kumar.Dommati@amd.com \
    --cc=Syed.SabaKareem@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=venkataprasad.potturu@amd.com \
    --cc=vijendar.mukunda@amd.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

all inboxes | Powered by JetHome®