drivers/base/firmware_loader/main.c | 68 ++++++++++++++++++++++++-- include/linux/firmware.h | 10 ++++ sound/hda/codecs/side-codecs/tas2781_hda_i2c.c | 3 ++ sound/hda/codecs/side-codecs/tas2781_hda_spi.c | 3 ++ 4 files changed, 80 insertions(+), 4 deletions(-)
TAS2781 HDA I2C and SPI queue RCA firmware loading with
request_firmware_nowait() during component bind. The firmware loader
keeps the callback module pinned and holds a device reference, but it
does not provide a way for drivers to cancel or synchronize the queued
callback before tearing down driver-private state.
Add a small firmware-loader helper to cancel or synchronize async firmware
requests, then use it from TAS2781 HDA unbind before controls and DSP state
are removed.
No hardware runtime test was available.
Signed-off-by: Cássio Gabriel <cassiogabrielcontato@gmail.com>
---
Changes in v4:
- Use spin_lock_irq() in the worker and cancel paths, which run from
sleepable contexts.
- Fold kfree(fw_work) into firmware_work_free().
- Keep irqsave in the request path so GFP_ATOMIC callers do not depend on
IRQ state assumptions.
- Link to v3: https://patch.msgid.link/20260501-alsa-hda-tas2781-fw-callback-teardown-v3-0-8d9f873b97bd@gmail.com
Changes in v3:
- Keep request_firmware_nowait() manually managed instead of making the
existing API implicitly devres-managed.
- Track scheduled async firmware work in an internal list protected by a
spinlock so request_firmware_nowait_cancel() can find and synchronize a
pending request without weakening the GFP_ATOMIC caller contract.
- Match pending requests by device, callback context and callback function
instead of matching by callback alone.
- Avoid the devres_add() / schedule_work() ordering race pointed out in
review.
- Leave devres-managed support for a separate devm_request_firmware_nowait()
API if needed.
- Link to v2: https://patch.msgid.link/20260430-alsa-hda-tas2781-fw-callback-teardown-v2-0-2c7d89cb3175@gmail.com
Changes in v2:
- Add request_firmware_nowait_cancel() in the firmware loader instead of
tracking the callback lifetime locally in the TAS2781 HDA driver.
- Keep the TAS2781 change to a cancel/sync call in I2C and SPI unbind.
- Drop the unrelated cached kcontrol pointer cleanup from the previous
local-driver version.
- Link to v1: https://patch.msgid.link/20260430-alsa-hda-tas2781-fw-callback-teardown-v1-1-874367d6b41b@gmail.com
---
Cássio Gabriel (2):
firmware_loader: Add cancel helper for async requests
ALSA: hda/tas2781: Cancel async firmware request at unbind
drivers/base/firmware_loader/main.c | 68 ++++++++++++++++++++++++--
include/linux/firmware.h | 10 ++++
sound/hda/codecs/side-codecs/tas2781_hda_i2c.c | 3 ++
sound/hda/codecs/side-codecs/tas2781_hda_spi.c | 3 ++
4 files changed, 80 insertions(+), 4 deletions(-)
---
base-commit: 0d672ef050d4e1c3891c9944f72c85769978bbee
change-id: 20260421-alsa-hda-tas2781-fw-callback-teardown-3b76404bb928
Best regards,
--
Cássio Gabriel <cassiogabrielcontato@gmail.com>
On Tue, 05 May 2026 13:18:15 +0200, Cássio Gabriel wrote: > > TAS2781 HDA I2C and SPI queue RCA firmware loading with > request_firmware_nowait() during component bind. The firmware loader > keeps the callback module pinned and holds a device reference, but it > does not provide a way for drivers to cancel or synchronize the queued > callback before tearing down driver-private state. > > Add a small firmware-loader helper to cancel or synchronize async firmware > requests, then use it from TAS2781 HDA unbind before controls and DSP state > are removed. > > No hardware runtime test was available. > > Signed-off-by: Cássio Gabriel <cassiogabrielcontato@gmail.com> > --- > Changes in v4: > - Use spin_lock_irq() in the worker and cancel paths, which run from > sleepable contexts. > - Fold kfree(fw_work) into firmware_work_free(). > - Keep irqsave in the request path so GFP_ATOMIC callers do not depend on > IRQ state assumptions. > - Link to v3: https://patch.msgid.link/20260501-alsa-hda-tas2781-fw-callback-teardown-v3-0-8d9f873b97bd@gmail.com > > Changes in v3: > - Keep request_firmware_nowait() manually managed instead of making the > existing API implicitly devres-managed. > - Track scheduled async firmware work in an internal list protected by a > spinlock so request_firmware_nowait_cancel() can find and synchronize a > pending request without weakening the GFP_ATOMIC caller contract. > - Match pending requests by device, callback context and callback function > instead of matching by callback alone. > - Avoid the devres_add() / schedule_work() ordering race pointed out in > review. > - Leave devres-managed support for a separate devm_request_firmware_nowait() > API if needed. > - Link to v2: https://patch.msgid.link/20260430-alsa-hda-tas2781-fw-callback-teardown-v2-0-2c7d89cb3175@gmail.com > > Changes in v2: > - Add request_firmware_nowait_cancel() in the firmware loader instead of > tracking the callback lifetime locally in the TAS2781 HDA driver. > - Keep the TAS2781 change to a cancel/sync call in I2C and SPI unbind. > - Drop the unrelated cached kcontrol pointer cleanup from the previous > local-driver version. > - Link to v1: https://patch.msgid.link/20260430-alsa-hda-tas2781-fw-callback-teardown-v1-1-874367d6b41b@gmail.com > > --- > Cássio Gabriel (2): > firmware_loader: Add cancel helper for async requests > ALSA: hda/tas2781: Cancel async firmware request at unbind I guess this could go via driver tree? Or I can take both if I get an ack, too. In anyway, for the series: Reviewed-by: Takashi Iwai <tiwai@suse.de> thanks, Takashi
On Wed May 6, 2026 at 10:05 AM CEST, Takashi Iwai wrote: > On Tue, 05 May 2026 13:18:15 +0200, > Cássio Gabriel wrote: >> Cássio Gabriel (2): >> firmware_loader: Add cancel helper for async requests >> ALSA: hda/tas2781: Cancel async firmware request at unbind Looks good to me now. > I guess this could go via driver tree? Or I can take both if I get an > ack, too. Sure, I can pick it up via the driver-core tree, but please also feel free to take it through the sounds tree. Acked-by: Danilo Krummrich <dakr@kernel.org> > In anyway, for the series: > > Reviewed-by: Takashi Iwai <tiwai@suse.de>
On Wed, 06 May 2026 11:34:39 +0200, Danilo Krummrich wrote: > > On Wed May 6, 2026 at 10:05 AM CEST, Takashi Iwai wrote: > > On Tue, 05 May 2026 13:18:15 +0200, > > Cássio Gabriel wrote: > >> Cássio Gabriel (2): > >> firmware_loader: Add cancel helper for async requests > >> ALSA: hda/tas2781: Cancel async firmware request at unbind > > Looks good to me now. > > > I guess this could go via driver tree? Or I can take both if I get an > > ack, too. > > Sure, I can pick it up via the driver-core tree, but please also feel free to > take it through the sounds tree. > > Acked-by: Danilo Krummrich <dakr@kernel.org> Thanks, then I'm going to take this to sound git tree, as it's the only user so far. Takashi
© 2016 - 2026 Red Hat, Inc.