Skip to contentSkip to conversation

wifi: ath10k: Fix WoW wakeups on WCN3990

PATCH New Michael Auer 1 participant 3 messages Nov 21 Qualcomm Atheros ATH10K wireless driver

lore
Share & tools
lore
#0 lore raw

v2 cover wifi: ath10k: Fix WoW wakeups on WCN3990

With WoWLAN enabled, WCN3990 firmware wakes the host on action frames right after every WoW entry, so the system hardly stays suspended. And when the firmware does wake the host for a real reason, user space cannot see that it was a network wakeup.

Patch 1 sets the action frame wakeup filter that Qualcomm's own host drivers set. Patch 2 reports WoW wakeups to the PM core.

Both are in daily use on a OnePlus 6 (sdm845) since late September, with an sdm845-mainline 7.1-rc1 based kernel. On ath-next they were only build tested (W=1). I could not test QCA6174 or QCA9377. qcacld-2.0, the vendor driver for QCA6174, sends the same command, so I expect their firmware to know it.

Tool use: the analysis, the code and the commit messages were written with an LLM coding assistant (Claude Code). I reviewed all of it and tested it on my phone as described above.

Changes in v2:
- Patch 2: report the wakeup before completing wow.wakeup_completed, so the system resume cannot finish before the report (found by the sashiko review of v1). Tested again on the OnePlus 6.
- Patch 1: unchanged.

v1: https://lore.kernel.org/linux-wireless/[email protected]/

Michael Auer (2):
wifi: ath10k: configure the WoW action frame wakeup filter
wifi: ath10k: report WoW wakeups to the PM core

 drivers/net/wireless/ath/ath10k/wmi-ops.h | 19 +++++++++
 drivers/net/wireless/ath/ath10k/wmi-tlv.c | 47 +++++++++++++++++++++++
 drivers/net/wireless/ath/ath10k/wmi-tlv.h | 32 +++++++++++++++
 drivers/net/wireless/ath/ath10k/wmi.c     | 17 +++++---
 drivers/net/wireless/ath/ath10k/wmi.h     | 23 +++++++++++
 drivers/net/wireless/ath/ath10k/wow.c     | 10 +++++
 6 files changed, 143 insertions(+), 5 deletions(-)

base-commit: 1983b40acfcb3c3464b291c85977290a785bcfdc

Signature · 1 line
2.43.0
#1 lore raw

PATCH v2 1/2 wifi: ath10k: configure the WoW action frame wakeup filter

On WCN3990 almost every system suspend with WoWLAN enabled ends within a second. The firmware wakes the host with wake reason 38, which is WOW_REASON_ACTION_FRAME_RECV in Qualcomm's fw-api. ath10k's wake reason enum stops at 27, so the debug log shows "wow wakeup host reason (null)".

Qualcomm's own host drivers (qcacld-2.0 and qcacld-3.0) send WMI_WOW_SET_ACTION_WAKE_UP_CMDID, which sets the action frame categories that may wake the host. ath10k never sends it, so the firmware default applies.

Send it for station vdevs in ath10k_vif_wow_set_wakeups() with the values of qcacld-3.0: allow spectrum management, QoS, public, SA query, protected dual of public, WNM, WME, FST and VHT action frames, and ignore spectrum management Measurement and TPC Requests. A failure is logged and does not abort the suspend.

Also add wake reasons 28 to 38 and print the reason number, so unknown reasons are visible.

On a OnePlus 6, 3 of 3 WoW suspends were woken within 1 s with reason 38 before this change. With it, suspends last until a real wakeup (magic packet, pattern match or RTC). In a one hour idle test with a push connection the phone was suspended 87.6 % of the time.

Tested-on: WCN3990 hw1.0 SNOC WLAN.HL.2.0.c8-00050-QCAHLSWMTPLZ-1

