From: Baochen Qiang <quic_bqiang@quicinc.com>
To: <ath12k@lists.infradead.org>
Cc: <linux-wireless@vger.kernel.org>, <quic_bqiang@quicinc.com>
Subject: [PATCH 06/10] wifi: ath12k: flush all packets before suspend
Date: Fri, 12 Apr 2024 14:06:16 +0800 [thread overview]
Message-ID: <20240412060620.27519-7-quic_bqiang@quicinc.com> (raw)
In-Reply-To: <20240412060620.27519-1-quic_bqiang@quicinc.com>
In order to send out all packets before going to suspend, current code
adds a 500ms delay as a workaround. It is a rough estimate and may not
work.
Fix this by checking packet counters, if counters become zero, then all
packets are sent out or dropped.
Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0-03427-QCAHMTSWPL_V1.0_V2.0_SILICONZ-1.15378.4
Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.0.1-00029-QCAHKSWPL_SILICONZ-1
Signed-off-by: Baochen Qiang <quic_bqiang@quicinc.com>
---
drivers/net/wireless/ath/ath12k/core.c | 20 +++++++++++++-----
drivers/net/wireless/ath/ath12k/mac.c | 28 ++++++++++++++++++++------
drivers/net/wireless/ath/ath12k/mac.h | 1 +
3 files changed, 38 insertions(+), 11 deletions(-)
diff --git a/drivers/net/wireless/ath/ath12k/core.c b/drivers/net/wireless/ath/ath12k/core.c
index 28663cf4db30..dfec390b66c6 100644
--- a/drivers/net/wireless/ath/ath12k/core.c
+++ b/drivers/net/wireless/ath/ath12k/core.c
@@ -44,15 +44,25 @@ static int ath12k_core_rfkill_config(struct ath12k_base *ab)
int ath12k_core_suspend(struct ath12k_base *ab)
{
- int ret;
+ struct ath12k *ar;
+ int ret, i;
if (!ab->hw_params->supports_suspend)
return -EOPNOTSUPP;
- /* TODO: there can frames in queues so for now add delay as a hack.
- * Need to implement to handle and remove this delay.
- */
- msleep(500);
+ rcu_read_lock();
+ for (i = 0; i < ab->num_radios; i++) {
+ ar = ath12k_mac_get_ar_by_pdev_id(ab, i);
+ if (!ar)
+ continue;
+ ret = ath12k_mac_wait_tx_complete(ar);
+ if (ret) {
+ ath12k_warn(ab, "failed to wait tx complete: %d\n", ret);
+ rcu_read_unlock();
+ return ret;
+ }
+ }
+ rcu_read_unlock();
ret = ath12k_dp_rx_pktlog_stop(ab, true);
if (ret) {
diff --git a/drivers/net/wireless/ath/ath12k/mac.c b/drivers/net/wireless/ath/ath12k/mac.c
index f15dcd75157d..69c5fd9d2612 100644
--- a/drivers/net/wireless/ath/ath12k/mac.c
+++ b/drivers/net/wireless/ath/ath12k/mac.c
@@ -7356,22 +7356,38 @@ static int ath12k_mac_op_set_frag_threshold(struct ieee80211_hw *hw, u32 value)
return -EOPNOTSUPP;
}
-static void ath12k_mac_flush(struct ath12k *ar)
+static int ath12k_mac_flush(struct ath12k *ar)
{
long time_left;
+ int ret = 0;
time_left = wait_event_timeout(ar->dp.tx_empty_waitq,
(atomic_read(&ar->dp.num_tx_pending) == 0),
ATH12K_FLUSH_TIMEOUT);
- if (time_left == 0)
- ath12k_warn(ar->ab, "failed to flush transmit queue %ld\n", time_left);
+ if (time_left == 0) {
+ ath12k_warn(ar->ab,
+ "failed to flush transmit queue, data pkts pending %d\n",
+ atomic_read(&ar->dp.num_tx_pending));
+ ret = -ETIMEDOUT;
+ }
time_left = wait_event_timeout(ar->txmgmt_empty_waitq,
(atomic_read(&ar->num_pending_mgmt_tx) == 0),
ATH12K_FLUSH_TIMEOUT);
- if (time_left == 0)
- ath12k_warn(ar->ab, "failed to flush mgmt transmit queue %ld\n",
- time_left);
+ if (time_left == 0) {
+ ath12k_warn(ar->ab,
+ "failed to flush mgmt transmit queue, mgmt pkts pending %d\n",
+ atomic_read(&ar->num_pending_mgmt_tx));
+ ret = -ETIMEDOUT;
+ }
+
+ return ret;
+}
+
+int ath12k_mac_wait_tx_complete(struct ath12k *ar)
+{
+ ath12k_mac_drain_tx(ar);
+ return ath12k_mac_flush(ar);
}
static void ath12k_mac_op_flush(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
diff --git a/drivers/net/wireless/ath/ath12k/mac.h b/drivers/net/wireless/ath/ath12k/mac.h
index 3f5e1be0dff9..f826822d30c8 100644
--- a/drivers/net/wireless/ath/ath12k/mac.h
+++ b/drivers/net/wireless/ath/ath12k/mac.h
@@ -78,4 +78,5 @@ enum ath12k_supported_bw ath12k_mac_mac80211_bw_to_ath12k_bw(enum rate_info_bw b
enum hal_encrypt_type ath12k_dp_tx_get_encrypt_type(u32 cipher);
int ath12k_mac_rfkill_enable_radio(struct ath12k *ar, bool enable);
int ath12k_mac_rfkill_config(struct ath12k *ar);
+int ath12k_mac_wait_tx_complete(struct ath12k *ar);
#endif
--
2.25.1
next prev parent reply other threads:[~2024-04-12 6:06 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-12 6:06 [PATCH 00/10] wifi: ath12k: support suspend/resume Baochen Qiang
2024-04-12 6:06 ` [PATCH 01/10] wifi: ath12k: rearrange IRQ enable/disable in reset path Baochen Qiang
2024-04-12 18:24 ` Sidhanta Sahu
2024-04-15 5:38 ` Baochen Qiang
2024-04-22 17:51 ` Jeff Johnson
2024-04-23 9:27 ` Kalle Valo
2024-04-12 6:06 ` [PATCH 02/10] wifi: ath12k: remove MHI LOOPBACK channels Baochen Qiang
2024-04-22 17:51 ` Jeff Johnson
2024-04-12 6:06 ` [PATCH 03/10] wifi: ath12k: do not dump SRNG statistics during resume Baochen Qiang
2024-04-22 17:51 ` Jeff Johnson
2024-04-12 6:06 ` [PATCH 04/10] wifi: ath12k: fix warning on DMA ring capabilities event Baochen Qiang
2024-04-22 17:51 ` Jeff Johnson
2024-04-12 6:06 ` [PATCH 05/10] wifi: ath12k: decrease MHI channel buffer length to 8KB Baochen Qiang
2024-04-22 17:51 ` Jeff Johnson
2024-04-12 6:06 ` Baochen Qiang [this message]
2024-04-22 17:52 ` [PATCH 06/10] wifi: ath12k: flush all packets before suspend Jeff Johnson
2024-04-12 6:06 ` [PATCH 07/10] wifi: ath12k: no need to handle pktlog during suspend/resume Baochen Qiang
2024-04-22 17:52 ` Jeff Johnson
2024-04-12 6:06 ` [PATCH 08/10] wifi: ath12k: avoid stopping mac80211 queues in ath12k_core_restart() Baochen Qiang
2024-04-22 17:52 ` Jeff Johnson
2024-04-12 6:06 ` [PATCH 09/10] wifi: ath12k: support suspend/resume Baochen Qiang
2024-04-22 17:52 ` Jeff Johnson
2024-04-12 6:06 ` [PATCH 10/10] wifi: ath12k: change supports_suspend to true for WCN7850 Baochen Qiang
2024-04-22 17:52 ` Jeff Johnson
2024-04-12 18:05 ` [PATCH 00/10] wifi: ath12k: support suspend/resume Jeff Johnson
2024-04-15 5:51 ` Baochen Qiang
2024-04-16 8:28 ` Kalle Valo
2024-04-16 10:31 ` Baochen Qiang
2024-04-17 14:22 ` Kalle Valo
2024-04-17 23:32 ` Jeff Johnson
2024-04-18 6:06 ` Jeff Johnson
2024-04-18 10:43 ` Baochen Qiang
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=20240412060620.27519-7-quic_bqiang@quicinc.com \
--to=quic_bqiang@quicinc.com \
--cc=ath12k@lists.infradead.org \
--cc=linux-wireless@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).