linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] Add changes to read caldata from EEPROM
@ 2022-12-23  5:06 Dinesh Karthikeyan
  2022-12-23  5:06 ` [PATCH 1/3] wifi: ath12k: Fix incorrect qmi_file_type enum values Dinesh Karthikeyan
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Dinesh Karthikeyan @ 2022-12-23  5:06 UTC (permalink / raw)
  To: ath12k; +Cc: linux-wireless, Dinesh Karthikeyan

Add support to read calibration data from EEPROM.

Dinesh Karthikeyan (3):
  wifi: ath12k: Fix incorrect qmi_file_type enum values
  wifi: ath12k: Add new qmi_bdf_type to handle caldata
  wifi: ath12k: Add support to read EEPROM caldata

 drivers/net/wireless/ath/ath12k/qmi.c | 131 ++++++++++++--------------
 drivers/net/wireless/ath/ath12k/qmi.h |   9 +-
 2 files changed, 66 insertions(+), 74 deletions(-)

-- 
2.17.1


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

* [PATCH 1/3] wifi: ath12k: Fix incorrect qmi_file_type enum values
  2022-12-23  5:06 [PATCH 0/3] Add changes to read caldata from EEPROM Dinesh Karthikeyan
@ 2022-12-23  5:06 ` Dinesh Karthikeyan
  2023-01-18  6:39   ` Kalle Valo
  2022-12-23  5:06 ` [PATCH 2/3] wifi: ath12k: Add new qmi_bdf_type to handle caldata Dinesh Karthikeyan
  2022-12-23  5:06 ` [PATCH 3/3] wifi: ath12k: Add support to read EEPROM caldata Dinesh Karthikeyan
  2 siblings, 1 reply; 5+ messages in thread
From: Dinesh Karthikeyan @ 2022-12-23  5:06 UTC (permalink / raw)
  To: ath12k; +Cc: linux-wireless, Dinesh Karthikeyan

Enum value for caldata in QMI_WLANFW_BDF_DOWNLOAD_REQ_V01 is set as 1
which is reserved for BDF_TYPE_ELF. The expected qmi_file_type value
for caldata is 2.

Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.0.1-00029-QCAHKSWPL_SILICONZ-1

Signed-off-by: Dinesh Karthikeyan <quic_dinek@quicinc.com>
---
 drivers/net/wireless/ath/ath12k/qmi.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/ath/ath12k/qmi.h b/drivers/net/wireless/ath/ath12k/qmi.h
index adbdaf727051..37af9674b89e 100644
--- a/drivers/net/wireless/ath/ath12k/qmi.h
+++ b/drivers/net/wireless/ath/ath12k/qmi.h
@@ -44,10 +44,10 @@
 struct ath12k_base;
 
 enum ath12k_qmi_file_type {
-	ATH12K_QMI_FILE_TYPE_BDF_GOLDEN,
-	ATH12K_QMI_FILE_TYPE_CALDATA,
-	ATH12K_QMI_FILE_TYPE_EEPROM,
-	ATH12K_QMI_MAX_FILE_TYPE,
+	ATH12K_QMI_FILE_TYPE_BDF_GOLDEN	= 0,
+	ATH12K_QMI_FILE_TYPE_CALDATA	= 2,
+	ATH12K_QMI_FILE_TYPE_EEPROM	= 3,
+	ATH12K_QMI_MAX_FILE_TYPE	= 4,
 };
 
 enum ath12k_qmi_bdf_type {
-- 
2.17.1


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

* [PATCH 2/3] wifi: ath12k: Add new qmi_bdf_type to handle caldata
  2022-12-23  5:06 [PATCH 0/3] Add changes to read caldata from EEPROM Dinesh Karthikeyan
  2022-12-23  5:06 ` [PATCH 1/3] wifi: ath12k: Fix incorrect qmi_file_type enum values Dinesh Karthikeyan
@ 2022-12-23  5:06 ` Dinesh Karthikeyan
  2022-12-23  5:06 ` [PATCH 3/3] wifi: ath12k: Add support to read EEPROM caldata Dinesh Karthikeyan
  2 siblings, 0 replies; 5+ messages in thread
From: Dinesh Karthikeyan @ 2022-12-23  5:06 UTC (permalink / raw)
  To: ath12k; +Cc: linux-wireless, Dinesh Karthikeyan