---
The per-category array has 32 words, like the 2018 qcacld-3.0 for sdm845. qcacld-2.0 and newer qcacld-3.0 send 256. The fw-api defines it as a variable length array, and all allowed categories are below
32. I only tested 32.

 drivers/net/wireless/ath/ath10k/wmi-ops.h | 19 +++++++++
 drivers/net/wireless/ath/ath10k/wmi-tlv.c | 47 +++++++++++++++++++++++
 drivers/net/wireless/ath/ath10k/wmi-tlv.h | 32 +++++++++++++++
 drivers/net/wireless/ath/ath10k/wmi.c     |  4 +-
 drivers/net/wireless/ath/ath10k/wmi.h     | 23 +++++++++++
 drivers/net/wireless/ath/ath10k/wow.c     | 10 +++++
 6 files changed, 133 insertions(+), 2 deletions(-)
drivers/net/wireless/ath/ath10k/wmi-ops.h +19 -0
index f3f6b5954b27..780c2947cc5f 100644
@@ -179,6 +179,8 @@ struct wmi_ops {
 						    enum wmi_wow_wakeup_event event,
 						    u32 enable);
 	struct sk_buff *(*gen_wow_host_wakeup_ind)(struct ath10k *ar);
+	struct sk_buff *(*gen_wow_set_action_wake_up)(struct ath10k *ar,
+						      u32 vdev_id);
 	struct sk_buff *(*gen_wow_add_pattern)(struct ath10k *ar, u32 vdev_id,
 					       u32 pattern_id,
 					       const u8 *pattern,
@@ -1422,6 +1424,23 @@ ath10k_wmi_wow_host_wakeup_ind(struct ath10k *ar)
 	return ath10k_wmi_cmd_send(ar, skb, cmd_id);
 }
 
