public inbox for linux-sound@vger.kernel.org
 help / color / mirror / Atom feed
From: Charles Keepax <ckeepax@opensource.cirrus.com>
To: Mark Brown <broonie@kernel.org>
Cc: lgirdwood@gmail.com, yung-chuan.liao@linux.intel.com,
	pierre-louis.bossart@linux.dev, peter.ujfalusi@linux.intel.com,
	linux-sound@vger.kernel.org, patches@opensource.cirrus.com
Subject: Re: [PATCH 3/5] ASoC: SDCA: Fix cleanup inversion in class driver
Date: Wed, 8 Apr 2026 15:11:12 +0100	[thread overview]
Message-ID: <adZiAB8MuYFO2ODE@opensource.cirrus.com> (raw)
In-Reply-To: <a4ddbfa3-127b-497b-9227-2a72c32ddd22@sirena.org.uk>

On Wed, Apr 08, 2026 at 02:43:59PM +0100, Mark Brown wrote:
> On Wed, Apr 08, 2026 at 10:38:33AM +0100, Charles Keepax wrote:
> 
> > This led to a cleanup inversion where the devm cleanup for the parent
> > Soundwire IRQ runs before the handler that removes the function drivers.
> > So the parent IRQ is destroyed before the function drivers had a chance
> > to do any cleanup and remove their IRQ handlers.
> 
> > Move the registrations of the function driver cleanup into
> > class_boot_work() after the function drivers are registered, so that it
> > runs before the cleanup of the parent SoundWire IRQ handler.
> 
> > +static void class_remove_functions(void *data)
> > +{
> > +	struct sdca_class_drv *drv = data;
> > +
> > +	cancel_work_sync(&drv->boot_work);
> > +
> > +	sdca_dev_unregister_functions(drv->sdw);
> > +}
> 
> > @@ -157,6 +166,11 @@ static void class_boot_work(struct work_struct *work)
> >  	if (ret)
> >  		goto err;
> >  
> > +	/* Ensure function drivers are removed before the IRQ is destroyed */
> > +	ret = devm_add_action_or_reset(drv->dev, class_remove_functions, drv);
> > +	if (ret)
> > +		goto err;
> > +
> 
> This means we register the cleanup of boot_work from boot_work which
> seems a bit fun and...
> 
> > -static void class_dev_remove(void *data)
> > -{
> > -	struct sdca_class_drv *drv = data;
> > -
> > -	cancel_work_sync(&drv->boot_work);
> 
> ...what now cancels boot_work if we somehow manage to remove before
> boot_work has completed (possibly even before it's scheduled)?

Hm... yeah I think you are right there is still an issue here.

I think the boot work sync should stay in the original remove
callback. The sequence of concern was:

1) driver probes
2) boot work runs
3) boot work is scheduled
4) driver removed
5) boot work completes

I think this current patch addresses calling
sdca_dev_unregister_functions() but we don't really want any of
boot work running once the driver starts being removed.

I will respin a v2.

Thanks,
Charles

  reply	other threads:[~2026-04-08 14:11 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-08  9:38 [PATCH 0/5] Yet another round of SDCA fixes Charles Keepax
2026-04-08  9:38 ` [PATCH 1/5] ASoC: SDCA: Fix overwritten var within for loop Charles Keepax
2026-04-08  9:38 ` [PATCH 2/5] ASoC: SDCA: mask Function_Status value Charles Keepax
2026-04-08  9:38 ` [PATCH 3/5] ASoC: SDCA: Fix cleanup inversion in class driver Charles Keepax
2026-04-08 13:43   ` Mark Brown
2026-04-08 14:11     ` Charles Keepax [this message]
2026-04-08  9:38 ` [PATCH 4/5] ASoC: SDCA: Unregister IRQ handlers on module remove Charles Keepax
2026-04-08  9:38 ` [PATCH 5/5] ASoC: SDCA: Tidy up irq_enable_flags()/sdca_irq_disable() Charles Keepax

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=adZiAB8MuYFO2ODE@opensource.cirrus.com \
    --to=ckeepax@opensource.cirrus.com \
    --cc=broonie@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-sound@vger.kernel.org \
    --cc=patches@opensource.cirrus.com \
    --cc=peter.ujfalusi@linux.intel.com \
    --cc=pierre-louis.bossart@linux.dev \
    --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