From: sashiko-bot@kernel.org
To: "George Moussalem" <george.moussalem@outlook.com>
Cc: conor+dt@kernel.org, robh@kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH ath-next 08/16] wifi: ath11k: Power up userPD
Date: Wed, 23 Sep 2026 12:17:20 +0000 [thread overview]
Message-ID: <20260923121721.09A811F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260923-ipq5018-qcn6122-mpd-v1-8-86729521a75c@outlook.com>
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] ath11k: hardware power and SMEM state leak on error paths in ath11k_ahb_boot_user_pd
- [High] ath11k: missing reinit_completion() in ath11k_ahb_boot_user_pd
- [High] ath11k: NULL pointer dereference in userPD IRQ handler due to late completion init
--
commit 6b777a3c2abf7cc48a88c29957b57c461963887f
Author: George Moussalem <george.moussalem@outlook.com>
wifi: ath11k: Power up userPD
Set the spawn bit to instruct Q6 to spawn the userPD thread.
Wait for userPD to spawn which is indicated by spawn interrupt. The
ready interrupt is triggered once the userPD is powered up completely.
> diff --git a/drivers/net/wireless/ath/ath11k/ahb.c b/drivers/net/wireless/ath/ath11k/ahb.c
> index 25f9a992a7d2f..2c41cf585d001 100644
> --- a/drivers/net/wireless/ath/ath11k/ahb.c
> +++ b/drivers/net/wireless/ath/ath11k/ahb.c
> @@ -430,8 +431,63 @@ static void ath11k_ahb_stop(struct ath11k_base *ab)
> ath11k_ce_cleanup_pipes(ab);
> }
>
> +static int ath11k_ahb_boot_user_pd(struct ath11k_base *ab)
> +{
> + struct ath11k_ahb *ab_ahb = ath11k_ahb_priv(ab);
> + unsigned long time_left;
> + int ret;
> +
> + if (ab->hw_rev == ATH11K_HW_IPQ5018_HW10) {
> + ret = qcom_scm_pas_set_wifi_power_mode(MPD_WCNSS_PAS_ID, true);
> + if (ret) {
> + ath11k_err(ab, "failed to power up wifi: %d\n", ret);
> + return ret;
> + }
> + }
> +
> + ret = qcom_smem_state_update_bits(ab_ahb->spawn_state, BIT(ab_ahb->spawn_bit),
> + BIT(ab_ahb->spawn_bit));
> + if (ret) {
> + ath11k_err(ab, "Failed to update spawn state %d\n", ret);
> + return ret;
> + }
> +
> + time_left = wait_for_completion_timeout(&ab_ahb->userpd_spawned,
> + ATH11K_USERPD_SPAWN_TIMEOUT);
[Severity: High]
Does this wait rely on a completion state that might carry over between driver
recoveries?
If a previous cycle timed out but the interrupt fired later, the completion's
done count might be > 0. Should reinit_completion() be called before setting the
SMEM state to prevent false positives?
> + if (!time_left) {
> + ath11k_err(ab, "UserPD spawn wait timed out\n");
> + return -ETIMEDOUT;
> + }
[Severity: High]
If this times out, should the SMEM spawn bit and Wi-Fi power mode be reverted?
Returning -ETIMEDOUT here without clearing ab_ahb->spawn_bit or calling
qcom_scm_pas_set_wifi_power_mode(MPD_WCNSS_PAS_ID, false) leaves the device
powered on and prevents subsequent recovery attempts from triggering the
edge-based spawn interrupt.
> +
> + time_left = wait_for_completion_timeout(&ab_ahb->userpd_ready,
> + ATH11K_USERPD_READY_TIMEOUT);
> + if (!time_left) {
> + ath11k_err(ab, "UserPD ready wait timed out\n");
> + return -ETIMEDOUT;
> + }
[Severity: High]
Similarly, if waiting for userpd_ready times out, should the SMEM spawn bit and
Wi-Fi power mode be cleaned up before returning -ETIMEDOUT?
> +
> + qcom_smem_state_update_bits(ab_ahb->spawn_state, BIT(ab_ahb->spawn_bit), 0);
> +
> + ath11k_dbg(ab, ATH11K_DBG_AHB, "UserPD%d is now UP\n", ab_ahb->userpd_id);
> +
> + return 0;
> +}
[Severity: High]
This isn't a bug introduced by this patch, but does the following pre-existing
code risk a NULL pointer dereference?
drivers/net/wireless/ath/ath11k/ahb.c:ath11k_ahb_config_userpd_irq() {
...
for (i = 0; i < ATH11K_USERPD_MAX_IRQ; i++) {
...
ret = devm_request_threaded_irq(&ab->pdev->dev, ab_ahb->userpd_irq_num[i],
NULL, ath11k_userpd_irq_handler,
IRQF_TRIGGER_RISING | IRQF_ONESHOT,
upd_irq_name, ab);
...
}
init_completion(&ab_ahb->userpd_spawned);
init_completion(&ab_ahb->userpd_ready);
...
}
If the interrupt fires immediately after registration and before
init_completion() is called, ath11k_userpd_irq_handler() would call complete()
on an uninitialized completion. Since ath11k_ahb is zero-allocated, the
completion's waitqueue list head is NULL, which will crash when complete() calls
list_empty().
Should init_completion() be called before registering the IRQ handlers?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260923-ipq5018-qcn6122-mpd-v1-0-86729521a75c@outlook.com?part=8
next prev parent reply other threads:[~2026-09-23 12:17 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-23 12:05 [PATCH ath-next 00/16] wifi: ath11k: add MultiPD support for AHB platforms George Moussalem via B4 Relay
2026-09-23 12:05 ` [PATCH ath-next 01/16] dt-bindings: net: wireless: ath11k: Sort compatible names alphabetically George Moussalem via B4 Relay
2026-09-28 10:45 ` Krzysztof Kozlowski
2026-09-23 12:05 ` [PATCH ath-next 02/16] dt-bindings: net: wireless: ath11k: Add bindings for IPQ5018 George Moussalem via B4 Relay
2026-09-23 12:14 ` sashiko-bot
2026-09-28 10:45 ` Krzysztof Kozlowski
2026-09-29 10:03 ` George Moussalem
2026-09-23 12:05 ` [PATCH ath-next 03/16] wifi: ath11k: Register root PD rproc notifier George Moussalem via B4 Relay
2026-09-23 12:17 ` sashiko-bot
2026-09-23 12:05 ` [PATCH ath-next 04/16] wifi: ath11k: Add support for loading m3 mbn firmware George Moussalem via B4 Relay
2026-09-23 12:15 ` sashiko-bot
2026-09-23 12:05 ` [PATCH ath-next 05/16] wifi: ath11k: Add ability to set BDF and M3 dump memory addresses George Moussalem via B4 Relay
2026-09-23 12:18 ` sashiko-bot
2026-09-23 12:05 ` [PATCH ath-next 06/16] firmware: qcom: scm: Add support for setting internal WiFi power mode George Moussalem via B4 Relay
2026-09-23 12:05 ` [PATCH ath-next 07/16] wifi: ath11k: Register userPD interrupts and SMEM entries George Moussalem via B4 Relay
2026-09-23 12:19 ` sashiko-bot
2026-09-23 12:05 ` [PATCH ath-next 08/16] wifi: ath11k: Power up userPD George Moussalem via B4 Relay
2026-09-23 12:17 ` sashiko-bot [this message]
2026-09-23 12:05 ` [PATCH ath-next 09/16] wifi: ath11k: Power down userPD George Moussalem via B4 Relay
2026-09-23 12:15 ` sashiko-bot
2026-09-23 12:05 ` [PATCH ath-next 10/16] dt-bindings: net: wireless: ath11k: Add bindings for QCN6122 George Moussalem via B4 Relay
2026-09-23 12:17 ` sashiko-bot
2026-09-23 12:05 ` [PATCH ath-next 11/16] wifi: ath11k: add hw params " George Moussalem via B4 Relay
2026-09-23 12:05 ` [PATCH ath-next 12/16] wifi: ath11k: add hal regs " George Moussalem via B4 Relay
2026-09-23 12:05 ` [PATCH ath-next 13/16] wifi: ath11k: add hw ring mask " George Moussalem via B4 Relay
2026-09-23 12:29 ` sashiko-bot
2026-09-23 12:05 ` [PATCH ath-next 14/16] wifi: ath11k: update hif and pci ops " George Moussalem via B4 Relay
2026-09-23 12:05 ` [PATCH ath-next 15/16] wifi: ath11k: define userPDs " George Moussalem via B4 Relay
2026-09-23 12:28 ` sashiko-bot
2026-09-23 12:05 ` [PATCH ath-next 16/16] wifi: ath11k: add QCN6122 device support George Moussalem via B4 Relay
2026-09-23 12:25 ` sashiko-bot
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=20260923121721.09A811F000FF@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=george.moussalem@outlook.com \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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