+static inline int
+ath10k_wmi_wow_set_action_wake_up(struct ath10k *ar, u32 vdev_id)
+{
+	struct sk_buff *skb;
+	u32 cmd_id;
+
+	if (!ar->wmi.ops->gen_wow_set_action_wake_up)
+		return -EOPNOTSUPP;
+
+	skb = ar->wmi.ops->gen_wow_set_action_wake_up(ar, vdev_id);
+	if (IS_ERR(skb))
+		return PTR_ERR(skb);
+
+	cmd_id = ar->wmi.cmd->wow_set_action_wake_up_cmdid;
+	return ath10k_wmi_cmd_send(ar, skb, cmd_id);
+}
+
 static inline int
 ath10k_wmi_wow_add_pattern(struct ath10k *ar, u32 vdev_id, u32 pattern_id,
 			   const u8 *pattern, const u8 *mask,
drivers/net/wireless/ath/ath10k/wmi-tlv.c +47 -0

65 lines not on this page · raw message

drivers/net/wireless/ath/ath10k/wmi-tlv.h +32 -0
index ea18ed8939db..2af7c9df4260 100644
@@ -189,6 +189,10 @@ enum wmi_tlv_cmd_id {
 	WMI_TLV_EXTWOW_ENABLE_CMDID,
 	WMI_TLV_EXTWOW_SET_APP_TYPE1_PARAMS_CMDID,
 	WMI_TLV_EXTWOW_SET_APP_TYPE2_PARAMS_CMDID,
+	WMI_TLV_WOW_ENABLE_ICMPV6_NA_FLT_CMDID,
+	WMI_TLV_WOW_UDP_SVC_OFLD_CMDID,
+	WMI_TLV_WOW_HOSTWAKEUP_GPIO_PIN_PATTERN_CONFIG_CMDID,
+	WMI_TLV_WOW_SET_ACTION_WAKE_UP_CMDID,
 	WMI_TLV_RTT_MEASREQ_CMDID = WMI_TLV_CMD(WMI_TLV_GRP_RTT),
 	WMI_TLV_RTT_TSF_CMDID,
 	WMI_TLV_SPECTRAL_SCAN_CONF_CMDID = WMI_TLV_CMD(WMI_TLV_GRP_SPECTRAL),
@@ -2202,6 +2206,34 @@ struct wmi_tlv_wow_add_del_event_cmd {
 	__le32 event_bitmap;
 } __packed;
 
+/* Action frame categories that may wake the host from WoW, as in
+ * qcacld-3.0: spectrum management (0), QoS (1), public (4), SA query (8),
+ * protected dual of public (9), WNM (10), WME (17), FST (18), VHT (21).
+ */
+#define WMI_TLV_WOW_ACTION_WAKE_UP_CATEGORY_MAP0	0x00260713
+
+/* Per-category bitmaps of action codes to ignore (1 = ignore). Like
+ * qcacld-3.0, ignore Measurement Request (0) and TPC Request (2).
+ */
+#define WMI_TLV_WOW_ACTION_WAKE_UP_NUM_CATEGORIES	32
+#define WMI_TLV_WOW_ACTION_WAKE_UP_SPECTRUM_MGMT_IGNORE	(BIT(0) | BIT(2))
+
+enum wmi_tlv_wow_action_wake_up_op {
+	WMI_TLV_WOW_ACTION_WAKE_UP_OP_RESET = 0,
+	WMI_TLV_WOW_ACTION_WAKE_UP_OP_SET = 1,
+	WMI_TLV_WOW_ACTION_WAKE_UP_OP_ADD_SET = 2,
+	WMI_TLV_WOW_ACTION_WAKE_UP_OP_DELETE_SET = 3,
+};
+
+/* WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param, followed by a
+ * WMI_TLV_TAG_ARRAY_UINT32 of per-category action code bitmaps.
+ */
+struct wmi_tlv_wow_set_action_wake_up_cmd {
+	__le32 vdev_id;
+	__le32 operation;
+	__le32 action_category_map[8];
+} __packed;
+
 struct wmi_tlv_request_peer_stats_info {
 	__le32 request_type;
 	__le32 vdev_id;
drivers/net/wireless/ath/ath10k/wmi.c +2 -2
index e57588c19c80..eca6bb189577 100644
@@ -4673,8 +4673,8 @@ void ath10k_wmi_event_wow_wakeup_host(struct ath10k *ar, struct sk_buff *skb)
 		return;
 	}
 
-	ath10k_dbg(ar, ATH10K_DBG_WMI, "wow wakeup host reason %s\n",
-		   wow_reason(ev.wake_reason));
+	ath10k_dbg(ar, ATH10K_DBG_WMI, "wow wakeup host reason %d %s\n",
+		   ev.wake_reason, wow_reason(ev.wake_reason));
 }
 
 void ath10k_wmi_event_dcs_interference(struct ath10k *ar, struct sk_buff *skb)
drivers/net/wireless/ath/ath10k/wmi.h +23 -0
index 7f50a1de6b97..f1a560fb3447 100644
@@ -944,6 +944,7 @@ struct wmi_cmd_map {
 	u32 wow_enable_disable_wake_event_cmdid;
 	u32 wow_enable_cmdid;
 	u32 wow_hostwakeup_from_sleep_cmdid;
+	u32 wow_set_action_wake_up_cmdid;
 	u32 rtt_measreq_cmdid;
 	u32 rtt_tsf_cmdid;
 	u32 vdev_spectral_scan_configure_cmdid;
@@ -7060,6 +7061,17 @@ enum wmi_wow_wake_reason {
 	WOW_REASON_DFS_PHYERR_RADADR_EVENT,
 	WOW_REASON_BEACON_RECV,
 	WOW_REASON_CLIENT_KICKOUT_EVENT,
+	WOW_REASON_NAN_EVENT,
+	WOW_REASON_EXTSCAN,
+	WOW_REASON_RSSI_BREACH_EVENT,
+	WOW_REASON_IOAC_REV_KA_FAIL_EVENT,
+	WOW_REASON_IOAC_SOCK_EVENT,
+	WOW_REASON_NLO_SCAN_COMPLETE,
+	WOW_REASON_PACKET_FILTER_MATCH,
+	WOW_REASON_ASSOC_RES_RECV,
+	WOW_REASON_REASSOC_REQ_RECV,
+	WOW_REASON_REASSOC_RES_RECV,
+	WOW_REASON_ACTION_FRAME_RECV,
 	WOW_REASON_DEBUG_TEST = 0xFF,
 };
 
@@ -7095,6 +7107,17 @@ static inline const char *wow_reason(enum wmi_wow_wake_reason reason)
 	C2S(WOW_REASON_DFS_PHYERR_RADADR_EVENT);
 	C2S(WOW_REASON_BEACON_RECV);
 	C2S(WOW_REASON_CLIENT_KICKOUT_EVENT);
+	C2S(WOW_REASON_NAN_EVENT);
+	C2S(WOW_REASON_EXTSCAN);
+	C2S(WOW_REASON_RSSI_BREACH_EVENT);
+	C2S(WOW_REASON_IOAC_REV_KA_FAIL_EVENT);
+	C2S(WOW_REASON_IOAC_SOCK_EVENT);
+	C2S(WOW_REASON_NLO_SCAN_COMPLETE);
+	C2S(WOW_REASON_PACKET_FILTER_MATCH);
+	C2S(WOW_REASON_ASSOC_RES_RECV);
+	C2S(WOW_REASON_REASSOC_REQ_RECV);
+	C2S(WOW_REASON_REASSOC_RES_RECV);
+	C2S(WOW_REASON_ACTION_FRAME_RECV);
 	C2S(WOW_REASON_DEBUG_TEST);
 	default:
 		return NULL;
drivers/net/wireless/ath/ath10k/wow.c +10 -0
index 92af8bc63362..5fc68e6cdeb6 100644
@@ -380,6 +380,16 @@ static int ath10k_vif_wow_set_wakeups(struct ath10k_vif *arvif,
 		}
 	}
 
+	if (arvif->vdev_type == WMI_VDEV_TYPE_STA) {
+		/* Without this filter WCN3990 wakes the host on action
+		 * frames right after WoW is enabled.
+		 */
+		ret = ath10k_wmi_wow_set_action_wake_up(ar, arvif->vdev_id);
+		if (ret && ret != -EOPNOTSUPP)
+			ath10k_warn(ar, "failed to set action frame wakeup filter on vdev %i: %d\n",
+				    arvif->vdev_id, ret);
+	}
+
 	return 0;
 }
 
