[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <d77636dc-f239-9780-edca-fa568582c05f@opensource.cirrus.com>
Date: Mon, 23 Jan 2023 16:14:49 +0000
From: Richard Fitzgerald <rf@...nsource.cirrus.com>
To: Pierre-Louis Bossart <pierre-louis.bossart@...ux.intel.com>,
Stefan Binding <sbinding@...nsource.cirrus.com>,
Mark Brown <broonie@...nel.org>
CC: <patches@...nsource.cirrus.com>, <alsa-devel@...a-project.org>,
<linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v2 6/8] ASoC: cs42l42: Add Soundwire support
On 23/01/2023 16:05, Pierre-Louis Bossart wrote:
>
>>>> It's nicer to do the check in startup() because then the application
>>>> open() will fail cleanly. We could delay until prepare - which is the
>>>> point we really need the hardware to be accessible - and hope the
>>>> hardware enumerated and initialized by that time. But that's not so
>>>> nice from the app point of view.
>>>
>>> Another way to avoid problems is to rely on the codec component .probe
>>> to check if the SoundWire device is initialized before registering a
>>> card.
>>>
>>> I just tried with a system where the ACPI info exposes a codec which is
>>> not connected, it fails nicely. That avoids the pitfalls of creating a
>>> card which isn't functional since all dependencies are not met.
>>>
>>> [ 64.616530] snd_soc_sof_sdw:mc_probe: sof_sdw sof_sdw: Entry
>>> [ 64.616549] snd_soc_sof_sdw:log_quirks: sof_sdw sof_sdw: quirk
>>> SOF_SDW_PCH_DMIC enabled
>>> [ 64.616559] snd_soc_sof_sdw:sof_card_dai_links_create: sof_sdw
>>> sof_sdw: sdw 2, ssp 0, dmic 2, hdmi 0
>>> [ 64.616587] snd_soc_sof_sdw:init_dai_link: sof_sdw sof_sdw: create
>>> dai link SDW0-Playback, id 0
>>> [ 64.616600] snd_soc_sof_sdw:init_dai_link: sof_sdw sof_sdw: create
>>> dai link SDW0-Capture, id 1
>>> [ 64.616607] snd_soc_sof_sdw:init_dai_link: sof_sdw sof_sdw: create
>>> dai link dmic01, id 2
>>> [ 64.616614] snd_soc_sof_sdw:init_dai_link: sof_sdw sof_sdw: create
>>> dai link dmic16k, id 3
>>> [ 69.757115] rt5682 sdw:0:025d:5682:00: Initialization not complete,
>>> timed out
>>> [ 69.757128] rt5682 sdw:0:025d:5682:00: ASoC: error at
>>> snd_soc_component_probe on sdw:0:025d:5682:00: -110
>>> [ 69.757224] sof_sdw sof_sdw: ASoC: failed to instantiate card -110
>>> [ 69.757734] sof_sdw sof_sdw: snd_soc_register_card failed -110
>>>
>>> see
>>> https://elixir.bootlin.com/linux/latest/source/sound/soc/codecs/rt5682.c#L2927
>>>
>>> I think this is compatible with the device model and bind/unbind, but it
>>> could be improved with the removal of the wait if we had a way to return
>>> -EPROBEDEFER, and have a mechanism to force the deferred probe work to
>>> be triggered when a device actually shows up. It's a generic problem
>>> that the probe cannot always be a synchronous function but may complete
>>> 'later'.
>>
>> I see what you've done in your patch, but I had already experimented
>> with this idea and found that the wait_for_completion() can deadlock the
>> Soundwire core.
>
> That's not good. Do you have any logs or explanation on what the
> root-cause of this deadlock might be? If something's broken, we might as
> well fix it.
I suspect it might be the big mutex lock around the call to probe(),
that I removed in one of my pending patches
(https://lore.kernel.org/all/20221121162453.1834170-1-rf@opensource.cirrus.com/)
So fixing that might make the problem go away.
Charles just pointed out to me that whether component_probe() is
called within probe() depends whether everything needed to create
a soundcard is already present. Most likely in my case everything is
available and so snd_soc_register_component() immediately calls
my component_probe(). So probably in your case not everything is
ready and so the call to component_probe() is deferred and you
don't see the deadlock.
Powered by blists - more mailing lists