From: Pierre-Louis Bossart <pierre-louis.bossart@linux.dev>
To: Charles Keepax <ckeepax@opensource.cirrus.com>
Cc: broonie@kernel.org, vkoul@kernel.org, lee@kernel.org,
lgirdwood@gmail.com, yung-chuan.liao@linux.intel.com,
peter.ujfalusi@linux.intel.com, oder_chiou@realtek.com,
jack.yu@realtek.com, shumingf@realtek.com, srini@kernel.org,
linux-sound@vger.kernel.org, linux-arm-msm@vger.kernel.org,
linux-kernel@vger.kernel.org, patches@opensource.cirrus.com
Subject: Re: [PATCH v3 00/10] Expand SoundWire enumeration helper coverage
Date: Mon, 22 Jun 2026 13:53:03 +0200 [thread overview]
Message-ID: <40ee213b-7aff-4bae-a779-8bbc8a12c307@linux.dev> (raw)
In-Reply-To: <ajkLfSeJDAG53/ZM@opensource.cirrus.com>
On 6/22/26 12:16, Charles Keepax wrote:
> On Mon, Jun 22, 2026 at 11:44:01AM +0200, Pierre-Louis Bossart wrote:
>> On 6/19/26 18:07, Charles Keepax wrote:
>>> On Fri, Jun 19, 2026 at 03:41:44PM +0200, Pierre-Louis Bossart wrote:
>>> The problem is mostly from the device side. This usually comes up
>>> from a device reset. So the driver does a reset, device drops off
>>> the bus, the device driver doesn't want to carry on until it
>>> knows the device is back on the bus. So naively one calls
>>> sdw_slave_wait_for_init() but there is nothing the ensures the
>>> core saw the bus disconnection before that call so it might
>>> immediately succeed, causing the driver to attempt to access a
>>> missing device.
>>>
>>> Yeah the fall of the bus is fast but so are processors, you need
>>> to actually ensure you can't shortcut the wait. Although typing
>>> this it occurs to me it probably doesn't have to be a wait one
>>> can probably just manually reinit the initalization_complete
>>> completion. But hopefully I will get this series ready soon and
>>> we can discuss on there.
>>
>> Don't we already have the interface to detect a device was UNATTACHED?
>> In theory the core will invoke the update_status() callback on
>> every status change. Each driver would use the information to
>> know when the UNATTACHED happened and likewise when the device
>> is enumerated/initialized again. So far most drivers just return
>> and do nothing when an UNATTACHED status is reported.
>
> Yeah so update_status() is the normal mechanism for a driver to
> know if it becomes unattached AFAIK. Indeed what this is working
> up to is removing the code in cs42l43 that uses that to track if
> the device is attached. Although also now you can also use the
> intialization_complete completion for this purpose too, since it
> was moved to complete_all().
>
>> The only thing we can't control at the moment is that when
>> a device reports as device0, the core will enumerate it and
>> attempt to initialize it. If additional time is needed prior
>> to the enumeration, we don't have the hooks for it - that would
>> not be quite standard behavior anyways.
>
> Its not really about additional time, there is always time,
> events in the real world are not instant.
>
> Thread 1 (driver) Thread 2 (core)
> ----------------- ---------------
> Reset device
> call wait_for_init()
> reinit_completion()
>
> You need something to ensure that wait_for_init() doesn't skip
> the completion before the core calls reinit_completion(). Or are
> you saying there is already a mechanism that prevents this that I
> am missing?
Ah ok I see what you are trying to do.
I am afraid we don't have a mechanism to do what your Thread1 describes, but you could alternatively have a less sequential mechanism where you only do the reset, and then the rest of the initialization is done in the update_status() callback. Your Thread1 would be implemented in two disjoint parts with no need for waiting.
The completions were meant for the suspend/resume cases mostly. I am not sure we want to use completion or any other synchronization between core and peripheral driver, it'd be introducing even more races.
Anyways, best to follow-up with next series, my comments are speculative and probably somewhat off-track..
prev parent reply other threads:[~2026-06-22 11:53 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-08 10:27 [PATCH v3 00/10] Expand SoundWire enumeration helper coverage Charles Keepax
2026-06-08 10:27 ` [PATCH v3 01/10] soundwire: Always wait for initialisation of unattached devices Charles Keepax
2026-06-08 10:27 ` [PATCH v3 02/10] ASoC: wsa881x: Use new SoundWire enumeration helper Charles Keepax
2026-06-08 10:27 ` [PATCH v3 03/10] mfd: cs42l43: " Charles Keepax
2026-06-18 12:04 ` (subset) " Lee Jones
2026-06-08 10:27 ` [PATCH v3 04/10] ASoC: rt5682: " Charles Keepax
2026-06-08 10:27 ` [PATCH v3 05/10] ASoC: pm4125: " Charles Keepax
2026-06-08 10:27 ` [PATCH v3 06/10] ASoC: wcd937x: " Charles Keepax
2026-06-08 10:27 ` [PATCH v3 07/10] ASoC: wcd938x: " Charles Keepax
2026-06-08 10:27 ` [PATCH v3 08/10] ASoC: wcd939x: " Charles Keepax
2026-06-08 10:27 ` [PATCH v3 09/10] ASoC: SDCA: " Charles Keepax
2026-06-08 10:27 ` [PATCH v3 10/10] ASoC: cs35l56: Remove unnecessary conditionals waiting for enumeration Charles Keepax
2026-06-11 19:47 ` (subset) [PATCH v3 00/10] Expand SoundWire enumeration helper coverage Mark Brown
2026-06-19 13:41 ` Pierre-Louis Bossart
2026-06-19 16:07 ` Charles Keepax
2026-06-22 9:44 ` Pierre-Louis Bossart
2026-06-22 10:16 ` Charles Keepax
2026-06-22 11:53 ` Pierre-Louis Bossart [this message]
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=40ee213b-7aff-4bae-a779-8bbc8a12c307@linux.dev \
--to=pierre-louis.bossart@linux.dev \
--cc=broonie@kernel.org \
--cc=ckeepax@opensource.cirrus.com \
--cc=jack.yu@realtek.com \
--cc=lee@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=oder_chiou@realtek.com \
--cc=patches@opensource.cirrus.com \
--cc=peter.ujfalusi@linux.intel.com \
--cc=shumingf@realtek.com \
--cc=srini@kernel.org \
--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