From: "Nicolas Escande" <nico.escande@gmail.com>
To: "Rameshkumar Sundaram" <rameshkumar.sundaram@oss.qualcomm.com>,
"Nicolas Escande" <nico.escande@gmail.com>,
<ath12k@lists.infradead.org>
Cc: <linux-wireless@vger.kernel.org>
Subject: Re: [PATCH ath-next v4] wifi: ath12k: avoid dynamic alloc when parsing wmi tb
Date: Thu, 19 Mar 2026 15:35:57 +0100 [thread overview]
Message-ID: <DH6U1JMUQXVM.287BFERLLK9KK@gmail.com> (raw)
In-Reply-To: <36c1cae8-d6c0-4432-bc8e-57216c5ea3fd@oss.qualcomm.com>
On Thu Mar 19, 2026 at 12:08 PM CET, Rameshkumar Sundaram wrote:
>
> Since CONFIG_ATH12K is tristate, a built-in boot can continue past a
> failed ath12k_init() and still run ath12k_wifi7_init().
>
I genuinely thought the kernel prevented this. I was wrong.
> Please ensure that later initialization path is guarded against
> allocation failure.
>
I can add a flag like so to be able to check from ath12k_wifi7_init() if the
init finished ok. Something in the lines of
diff --git a/drivers/net/wireless/ath/ath12k/core.c b/drivers/net/wireless/ath/ath12k/core.c
index 6c034071cc6d..742fb33f41ff 100644
--- a/drivers/net/wireless/ath/ath12k/core.c
+++ b/drivers/net/wireless/ath/ath12k/core.c
@@ -34,6 +34,9 @@ module_param_named(ftm_mode, ath12k_ftm_mode, bool, 0444);
MODULE_PARM_DESC(ftm_mode, "Boots up in factory test mode");
EXPORT_SYMBOL(ath12k_ftm_mode);
+bool ath12k_init_ok = false;
+EXPORT_SYMBOL(ath12k_init_ok);
+
/* protected with ath12k_hw_group_mutex */
static struct list_head ath12k_hw_group_list = LIST_HEAD_INIT(ath12k_hw_group_list);
@@ -2323,7 +2326,14 @@ struct ath12k_base *ath12k_core_alloc(struct device *dev, size_t priv_size,
static int ath12k_init(void)
{
- return ath12k_wmi_alloc();
+ int ret;
+
+ ret = ath12k_wmi_alloc();
+ if (ret)
+ return -ENOMEM;
+
+ ath12k_init_ok = true;
+ return 0;
}
static void ath12k_exit(void)
diff --git a/drivers/net/wireless/ath/ath12k/core.h b/drivers/net/wireless/ath/ath12k/core.h
index 59c193b24764..f35571b1a541 100644
--- a/drivers/net/wireless/ath/ath12k/core.h
+++ b/drivers/net/wireless/ath/ath12k/core.h
@@ -101,6 +101,8 @@ enum ath12k_crypt_mode {
ATH12K_CRYPT_MODE_SW,
};
+extern bool ath12k_init_ok;
+
static inline enum wme_ac ath12k_tid_to_ac(u32 tid)
{
return (((tid == 0) || (tid == 3)) ? WME_AC_BE :
diff --git a/drivers/net/wireless/ath/ath12k/wifi7/core.c b/drivers/net/wireless/ath/ath12k/wifi7/core.c
index a02c57acf137..542ec10fabf1 100644
--- a/drivers/net/wireless/ath/ath12k/wifi7/core.c
+++ b/drivers/net/wireless/ath/ath12k/wifi7/core.c
@@ -38,6 +38,9 @@ void ath12k_wifi7_arch_deinit(struct ath12k_base *ab)
static int ath12k_wifi7_init(void)
{
+ if (!ath12k_init_ok)
+ return -ENOTSUPP;
+
ahb_err = ath12k_wifi7_ahb_init();
if (ahb_err)
pr_warn("Failed to initialize ath12k Wi-Fi 7 AHB device: %d\n",
I don't like it much but it is easy enough.
But I don't know if there is a more idiomatic way of doing things
> Or may be have this allocated on first device probe and free it on last
> device deinit ?
That seems even more involved. It would be easier to go back to the previous
version and simply, alloc it once per ath12k_base
What do you guys think ?
next prev parent reply other threads:[~2026-03-19 14:36 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-17 8:47 [PATCH ath-next v4] wifi: ath12k: avoid dynamic alloc when parsing wmi tb Nicolas Escande
2026-03-17 8:57 ` Baochen Qiang
2026-03-19 11:08 ` Rameshkumar Sundaram
2026-03-19 14:35 ` Nicolas Escande [this message]
2026-03-19 15:59 ` Jeff Johnson
2026-03-23 12:40 ` Rameshkumar Sundaram
2026-03-24 16:55 ` Jeff Johnson
2026-03-26 8:37 ` Nicolas Escande
2026-03-26 16:29 ` Jeff Johnson
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=DH6U1JMUQXVM.287BFERLLK9KK@gmail.com \
--to=nico.escande@gmail.com \
--cc=ath12k@lists.infradead.org \
--cc=linux-wireless@vger.kernel.org \
--cc=rameshkumar.sundaram@oss.qualcomm.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