linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ath11k: cold boot calibration support
@ 2020-07-02 14:24 Sowmiya Sree Elavalagan
  2020-07-02 18:02 ` kernel test robot
  2020-07-03 14:39 ` kernel test robot
  0 siblings, 2 replies; 3+ messages in thread
From: Sowmiya Sree Elavalagan @ 2020-07-02 14:24 UTC (permalink / raw)
  To: ath11k; +Cc: linux-wireless, Govindaraj Saminathan, Sowmiya Sree Elavalagan

From: Govindaraj Saminathan <gsamin@codeaurora.org>

cold boot calibration is the process to calibrate all the channels
during the boot-up to avoid the calibration delay during the
channel change.
During the boot-up, firmware started with mode “cold_boot_calibration”
Firmware calibrate all channels and generate CalDb(DDR).
Subsequent WIFI ON will reuse the same CalDb.
Firmware restarted with Mission mode to continue the normal operation.

caldb memory address send to firmware through the QMI message.Firmware
use this address to store the caldb data and use it until next reboot.

This will give the improvement during the channel change. But it is
increasing the boot-up time(up to 15sec depend on number of radios).
So if the user want to reduce the boot-up time and accepting for channel
change delay, user can disable this feature using the module param
cold_boot_cal =0.

Signed-off-by: Govindaraj Saminathan <gsamin@codeaurora.org>
Co-developed-by: Sowmiya Sree Elavalagan <ssreeela@codeaurora.org>
Signed-off-by: Sowmiya Sree Elavalagan <ssreeela@codeaurora.org>
---
 drivers/net/wireless/ath/ath11k/ahb.c  | 26 ++++++++++++++
 drivers/net/wireless/ath/ath11k/core.c |  1 +
 drivers/net/wireless/ath/ath11k/core.h |  5 +++
 drivers/net/wireless/ath/ath11k/qmi.c  | 66 ++++++++++++++++++++++++++++++----
 drivers/net/wireless/ath/ath11k/qmi.h  |  3 ++
 5 files changed, 94 insertions(+), 7 deletions(-)

diff --git a/drivers/net/wireless/ath/ath11k/ahb.c b/drivers/net/wireless/ath/ath11k/ahb.c
index 7e9bfea..7f31ab0 100644
--- a/drivers/net/wireless/ath/ath11k/ahb.c
+++ b/drivers/net/wireless/ath/ath11k/ahb.c
@@ -638,6 +638,30 @@ static void ath11k_ahb_power_down(struct ath11k_base *ab)
 	rproc_shutdown(ab->tgt_rproc);
 }
 
+int ath11k_ahb_fwreset_from_cold_boot(struct ath11k_base *ab)
+{
+	int timeout;
+
+	if (ath11k_cold_boot_cal == 0 || ab->qmi.cal_done)
+		return 0;
+
+	ath11k_dbg(ab, ATH11K_DBG_AHB, "wait for cold boot done\n");
+	timeout = wait_event_timeout(ab->qmi.cold_boot_waitq,
+				     (ab->qmi.cal_done  == 1),
+				     ATH11K_COLD_BOOT_FW_RESET_DELAY);
+	if (timeout <= 0) {
+		ath11k_warn(ab, "Coldboot Calibration timed out\n");
+		return -ETIMEDOUT;
+	}
+
+	/* reset the firmware */
+	ath11k_ahb_power_down(ab);
+	ath11k_ahb_power_up(ab);
+
+	ath11k_dbg(ab, ATH11K_DBG_AHB, "exit wait for cold boot done\n");
+	return 0;
+}
+
 static void ath11k_ahb_init_qmi_ce_config(struct ath11k_base *ab)
 {
 	struct ath11k_qmi_ce_cfg *cfg = &ab->qmi.ce_cfg;
@@ -964,6 +988,8 @@ static int ath11k_ahb_probe(struct platform_device *pdev)
 		goto err_ce_free;
 	}
 
+	ath11k_ahb_fwreset_from_cold_boot(ab);
+
 	return 0;
 
 err_ce_free:
