Browse Source

Merge 34e74266d24e43ecf38b586df78cb6878be5c030 on remote branch

Change-Id: I0ce9a36a68142729b5a8d8e6053c7a9f4ee3c66a
Linux Build Service Account 1 year ago
parent
commit
178e55e7c4
9 changed files with 188 additions and 178 deletions
  1. 22 5
      cnss2/main.c
  2. 13 3
      cnss2/pci.c
  3. 7 0
      cnss2/pci_qcom.c
  4. 2 2
      cnss2/power.c
  5. 0 146
      cnss2/qmi.c
  6. 0 8
      cnss2/qmi.h
  7. 87 5
      icnss2/main.c
  8. 1 0
      inc/cnss2.h
  9. 56 9
      wlan_platform_modules.bzl

+ 22 - 5
cnss2/main.c

@@ -903,8 +903,6 @@ static int cnss_fw_mem_ready_hdlr(struct cnss_plat_data *plat_priv)
 	if (plat_priv->device_id == QCN7605_DEVICE_ID)
 		plat_priv->ctrl_params.bdf_type = CNSS_BDF_BIN;
 
-	cnss_wlfw_ini_file_send_sync(plat_priv, WLFW_CONN_ROAM_INI_V01);
-
 	ret = cnss_wlfw_bdf_dnld_send_sync(plat_priv,
 					   plat_priv->ctrl_params.bdf_type);
 	if (ret)
@@ -1991,8 +1989,10 @@ void cnss_recovery_handler(struct cnss_plat_data *plat_priv)
 	msleep(POWER_RESET_MIN_DELAY_MS);
 
 	ret = cnss_bus_dev_powerup(plat_priv);
-	if (ret)
+	if (ret) {
 		__pm_relax(plat_priv->recovery_ws);
+		clear_bit(CNSS_DRIVER_RECOVERY, &plat_priv->driver_state);
+	}
 
 	return;
 }
@@ -2052,6 +2052,8 @@ static const char *cnss_recovery_reason_to_str(enum cnss_recovery_reason reason)
 static int cnss_do_recovery(struct cnss_plat_data *plat_priv,
 			    enum cnss_recovery_reason reason)
 {
+	int ret;
+
 	plat_priv->recovery_count++;
 
 	if (plat_priv->device_id == QCA6174_DEVICE_ID)
@@ -2124,7 +2126,9 @@ self_recovery:
 		return 0;
 	}
 
-	cnss_bus_dev_powerup(plat_priv);
+	ret = cnss_bus_dev_powerup(plat_priv);
+	if (ret)
+		clear_bit(CNSS_DRIVER_RECOVERY, &plat_priv->driver_state);
 
 	return 0;
 }
@@ -3237,6 +3241,18 @@ skip_elf_dump:
 }
 
 #ifdef CONFIG_CNSS2_SSR_DRIVER_DUMP
+/**
+ * cnss_host_ramdump_dev_release() - callback function for device release
+ * @dev: device to be released
+ *
+ * Return: None
+ */
+static void cnss_host_ramdump_dev_release(struct device *dev)
+{
+	cnss_pr_dbg("free host ramdump device\n");
+	kfree(dev);
+}
+
 int cnss_do_host_ramdump(struct cnss_plat_data *plat_priv,
 			 struct cnss_ssr_driver_dump_entry *ssr_entry,
 			 size_t num_entries_loaded)
@@ -3377,6 +3393,7 @@ int cnss_do_host_ramdump(struct cnss_plat_data *plat_priv,
 		return -ENOMEM;
 	}
 
+	new_device->release = cnss_host_ramdump_dev_release;
 	device_initialize(new_device);
 	dev_set_name(new_device, "wlan_driver");
 	dev_ret = device_add(new_device);
@@ -3444,7 +3461,7 @@ skip_host_dump:
 	device_del(new_device);
 put_device:
 	put_device(new_device);
-	kfree(new_device);
+	cnss_pr_dbg("host ramdump result %d\n", ret);
 	return ret;
 }
 #endif

+ 13 - 3
cnss2/pci.c