With current implementation, the calibration data download request, is
sent twice incorrectly because the request for ELF_TYPE and REGDB_TYPE
are handled in a common api ath12k_qmi_load_bdf_qmi.
Add new type as ATH12K_QMI_BDF_TYPE_CALIBRATION to send calibration data
download request as a separate case. With this the firmware is indicated
to read caldata from EEPROM.

Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.0.1-00029-QCAHKSWPL_SILICONZ-1

Signed-off-by: Dinesh Karthikeyan <quic_dinek@quicinc.com>
---
 drivers/net/wireless/ath/ath12k/qmi.c | 115 ++++++++++++--------------
 drivers/net/wireless/ath/ath12k/qmi.h |   1 +
 2 files changed, 52 insertions(+), 64 deletions(-)

diff --git a/drivers/net/wireless/ath/ath12k/qmi.c b/drivers/net/wireless/ath/ath12k/qmi.c
index 56df607646fa..a69307bea596 100644
--- a/drivers/net/wireless/ath/ath12k/qmi.c
+++ b/drivers/net/wireless/ath/ath12k/qmi.c
@@ -2419,6 +2419,50 @@ static int ath12k_qmi_load_bdf_qmi(struct ath12k_base *ab,
 			goto out;
 		}
 		break;
+	case ATH12K_QMI_BDF_TYPE_CALIBRATION:
+
+		if (ab->qmi.target.eeprom_caldata) {
+			file_type = ATH12K_QMI_FILE_TYPE_CALDATA;
+			tmp = filename;
+			fw_size = ATH12K_QMI_MAX_BDF_FILE_NAME_SIZE;
+		} else {
+			file_type = ATH12K_QMI_FILE_TYPE_CALDATA;
+
+			/* cal-<bus>-<id>.bin */
+			snprintf(filename, sizeof(filename), "cal-%s-%s.bin",
+				 ath12k_bus_str(ab->hif.bus), dev_name(dev));
+			fw_entry = ath12k_core_firmware_request(ab, filename);
+			if (!IS_ERR(fw_entry))
+				goto success;
+
+			fw_entry = ath12k_core_firmware_request(ab,
+								ATH12K_DEFAULT_CAL_FILE);
+			if (IS_ERR(fw_entry)) {
+				ret = PTR_ERR(fw_entry);
+				ath12k_warn(ab,
+					    "qmi failed to load CAL data file:%s\n",
+					    filename);
+				goto out;
+			}
+
+success:
+			fw_size = min_t(u32, ab->hw_params->fw.board_size,
+					fw_entry->size);
+			tmp = fw_entry->data;
+		}
+		ret = ath12k_qmi_load_file_target_mem(ab, tmp, fw_size, file_type);
+		if (ret < 0) {
+			ath12k_warn(ab, "qmi failed to load caldata\n");
+			goto out_qmi_cal;
+		}
+
+		ath12k_dbg(ab, ATH12K_DBG_QMI, "qmi caldata downloaded: type: %u\n",
+			   file_type);
+
+out_qmi_cal:
+		if (!ab->qmi.target.eeprom_caldata)
+			release_firmware(fw_entry);
+		return ret;
 	default:
 		ath12k_warn(ab, "unknown file type for load %d", type);
 		goto out;
