<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">From fb1c40c225cbc413d82c872dd8c8af3469b2b921 Mon Sep 17 00:00:00 2001
From: Robert Marko &lt;robimarko@gmail.com&gt;
Date: Fri, 16 Dec 2022 17:17:52 +0100
Subject: [PATCH] ath11k: support setting FW memory mode via DT

ath11k is really memory intensive for devices with less that 1GB of RAM,
so lets allow saving a significant amount of memory by setting the FW to
Mode-1 via DTS for devices that need it.

However the drawback is reduced number of VDEV-s and peers which is a
reasonable tradeoff.

Mode-2 allows for further reduction, but it has further restrictions.

While we are here, lets add a print to be able to easily determine what
FW memory mode is being used.

Signed-off-by: Robert Marko &lt;robimarko@gmail.com&gt;
---
 drivers/net/wireless/ath/ath11k/core.c | 28 ++++++++++++++++++++++++--
 1 file changed, 26 insertions(+), 2 deletions(-)

--- a/drivers/net/wireless/ath/ath11k/core.c
+++ b/drivers/net/wireless/ath/ath11k/core.c
@@ -36,7 +36,7 @@ bool ath11k_ftm_mode;
 module_param_named(ftm_mode, ath11k_ftm_mode, bool, 0444);
 MODULE_PARM_DESC(ftm_mode, "Boots up in factory test mode");
 
-static const struct ath11k_hw_params ath11k_hw_params[] = {
+static struct ath11k_hw_params ath11k_hw_params[] = {
 	{
 		.hw_rev = ATH11K_HW_IPQ8074,
 		.name = "ipq8074 hw2.0",
@@ -2040,7 +2040,8 @@ static void ath11k_core_reset(struct wor
 static int ath11k_init_hw_params(struct ath11k_base *ab)
 {
 	const struct ath11k_hw_params *hw_params = NULL;
-	int i;
+	u32 fw_mem_mode;
+	int i, ret;
 
 	for (i = 0; i &lt; ARRAY_SIZE(ath11k_hw_params); i++) {
 		hw_params = &amp;ath11k_hw_params[i];
@@ -2056,7 +2057,31 @@ static int ath11k_init_hw_params(struct
 
 	ab-&gt;hw_params = *hw_params;
 
+	ret = of_property_read_u32(ab-&gt;dev-&gt;of_node,
+				   "qcom,ath11k-fw-memory-mode",
+				   &amp;fw_mem_mode);
+	if (!ret) {
+		if (fw_mem_mode == 0) {
+			ab-&gt;hw_params.fw_mem_mode = 0;
+			ab-&gt;hw_params.num_vdevs = 16 + 1;
+			ab-&gt;hw_params.num_peers = 512;
+		}
+		else if (fw_mem_mode == 1) {
+			ab-&gt;hw_params.fw_mem_mode = 1;
+			ab-&gt;hw_params.num_vdevs = 8;
+			ab-&gt;hw_params.num_peers = 128;
+		} else if (fw_mem_mode == 2) {
+			ab-&gt;hw_params.fw_mem_mode = 2;
+			ab-&gt;hw_params.num_vdevs = 8;
+			ab-&gt;hw_params.num_peers = 128;
+			ab-&gt;hw_params.coldboot_cal_mm = false;
+			ab-&gt;hw_params.coldboot_cal_ftm = false;
+		} else
+			ath11k_info(ab, "Unsupported FW memory mode: %u\n", fw_mem_mode);
+	}
+
 	ath11k_info(ab, "%s\n", ab-&gt;hw_params.name);
+	ath11k_info(ab, "FW memory mode: %d\n", ab-&gt;hw_params.fw_mem_mode);
 
 	return 0;
 }
</pre></body></html>