From: sashiko-bot@kernel.org
To: "Jose Ignacio Tornos Martinez" <jtornosm@redhat.com>
Cc: kvm@vger.kernel.org, linux-pci@vger.kernel.org
Subject: Re: [PATCH 4/7] ath11k: add PCIe link recovery retry
Date: Wed, 30 Sep 2026 14:56:50 +0000 [thread overview]
Message-ID: <20260930145650.E037D1F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260930140833.576941-5-jtornosm@redhat.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] ath11k: 5-second busy-wait loop using mdelay() causes CPU stalls and soft lockups
- [Medium] ath11k: polling loop misses final condition check on timeout causing false failures
--
commit c8d0b71714f3dd812345dc63d33d90b3fe00f198
Author: Jose Ignacio Tornos Martinez <jtornosm@redhat.com>
Subject: ath11k: add PCIe link recovery retry
This commit adds a retry loop (up to 5000ms) to wait for the PCIe link
to recover after a global reset. This aims to fix initialization failures
in virtualized environments where link stabilization may take longer.
> diff --git a/drivers/net/wireless/ath/ath11k/pci.c b/drivers/net/wireless/ath/ath11k/pci.c
> index a163168f36176..c372676b097f5 100644
> --- a/drivers/net/wireless/ath/ath11k/pci.c
> +++ b/drivers/net/wireless/ath/ath11k/pci.c
[ ... ]
> @@ -215,14 +217,29 @@ static void ath11k_pci_soc_global_reset(struct ath11k_base *ab)
>
> mdelay(delay);
>
> - val = ath11k_pcic_read32(ab, PCIE_SOC_GLOBAL_RESET);
> - if (val == 0xffffffff)
> - ath11k_warn(ab, "link down error during global reset\n");
> + /* Wait for PCIe link to recover, especially important in VM environments
> + * where timing can vary significantly from bare metal.
> + */
> + timeout = jiffies + msecs_to_jiffies(5000);
> + while (time_before(jiffies, timeout)) {
[Severity: Medium]
Will this polling loop incorrectly return -ETIMEDOUT if the thread is
preempted?
If the thread is preempted during the delay, jiffies could advance past
timeout before the next iteration. When the thread resumes, time_before()
will evaluate to false immediately, and the loop will exit without a final
register check despite the hardware having potentially recovered.
Should the hardware state be evaluated one final time after exiting the
time bounds check to avoid false timeouts?
> + val = ath11k_pcic_read32(ab, PCIE_SOC_GLOBAL_RESET);
> + if (val != 0xffffffff) {
> + link_recovered = true;
> + break;
> + }
> + mdelay(20);
[Severity: High]
Does this mdelay() in a loop of up to 5 seconds cause soft lockups?
During device unbind or surprise removal, the following call chain is
executed:
ath11k_pci_remove()
ath11k_core_deinit()
ath11k_hif_power_down()
ath11k_pci_power_down()
ath11k_pci_sw_reset()
ath11k_pci_soc_global_reset()
In these cases, the PCIe link is permanently dead and will never recover,
resulting in an unconditional 5-second CPU stall using a busy-wait.
Since ath11k_pci_soc_global_reset() is called from sleepable process and
workqueue contexts, could msleep() or read_poll_timeout() be used instead
of mdelay() to avoid blocking the CPU?
> + }
> + if (!link_recovered) {
> + ath11k_err(ab, "PCIe link failed to recover - device may need power cycle\n");
> + return -ETIMEDOUT;
> + }
>
> /* Restore window register as its content is cleared during
> * hardware global reset, such that it aligns with host cache.
> */
> ath11k_pci_restore_window(ab);
> +
> + return 0;
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260930140833.576941-1-jtornosm@redhat.com?part=4
next prev parent reply other threads:[~2026-09-30 14:56 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-30 14:08 [PATCH 0/7] Enable Qualcomm WiFi PCIe passthrough to VMs Jose Ignacio Tornos Martinez
2026-09-30 14:08 ` [PATCH 1/7] PCI: Add pci_find_free_ext_cap_offset() helper Jose Ignacio Tornos Martinez
2026-09-30 14:21 ` sashiko-bot
2026-09-30 14:08 ` [PATCH 2/7] vfio: Add qcom_vfio.h header for MSI cache protocol Jose Ignacio Tornos Martinez
2026-09-30 14:31 ` sashiko-bot
2026-09-30 14:08 ` [PATCH 3/7] vfio/pci: Add qcom-vfio-pci variant driver Jose Ignacio Tornos Martinez
2026-09-30 14:45 ` sashiko-bot
2026-09-30 15:12 ` Jason Gunthorpe
2026-10-01 7:19 ` Jose Ignacio Tornos Martinez
2026-10-02 17:10 ` Jason Gunthorpe
2026-10-05 11:01 ` Jose Ignacio Tornos Martinez
2026-09-30 14:08 ` [PATCH 4/7] ath11k: add PCIe link recovery retry Jose Ignacio Tornos Martinez
2026-09-30 14:56 ` sashiko-bot [this message]
2026-09-30 14:08 ` [PATCH 5/7] ath11k: Use VFIO MSI cache when available Jose Ignacio Tornos Martinez
2026-09-30 15:08 ` sashiko-bot
2026-09-30 14:08 ` [PATCH 6/7] ath12k: add PCIe link recovery retry Jose Ignacio Tornos Martinez
2026-09-30 15:17 ` sashiko-bot
2026-09-30 14:08 ` [PATCH 7/7] ath12k: Use VFIO MSI cache when available Jose Ignacio Tornos Martinez
2026-09-30 15:29 ` 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=20260930145650.E037D1F000FF@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=jtornosm@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linux-pci@vger.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