Linux Sound subsystem development
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: "Cássio Gabriel" <cassiogabrielcontato@gmail.com>
Cc: Shenghao Ding <shenghao-ding@ti.com>, Kevin Lu <kevin-lu@ti.com>,
	Baojun Xu <baojun.xu@ti.com>, Takashi Iwai <tiwai@suse.com>,
	Jaroslav Kysela <perex@perex.cz>,
	linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org
Subject: Re: [PATCH] ALSA: hda/tas2781: Wait for async firmware callback at unbind
Date: Thu, 30 Apr 2026 15:55:33 +0200	[thread overview]
Message-ID: <87y0i4mu22.wl-tiwai@suse.de> (raw)
In-Reply-To: <20260430-alsa-hda-tas2781-fw-callback-teardown-v1-1-874367d6b41b@gmail.com>

On Thu, 30 Apr 2026 06:02:02 +0200,
Cássio Gabriel wrote:
> 
> The TAS2781 HDA I2C and SPI side-codec drivers queue the RCA
> firmware load with request_firmware_nowait() from component bind. The
> firmware loader keeps a device reference and pins the callback module,
> but it does not protect the driver's HDA private state from component
> unbind.
> 
> The callback dereferences tas_hda/tas_priv, takes codec_lock,
> creates ALSA controls, updates RCA/DSP state, runs runtime PM, and may
> load DSP and calibration data. Component unbind currently removes
> controls and DSP state immediately, and the later device remove destroys
> codec_lock through tasdevice_remove(). A delayed callback can therefore
> run after the HDA component state has been torn down.
> 
> Track the pending HDA RCA request with a completion. Mark it cancelled
> at unbind, let a callback that observes cancellation exit before parsing
> firmware or creating controls, and wait for any already-running callback
> before tearing down HDA controls and DSP state.
> 
> Clear cached kcontrol pointers as controls are removed, and when
> snd_ctl_add() rejects them, so a later cancelled or failed bind cannot
> remove stale controls from an earlier bind.
> 
> Fixes: 5be27f1e3ec9 ("ALSA: hda/tas2781: Add tas2781 HDA driver")
> Fixes: bb5f86ea50ff ("ALSA: hda/tas2781: Add tas2781 hda SPI driver")
> Cc: stable@vger.kernel.org
> Signed-off-by: Cássio Gabriel <cassiogabrielcontato@gmail.com>

Hmm, this looks too complex than needed.  Basically what we want is a
simple cancel or sync for async firmware loading work.  Once when such
a helper is provided, the rest in the HD-audio side will be just a
call of it at the remove or unbind.  And, I guess we can implement the
helper in the f/w loader with a help of devres or such.


thanks,

Takashi

  reply	other threads:[~2026-04-30 13:55 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-30  4:02 [PATCH] ALSA: hda/tas2781: Wait for async firmware callback at unbind Cássio Gabriel
2026-04-30 13:55 ` Takashi Iwai [this message]
2026-04-30 14:29   ` Takashi Iwai
2026-04-30 14:54     ` Cássio Gabriel Monteiro Pires

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=87y0i4mu22.wl-tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=baojun.xu@ti.com \
    --cc=cassiogabrielcontato@gmail.com \
    --cc=kevin-lu@ti.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=shenghao-ding@ti.com \
    --cc=stable@vger.kernel.org \
    --cc=tiwai@suse.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