@@ -99,6 +99,7 @@ static DEFINE_SPINLOCK(time_sync_lock);
 #define HANG_DATA_LENGTH		384
 #define HST_HANG_DATA_OFFSET		((3 * 1024 * 1024) - HANG_DATA_LENGTH)
 #define HSP_HANG_DATA_OFFSET		((2 * 1024 * 1024) - HANG_DATA_LENGTH)
+#define GNO_HANG_DATA_OFFSET		(0x7d000 - HANG_DATA_LENGTH)
 
 #define AFC_SLOT_SIZE                   0x1000
 #define AFC_MAX_SLOT                    2
@@ -781,6 +782,9 @@ static struct cnss_print_optimize print_optimize;
 static int cnss_pci_update_fw_name(struct cnss_pci_data *pci_priv);
 static void cnss_pci_suspend_pwroff(struct pci_dev *pci_dev);
 static bool cnss_should_suspend_pwroff(struct pci_dev *pci_dev);
+static void cnss_pci_update_link_event(struct cnss_pci_data *pci_priv,
+				       enum cnss_bus_event_type type,
+				       void *data);
 
 
 #if IS_ENABLED(CONFIG_MHI_BUS_MISC)
@@ -992,6 +996,9 @@ static void cnss_pci_select_window(struct cnss_pci_data *pci_priv, u32 offset)
 	u32 window_enable = WINDOW_ENABLE_BIT | window;
 	u32 val;
 
+	if (plat_priv->device_id == QCN7605_DEVICE_ID)
+		window_enable = QCN7605_WINDOW_ENABLE_BIT | window;
+
 	if (plat_priv->device_id == PEACH_DEVICE_ID) {
 		writel_relaxed(window_enable, pci_priv->bar +
 			       PEACH_PCIE_REMAP_BAR_CTRL_OFFSET);
@@ -1000,9 +1007,6 @@ static void cnss_pci_select_window(struct cnss_pci_data *pci_priv, u32 offset)
 			       QCA6390_PCIE_REMAP_BAR_CTRL_OFFSET);
 	}
 