diff --git a/drivers/net/wireless/ath/ath11k/core.c b/drivers/net/wireless/ath/ath11k/core.c
index 38e830a..533c7b2 100644
--- a/drivers/net/wireless/ath/ath11k/core.c
+++ b/drivers/net/wireless/ath/ath11k/core.c
@@ -801,6 +801,7 @@ struct ath11k_base *ath11k_core_alloc(struct device *dev, size_t priv_size,
 	INIT_LIST_HEAD(&ab->peers);
 	init_waitqueue_head(&ab->peer_mapping_wq);
 	init_waitqueue_head(&ab->wmi_ab.tx_credits_wq);
+	init_waitqueue_head(&ab->qmi.cold_boot_waitq);
 	INIT_WORK(&ab->restart_work, ath11k_core_restart);
 	timer_setup(&ab->rx_replenish_retry, ath11k_ce_rx_replenish_retry, 0);
 	ab->dev = dev;
diff --git a/drivers/net/wireless/ath/ath11k/core.h b/drivers/net/wireless/ath/ath11k/core.h
index b6ccd9f..d736fb0 100644
--- a/drivers/net/wireless/ath/ath11k/core.h
+++ b/drivers/net/wireless/ath/ath11k/core.h
@@ -98,8 +98,13 @@ enum ath11k_firmware_mode {
 
 	/* factory tests etc */
 	ATH11K_FIRMWARE_MODE_FTM,
+
+	/* Cold boot calibration */
+	ATH11K_FIRMWARE_MODE_COLD_BOOT = 7,
 };
 
+extern bool ath11k_cold_boot_cal;
+
 #define ATH11K_IRQ_NUM_MAX 52
 #define ATH11K_EXT_IRQ_GRP_NUM_MAX 11
 #define ATH11K_EXT_IRQ_NUM_MAX	16
diff --git a/drivers/net/wireless/ath/ath11k/qmi.c b/drivers/net/wireless/ath/ath11k/qmi.c
index 50812df..599a389 100644
--- a/drivers/net/wireless/ath/ath11k/qmi.c
+++ b/drivers/net/wireless/ath/ath11k/qmi.c
@@ -9,6 +9,12 @@
 #include <linux/of.h>
 #include <linux/firmware.h>
 
+bool ath11k_cold_boot_cal = 1;
+module_param_named(cold_boot_cal, ath11k_cold_boot_cal, bool, 0644);
+MODULE_PARM_DESC(cold_boot_cal,
+		 "Cold boot will bring down the channel switch time but "
+		 "it will increase the driver load time (enable:1, disable:0)");
+
 static struct qmi_elem_info qmi_wlanfw_host_cap_req_msg_v01_ei[] = {
 	{
 		.data_type	= QMI_OPT_FLAG,
@@ -1692,9 +1698,16 @@ static int ath11k_qmi_alloc_target_mem_chunk(struct ath11k_base *ab)
 				ath11k_warn(ab, "qmi mem size is low to load caldata\n");
 				return -EINVAL;
 			}
-			/* TODO ath11k does not support cold boot calibration */
-			ab->qmi.target_mem[idx].paddr = 0;
-			ab->qmi.target_mem[idx].vaddr = 0;
+
+			if (ath11k_cold_boot_cal) {
+				ab->qmi.target_mem[idx].paddr =
+						     ATH11K_QMI_CALDB_ADDRESS;
+				ab->qmi.target_mem[idx].vaddr =
+						     ATH11K_QMI_CALDB_ADDRESS;
+			} else {
+				ab->qmi.target_mem[idx].paddr = 0;
+				ab->qmi.target_mem[idx].vaddr = 0;
+			}
 			ab->qmi.target_mem[idx].size = ab->qmi.target_mem[i].size;
 			ab->qmi.target_mem[idx].type = ab->qmi.target_mem[i].type;
 			idx++;
@@ -2111,6 +2124,32 @@ int ath11k_qmi_firmware_start(struct ath11k_base *ab,
 	return 0;
 }
 
+int ath11k_qmi_process_coldboot_calibration(struct ath11k_base *ab)
+{
+	int timeout;
+	int ret;
+
+	ret = ath11k_qmi_wlanfw_mode_send(ab, ATH11K_FIRMWARE_MODE_COLD_BOOT);
+	if (ret < 0) {
+		ath11k_warn(ab, "qmi failed to send wlan fw mode:%d\n", ret);
+		return ret;
+	}
+
+	ath11k_warn(ab, "Coldboot calibration wait started\n");
+
+	timeout = wait_event_timeout(ab->qmi.cold_boot_waitq,
+				     (ab->qmi.cal_done  == 1),
+				     ATH11K_COLD_BOOT_FW_RESET_DELAY);
+	if (timeout <= 0) {
+		ath11k_warn(ab, "Coldboot Calibration timed out\n");
+		return -ETIMEDOUT;
+	}
+
+	ath11k_warn(ab, "Coldboot calibration wait ended\n");
+
+	return 0;
+}
+
 static int
 ath11k_qmi_driver_event_post(struct ath11k_qmi *qmi,
 			     enum ath11k_qmi_event_type type,
@@ -2247,11 +2286,18 @@ static void ath11k_qmi_msg_fw_ready_cb(struct qmi_handle *qmi_hdl,
 	ath11k_qmi_driver_event_post(qmi, ATH11K_QMI_EVENT_FW_READY, NULL);
 }
 
-static void ath11k_qmi_msg_cold_boot_cal_done_cb(struct qmi_handle *qmi,
+static void ath11k_qmi_msg_cold_boot_cal_done_cb(struct qmi_handle *qmi_hdl,
 						 struct sockaddr_qrtr *sq,
 						 struct qmi_txn *txn,
 						 const void *decoded)
 {
+	struct ath11k_qmi *qmi = container_of(qmi_hdl,
+					      struct ath11k_qmi, handle);
+	struct ath11k_base *ab = qmi->ab;
+
+	ab->qmi.cal_done = 1;
+	wake_up(&ab->qmi.cold_boot_waitq);
+	ath11k_dbg(ab, ATH11K_DBG_QMI, "qmi cold boot calibration done\n");
 }
 
 static const struct qmi_msg_handler ath11k_qmi_msg_handlers[] = {
@@ -2364,9 +2410,15 @@ static void ath11k_qmi_driver_event_work(struct work_struct *work)
 				break;
 			}
 
-			ath11k_core_qmi_firmware_ready(ab);
-			ab->qmi.cal_done = 1;
-			set_bit(ATH11K_FLAG_REGISTERED, &ab->dev_flags);
+			if (ath11k_cold_boot_cal && ab->qmi.cal_done == 0) {
+				ath11k_qmi_process_coldboot_calibration(ab);
+			} else {
+				clear_bit(ATH11K_FLAG_CRASH_FLUSH,
+					  &ab->dev_flags);
+				clear_bit(ATH11K_FLAG_RECOVERY, &ab->dev_flags);
+				ath11k_core_qmi_firmware_ready(ab);
+				set_bit(ATH11K_FLAG_REGISTERED, &ab->dev_flags);
+			}
 
 			break;
 		case ATH11K_QMI_EVENT_COLD_BOOT_CAL_DONE:
diff --git a/drivers/net/wireless/ath/ath11k/qmi.h b/drivers/net/wireless/ath/ath11k/qmi.h
index 3307be5..02c05cc 100644
--- a/drivers/net/wireless/ath/ath11k/qmi.h
+++ b/drivers/net/wireless/ath/ath11k/qmi.h
@@ -12,6 +12,7 @@
 #define ATH11K_HOST_VERSION_STRING		"WIN"
 #define ATH11K_QMI_WLANFW_TIMEOUT_MS		5000
 #define ATH11K_QMI_MAX_BDF_FILE_NAME_SIZE	64
+#define ATH11K_QMI_CALDB_ADDRESS		0x4BA00000
 #define ATH11K_QMI_BDF_MAX_SIZE			(256 * 1024)
 #define ATH11K_QMI_CALDATA_OFFSET		(128 * 1024)
 #define ATH11K_QMI_WLANFW_MAX_BUILD_ID_LEN_V01	128
@@ -31,6 +32,7 @@
 #define QMI_WLANFW_MAX_DATA_SIZE_V01		6144
 #define ATH11K_FIRMWARE_MODE_OFF		4
 #define ATH11K_QMI_TARGET_MEM_MODE_DEFAULT	0
+#define ATH11K_COLD_BOOT_FW_RESET_DELAY		(40 * HZ)
 
 struct ath11k_base;
 
@@ -110,6 +112,7 @@ struct ath11k_qmi {
 	u32 target_mem_mode;
 	u8 cal_done;
 	struct target_info target;
+	wait_queue_head_t cold_boot_waitq;
 };
 
 #define QMI_WLANFW_HOST_CAP_REQ_MSG_V01_MAX_LEN		189
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] ath11k: cold boot calibration support
  2020-07-02 14:24 [PATCH] ath11k: cold boot calibration support Sowmiya Sree Elavalagan
@ 2020-07-02 18:02 ` kernel test robot
  2020-07-03 14:39 ` kernel test robot
  1 sibling, 0 replies; 3+ messages in thread
From: kernel test robot @ 2020-07-02 18:02 UTC (permalink / raw)
  To: Sowmiya Sree Elavalagan, ath11k
  Cc: kbuild-all, linux-wireless, Govindaraj Saminathan,
	Sowmiya Sree Elavalagan

[-- Attachment #1: Type: text/plain, Size: 2614 bytes --]

Hi Sowmiya,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on ath6kl/ath-next]
[cannot apply to v5.8-rc3 next-20200702]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use  as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Sowmiya-Sree-Elavalagan/ath11k-cold-boot-calibration-support/20200702-222828
base:   https://git.kernel.org/pub/scm/linux/kernel/git/kvalo/ath.git ath-next
config: mips-allyesconfig (attached as .config)
compiler: mips-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=mips 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

>> drivers/net/wireless/ath/ath11k/ahb.c:641:5: warning: no previous prototype for 'ath11k_ahb_fwreset_from_cold_boot' [-Wmissing-prototypes]
     641 | int ath11k_ahb_fwreset_from_cold_boot(struct ath11k_base *ab)
         |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--
>> drivers/net/wireless/ath/ath11k/qmi.c:2127:5: warning: no previous prototype for 'ath11k_qmi_process_coldboot_calibration' [-Wmissing-prototypes]
    2127 | int ath11k_qmi_process_coldboot_calibration(struct ath11k_base *ab)
         |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

vim +/ath11k_ahb_fwreset_from_cold_boot +641 drivers/net/wireless/ath/ath11k/ahb.c

   640	
 > 641	int ath11k_ahb_fwreset_from_cold_boot(struct ath11k_base *ab)
   642	{
   643		int timeout;
   644	
   645		if (ath11k_cold_boot_cal == 0 || ab->qmi.cal_done)
   646			return 0;
   647	
   648		ath11k_dbg(ab, ATH11K_DBG_AHB, "wait for cold boot done\n");
   649		timeout = wait_event_timeout(ab->qmi.cold_boot_waitq,
   650					     (ab->qmi.cal_done  == 1),
   651					     ATH11K_COLD_BOOT_FW_RESET_DELAY);
   652		if (timeout <= 0) {
   653			ath11k_warn(ab, "Coldboot Calibration timed out\n");
   654			return -ETIMEDOUT;
   655		}
   656	
   657		/* reset the firmware */
   658		ath11k_ahb_power_down(ab);
   659		ath11k_ahb_power_up(ab);
   660	
   661		ath11k_dbg(ab, ATH11K_DBG_AHB, "exit wait for cold boot done\n");
   662		return 0;
   663	}
   664	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 67073 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] ath11k: cold boot calibration support
  2020-07-02 14:24 [PATCH] ath11k: cold boot calibration support Sowmiya Sree Elavalagan
  2020-07-02 18:02 ` kernel test robot
@ 2020-07-03 14:39 ` kernel test robot
  1 sibling, 0 replies; 3+ messages in thread
From: kernel test robot @ 2020-07-03 14:39 UTC (permalink / raw)
  To: Sowmiya Sree Elavalagan, ath11k
  Cc: kbuild-all, clang-built-linux, linux-wireless,
	Govindaraj Saminathan, Sowmiya Sree Elavalagan

[-- Attachment #1: Type: text/plain, Size: 3501 bytes --]

Hi Sowmiya,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on ath6kl/ath-next]
[cannot apply to v5.8-rc3 next-20200703]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use  as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Sowmiya-Sree-Elavalagan/ath11k-cold-boot-calibration-support/20200702-222828
base:   https://git.kernel.org/pub/scm/linux/kernel/git/kvalo/ath.git ath-next
config: x86_64-allyesconfig (attached as .config)
compiler: clang version 11.0.0 (https://github.com/llvm/llvm-project 003a086ffc0d1affbb8300b36225fb8150a2d40a)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install x86_64 cross compiling tool for clang build
        # apt-get install binutils-x86-64-linux-gnu
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

>> drivers/net/wireless/ath/ath11k/ahb.c:641:5: warning: no previous prototype for function 'ath11k_ahb_fwreset_from_cold_boot' [-Wmissing-prototypes]
   int ath11k_ahb_fwreset_from_cold_boot(struct ath11k_base *ab)
       ^
   drivers/net/wireless/ath/ath11k/ahb.c:641:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   int ath11k_ahb_fwreset_from_cold_boot(struct ath11k_base *ab)
   ^
   static 
   drivers/net/wireless/ath/ath11k/ahb.c:962:15: warning: cast to smaller integer type 'enum ath11k_hw_rev' from 'const void *' [-Wvoid-pointer-to-enum-cast]
           ab->hw_rev = (enum ath11k_hw_rev)of_id->data;
                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   2 warnings generated.
--
>> drivers/net/wireless/ath/ath11k/qmi.c:2127:5: warning: no previous prototype for function 'ath11k_qmi_process_coldboot_calibration' [-Wmissing-prototypes]
   int ath11k_qmi_process_coldboot_calibration(struct ath11k_base *ab)
       ^
   drivers/net/wireless/ath/ath11k/qmi.c:2127:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   int ath11k_qmi_process_coldboot_calibration(struct ath11k_base *ab)
   ^
   static 
   1 warning generated.

vim +/ath11k_ahb_fwreset_from_cold_boot +641 drivers/net/wireless/ath/ath11k/ahb.c

   640	
 > 641	int ath11k_ahb_fwreset_from_cold_boot(struct ath11k_base *ab)
   642	{
   643		int timeout;
   644	
   645		if (ath11k_cold_boot_cal == 0 || ab->qmi.cal_done)
   646			return 0;
   647	
   648		ath11k_dbg(ab, ATH11K_DBG_AHB, "wait for cold boot done\n");
   649		timeout = wait_event_timeout(ab->qmi.cold_boot_waitq,
   650					     (ab->qmi.cal_done  == 1),
   651					     ATH11K_COLD_BOOT_FW_RESET_DELAY);
   652		if (timeout <= 0) {
   653			ath11k_warn(ab, "Coldboot Calibration timed out\n");
   654			return -ETIMEDOUT;
   655		}
   656	
   657		/* reset the firmware */
   658		ath11k_ahb_power_down(ab);
   659		ath11k_ahb_power_up(ab);
   660	
   661		ath11k_dbg(ab, ATH11K_DBG_AHB, "exit wait for cold boot done\n");
   662		return 0;
   663	}
   664	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 75332 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-07-03 15:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-02 14:24 [PATCH] ath11k: cold boot calibration support Sowmiya Sree Elavalagan
2020-07-02 18:02 ` kernel test robot
2020-07-03 14:39 ` kernel test robot

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).