diff --git a/hif/src/ce/ce_main.c b/hif/src/ce/ce_main.c index 89202ed241..db8536816f 100644 --- a/hif/src/ce/ce_main.c +++ b/hif/src/ce/ce_main.c @@ -1838,7 +1838,6 @@ static int hif_wlan_enable(void) */ int hif_config_ce(hif_handle_t hif_hdl) { - struct HIF_CE_state *hif_state; struct HIF_CE_pipe_info *pipe_info; int pipe_num; #ifdef ADRASTEA_SHADOW_REGISTERS @@ -1847,6 +1846,7 @@ int hif_config_ce(hif_handle_t hif_hdl) CDF_STATUS rv = CDF_STATUS_SUCCESS; int ret; struct ol_softc *scn = hif_hdl; + struct HIF_CE_state *hif_state = (struct HIF_CE_state *)scn; struct icnss_soc_info soc_info; struct hif_target_info *tgt_info = hif_get_target_info_handle(scn); @@ -1880,12 +1880,6 @@ int hif_config_ce(hif_handle_t hif_hdl) return CDF_STATUS_NOT_INITIALIZED; } - hif_state = (struct HIF_CE_state *)cdf_mem_malloc(sizeof(*hif_state)); - if (!hif_state) { - return -ENOMEM; - } - cdf_mem_zero(hif_state, sizeof(*hif_state)); - hif_state->scn = scn; scn->hif_hdl = hif_state; scn->mem = soc_info.v_addr; @@ -2016,10 +2010,8 @@ err: cdf_softirq_timer_free(&hif_state->sleep_timer); hif_state->sleep_timer_init = false; } - if (scn->hif_hdl) { - scn->hif_hdl = NULL; - cdf_mem_free(hif_state); - } + + scn->hif_hdl = NULL; athdiag_procfs_remove(); scn->athdiag_procfs_inited = false; HIF_TRACE("%s: X, ret = %d\n", __func__, rv); diff --git a/hif/src/ce/ce_main.h b/hif/src/ce/ce_main.h index 4589c464e8..354c812c37 100644 --- a/hif/src/ce/ce_main.h +++ b/hif/src/ce/ce_main.h @@ -108,6 +108,7 @@ struct ce_tasklet_entry { }; struct HIF_CE_state { + struct ol_softc ol_sc; struct ol_softc *scn; bool started; struct ce_tasklet_entry tasklets[CE_COUNT_MAX]; diff --git a/hif/src/hif_main.c b/hif/src/hif_main.c index f6d42a5071..52dec6e425 100644 --- a/hif/src/hif_main.c +++ b/hif/src/hif_main.c @@ -497,16 +497,17 @@ CDF_STATUS hif_open(cdf_device_t cdf_ctx, enum ath_hal_bus_type bus_type) v_CONTEXT_t cds_context; CDF_STATUS status = CDF_STATUS_SUCCESS; struct hif_config_info *cfg; + int bus_context_size = hif_bus_get_context_size(); cds_context = cds_get_global_context(); status = cds_alloc_context(cds_context, CDF_MODULE_ID_HIF, - (void **)&scn, sizeof(*scn)); + (void **)&scn, bus_context_size); if (status != CDF_STATUS_SUCCESS) { HIF_ERROR("%s: cannot alloc ol_sc", __func__); return status; } - cdf_mem_zero(scn, sizeof(*scn)); + cdf_mem_zero(scn, bus_context_size); scn->cdf_dev = cdf_ctx; cfg = hif_get_ini_handle(scn); cfg->max_no_of_peers = 1; diff --git a/hif/src/hif_main.h b/hif/src/hif_main.h index 9544ef823d..c357c8e1e7 100644 --- a/hif/src/hif_main.h +++ b/hif/src/hif_main.h @@ -132,5 +132,5 @@ CDF_STATUS hif_enable_bus(struct ol_softc *ol_sc, struct device *dev, void *bdev, const hif_bus_id *bid, enum hif_enable_type type); void hif_disable_bus(void *bdev); void hif_bus_prevent_linkdown(struct ol_softc *scn, bool flag); - +int hif_bus_get_context_size(void); #endif /* __HIF_MAIN_H__ */ diff --git a/hif/src/pcie/if_pci.c b/hif/src/pcie/if_pci.c index 2241313ad3..de4b74ae02 100644 --- a/hif/src/pcie/if_pci.c +++ b/hif/src/pcie/if_pci.c @@ -1183,6 +1183,16 @@ void hif_disable_power_management(void *hif_ctx) } #define ATH_PCI_PROBE_RETRY_MAX 3 +/** + * hif_bus_get_context_size - API to return size of the bus specific structure + * + * Return: sizeof of hif_pci_softc + */ +int hif_bus_get_context_size(void) +{ + return sizeof(struct hif_pci_softc); +} + /** * hif_bus_open(): hif_bus_open * @scn: scn @@ -1192,13 +1202,8 @@ void hif_disable_power_management(void *hif_ctx) */ CDF_STATUS hif_bus_open(struct ol_softc *ol_sc, enum ath_hal_bus_type bus_type) { - struct hif_pci_softc *sc; + struct hif_pci_softc *sc = (struct hif_pci_softc *)ol_sc; - sc = cdf_mem_malloc(sizeof(*sc)); - if (!sc) { - HIF_ERROR("%s: no mem", __func__); - return CDF_STATUS_E_NOMEM; - } ol_sc->hif_sc = (void *)sc; sc->ol_sc = ol_sc; ol_sc->bus_type = bus_type; @@ -1227,7 +1232,6 @@ void hif_bus_close(struct ol_softc *ol_sc) return; hif_pm_runtime_close(sc); - cdf_mem_free(sc); ol_sc->hif_sc = NULL; } diff --git a/hif/src/pcie/if_pci.h b/hif/src/pcie/if_pci.h index 0c05cddc96..849d06f73a 100644 --- a/hif/src/pcie/if_pci.h +++ b/hif/src/pcie/if_pci.h @@ -39,9 +39,7 @@ #include "osapi_linux.h" #include "hif.h" #include "cepci.h" - -struct CE_state; -struct ol_softc; +#include "ce_main.h" /* An address (e.g. of a buffer) in Copy Engine space. */ @@ -113,6 +111,7 @@ struct hif_msi_info { }; struct hif_pci_softc { + struct HIF_CE_state ce_sc; void __iomem *mem; /* PCI address. */ /* For efficiency, should be first in struct */ diff --git a/hif/src/snoc/if_snoc.c b/hif/src/snoc/if_snoc.c index 6d46dfafa6..e739a00739 100644 --- a/hif/src/snoc/if_snoc.c +++ b/hif/src/snoc/if_snoc.c @@ -187,6 +187,15 @@ void hif_bus_close(struct ol_softc *scn) { } +/** + * hif_bus_get_context_size - API to get Bus Context Size + * + * Return: Sizeof HIF_CE_state + */ +int hif_bus_get_context_size(void) +{ + return sizeof(struct HIF_CE_state); +} /** * hif_bus_open(): hif_bus_open * @scn: scn