wifi: ath10k: Add WLAN firmware image version info into smem

Message ID 20221026102257.19919-1-quic_youghand@quicinc.com
State New
Headers
Series wifi: ath10k: Add WLAN firmware image version info into smem |

Commit Message

Youghandhar Chintala Oct. 26, 2022, 10:22 a.m. UTC
  In a SoC based solution, it would be useful to know the versions of the
various binary firmware blobs the system is running on. On a QCOM based
SoC, this info can be obtained from socinfo debugfs infrastructure. For
this to work, respective subsystem drivers have to export the firmware
version information to an SMEM based version information table.

Having firmware version information at one place will help quickly
figure out the firmware versions of various subsystems on the device
instead of going through builds/logs in an event of a system crash.

Fill WLAN firmware version information in SMEM version table to be
printed as part of socinfo debugfs infrastructure on a Qualcomm based
SoC.

This change is applicable only for WCN399X targets.

Tested-on: WCN3990 hw1.0 SNOC WLAN.HL.3.2.2.c10-00754-QCAHLSWMTPL-1

Signed-off-by: Youghandhar Chintala <quic_youghand@quicinc.com>
---
 drivers/net/wireless/ath/ath10k/qmi.c | 28 +++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
  

Comments

kernel test robot Oct. 26, 2022, 12:11 p.m. UTC | #1
Hi Youghandhar,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on kvalo-ath/ath-next]
[also build test WARNING on wireless/main wireless-next/main linus/master v6.1-rc2 next-20221026]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Youghandhar-Chintala/wifi-ath10k-Add-WLAN-firmware-image-version-info-into-smem/20221026-182411
base:   https://git.kernel.org/pub/scm/linux/kernel/git/kvalo/ath.git ath-next
patch link:    https://lore.kernel.org/r/20221026102257.19919-1-quic_youghand%40quicinc.com
patch subject: [PATCH] wifi: ath10k: Add WLAN firmware image version info into smem
config: ia64-allyesconfig (attached as .config)
compiler: ia64-linux-gcc (GCC) 12.1.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
        # https://github.com/intel-lab-lkp/linux/commit/8faae971fb76b9c21178b19d7e9c37519cda06e1
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Youghandhar-Chintala/wifi-ath10k-Add-WLAN-firmware-image-version-info-into-smem/20221026-182411
        git checkout 8faae971fb76b9c21178b19d7e9c37519cda06e1
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=ia64 SHELL=/bin/bash drivers/net/

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

All warnings (new ones prefixed by >>):

   In file included from drivers/net/wireless/ath/ath10k/qmi.c:21:
   drivers/net/wireless/ath/ath10k/qmi.c: In function 'ath10k_qmi_add_wlan_ver_smem':
