From: Takashi Iwai <tiwai@suse.de>
To: "Cássio Gabriel" <cassiogabrielcontato@gmail.com>
Cc: Luis Chamberlain <mcgrof@kernel.org>,
Russ Weight <russ.weight@linux.dev>,
Danilo Krummrich <dakr@kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
"Rafael J. Wysocki" <rafael@kernel.org>,
Takashi Iwai <tiwai@suse.com>,
Shenghao Ding <shenghao-ding@ti.com>, Kevin Lu <kevin-lu@ti.com>,
Baojun Xu <baojun.xu@ti.com>, Jaroslav Kysela <perex@perex.cz>,
driver-core@lists.linux.dev, linux-kernel@vger.kernel.org,
linux-sound@vger.kernel.org
Subject: Re: [PATCH v3 1/2] firmware_loader: Add cancel helper for async requests
Date: Mon, 04 May 2026 17:25:08 +0200 [thread overview]
Message-ID: <871pfrxkmj.wl-tiwai@suse.de> (raw)
In-Reply-To: <20260501-alsa-hda-tas2781-fw-callback-teardown-v3-1-8d9f873b97bd@gmail.com>
On Fri, 01 May 2026 12:22:12 +0200,
Cássio Gabriel wrote:
> +static void firmware_work_free(struct firmware_work *fw_work)
> +{
> + put_device(fw_work->device); /* taken in request_firmware_nowait() */
> + module_put(fw_work->module);
> + kfree_const(fw_work->name);
> +}
> +
> static void request_firmware_work_func(struct work_struct *work)
> {
> struct firmware_work *fw_work;
> const struct firmware *fw;
> + unsigned long flags;
>
> fw_work = container_of(work, struct firmware_work, work);
>
> _request_firmware(&fw, fw_work->name, fw_work->device, NULL, 0, 0,
> fw_work->opt_flags);
> fw_work->cont(fw, fw_work->context);
> - put_device(fw_work->device); /* taken in request_firmware_nowait() */
>
> - module_put(fw_work->module);
> - kfree_const(fw_work->name);
> - kfree(fw_work);
> + spin_lock_irqsave(&firmware_work_lock, flags);
This is a sleepable context, so you can use spin_lock_irq().
> + if (!list_empty(&fw_work->list)) {
> + list_del_init(&fw_work->list);
> + spin_unlock_irqrestore(&firmware_work_lock, flags);
> + firmware_work_free(fw_work);
> + kfree(fw_work);
Can kfree(fw_work) be in firmware_work_free(), too? All callers free
it in anyway.
(snip)
> +void request_firmware_nowait_cancel(struct device *device, void *context,
> + void (*cont)(const struct firmware *fw,
> + void *context))
> +{
> + struct firmware_work *fw_work = NULL;
> + struct firmware_work *tmp;
> + unsigned long flags;
> +
> + spin_lock_irqsave(&firmware_work_lock, flags);
Here you can use spin_lock_irq() as well.
thanks,
Takashi
next prev parent reply other threads:[~2026-05-04 15:25 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-01 10:22 [PATCH v3 0/2] firmware_loader/ALSA: Fix TAS2781 async firmware teardown Cássio Gabriel
2026-05-01 10:22 ` [PATCH v3 1/2] firmware_loader: Add cancel helper for async requests Cássio Gabriel
2026-05-04 15:25 ` Takashi Iwai [this message]
2026-05-04 22:40 ` Cássio Gabriel Monteiro Pires
2026-05-01 10:22 ` [PATCH v3 2/2] ALSA: hda/tas2781: Cancel async firmware request at unbind Cássio Gabriel
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=871pfrxkmj.wl-tiwai@suse.de \
--to=tiwai@suse.de \
--cc=baojun.xu@ti.com \
--cc=cassiogabrielcontato@gmail.com \
--cc=dakr@kernel.org \
--cc=driver-core@lists.linux.dev \
--cc=gregkh@linuxfoundation.org \
--cc=kevin-lu@ti.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=mcgrof@kernel.org \
--cc=perex@perex.cz \
--cc=rafael@kernel.org \
--cc=russ.weight@linux.dev \
--cc=shenghao-ding@ti.com \
--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