@@ -2429,72 +2473,9 @@ static int ath12k_qmi_load_bdf_qmi(struct ath12k_base *ab,
 	fw_size = min_t(u32, ab->hw_params->fw.board_size, bd.len);
 
 	ret = ath12k_qmi_load_file_target_mem(ab, bd.data, fw_size, type);
-	if (ret < 0) {
+	if (ret < 0)
 		ath12k_warn(ab, "qmi failed to load bdf file\n");
-		goto out;
-	}
-
-	if (!ab->hw_params->download_calib)
-		goto out;
 
-	file_type = ATH12K_QMI_FILE_TYPE_CALDATA;
-
-	/* cal-<bus>-<id>.bin */
-	snprintf(filename, sizeof(filename), "cal-%s-%s.bin",
-		 ath12k_bus_str(ab->hif.bus), dev_name(dev));
-	fw_entry = ath12k_core_firmware_request(ab, filename);
-	if (!IS_ERR(fw_entry))
-		goto success;
-
-	fw_entry = ath12k_core_firmware_request(ab, ATH12K_DEFAULT_CAL_FILE);
-	if (IS_ERR(fw_entry)) {
-		ret = PTR_ERR(fw_entry);
-		ath12k_warn(ab,
-			    "qmi failed to load CAL data file:%s\n",
-			    filename);
-		goto out;
-	}
-
-	if (ab->qmi.target.eeprom_caldata) {
-		file_type = ATH12K_QMI_FILE_TYPE_CALDATA;
-		tmp = filename;
-		fw_size = ATH12K_QMI_MAX_BDF_FILE_NAME_SIZE;
-	} else {
-		file_type = ATH12K_QMI_FILE_TYPE_CALDATA;
-
-		/* cal-<bus>-<id>.bin */
-		snprintf(filename, sizeof(filename), "cal-%s-%s.bin",
-			 ath12k_bus_str(ab->hif.bus), dev_name(dev));
-		fw_entry = ath12k_core_firmware_request(ab, filename);
-		if (!IS_ERR(fw_entry))
-			goto success;
-
-		fw_entry = ath12k_core_firmware_request(ab, ATH12K_DEFAULT_CAL_FILE);
-		if (IS_ERR(fw_entry)) {
-			ret = PTR_ERR(fw_entry);
-			ath12k_warn(ab,
-				    "qmi failed to load CAL data file:%s\n",
-				    filename);
-			goto out;
-		}
-
-success:
-		fw_size = min_t(u32, ab->hw_params->fw.board_size, fw_entry->size);
-		tmp = fw_entry->data;
-	}
-
-	ret = ath12k_qmi_load_file_target_mem(ab, tmp, fw_size, file_type);
-	if (ret < 0) {
-		ath12k_warn(ab, "qmi failed to load caldata\n");
-		goto out_qmi_cal;
-	}
-
-	ath12k_dbg(ab, ATH12K_DBG_QMI, "qmi caldata downloaded: type: %u\n",
-		   file_type);
-
-out_qmi_cal:
-	if (!ab->qmi.target.eeprom_caldata)
-		release_firmware(fw_entry);
 out:
 	ath12k_core_free_bdf(ab, &bd);
 	ath12k_dbg(ab, ATH12K_DBG_QMI, "qmi BDF download sequence completed\n");
@@ -2851,6 +2832,12 @@ static int ath12k_qmi_event_load_bdf(struct ath12k_qmi *qmi)
 		return ret;
 	}
 