>> drivers/net/wireless/ath/ath10k/qmi.c:557:48: warning: format '%i' expects argument of type 'int', but argument 4 has type 'size_t' {aka 'long unsigned int'} [-Wformat=]
     557 |                 ath10k_dbg(ar, ATH10K_DBG_QMI, "smem block size too small: %i",
         |                                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     558 |                            smem_block_size);
         |                            ~~~~~~~~~~~~~~~      
         |                            |
         |                            size_t {aka long unsigned int}
   drivers/net/wireless/ath/ath10k/debug.h:286:44: note: in definition of macro 'ath10k_dbg'
     286 |                 __ath10k_dbg(ar, dbg_mask, fmt, ##__VA_ARGS__); \
         |                                            ^~~
   drivers/net/wireless/ath/ath10k/qmi.c:557:77: note: format string is defined here
     557 |                 ath10k_dbg(ar, ATH10K_DBG_QMI, "smem block size too small: %i",
         |                                                                            ~^
         |                                                                             |
         |                                                                             int
         |                                                                            %li


vim +557 drivers/net/wireless/ath/ath10k/qmi.c

   541	
   542	static void ath10k_qmi_add_wlan_ver_smem(struct ath10k *ar, char *fw_build_id)
   543	{
   544		u8 *smem_table_ptr;
   545		size_t smem_block_size;
   546		const u32 version_string_size = 128;
   547		const u32 smem_img_idx_wlan = ATH10K_SMEM_IMAGE_TABLE_CNSS_INDEX * 128;
   548	
   549		smem_table_ptr = qcom_smem_get(QCOM_SMEM_HOST_ANY,
   550					       ATH10K_SMEM_IMAGE_VERSION_TABLE,
   551					       &smem_block_size);
   552		if (IS_ERR(smem_table_ptr)) {
   553			ath10k_dbg(ar, ATH10K_DBG_QMI, "smem image version table not found");
   554			return;
   555		}
   556		if (smem_img_idx_wlan + version_string_size > smem_block_size) {
 > 557			ath10k_dbg(ar, ATH10K_DBG_QMI, "smem block size too small: %i",
   558				   smem_block_size);
   559			return;
   560		}
   561		memcpy(smem_table_ptr + smem_img_idx_wlan, fw_build_id,
   562		       version_string_size);
   563	}
   564
  
Jeff Johnson Oct. 27, 2022, 6:49 p.m. UTC | #2
On 10/26/2022 3:22 AM, Youghandhar Chintala wrote:
> In a SoC based solution, it would be useful to know the versions of the
> various binary firmware blobs the system is running on. On a QCOM based
> SoC, this info can be obtained from socinfo debugfs infrastructure. For
> this to work, respective subsystem drivers have to export the firmware
> version information to an SMEM based version information table.
> 
> Having firmware version information at one place will help quickly
> figure out the firmware versions of various subsystems on the device
> instead of going through builds/logs in an event of a system crash.
> 
> Fill WLAN firmware version information in SMEM version table to be
> printed as part of socinfo debugfs infrastructure on a Qualcomm based
> SoC.
> 
> This change is applicable only for WCN399X targets.
> 
> Tested-on: WCN3990 hw1.0 SNOC WLAN.HL.3.2.2.c10-00754-QCAHLSWMTPL-1
> 
> Signed-off-by: Youghandhar Chintala <quic_youghand@quicinc.com>
> ---
>   drivers/net/wireless/ath/ath10k/qmi.c | 28 +++++++++++++++++++++++++++
>   1 file changed, 28 insertions(+)
> 
> diff --git a/drivers/net/wireless/ath/ath10k/qmi.c b/drivers/net/wireless/ath/ath10k/qmi.c
> index 66cb7a1e628a..e88bcfd96859 100644
> --- a/drivers/net/wireless/ath/ath10k/qmi.c
> +++ b/drivers/net/wireless/ath/ath10k/qmi.c
> @@ -14,6 +14,7 @@
>   #include <linux/net.h>
>   #include <linux/platform_device.h>
>   #include <linux/qcom_scm.h>
> +#include <linux/soc/qcom/smem.h>
>   #include <linux/string.h>
>   #include <net/sock.h>
>   
> @@ -22,6 +23,8 @@
>   
>   #define ATH10K_QMI_CLIENT_ID		0x4b4e454c
>   #define ATH10K_QMI_TIMEOUT		30
> +#define ATH10K_SMEM_IMAGE_VERSION_TABLE       469
> +#define ATH10K_SMEM_IMAGE_TABLE_CNSS_INDEX     13
>   
>   static int ath10k_qmi_map_msa_permission(struct ath10k_qmi *qmi,
>   					 struct ath10k_msa_mem_info *mem_info)
> @@ -536,6 +539,29 @@ int ath10k_qmi_wlan_disable(struct ath10k *ar)
>   	return ath10k_qmi_mode_send_sync_msg(ar, QMI_WLFW_OFF_V01);
>   }
>   
> +static void ath10k_qmi_add_wlan_ver_smem(struct ath10k *ar, char *fw_build_id)

const char *fw_build_id?

> +{
> +	u8 *smem_table_ptr;
> +	size_t smem_block_size;
> +	const u32 version_string_size = 128;

should you s/128/MAX_BUILD_ID_LEN/ since that is what is used to size 
qmi->fw_build_id?

or alternately have the caller pass fw_build_id length as a separate param?


> +	const u32 smem_img_idx_wlan = ATH10K_SMEM_IMAGE_TABLE_CNSS_INDEX * 128;
> +
> +	smem_table_ptr = qcom_smem_get(QCOM_SMEM_HOST_ANY,
> +				       ATH10K_SMEM_IMAGE_VERSION_TABLE,
> +				       &smem_block_size);
> +	if (IS_ERR(smem_table_ptr)) {
> +		ath10k_dbg(ar, ATH10K_DBG_QMI, "smem image version table not found");
> +		return;
> +	}
> +	if (smem_img_idx_wlan + version_string_size > smem_block_size) {
> +		ath10k_dbg(ar, ATH10K_DBG_QMI, "smem block size too small: %i",
> +			   smem_block_size);
> +		return;
> +	}
> +	memcpy(smem_table_ptr + smem_img_idx_wlan, fw_build_id,
> +	       version_string_size);
> +}
> +
>   static int ath10k_qmi_cap_send_sync_msg(struct ath10k_qmi *qmi)
>   {
>   	struct wlfw_cap_resp_msg_v01 *resp;
> @@ -606,6 +632,8 @@ static int ath10k_qmi_cap_send_sync_msg(struct ath10k_qmi *qmi)
>   			    qmi->fw_version, qmi->fw_build_timestamp, qmi->fw_build_id);
>   	}
>   
> +	ath10k_qmi_add_wlan_ver_smem(ar, qmi->fw_build_id);
> +
>   	kfree(resp);
>   	return 0;
>
  
