Browse Source

qcacld-3.0: Make OEM data as static instead of dynamic

Currently host allocates OEM data with memalloc and frees
this memory at stop modules. Because of this host driver
is not able to share the oem data information when wifi
is off.
Based on new requirement driver needs to share this oem data
information on wifi off as well so change the oem data as
static allocation so that this information will remain intact.

Change-Id: I839c4da0c589afe0e0ace1138c568b2a07d66ef6
CRs-Fixed: 3311089
Ashish Kumar Dhanotiya 2 years ago
parent
commit
61c25c8f84

+ 4 - 2
core/hdd/inc/wlan_hdd_main.h

@@ -132,6 +132,8 @@ static qdf_atomic_t dp_protect_entry_count;
 #define MAX_SSR_WAIT_ITERATIONS 100
 #define MAX_SSR_PROTECT_LOG (16)
 
+#define HDD_MAX_OEM_DATA_LEN 1024
+#define HDD_MAX_FILE_NAME_LEN 64
 #ifdef FEATURE_WLAN_APF
 /**
  * struct hdd_apf_context - hdd Context for apf
@@ -2035,9 +2037,9 @@ struct hdd_context {
 #endif
 	bool is_wlan_disabled;
 
-	uint8_t *oem_data;
+	uint8_t oem_data[HDD_MAX_OEM_DATA_LEN];
 	uint8_t oem_data_len;
-	uint8_t *file_name;
+	uint8_t file_name[HDD_MAX_FILE_NAME_LEN];
 	qdf_mutex_t wifi_kobj_lock;
 #ifdef WLAN_FEATURE_DBAM_CONFIG
 	enum coex_dbam_config_mode dbam_mode;

+ 0 - 19
core/hdd/src/wlan_hdd_main.c

@@ -14835,24 +14835,6 @@ static void hdd_deregister_policy_manager_callback(
 }
 #endif
 
-/**
- * wlan_hdd_free_file_name_and_oem_data() -Free file name and oem data memory
- * @hdd_ctx: pointer to hdd context
- *
- * Return: none
- */
-static void wlan_hdd_free_file_name_and_oem_data(struct hdd_context *hdd_ctx)
-{
-	if (hdd_ctx->file_name) {
-		qdf_mem_free(hdd_ctx->file_name);
-		hdd_ctx->file_name = NULL;
-	}
-	if (hdd_ctx->oem_data) {
-		qdf_mem_free(hdd_ctx->oem_data);
-		hdd_ctx->oem_data = NULL;
-	}
-}
-
 int hdd_wlan_stop_modules(struct hdd_context *hdd_ctx, bool ftm_mode)
 {
 	void *hif_ctx;
@@ -15012,7 +14994,6 @@ int hdd_wlan_stop_modules(struct hdd_context *hdd_ctx, bool ftm_mode)
 
 	/* Free the cache channels of the command SET_DISABLE_CHANNEL_LIST */
 	wlan_hdd_free_cache_channels(hdd_ctx);
-	wlan_hdd_free_file_name_and_oem_data(hdd_ctx);
 	hdd_driver_mem_cleanup();
 
 	/* Free the resources allocated while storing SAR config. These needs

+ 13 - 16
core/hdd/src/wlan_hdd_oemdata.c

@@ -1152,25 +1152,22 @@ static void hdd_copy_file_name_and_oem_data(
 		return;
 	}
 
-	if (hdd_ctx->oem_data || hdd_ctx->file_name) {
-		hdd_err("OEM data or file name already present");
+	if (oem_event_data->data_len > HDD_MAX_OEM_DATA_LEN ||
+	    oem_event_data->file_name_len > HDD_MAX_FILE_NAME_LEN) {
+		hdd_err("Invalid oem data len %zu or file name len %d",
+			oem_event_data->data_len,
+			oem_event_data->file_name_len);
 		return;
 	}
+	qdf_mem_zero(hdd_ctx->oem_data, HDD_MAX_OEM_DATA_LEN);
+	qdf_mem_zero(hdd_ctx->file_name, HDD_MAX_FILE_NAME_LEN);
 
-	hdd_ctx->oem_data = qdf_mem_malloc(oem_event_data->data_len);
-	if (hdd_ctx->oem_data) {
-		hdd_ctx->oem_data_len = oem_event_data->data_len;
-		qdf_mem_copy(hdd_ctx->oem_data, oem_event_data->data,
-			     oem_event_data->data_len);
-		hdd_ctx->file_name = qdf_mem_malloc(
-					oem_event_data->file_name_len);
-		if (hdd_ctx->file_name)
-			qdf_mem_copy(hdd_ctx->file_name,
-				     oem_event_data->file_name,
-				     oem_event_data->file_name_len);
-		else
-			qdf_mem_free(hdd_ctx->oem_data);
-	}
+	qdf_mem_copy(hdd_ctx->oem_data, oem_event_data->data,
+		     oem_event_data->data_len);
+	hdd_ctx->oem_data_len = oem_event_data->data_len;
+
+	qdf_mem_copy(hdd_ctx->file_name, oem_event_data->file_name,
+		     oem_event_data->file_name_len);
 }
 
 void hdd_oem_event_async_cb(const struct oem_data *oem_event_data)

+ 1 - 1
core/hdd/src/wlan_hdd_sysfs_wifi_features.c

@@ -35,7 +35,7 @@ static ssize_t  __hdd_sysfs_feature_set_show(struct hdd_context *hdd_ctx,
 	uint8_t i = 0;
 	char const *solution_provider = "QCT";
 
-	if (!hdd_ctx->oem_data) {
+	if (!hdd_ctx->oem_data_len) {
 		hdd_debug("Feature info is not available");
 		return 0;
 	}