Re: [PATCH] ALSA: hda: cs35l56: Perform firmware download in the background

From: Takashi Iwai
Date: Thu May 02 2024 - 06:25:52 EST


On Thu, 02 May 2024 12:17:48 +0200,
Simon Trimmer wrote:
>
> > -----Original Message-----
> > From: Takashi Iwai <tiwai@xxxxxxx>
> > Sent: Thursday, May 2, 2024 10:53 AM
> > To: Richard Fitzgerald <rf@xxxxxxxxxxxxxxxxxxxxx>
> > Cc: Simon Trimmer <simont@xxxxxxxxxxxxxxxxxxxxx>; tiwai@xxxxxxxx; linux-
> > sound@xxxxxxxxxxxxxxx; alsa-devel@xxxxxxxxxxxxxxxx; linux-
> > kernel@xxxxxxxxxxxxxxx; patches@xxxxxxxxxxxxxxxxxxxxx
> > Subject: Re: [PATCH] ALSA: hda: cs35l56: Perform firmware download in the
> > background
> >
> > On Thu, 02 May 2024 11:21:36 +0200,
> > Richard Fitzgerald wrote:
> > >
> > > On 02/05/2024 08:34, Takashi Iwai wrote:
> > > > On Wed, 01 May 2024 13:17:55 +0200,
> > > > Simon Trimmer wrote:
> > > >> @@ -964,6 +1011,14 @@ int cs35l56_hda_common_probe(struct
> > cs35l56_hda *cs35l56, int hid, int id)
> > > >> mutex_init(&cs35l56->base.irq_lock);
> > > >> dev_set_drvdata(cs35l56->base.dev, cs35l56);
> > > >> + cs35l56->dsp_wq =
> > > >> create_singlethread_workqueue("cs35l56-dsp");
> > > >> + if (!cs35l56->dsp_wq) {
> > > >> + ret = -ENOMEM;
> > > >> + goto err;
> > > >> + }
> > > >
> > > > Do we really need a dedicated workqueue? In most usages, simple
> > > > schedule_work*() works fine and is recommended.
> > > >
> > >
> > > On a slow I2C bus with 4 amps this work could take over 2 seconds.
> > > That seems too long to be blocking a global system queue. We use a
> > > dedicated queue in the ASoC driver.
> > >
> > > Also if we queue work on an ordered (single-threaded) system queue the
> > > firmware won't be downloaded to multiple amps in parallel, so we don't
> > > get the best use of the available bus bandwidth.
> >
> > OK, that sounds like a sensible argument.
> >
> > But the patch has no call of a queue destructor. Won't it leak
> > resources?
>
> Oops that's a good spot - I missed that and will send a v2

If you submit a newer version, it'd be appreciated to explain about
the workqueue usage in the patch description, too.


thanks,

Takashi