Browse Source

qcacld-3.0: Dynamically allocate hdd_txrx_hist

qcacld-2.0 to qcacld-3.0 propagation.

Dynamically allocate hdd_txrx_hist to reduce size
of HDD context and avoid order 4 memory allocation
from kernel.

Change-Id: I04dd8f3cdb7f401fb761262bd34b0a2177f6097f
CRs-Fixed: 950790
Nirav Shah 9 years ago
parent
commit
ed34b21226
3 changed files with 48 additions and 4 deletions
  1. 3 1
      core/hdd/inc/wlan_hdd_main.h
  2. 44 2
      core/hdd/src/wlan_hdd_main.c
  3. 1 1
      core/hdd/src/wlan_hdd_power.c

+ 3 - 1
core/hdd/inc/wlan_hdd_main.h

@@ -1386,7 +1386,7 @@ struct hdd_context_s {
 	qdf_spinlock_t connection_status_lock;
 
 	uint16_t hdd_txrx_hist_idx;
-	struct hdd_tx_rx_histogram hdd_txrx_hist[NUM_TX_RX_HISTOGRAM];
+	struct hdd_tx_rx_histogram *hdd_txrx_hist;
 	/*
 	 * Dfs lock used to syncronize on sap channel switch during
 	 * radar found indication and application triggered channel
@@ -1614,6 +1614,8 @@ void wlan_hdd_txrx_pause_cb(uint8_t vdev_id,
 	enum netif_action_type action, enum netif_reason_type reason);
 
 void hdd_wlan_dump_stats(hdd_adapter_t *adapter, int value);
+int wlan_hdd_init_tx_rx_histogram(hdd_context_t *hdd_ctx);
+void wlan_hdd_deinit_tx_rx_histogram(hdd_context_t *hdd_ctx);
 void wlan_hdd_display_tx_rx_histogram(hdd_context_t *pHddCtx);
 void wlan_hdd_clear_tx_rx_histogram(hdd_context_t *pHddCtx);
 void wlan_hdd_display_netif_queue_history(hdd_context_t *hdd_ctx);

+ 44 - 2
core/hdd/src/wlan_hdd_main.c

@@ -4213,6 +4213,7 @@ void hdd_wlan_exit(hdd_context_t *hdd_ctx)
 
 free_hdd_ctx:
 
+	wlan_hdd_deinit_tx_rx_histogram(hdd_ctx);
 	wiphy_unregister(wiphy);
 
 	hdd_context_destroy(hdd_ctx);
@@ -4754,6 +4755,38 @@ static void hdd_bus_bw_compute_cbk(void *priv)
 }
 #endif
 
+/**
+ * wlan_hdd_init_tx_rx_histogram() - init tx/rx histogram stats
+ * @hdd_ctx: hdd context
+ *
+ * Return: 0 for success or error code
+ */
+int wlan_hdd_init_tx_rx_histogram(hdd_context_t *hdd_ctx)
+{
+	hdd_ctx->hdd_txrx_hist = qdf_mem_malloc(
+		(sizeof(struct hdd_tx_rx_histogram) * NUM_TX_RX_HISTOGRAM));
+	if (hdd_ctx->hdd_txrx_hist == NULL) {
+		hdd_err("%s: Failed malloc for hdd_txrx_hist", __func__);
+		return -ENOMEM;
+	}
+	return 0;
+}
+
+/**
+ * wlan_hdd_deinit_tx_rx_histogram() - deinit tx/rx histogram stats
+ * @hdd_ctx: hdd context
+ *
+ * Return: none
+ */
+void wlan_hdd_deinit_tx_rx_histogram(hdd_context_t *hdd_ctx)
+{
+	if (hdd_ctx->hdd_txrx_hist) {
+		qdf_mem_free(hdd_ctx->hdd_txrx_hist);
+		hdd_ctx->hdd_txrx_hist = NULL;
+	}
+}
+
+
 /**
  * wlan_hdd_display_tx_rx_histogram() - display tx rx histogram
  * @hdd_ctx: hdd context
@@ -4804,7 +4837,8 @@ void wlan_hdd_display_tx_rx_histogram(hdd_context_t *hdd_ctx)
 void wlan_hdd_clear_tx_rx_histogram(hdd_context_t *hdd_ctx)
 {
 	hdd_ctx->hdd_txrx_hist_idx = 0;
-	qdf_mem_zero(hdd_ctx->hdd_txrx_hist, sizeof(hdd_ctx->hdd_txrx_hist));
+	qdf_mem_zero(hdd_ctx->hdd_txrx_hist,
+		(sizeof(struct hdd_tx_rx_histogram) * NUM_TX_RX_HISTOGRAM));
 }
 
 /**
@@ -5643,9 +5677,14 @@ hdd_context_t *hdd_context_create(struct device *dev, void *hif_sc)
 
 	cds_set_multicast_logging(hdd_ctx->config->multicast_host_fw_msgs);
 
+	status = wlan_hdd_init_tx_rx_histogram(hdd_ctx);
+	if (status)
+		goto err_free_config;
+
 	ret = hdd_logging_sock_activate_svc(hdd_ctx);
 	if (ret)
-		goto err_free_config;
+		goto err_free_histogram;
+
 
 	/*
 	 * Update QDF trace levels based upon the code. The multicast
@@ -5660,6 +5699,9 @@ skip_multicast_logging:
 
 	return hdd_ctx;
 
+err_free_histogram:
+	wlan_hdd_deinit_tx_rx_histogram(hdd_ctx);
+
 err_free_config:
 	qdf_mem_free(hdd_ctx->config);
 

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

@@ -1684,7 +1684,7 @@ err_cds_close:
 		/* Free up dynamically allocated members inside HDD Adapter */
 		kfree(pHddCtx->config);
 		pHddCtx->config = NULL;
-
+		wlan_hdd_deinit_tx_rx_histogram(pHddCtx);
 		wiphy_unregister(pHddCtx->wiphy);
 		wiphy_free(pHddCtx->wiphy);