+	if (ab->hw_params->download_calib) {
+		ret = ath12k_qmi_load_bdf_qmi(ab, ATH12K_QMI_BDF_TYPE_CALIBRATION);
+		if (ret < 0)
+			ath12k_warn(ab, "qmi failed to load calibrated data :%d\n", ret);
+	}
+
 	ret = ath12k_qmi_wlanfw_m3_info_send(ab);
 	if (ret < 0) {
 		ath12k_warn(ab, "qmi failed to send m3 info req:%d\n", ret);
diff --git a/drivers/net/wireless/ath/ath12k/qmi.h b/drivers/net/wireless/ath/ath12k/qmi.h
index 37af9674b89e..ad87f19903db 100644
--- a/drivers/net/wireless/ath/ath12k/qmi.h
+++ b/drivers/net/wireless/ath/ath12k/qmi.h
@@ -54,6 +54,7 @@ enum ath12k_qmi_bdf_type {
 	ATH12K_QMI_BDF_TYPE_BIN			= 0,
 	ATH12K_QMI_BDF_TYPE_ELF			= 1,
 	ATH12K_QMI_BDF_TYPE_REGDB		= 4,
+	ATH12K_QMI_BDF_TYPE_CALIBRATION		= 5,
 };
 
 enum ath12k_qmi_event_type {
-- 
2.17.1


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

* [PATCH 3/3] wifi: ath12k: Add support to read EEPROM caldata
  2022-12-23  5:06 [PATCH 0/3] Add changes to read caldata from EEPROM Dinesh Karthikeyan
  2022-12-23  5:06 ` [PATCH 1/3] wifi: ath12k: Fix incorrect qmi_file_type enum values Dinesh Karthikeyan
  2022-12-23  5:06 ` [PATCH 2/3] wifi: ath12k: Add new qmi_bdf_type to handle caldata Dinesh Karthikeyan
@ 2022-12-23  5:06 ` Dinesh Karthikeyan
  2 siblings, 0 replies; 5+ messages in thread
From: Dinesh Karthikeyan @ 2022-12-23  5:06 UTC (permalink / raw)
  To: ath12k; +Cc: linux-wireless, Dinesh Karthikeyan

In current implementation, there is a overhead of maintaining caldata
in the filesystem manually. To eliminate this overhead, for pci based
chipsets, if calibration data is present in EEPROM, indicate firmware
to download and read caldata from EEPROM. If the caldata is present in
EEPROM, host is notified in the target capability.
Upon this, the download request for the type ATH12K_QMI_FILE_TYPE_EEPROM
is sent to firmware.

Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.0.1-00029-QCAHKSWPL_SILICONZ-1

Signed-off-by: Dinesh Karthikeyan <quic_dinek@quicinc.com>
---
 drivers/net/wireless/ath/ath12k/qmi.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/drivers/net/wireless/ath/ath12k/qmi.c b/drivers/net/wireless/ath/ath12k/qmi.c
index a69307bea596..979a63f2e2ab 100644
--- a/drivers/net/wireless/ath/ath12k/qmi.c
+++ b/drivers/net/wireless/ath/ath12k/qmi.c
@@ -2371,12 +2371,16 @@ static int ath12k_qmi_load_file_target_mem(struct ath12k_base *ab,
 			goto out;
 		}
 
-		remaining -= req->data_len;
-		temp += req->data_len;
-		req->seg_id++;
-		ath12k_dbg(ab, ATH12K_DBG_QMI,
-			   "qmi bdf download request remaining %i\n",
-			   remaining);
+		if (type == ATH12K_QMI_FILE_TYPE_EEPROM) {
+			remaining = 0;
+		} else {
+			remaining -= req->data_len;
+			temp += req->data_len;
+			req->seg_id++;
+			ath12k_dbg(ab, ATH12K_DBG_QMI,
+				   "qmi bdf download request remaining %i\n",
+				   remaining);
+		}
 	}
 
 out:
@@ -2422,7 +2426,7 @@ static int ath12k_qmi_load_bdf_qmi(struct ath12k_base *ab,
 	case ATH12K_QMI_BDF_TYPE_CALIBRATION:
 
 		if (ab->qmi.target.eeprom_caldata) {
-			file_type = ATH12K_QMI_FILE_TYPE_CALDATA;
+			file_type = ATH12K_QMI_FILE_TYPE_EEPROM;
 			tmp = filename;
 			fw_size = ATH12K_QMI_MAX_BDF_FILE_NAME_SIZE;
 		} else {
-- 
2.17.1


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

* Re: [PATCH 1/3] wifi: ath12k: Fix incorrect qmi_file_type enum values
  2022-12-23  5:06 ` [PATCH 1/3] wifi: ath12k: Fix incorrect qmi_file_type enum values Dinesh Karthikeyan
@ 2023-01-18  6:39   ` Kalle Valo
  0 siblings, 0 replies; 5+ messages in thread
From: Kalle Valo @ 2023-01-18  6:39 UTC (permalink / raw)
  To: Dinesh Karthikeyan; +Cc: ath12k, linux-wireless, Dinesh Karthikeyan

Dinesh Karthikeyan <quic_dinek@quicinc.com> wrote:

> Enum value for caldata in QMI_WLANFW_BDF_DOWNLOAD_REQ_V01 is set as 1
> which is reserved for BDF_TYPE_ELF. The expected qmi_file_type value
> for caldata is 2.
> 
> Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.0.1-00029-QCAHKSWPL_SILICONZ-1
> 
> Signed-off-by: Dinesh Karthikeyan <quic_dinek@quicinc.com>
> Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>

3 patches applied to ath-next branch of ath.git, thanks.

27d7e348efb3 wifi: ath12k: Fix incorrect qmi_file_type enum values
42982259e9b7 wifi: ath12k: Add new qmi_bdf_type to handle caldata
801fc159e30d wifi: ath12k: Add support to read EEPROM caldata

-- 
https://patchwork.kernel.org/project/linux-wireless/patch/20221223050646.27785-2-quic_dinek@quicinc.com/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches


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

end of thread, other threads:[~2023-01-18  7:15 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-23  5:06 [PATCH 0/3] Add changes to read caldata from EEPROM Dinesh Karthikeyan
2022-12-23  5:06 ` [PATCH 1/3] wifi: ath12k: Fix incorrect qmi_file_type enum values Dinesh Karthikeyan
2023-01-18  6:39   ` Kalle Valo
2022-12-23  5:06 ` [PATCH 2/3] wifi: ath12k: Add new qmi_bdf_type to handle caldata Dinesh Karthikeyan
2022-12-23  5:06 ` [PATCH 3/3] wifi: ath12k: Add support to read EEPROM caldata Dinesh Karthikeyan

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