Signature · 1 line
2.43.0
#2 lore raw

PATCH v2 2/2 wifi: ath10k: report WoW wakeups to the PM core

In reply to Michael Auer

ath10k does not report a WoW wakeup to the PM core, so the wakeup source of the device never counts it, and user space cannot tell a network wakeup from other resumes. Plasma's powerdevil, for example, checks the wakeup_count of each wakeup source after resume. It keeps the display off after a network wakeup and turns it on otherwise.

Call pm_wakeup_event() when the firmware reports a wake reason other than WOW_REASON_UNSPECIFIED, which it uses when the host resumed for another reason. iwlwifi does the same since commit 06ae2ad413d2 ("iwlwifi: mvm: report wakeup for wowlan").

Report it before completing wow.wakeup_completed. Once the resume path continues, the system resume can finish and stop counting wakeup events before the report.

On a OnePlus 6 the wakeup source of the WLAN device now counts WoW wakeups, and powerdevil keeps the display off for them.

Tested-on: WCN3990 hw1.0 SNOC WLAN.HL.2.0.c8-00050-QCAHLSWMTPLZ-1

---
v2: report the wakeup before complete(), also on the parse error path

 drivers/net/wireless/ath/ath10k/wmi.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)
drivers/net/wireless/ath/ath10k/wmi.c +10 -3
index eca6bb189577..e12fdd5aabc8 100644
@@ -4665,16 +4665,23 @@ void ath10k_wmi_event_wow_wakeup_host(struct ath10k *ar, struct sk_buff *skb)
 	struct wmi_wow_ev_arg ev = {};
 	int ret;
 
-	complete(&ar->wow.wakeup_completed);
-
 	ret = ath10k_wmi_pull_wow_event(ar, skb, &ev);
 	if (ret) {
 		ath10k_warn(ar, "failed to parse wow wakeup event: %d\n", ret);
-		return;
+		goto out;
 	}
 
 	ath10k_dbg(ar, ATH10K_DBG_WMI, "wow wakeup host reason %d %s\n",
 		   ev.wake_reason, wow_reason(ev.wake_reason));
+
+	/* UNSPECIFIED: the host resumed for another reason. Report before
+	 * the completion, so the system resume cannot finish first.
+	 */
+	if (ev.wake_reason != WOW_REASON_UNSPECIFIED)
+		pm_wakeup_event(ar->dev, 0);
+
+out:
+	complete(&ar->wow.wakeup_completed);
 }
 
 void ath10k_wmi_event_dcs_interference(struct ath10k *ar, struct sk_buff *skb)
Signature · 1 line
2.43.0