Youghandhar Chintala Oct. 31, 2022, 6:54 a.m. UTC | #3
On 10/28/2022 12:19 AM, Jeff Johnson wrote:
> On 10/26/2022 3:22 AM, Youghandhar Chintala wrote:
>> In a SoC based solution, it would be useful to know the versions of the
>> various binary firmware blobs the system is running on. On a QCOM based
>> SoC, this info can be obtained from socinfo debugfs infrastructure. For
>> this to work, respective subsystem drivers have to export the firmware
>> version information to an SMEM based version information table.
>>
>> Having firmware version information at one place will help quickly
>> figure out the firmware versions of various subsystems on the device
>> instead of going through builds/logs in an event of a system crash.
>>
>> Fill WLAN firmware version information in SMEM version table to be
>> printed as part of socinfo debugfs infrastructure on a Qualcomm based
>> SoC.
>>
>> This change is applicable only for WCN399X targets.
>>
>> Tested-on: WCN3990 hw1.0 SNOC WLAN.HL.3.2.2.c10-00754-QCAHLSWMTPL-1
>>
>> Signed-off-by: Youghandhar Chintala <quic_youghand@quicinc.com>
>> ---
>>   drivers/net/wireless/ath/ath10k/qmi.c | 28 +++++++++++++++++++++++++++
>>   1 file changed, 28 insertions(+)
>>
>> diff --git a/drivers/net/wireless/ath/ath10k/qmi.c 
>> b/drivers/net/wireless/ath/ath10k/qmi.c
>> index 66cb7a1e628a..e88bcfd96859 100644
>> --- a/drivers/net/wireless/ath/ath10k/qmi.c
>> +++ b/drivers/net/wireless/ath/ath10k/qmi.c
>> @@ -14,6 +14,7 @@
>>   #include <linux/net.h>
>>   #include <linux/platform_device.h>
>>   #include <linux/qcom_scm.h>
>> +#include <linux/soc/qcom/smem.h>
>>   #include <linux/string.h>
>>   #include <net/sock.h>
>>   @@ -22,6 +23,8 @@
>>     #define ATH10K_QMI_CLIENT_ID        0x4b4e454c
>>   #define ATH10K_QMI_TIMEOUT        30
>> +#define ATH10K_SMEM_IMAGE_VERSION_TABLE       469
>> +#define ATH10K_SMEM_IMAGE_TABLE_CNSS_INDEX     13
>>     static int ath10k_qmi_map_msa_permission(struct ath10k_qmi *qmi,
>>                        struct ath10k_msa_mem_info *mem_info)
>> @@ -536,6 +539,29 @@ int ath10k_qmi_wlan_disable(struct ath10k *ar)
>>       return ath10k_qmi_mode_send_sync_msg(ar, QMI_WLFW_OFF_V01);
>>   }
>>   +static void ath10k_qmi_add_wlan_ver_smem(struct ath10k *ar, char 
>> *fw_build_id)
>
> const char *fw_build_id?
>
>> +{
>> +    u8 *smem_table_ptr;
>> +    size_t smem_block_size;
>> +    const u32 version_string_size = 128;
>
> should you s/128/MAX_BUILD_ID_LEN/ since that is what is used to size 
> qmi->fw_build_id?
>
> or alternately have the caller pass fw_build_id length as a separate 
> param?
>   Sure Jeff. Will address it in next version of patch.
>
>> +    const u32 smem_img_idx_wlan = ATH10K_SMEM_IMAGE_TABLE_CNSS_INDEX 
>> * 128;
>> +
>> +    smem_table_ptr = qcom_smem_get(QCOM_SMEM_HOST_ANY,
>> +                       ATH10K_SMEM_IMAGE_VERSION_TABLE,
>> +                       &smem_block_size);
>> +    if (IS_ERR(smem_table_ptr)) {
>> +        ath10k_dbg(ar, ATH10K_DBG_QMI, "smem image version table not 
>> found");
>> +        return;
>> +    }
>> +    if (smem_img_idx_wlan + version_string_size > smem_block_size) {
>> +        ath10k_dbg(ar, ATH10K_DBG_QMI, "smem block size too small: %i",
>> +               smem_block_size);
>> +        return;
>> +    }
>> +    memcpy(smem_table_ptr + smem_img_idx_wlan, fw_build_id,
>> +           version_string_size);
>> +}
>> +
>>   static int ath10k_qmi_cap_send_sync_msg(struct ath10k_qmi *qmi)
>>   {
>>       struct wlfw_cap_resp_msg_v01 *resp;
>> @@ -606,6 +632,8 @@ static int ath10k_qmi_cap_send_sync_msg(struct 
>> ath10k_qmi *qmi)
>>                   qmi->fw_version, qmi->fw_build_timestamp, 
>> qmi->fw_build_id);
>>       }
>>   +    ath10k_qmi_add_wlan_ver_smem(ar, qmi->fw_build_id);
>> +
>>       kfree(resp);
>>       return 0;
>
  
