[PATCH v2 08/26][SRU][U/OEM-5.10] UBUNTU: SAUCE: ath11k: implement htc suspend related callbacks

You-Sheng Yang vicamo.yang at canonical.com
Fri Dec 4 15:25:02 UTC 2020


From: Carl Huang <cjhuang at codeaurora.org>

BugLink: https://bugs.launchpad.net/bugs/1879633

When ath11k sends suspend command to firmware, firmware will
return suspend_complete events.

Tested-on: QCA6390 hw2.0 PCI WLAN.HST.1.0.1-01740-QCAHSTSWPLZ_V2_TO_X86-1

Signed-off-by: Carl Huang <cjhuang at codeaurora.org>
Signed-off-by: Kalle Valo <kvalo at codeaurora.org>
(cherry picked from commit 69ab2835b82c176e793195243e1400d4f8db3647
https://git.kernel.org/pub/scm/linux/kernel/git/kvalo/ath.git)
Signed-off-by: You-Sheng Yang <vicamo.yang at canonical.com>
---
 drivers/net/wireless/ath/ath11k/core.h |  2 ++
 drivers/net/wireless/ath/ath11k/htc.c  | 30 +++++++++++++++++++++++++-
 drivers/net/wireless/ath/ath11k/htc.h  |  9 ++++++--
 drivers/net/wireless/ath/ath11k/mac.c  |  1 +
 4 files changed, 39 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/ath/ath11k/core.h b/drivers/net/wireless/ath/ath11k/core.h
index 0de6b2cd8c75..a51bb6f918a0 100644
--- a/drivers/net/wireless/ath/ath11k/core.h
+++ b/drivers/net/wireless/ath/ath11k/core.h
@@ -555,6 +555,8 @@ struct ath11k {
 #endif
 	bool dfs_block_radar_events;
 	struct ath11k_thermal thermal;
+	struct completion target_suspend;
+	bool target_suspend_ack;
 };
 
 struct ath11k_band_cap {
diff --git a/drivers/net/wireless/ath/ath11k/htc.c b/drivers/net/wireless/ath/ath11k/htc.c
index 6b57dc273e0b..1b53c01b590f 100644
--- a/drivers/net/wireless/ath/ath11k/htc.c
+++ b/drivers/net/wireless/ath/ath11k/htc.c
@@ -328,8 +328,18 @@ void ath11k_htc_rx_completion_handler(struct ath11k_base *ab,
 
 			complete(&htc->ctl_resp);
 			break;
+		case ATH11K_HTC_MSG_SEND_SUSPEND_COMPLETE:
+			htc->htc_ops.target_send_suspend_complete(ab->pdevs[0].ar, true);
+			break;
+		case ATH11K_HTC_MSG_NACK_SUSPEND:
+			htc->htc_ops.target_send_suspend_complete(ab->pdevs[0].ar, false);
+			break;
+		case ATH11K_HTC_MSG_WAKEUP_FROM_SUSPEND_ID:
+			htc->htc_ops.target_wakeup_from_suspend(ab->pdevs[0].ar);
+			break;
 		default:
-			ath11k_warn(ab, "ignoring unsolicited htc ep0 event\n");
+			ath11k_warn(ab, "ignoring unsolicited htc ep0 event %ld\n",
+				    FIELD_GET(HTC_MSG_MESSAGEID, msg->msg_svc_id));
 			break;
 		}
 		goto out;
@@ -720,6 +730,19 @@ int ath11k_htc_start(struct ath11k_htc *htc)
 	return 0;
 }
 
+static void ath11k_send_suspend_complete(struct ath11k *ar, bool ack)
+{
+	ath11k_dbg(ar->ab, ATH11K_DBG_BOOT, "boot suspend complete %d\n", ack);
+
+	ar->target_suspend_ack = ack;
+	complete(&ar->target_suspend);
+}
+
+static void ath11k_wakeup_from_suspend(struct ath11k *ar)
+{
+	ath11k_dbg(ar->ab, ATH11K_DBG_BOOT, "wakeup from suspend is received\n");
+}
+
 int ath11k_htc_init(struct ath11k_base *ab)
 {
 	struct ath11k_htc *htc = &ab->htc;
@@ -731,6 +754,11 @@ int ath11k_htc_init(struct ath11k_base *ab)
 
 	ath11k_htc_reset_endpoint_states(htc);
 
+	htc->htc_ops.target_send_suspend_complete =
+		ath11k_send_suspend_complete;
+	htc->htc_ops.target_wakeup_from_suspend =
+		ath11k_wakeup_from_suspend;
+
 	htc->ab = ab;
 
 	switch (ab->wmi_ab.preferred_hw_mode) {
diff --git a/drivers/net/wireless/ath/ath11k/htc.h b/drivers/net/wireless/ath/ath11k/htc.h
index f0a3387567ca..28435c0b8e8f 100644
--- a/drivers/net/wireless/ath/ath11k/htc.h
+++ b/drivers/net/wireless/ath/ath11k/htc.h
@@ -13,6 +13,7 @@
 #include <linux/timer.h>
 
 struct ath11k_base;
+struct ath11k;
 
 #define HTC_HDR_ENDPOINTID                       GENMASK(7, 0)
 #define HTC_HDR_FLAGS                            GENMASK(15, 8)
@@ -65,7 +66,10 @@ enum ath11k_htc_msg_id {
 	ATH11K_HTC_MSG_CONNECT_SERVICE_RESP_ID = 3,
 	ATH11K_HTC_MSG_SETUP_COMPLETE_ID       = 4,
 	ATH11K_HTC_MSG_SETUP_COMPLETE_EX_ID    = 5,
-	ATH11K_HTC_MSG_SEND_SUSPEND_COMPLETE   = 6
+	ATH11K_HTC_MSG_SEND_SUSPEND_COMPLETE   = 6,
+	ATH11K_HTC_MSG_NACK_SUSPEND	       = 7,
+	ATH11K_HTC_MSG_WAKEUP_FROM_SUSPEND_ID  = 8
+
 };
 
 enum ath11k_htc_version {
@@ -222,7 +226,8 @@ enum ath11k_htc_ep_id {
 };
 
 struct ath11k_htc_ops {
-	void (*target_send_suspend_complete)(struct ath11k_base *ar);
+	void (*target_send_suspend_complete)(struct ath11k *ar, bool ack);
+	void (*target_wakeup_from_suspend)(struct ath11k *ar);
 };
 
 struct ath11k_htc_ep_ops {
diff --git a/drivers/net/wireless/ath/ath11k/mac.c b/drivers/net/wireless/ath/ath11k/mac.c
index 7f8dd47d2333..a16b5d69b236 100644
--- a/drivers/net/wireless/ath/ath11k/mac.c
+++ b/drivers/net/wireless/ath/ath11k/mac.c
@@ -6403,6 +6403,7 @@ int ath11k_mac_allocate(struct ath11k_base *ab)
 		init_completion(&ar->scan.started);
 		init_completion(&ar->scan.completed);
 		init_completion(&ar->thermal.wmi_sync);
+		init_completion(&ar->target_suspend);
 
 		INIT_DELAYED_WORK(&ar->scan.timeout, ath11k_scan_timeout_work);
 		INIT_WORK(&ar->regd_update_work, ath11k_regd_update_work);
-- 
2.29.2




More information about the kernel-team mailing list