From: Sean Anderson <sanderson@brivo.com>
To: Arend van Spriel <arend.vanspriel@broadcom.com>,
linux-wireless@vger.kernel.org
Cc: "Johannes Berg" <johannes.berg@intel.com>,
brcm80211@lists.linux.dev, linux-kernel@vger.kernel.org,
brcm80211-dev-list.pdl@broadcom.com,
"Sean Anderson" <sanderson@brivo.com>,
"Cássio Gabriel" <cassiogabrielcontato@gmail.com>,
"Danilo Krummrich" <dakr@kernel.org>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Luis Chamberlain" <mcgrof@kernel.org>,
"Rafael J. Wysocki" <rafael@kernel.org>,
"Takashi Iwai" <tiwai@suse.de>,
driver-core@lists.linux.dev
Subject: [PATCH 3/4] firmware_loader: Return status from request_firmware_nowait_cancel
Date: Mon, 21 Sep 2026 17:18:13 -0400 [thread overview]
Message-ID: <20260921211817.2432341-4-sanderson@brivo.com> (raw)
In-Reply-To: <20260921211817.2432341-1-sanderson@brivo.com>
request_firmware_nowait_cancel only cancels the most-recent matching
firmware request. If the callback creates additional requests then there
can be multiple requests in-flight (the original request and the
(pending) additional request). If we try to cancel the request at that
point, the original request may still be running. Add a status return
from request_firmware_nowait_cancel so we can tell if there may still be
additional requests we need to cancel.
Signed-off-by: Sean Anderson <sanderson@brivo.com>
---
drivers/base/firmware_loader/main.c | 11 ++++++++---
include/linux/firmware.h | 2 +-
2 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/drivers/base/firmware_loader/main.c b/drivers/base/firmware_loader/main.c
index 24213a0ea8317..ea475aa48a316 100644
--- a/drivers/base/firmware_loader/main.c
+++ b/drivers/base/firmware_loader/main.c
@@ -1290,11 +1290,15 @@ EXPORT_SYMBOL_GPL(firmware_request_nowait_nowarn);
* Cancel a pending request_firmware_nowait() request for @device, @context
* and @cont. If the associated work has already started, this function waits
* until the callback has returned. If the callback has already completed, this
- * function does nothing.
+ * function does nothing. This function may need to be called multiple times if
+ * the callback makes additional firmware requests.
*
* This function may sleep.
+ *
+ * Return: %true if a request was canceled, or %false if no requests matched
+ * @device and @context.
*/
-void request_firmware_nowait_cancel(struct device *device, void *context,
+bool request_firmware_nowait_cancel(struct device *device, void *context,
void (*cont)(const struct firmware *fw,
void *context))
{
@@ -1313,9 +1317,10 @@ void request_firmware_nowait_cancel(struct device *device, void *context,
spin_unlock_irq(&firmware_work_lock);
if (!fw_work)
- return;
+ return false;
cancel_work_sync(&fw_work->work);
firmware_work_free(fw_work);
+ return true;
}
EXPORT_SYMBOL_GPL(request_firmware_nowait_cancel);
diff --git a/include/linux/firmware.h b/include/linux/firmware.h
index 0fa3b027f02f1..46c34ad0067e7 100644
--- a/include/linux/firmware.h
+++ b/include/linux/firmware.h
@@ -110,7 +110,7 @@ int request_firmware_nowait(
struct module *module, bool uevent,
const char *name, struct device *device, gfp_t gfp, void *context,
void (*cont)(const struct firmware *fw, void *context));
-void request_firmware_nowait_cancel(struct device *device, void *context,
+bool request_firmware_nowait_cancel(struct device *device, void *context,
void (*cont)(const struct firmware *fw,
void *context));
int request_firmware_direct(const struct firmware **fw, const char *name,
--
2.53.0
next prev parent reply other threads:[~2026-09-21 21:18 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-21 21:18 [PATCH 0/4] wifi: brcmfmac: Fix bugs when the device is removed before firmware is loaded Sean Anderson
2026-09-21 21:18 ` [PATCH 1/4] wifi: brcmfmac: Fix canceling uninitialized datawork Sean Anderson
2026-09-21 21:18 ` [PATCH 2/4] wifi: brcmfmac: Fix brcmf_pno_detach NULL-pointer deference Sean Anderson
2026-09-21 21:18 ` Sean Anderson [this message]
2026-09-21 21:18 ` [PATCH 4/4] wifi: brcmfmac: Fix firmware requests racing against SDIO removal Sean Anderson
2026-09-22 13:33 ` Sean Anderson
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=20260921211817.2432341-4-sanderson@brivo.com \
--to=sanderson@brivo.com \
--cc=arend.vanspriel@broadcom.com \
--cc=brcm80211-dev-list.pdl@broadcom.com \
--cc=brcm80211@lists.linux.dev \
--cc=cassiogabrielcontato@gmail.com \
--cc=dakr@kernel.org \
--cc=driver-core@lists.linux.dev \
--cc=gregkh@linuxfoundation.org \
--cc=johannes.berg@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=mcgrof@kernel.org \
--cc=rafael@kernel.org \
--cc=tiwai@suse.de \
/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
all inboxes | Powered by JetHome®