-	if (plat_priv->device_id == QCN7605_DEVICE_ID)
-		window_enable = QCN7605_WINDOW_ENABLE_BIT | window;
-
 	if (window != pci_priv->remap_window) {
 		pci_priv->remap_window = window;
 		cnss_pr_dbg("Config PCIe remap window register to 0x%x\n",
@@ -1462,6 +1466,8 @@ int cnss_resume_pci_link(struct cnss_pci_data *pci_priv)
 	ret = cnss_set_pci_link(pci_priv, PCI_LINK_UP);
 	if (ret) {
 		ret = -EAGAIN;
+		cnss_pci_update_link_event(pci_priv,
+					   BUS_EVENT_PCI_LINK_RESUME_FAIL, NULL);
 		goto out;
 	}
 
@@ -5936,6 +5942,10 @@ static void cnss_pci_send_hang_event(struct cnss_pci_data *pci_priv)
 		offset = plat_priv->hang_data_addr_offset;
 		length = plat_priv->hang_event_data_len;
 		break;
+	case QCN7605_DEVICE_ID:
+		offset = GNO_HANG_DATA_OFFSET;
+		length = HANG_DATA_LENGTH;
+		break;
 	default:
 		cnss_pr_err("Skip Hang Event Data as unsupported Device ID received: %d\n",
 			    pci_priv->device_id);

+ 7 - 0
cnss2/pci_qcom.c

@@ -365,6 +365,11 @@ static int cnss_set_pci_link_status(struct cnss_pci_data *pci_priv,
 int cnss_set_pci_link(struct cnss_pci_data *pci_priv, bool link_up)
 {
 	int ret = 0, retry = 0;
+	struct cnss_plat_data *plat_priv;
+	int sw_ctrl_gpio;
+
+	plat_priv = pci_priv->plat_priv;
+	sw_ctrl_gpio = plat_priv->pinctrl_info.sw_ctrl_gpio;
 
 	cnss_pr_vdbg("%s PCI link\n", link_up ? "Resuming" : "Suspending");
 
@@ -373,6 +378,8 @@ retry:
 		ret = cnss_pci_set_link_up(pci_priv);
 		if (ret && retry++ < LINK_TRAINING_RETRY_MAX_TIMES) {
 			cnss_pr_dbg("Retry PCI link training #%d\n", retry);
+			cnss_pr_dbg("Value of SW_CTRL GPIO: %d\n",
+				    cnss_get_input_gpio_value(plat_priv, sw_ctrl_gpio));
 			if (pci_priv->pci_link_down_ind)
 				msleep(LINK_TRAINING_RETRY_DELAY_MS * retry);
 			goto retry;

+ 2 - 2
cnss2/power.c

@@ -1784,7 +1784,7 @@ int cnss_update_cpr_info(struct cnss_plat_data *plat_priv)
 		return -EINVAL;
 
 	if (!plat_priv->vreg_ol_cpr ||
-	    (!plat_priv->mbox_chan && !plat_priv->qmp)) {
+	    (!plat_priv->mbox_chan && !plat_priv->use_direct_qmp)) {
 		cnss_pr_dbg("Mbox channel / QMP / OL CPR Vreg not configured\n");
 	} else {
 		return cnss_aop_set_vreg_param(plat_priv,
@@ -1865,7 +1865,7 @@ int cnss_enable_int_pow_amp_vreg(struct cnss_plat_data *plat_priv)
 	}
 
 	if (!plat_priv->vreg_ipa ||
-	    (!plat_priv->mbox_chan && !plat_priv->qmp)) {
+	    (!plat_priv->mbox_chan && !plat_priv->use_direct_qmp)) {
 		cnss_pr_dbg("Mbox channel / QMP / IPA Vreg not configured\n");
 	} else {
 		ret = cnss_aop_set_vreg_param(plat_priv,

+ 0 - 146
cnss2/qmi.c

@@ -28,10 +28,6 @@
 #define HDS_FILE_NAME			"hds.bin"
 #define CHIP_ID_GF_MASK			0x10
 
-#define CONN_ROAM_FILE_NAME		"wlan-connection-roaming"
-#define INI_EXT			".ini"
-#define INI_FILE_NAME_LEN		100
-
 #define QDSS_TRACE_CONFIG_FILE		"qdss_trace_config"
 /*
  * Download QDSS config file based on build type. Add build type string to
@@ -765,148 +761,6 @@ static int cnss_get_bdf_file_name(struct cnss_plat_data *plat_priv,
 	return ret;
 }
 
-int cnss_wlfw_ini_file_send_sync(struct cnss_plat_data *plat_priv,
-				 enum wlfw_ini_file_type_v01 file_type)
-{
-	struct wlfw_ini_file_download_req_msg_v01 *req;
-	struct wlfw_ini_file_download_resp_msg_v01 *resp;
-	struct qmi_txn txn;
-	int ret = 0;
-	const struct firmware *fw;
-	char filename[INI_FILE_NAME_LEN] = {0};
-	char tmp_filename[INI_FILE_NAME_LEN] = {0};
-	const u8 *temp;
-	unsigned int remaining;
-	bool backup_supported = false;
-
-	cnss_pr_dbg("Sending QMI_WLFW_INI_FILE_DOWNLOAD_REQ_V01 message for ini_type: %d, state: 0x%lx\n",
-		    file_type, plat_priv->driver_state);
-
-	req = kzalloc(sizeof(*req), GFP_KERNEL);
-	if (!req)
-		return -ENOMEM;
-
-	resp = kzalloc(sizeof(*resp), GFP_KERNEL);
-	if (!resp) {
-		kfree(req);
-		return -ENOMEM;
-	}
-
-	switch (file_type) {
-	case WLFW_CONN_ROAM_INI_V01:
-		snprintf(tmp_filename, sizeof(tmp_filename),
-			 CONN_ROAM_FILE_NAME);
-		backup_supported = true;
-		break;
-	default:
-		cnss_pr_err("Invalid file type: %u\n", file_type);
-		ret = -EINVAL;
-		goto err_req_fw;
-	}
-
-	snprintf(filename, sizeof(filename), "%s%s", tmp_filename, INI_EXT);
-
-	cnss_pr_dbg("Invoke firmware_request_nowarn for %s\n", filename);
-	/* Fetch the file */
-	ret = firmware_request_nowarn(&fw, filename, &plat_priv->plat_dev->dev);
-	if (ret) {
-		cnss_pr_dbg("Failed to read %s, ret: %d\n", filename, ret);
-		if (!backup_supported)
-			goto err_req_fw;
-
-		snprintf(filename, sizeof(filename),
-			 "%s-%s%s", tmp_filename, "backup", INI_EXT);
-
-		cnss_pr_dbg("Invoke firmware_request_nowarn for %s\n",
-			    filename);
-		ret = firmware_request_nowarn(&fw, filename,
-					      &plat_priv->plat_dev->dev);
-		if (ret) {
-			cnss_pr_dbg("Failed to read %s, ret: %d\n", filename,
-				    ret);
-			goto err_req_fw;
-		}
-	}
-
-	temp = fw->data;
-	remaining = fw->size;
-
-	cnss_pr_dbg("Downloading INI file: %s, size: %u\n", filename,
-		    remaining);
-
-	while (remaining) {
-		req->file_type_valid = 1;
-		req->file_type = file_type;
-		req->total_size_valid = 1;
-		req->total_size = remaining;
-		req->seg_id_valid = 1;
-		req->data_valid = 1;
-		req->end_valid = 1;
-
-		if (remaining > QMI_WLFW_MAX_DATA_SIZE_V01) {
-			req->data_len = QMI_WLFW_MAX_DATA_SIZE_V01;
-		} else {
-			req->data_len = remaining;
-			req->end = 1;
-		}
-
-		memcpy(req->data, temp, req->data_len);
-
-		ret = qmi_txn_init(&plat_priv->qmi_wlfw, &txn,
-				   wlfw_ini_file_download_resp_msg_v01_ei,
-				   resp);
-		if (ret < 0) {
-			cnss_pr_err("Failed to initialize txn for INI file download request, err: %d\n",
-				    ret);
-			goto err;
-		}
-
-		ret = qmi_send_request
-			(&plat_priv->qmi_wlfw, NULL, &txn,
-			 QMI_WLFW_INI_FILE_DOWNLOAD_REQ_V01,
-			 WLFW_INI_FILE_DOWNLOAD_REQ_MSG_V01_MAX_MSG_LEN,
-			 wlfw_ini_file_download_req_msg_v01_ei, req);
-		if (ret < 0) {
-			qmi_txn_cancel(&txn);
-			cnss_pr_err("Failed to send INI File download request, err: %d\n",
-				    ret);
-			goto err;
-		}
-
-		ret = qmi_txn_wait(&txn, QMI_WLFW_TIMEOUT_JF);
-		if (ret < 0) {
-			cnss_pr_err("Failed to wait for response of INI File download request, err: %d\n",
-				    ret);
-			goto err;
-		}
-
-		if (resp->resp.result != QMI_RESULT_SUCCESS_V01) {
-			cnss_pr_err("INI file download request failed, result: %d, err: %d\n",
-				    resp->resp.result, resp->resp.error);
-			ret = -resp->resp.result;
-			goto err;
-		}
-
-		remaining -= req->data_len;
-		temp += req->data_len;
-		req->seg_id++;
-	}
-
-	release_firmware(fw);
-
-	kfree(req);
-	kfree(resp);
-	return 0;
-
-err:
-	release_firmware(fw);
-err_req_fw:
-	kfree(req);
-	kfree(resp);
-
-	return ret;
-}
-
 int cnss_wlfw_bdf_dnld_send_sync(struct cnss_plat_data *plat_priv,
 				 u32 bdf_type)
 {

+ 0 - 8
cnss2/qmi.h

@@ -92,8 +92,6 @@ int wlfw_qdss_trace_stop(struct cnss_plat_data *plat_priv, unsigned long long op
 int cnss_wlfw_cal_report_req_send_sync(struct cnss_plat_data *plat_priv,
 				       u32 cal_file_download_size);
 int cnss_send_subsys_restart_level_msg(struct cnss_plat_data *plat_priv);
-int cnss_wlfw_ini_file_send_sync(struct cnss_plat_data *plat_priv,
-				 enum wlfw_ini_file_type_v01 file_type);
 int cnss_wlfw_send_host_wfc_call_status(struct cnss_plat_data *plat_priv,
 					struct cnss_wfc_cfg cfg);
 void cnss_cancel_dms_work(void);
@@ -324,12 +322,6 @@ int cnss_send_subsys_restart_level_msg(struct cnss_plat_data *plat_priv)
 	return 0;
 }
 
-int cnss_wlfw_ini_file_send_sync(struct cnss_plat_data *plat_priv,
-				 enum wlfw_ini_file_type_v01 file_type)
-{
-	return 0;
-}
-
 static void cnss_cancel_dms_work(void)
 {
 }

+ 87 - 5
icnss2/main.c

@@ -44,7 +44,10 @@
 #include <linux/remoteproc/qcom_rproc.h>
 #include <linux/soc/qcom/pdr.h>
 #include <linux/remoteproc.h>
+#include <linux/version.h>
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 2, 0))
 #include <trace/hooks/remoteproc.h>
+#endif
 #ifdef SLATE_MODULE_ENABLED
 #include <linux/soc/qcom/slatecom_interface.h>
 #include <linux/soc/qcom/slate_events_bridge_intf.h>
@@ -2676,7 +2679,11 @@ static int icnss_ramdump_devnode_init(struct icnss_priv *priv)
 {
 	int ret = 0;
 
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 2, 0))
 	priv->icnss_ramdump_class = class_create(THIS_MODULE, ICNSS_RAMDUMP_NAME);
+#else
+	priv->icnss_ramdump_class = class_create(ICNSS_RAMDUMP_NAME);
+#endif
 	if (IS_ERR_OR_NULL(priv->icnss_ramdump_class)) {
 		ret = PTR_ERR(priv->icnss_ramdump_class);
 		icnss_pr_err("%s:Class create failed for ramdump devices (%d)\n", __func__, ret);
@@ -3706,6 +3713,20 @@ struct iommu_domain *icnss_smmu_get_domain(struct device *dev)
 }
 EXPORT_SYMBOL(icnss_smmu_get_domain);
 
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 2, 0))
+int icnss_iommu_map(struct iommu_domain *domain,
+				   unsigned long iova, phys_addr_t paddr, size_t size, int prot)
+{
+		return iommu_map(domain, iova, paddr, size, prot);
+}
+#else
+int icnss_iommu_map(struct iommu_domain *domain,
+				   unsigned long iova, phys_addr_t paddr, size_t size, int prot)
+{
+		return iommu_map(domain, iova, paddr, size, prot, GFP_KERNEL);
+}
+#endif
+
 int icnss_smmu_map(struct device *dev,
 		   phys_addr_t paddr, uint32_t *iova_addr, size_t size)
 {
@@ -3749,7 +3770,7 @@ int icnss_smmu_map(struct device *dev,
 
 	icnss_pr_dbg("IOMMU Map: iova %lx, len %zu\n", iova, len);
 
-	ret = iommu_map(priv->iommu_domain, iova,
+	ret = icnss_iommu_map(priv->iommu_domain, iova,
 			rounddown(paddr, PAGE_SIZE), len,
 			flag);
 	if (ret) {
@@ -4161,6 +4182,39 @@ static void icnss_remove_sysfs_link(struct icnss_priv *priv)
 	sysfs_remove_link(kernel_kobj, "icnss");
 }
 
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 2, 0))
+union icnss_device_group_devres {
+	const struct attribute_group *group;
+};
+
+static void devm_icnss_group_remove(struct device *dev, void *res)
+{
+	union icnss_device_group_devres *devres = res;
+	const struct attribute_group *group = devres->group;
+
+	icnss_pr_dbg("%s: removing group %p\n", __func__, group);
+	sysfs_remove_group(&dev->kobj, group);
+}
+
+static int devm_icnss_group_match(struct device *dev, void *res, void *data)
+{
+	return ((union icnss_device_group_devres *)res) == data;
+}
+
+static void icnss_devm_device_remove_group(struct icnss_priv *priv)
+{
+	WARN_ON(devres_release(&priv->pdev->dev,
+			       devm_icnss_group_remove, devm_icnss_group_match,
+			       (void *)&icnss_attr_group));
+}
+#else
+static void icnss_devm_device_remove_group(struct icnss_priv *priv)
+{
+	devm_device_remove_group(&priv->pdev->dev, &icnss_attr_group);
+}
+#endif
+
 static int icnss_sysfs_create(struct icnss_priv *priv)
 {
 	int ret = 0;
@@ -4181,7 +4235,7 @@ static int icnss_sysfs_create(struct icnss_priv *priv)
 
 	return 0;
 remove_icnss_group:
-	devm_device_remove_group(&priv->pdev->dev, &icnss_attr_group);
+	icnss_devm_device_remove_group(priv);
 out:
 	return ret;
 }
@@ -4190,7 +4244,7 @@ static void icnss_sysfs_destroy(struct icnss_priv *priv)
 {
 	icnss_destroy_shutdown_sysfs(priv);
 	icnss_remove_sysfs_link(priv);
-	devm_device_remove_group(&priv->pdev->dev, &icnss_attr_group);
+	icnss_devm_device_remove_group(priv);
 }
 
 static int icnss_resource_parse(struct icnss_priv *priv)
@@ -4612,6 +4666,7 @@ static inline bool icnss_use_nv_mac(struct icnss_priv *priv)
 				     "use-nv-mac");
 }
 
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 2, 0))
 static void rproc_restart_level_notifier(void *data, struct rproc *rproc)
 {
 	struct icnss_subsys_restart_level_data *restart_level_data;
@@ -4633,6 +4688,7 @@ static void rproc_restart_level_notifier(void *data, struct rproc *rproc)
 					0, restart_level_data);
 	}
 }