Kalle Valo Nov. 1, 2022, 9:01 a.m. UTC | #4
(fixing quotation)

"Youghandhar Chintala (Temp)" <quic_youghand@quicinc.com> writes:

> On 10/28/2022 12:19 AM, Jeff Johnson wrote:
>
>> On 10/26/2022 3:22 AM, Youghandhar Chintala wrote:

>>>   +static void ath10k_qmi_add_wlan_ver_smem(struct ath10k *ar, char
>>> *fw_build_id)
>>
>> const char *fw_build_id?
>>
>>> +{
>>> +    u8 *smem_table_ptr;
>>> +    size_t smem_block_size;
>>> +    const u32 version_string_size = 128;
>>
>> should you s/128/MAX_BUILD_ID_LEN/ since that is what is used to
>> size qmi->fw_build_id?
>>
>> or alternately have the caller pass fw_build_id length as a separate
>> param?
>
> Sure Jeff. Will address it in next version of patch.

BTW Youghandhar, your quotes were broken in this mail so your reply was
difficult to find. See here:

https://patchwork.kernel.org/project/linux-wireless/patch/20221026102257.19919-1-quic_youghand@quicinc.com/

If you are using Outlook, I recommend switching to an application which
respects standards more :) For example, some people seem to be happy
with Thunderbird.
  
Youghandhar Chintala Nov. 1, 2022, 9:08 a.m. UTC | #5
On 11/1/2022 2:31 PM, Kalle Valo wrote:
> (fixing quotation)
>
> "Youghandhar Chintala (Temp)" <quic_youghand@quicinc.com> writes:
>
>> On 10/28/2022 12:19 AM, Jeff Johnson wrote:
>>
>>> On 10/26/2022 3:22 AM, Youghandhar Chintala wrote:
>>>>    +static void ath10k_qmi_add_wlan_ver_smem(struct ath10k *ar, char
>>>> *fw_build_id)
>>> const char *fw_build_id?
>>>
>>>> +{
>>>> +    u8 *smem_table_ptr;
>>>> +    size_t smem_block_size;
>>>> +    const u32 version_string_size = 128;
>>> should you s/128/MAX_BUILD_ID_LEN/ since that is what is used to
>>> size qmi->fw_build_id?
>>>
>>> or alternately have the caller pass fw_build_id length as a separate
>>> param?
>> Sure Jeff. Will address it in next version of patch.
> BTW Youghandhar, your quotes were broken in this mail so your reply was
> difficult to find. See here:
>
> https://patchwork.kernel.org/project/linux-wireless/patch/20221026102257.19919-1-quic_youghand@quicinc.com/
>
> If you are using Outlook, I recommend switching to an application which
> respects standards more :) For example, some people seem to be happy
> with Thunderbird.


