[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87zfwdvjbw.wl-tiwai@suse.de>
Date: Tue, 06 Feb 2024 14:00:19 +0100
From: Takashi Iwai <tiwai@...e.de>
To: Amadeusz Sławiński
<amadeuszx.slawinski@...ux.intel.com>
Cc: Wesley Cheng <quic_wcheng@...cinc.com>,
srinivas.kandagatla@...aro.org,
mathias.nyman@...el.com,
perex@...ex.cz,
conor+dt@...nel.org,
corbet@....net,
lgirdwood@...il.com,
andersson@...nel.org,
krzysztof.kozlowski+dt@...aro.org,
gregkh@...uxfoundation.org,
Thinh.Nguyen@...opsys.com,
broonie@...nel.org,
bgoswami@...cinc.com,
tiwai@...e.com,
robh+dt@...nel.org,
konrad.dybcio@...aro.org,
linux-kernel@...r.kernel.org,
devicetree@...r.kernel.org,
linux-sound@...r.kernel.org,
linux-usb@...r.kernel.org,
linux-arm-msm@...r.kernel.org,
linux-doc@...r.kernel.org,
alsa-devel@...a-project.org
Subject: Re: [PATCH v13 50/53] ALSA: usb-audio: Allow for rediscovery of connected USB SND devices
On Mon, 05 Feb 2024 10:01:03 +0100,
Amadeusz Sławiński wrote:
>
> On 2/3/2024 3:36 AM, Wesley Cheng wrote:
> > In case of notifying SND platform drivers of connection events, some of
> > these use cases, such as offloading, require an ASoC USB backend device to
> > be initialized before the events can be handled. If the USB backend device
> > has not yet been probed, this leads to missing initial USB audio device
> > connection events.
> >
> > Expose an API that traverses the usb_chip array for connected devices, and
> > to call the respective connection callback registered to the SND platform
> > driver.
> >
> > Signed-off-by: Wesley Cheng <quic_wcheng@...cinc.com>
> > ---
> > sound/usb/card.c | 19 +++++++++++++++++++
> > sound/usb/card.h | 2 ++
> > sound/usb/qcom/qc_audio_offload.c | 2 ++
> > 3 files changed, 23 insertions(+)
> >
> > diff --git a/sound/usb/card.c b/sound/usb/card.c
> > index 11b827b7a2a5..995b2df676ab 100644
> > --- a/sound/usb/card.c
> > +++ b/sound/usb/card.c
> > @@ -202,6 +202,25 @@ struct snd_usb_stream *snd_usb_find_suppported_substream(int card_idx,
> > }
> > EXPORT_SYMBOL_GPL(snd_usb_find_suppported_substream);
> > +/*
> > + * in case the platform driver was not ready at the time of USB SND
> > + * device connect, expose an API to discover all connected USB devices
> > + * so it can populate any dependent resources/structures.
> > + */
> > +void snd_usb_rediscover_devices(void)
> > +{
> > + int i;
> > +
> > + mutex_lock(®ister_mutex);
> > + for (i = 0; i < SNDRV_CARDS; i++) {
> > + if (usb_chip[i])
> > + if (platform_ops && platform_ops->connect_cb)
> > + platform_ops->connect_cb(usb_chip[i]);
>
> if inside if, it can just be && or maybe move callback check before
> mutex lock and just return early if it is not present?
The callback check must be inside mutex; otherwise you'll get a race
about the platform_ops registration.
thanks,
Takashi
Powered by blists - more mailing lists