+#endif
 
 #if IS_ENABLED(CONFIG_WCNSS_MEM_PRE_ALLOC)
 static void icnss_initialize_mem_pool(unsigned long device_id)
@@ -4652,6 +4708,32 @@ static void icnss_deinitialize_mem_pool(void)
 }
 #endif
 
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 2, 0))
+static void register_rproc_restart_level_notifier(void)
+{
+	register_trace_android_vh_rproc_recovery_set(rproc_restart_level_notifier, NULL);
+}
+#else
+static void register_rproc_restart_level_notifier(void)
+{
+	return;
+}
+#endif
+
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 2, 0))
+static void unregister_rproc_restart_level_notifier(void)
+{
+	unregister_trace_android_vh_rproc_recovery_set(rproc_restart_level_notifier, NULL);
+}
+#else
+static void unregister_rproc_restart_level_notifier(void)
+{
+	return;
+}
+#endif
+
+
+
 static int icnss_probe(struct platform_device *pdev)
 {
 	int ret = 0;
@@ -4770,7 +4852,7 @@ static int icnss_probe(struct platform_device *pdev)
 		icnss_aop_interface_init(priv);
 		set_bit(ICNSS_COLD_BOOT_CAL, &priv->state);
 		priv->bdf_download_support = true;
-		register_trace_android_vh_rproc_recovery_set(rproc_restart_level_notifier, NULL);
+		register_rproc_restart_level_notifier();
 	}
 
 	if (priv->wpss_supported) {
@@ -4881,7 +4963,7 @@ static int icnss_remove(struct platform_device *pdev)
 	    priv->device_id == WCN6450_DEVICE_ID) {
 		icnss_genl_exit();
 		icnss_runtime_pm_deinit(priv);
-		unregister_trace_android_vh_rproc_recovery_set(rproc_restart_level_notifier, NULL);
+		unregister_rproc_restart_level_notifier();
 		complete_all(&priv->smp2p_soc_wake_wait);
 		icnss_destroy_ramdump_device(priv->m3_dump_phyareg);
 		icnss_destroy_ramdump_device(priv->m3_dump_phydbg);

+ 1 - 0
inc/cnss2.h

@@ -209,6 +209,7 @@ enum cnss_host_dump_type {
 
 enum cnss_bus_event_type {
 	BUS_EVENT_PCI_LINK_DOWN = 0,
+	BUS_EVENT_PCI_LINK_RESUME_FAIL = 1,
 
 	BUS_EVENT_INVALID = 0xFFFF,
 };

+ 56 - 9
wlan_platform_modules.bzl

@@ -31,6 +31,32 @@ def _get_module_list(target, variant):
 
     return [":{}_{}".format(tv, mod) for mod in ret]
 
+def _define_platform_config_rule(module, target, variant):
+    tv = "{}_{}".format(target, variant)
+    native.genrule(
+        name = "{}/{}_defconfig_generate_perf".format(module, tv),
+        outs = ["{}/{}_defconfig.generated_perf".format(module, tv)],
+        srcs = [
+            "{}/{}_gki_defconfig".format(module, target),
+        ],
+        cmd = "cat $(SRCS) > $@",
+    )
+    native.genrule(
+        name = "{}/{}_defconfig_generate_gki".format(module, tv),
+        outs = ["{}/{}_defconfig.generated_gki".format(module, tv)],
+        srcs = [
+            "{}/{}_gki_defconfig".format(module, target),
+        ],
+        cmd = "cat $(SRCS) > $@",
+    )
+    native.genrule(
+        name = "{}/{}_defconfig_generate_consolidate".format(module, tv),
+        outs = ["{}/{}_defconfig.generated_consolidate".format(module, tv)],
+        srcs = [
+            "{}/{}_consolidate_defconfig".format(module, target),
+        ],
+        cmd = "cat $(SRCS) > $@",
+    )
 
 def _define_modules_for_target_variant(target, variant):
     tv = "{}_{}".format(target, variant)
@@ -46,7 +72,11 @@ def _define_modules_for_target_variant(target, variant):
     if target in _icnss2_enabled_target:
         icnss2_enabled = 1
 
+    print("tv=", tv)
     if cnss2_enabled:
+        module = "cnss2"
+        _define_platform_config_rule(module, target, variant)
+        defconfig = ":{}/{}_defconfig_generate_{}".format(module, tv, variant)
         ddk_module(
             name = "{}_cnss2".format(tv),
             srcs = native.glob([
@@ -62,7 +92,7 @@ def _define_modules_for_target_variant(target, variant):
             ]),
             includes = ["cnss", "cnss_utils"],
             kconfig = "cnss2/Kconfig",
-            defconfig = "cnss2/{}_defconfig".format(tv),
+            defconfig = defconfig,
             conditional_srcs =  {
                 "CONFIG_CNSS2_QMI": {
                     True: [
@@ -91,6 +121,9 @@ def _define_modules_for_target_variant(target, variant):
         )
 
     if icnss2_enabled:
+        module = "icnss2"
+        _define_platform_config_rule(module, target, variant)
+        defconfig = ":{}/{}_defconfig_generate_{}".format(module, tv, variant)
         ddk_module(
             name = "{}_icnss2".format(tv),
             srcs = native.glob([
@@ -103,7 +136,8 @@ def _define_modules_for_target_variant(target, variant):
             ]),
             includes = ["icnss2", "cnss_utils"],
             kconfig = "icnss2/Kconfig",
-            defconfig = "icnss2/{}_defconfig".format(tv),
+            copts = ["-Wno-format"],
+            defconfig = defconfig,
             conditional_srcs = {
                 "CONFIG_ICNSS2_QMI": {
                     True: [
@@ -121,14 +155,16 @@ def _define_modules_for_target_variant(target, variant):
                 ":wlan-platform-headers",
             ],
         )
-
+    module = "cnss_genl"
+    _define_platform_config_rule(module, target, variant)
+    defconfig = ":{}/{}_defconfig_generate_{}".format(module, tv, variant)
     ddk_module(
         name = "{}_cnss_nl".format(tv),
         srcs = [
             "cnss_genl/cnss_nl.c",
         ],
         kconfig = "cnss_genl/Kconfig",
-        defconfig = "cnss_genl/{}_defconfig".format(tv),
+        defconfig = defconfig,
         out = "cnss_nl.ko",
         kernel_build = "//msm-kernel:{}".format(tv),
         deps = [
@@ -137,6 +173,9 @@ def _define_modules_for_target_variant(target, variant):
         ],
     )
 
+    module = "cnss_prealloc"
+    _define_platform_config_rule(module, target, variant)
+    defconfig = ":{}/{}_defconfig_generate_{}".format(module, tv, variant)
     ddk_module(
         name = "{}_cnss_prealloc".format(tv),
         srcs = native.glob([
@@ -145,7 +184,7 @@ def _define_modules_for_target_variant(target, variant):
         ]),
         includes = ["cnss_utils"],
         kconfig = "cnss_prealloc/Kconfig",
-        defconfig = "cnss_prealloc/{}_defconfig".format(tv),
+        defconfig = defconfig,
         out = "cnss_prealloc.ko",
         kernel_build = "//msm-kernel:{}".format(tv),
         deps = [
@@ -154,6 +193,9 @@ def _define_modules_for_target_variant(target, variant):
         ],
     )
 
+    module = "cnss_utils"
+    _define_platform_config_rule(module, target, variant)
+    defconfig = ":{}/{}_defconfig_generate_{}".format(module, tv, variant)
     ddk_module(
         name = "{}_cnss_utils".format(tv),
         srcs = native.glob([
@@ -161,7 +203,7 @@ def _define_modules_for_target_variant(target, variant):
             "cnss_utils/*.h"
         ]),
         kconfig = "cnss_utils/Kconfig",
-        defconfig = "cnss_utils/{}_defconfig".format(tv),
+        defconfig = defconfig,
         out = "cnss_utils.ko",
         kernel_build = "//msm-kernel:{}".format(tv),
         deps = [
@@ -170,6 +212,8 @@ def _define_modules_for_target_variant(target, variant):
         ],
     )
 
+    module = "cnss_utils"
+    defconfig = ":{}/{}_defconfig_generate_{}".format(module, tv, variant)
     ddk_module(
         name = "{}_wlan_firmware_service".format(tv),
         srcs = native.glob([
@@ -178,12 +222,14 @@ def _define_modules_for_target_variant(target, variant):
             "cnss_utils/*.h"
         ]),
         kconfig = "cnss_utils/Kconfig",
-        defconfig = "cnss_utils/{}_defconfig".format(tv),
+        defconfig = defconfig,
         out = "wlan_firmware_service.ko",
         kernel_build = "//msm-kernel:{}".format(tv),
         deps = ["//msm-kernel:all_headers"],
     )
 
+    module = "cnss_utils"
+    defconfig = ":{}/{}_defconfig_generate_{}".format(module, tv, variant)
     if plat_ipc_qmi_svc_enabled:
         ddk_module(
             name = "{}_cnss_plat_ipc_qmi_svc".format(tv),
@@ -193,12 +239,12 @@ def _define_modules_for_target_variant(target, variant):
                 "cnss_utils/*.h"
             ]),
             kconfig = "cnss_utils/Kconfig",
-            defconfig = "cnss_utils/{}_defconfig".format(tv),
+            defconfig = defconfig,
             out = "cnss_plat_ipc_qmi_svc.ko",
             kernel_build = "//msm-kernel:{}".format(tv),
             deps = ["//msm-kernel:all_headers"],
         )
-
+    tv = "{}_{}".format(target, variant)
     copy_to_dist_dir(
         name = "{}_modules_dist".format(tv),
         data = _get_module_list(target, variant),
@@ -212,4 +258,5 @@ def _define_modules_for_target_variant(target, variant):
 
 def define_modules():
     for (t, v) in get_all_variants():
+        print("v=", v)
         _define_modules_for_target_variant(t, v)