Thank you so much for your suggestion. I will address it.

Currently I am using  Thunderbird.
  
Kalle Valo Nov. 1, 2022, 9:29 a.m. UTC | #6
"Youghandhar Chintala (Temp)" <quic_youghand@quicinc.com> writes:

> On 11/1/2022 2:31 PM, Kalle Valo wrote:
>
>> BTW Youghandhar, your quotes were broken in this mail so your reply was
>> difficult to find. See here:
>>
>> https://patchwork.kernel.org/project/linux-wireless/patch/20221026102257.19919-1-quic_youghand@quicinc.com/
>>
>> If you are using Outlook, I recommend switching to an application which
>> respects standards more :) For example, some people seem to be happy
>> with Thunderbird.
>
>
> Thank you so much for your suggestion. I will address it.
>
> Currently I am using  Thunderbird.

Good, and now your quotes were correct.
  

Patch

diff --git a/drivers/net/wireless/ath/ath10k/qmi.c b/drivers/net/wireless/ath/ath10k/qmi.c
index 66cb7a1e628a..e88bcfd96859 100644
--- a/drivers/net/wireless/ath/ath10k/qmi.c
+++ b/drivers/net/wireless/ath/ath10k/qmi.c
@@ -14,6 +14,7 @@ 
 #include <linux/net.h>
 #include <linux/platform_device.h>
 #include <linux/qcom_scm.h>
+#include <linux/soc/qcom/smem.h>
 #include <linux/string.h>
 #include <net/sock.h>
 
@@ -22,6 +23,8 @@ 
 
 #define ATH10K_QMI_CLIENT_ID		0x4b4e454c
 #define ATH10K_QMI_TIMEOUT		30
+#define ATH10K_SMEM_IMAGE_VERSION_TABLE       469
+#define ATH10K_SMEM_IMAGE_TABLE_CNSS_INDEX     13
 
 static int ath10k_qmi_map_msa_permission(struct ath10k_qmi *qmi,
 					 struct ath10k_msa_mem_info *mem_info)
@@ -536,6 +539,29 @@  int ath10k_qmi_wlan_disable(struct ath10k *ar)
 	return ath10k_qmi_mode_send_sync_msg(ar, QMI_WLFW_OFF_V01);
 }
 
+static void ath10k_qmi_add_wlan_ver_smem(struct ath10k *ar, char *fw_build_id)
+{
+	u8 *smem_table_ptr;
+	size_t smem_block_size;
+	const u32 version_string_size = 128;
+	const u32 smem_img_idx_wlan = ATH10K_SMEM_IMAGE_TABLE_CNSS_INDEX * 128;
+
+	smem_table_ptr = qcom_smem_get(QCOM_SMEM_HOST_ANY,
+				       ATH10K_SMEM_IMAGE_VERSION_TABLE,
+				       &smem_block_size);
+	if (IS_ERR(smem_table_ptr)) {
+		ath10k_dbg(ar, ATH10K_DBG_QMI, "smem image version table not found");
+		return;
+	}
+	if (smem_img_idx_wlan + version_string_size > smem_block_size) {
+		ath10k_dbg(ar, ATH10K_DBG_QMI, "smem block size too small: %i",
+			   smem_block_size);
+		return;
+	}
+	memcpy(smem_table_ptr + smem_img_idx_wlan, fw_build_id,
+	       version_string_size);
+}
+
 static int ath10k_qmi_cap_send_sync_msg(struct ath10k_qmi *qmi)
 {
 	struct wlfw_cap_resp_msg_v01 *resp;
@@ -606,6 +632,8 @@  static int ath10k_qmi_cap_send_sync_msg(struct ath10k_qmi *qmi)
 			    qmi->fw_version, qmi->fw_build_timestamp, qmi->fw_build_id);
 	}
 
+	ath10k_qmi_add_wlan_ver_smem(ar, qmi->fw_build_id);
+
 	kfree(resp);
 	return 0;