diff options
| author | Krishna Kumaar Natarajan <kknatara@qca.qualcomm.com> | 2016-02-16 16:31:36 -0800 |
|---|---|---|
| committer | Anjaneedevi Kapparapu <akappa@codeaurora.org> | 2016-03-11 12:21:43 +0530 |
| commit | 25a708a1554590afa97eba8c6147743bd2b79a69 (patch) | |
| tree | ce80eeb1c389474aae9dfd2d994aa64c2753dc67 | |
| parent | 486387bd7aa60bfae5edec196ed8e59384d3aaef (diff) | |
qcacld-2.0: Redefine dfs data structure to fix prealloc size
Redefine dfs filter type to avoid prealloc problem by making one
large chunk into multiple smaller chunks.
With current data structure, dfs attach was requesting huge chunk
of memory from the heap which results in failure. This change set
fixes the issue by modifying the data structure so that one
large chunk is made as multiple smaller chunks.
Change-Id: If944747de63a68d55a83b8595d0a07dd05f53dbe
CRs-Fixed: 975903
| -rw-r--r-- | CORE/SERVICES/DFS/inc/dfs.h | 2 | ||||
| -rw-r--r-- | CORE/SERVICES/DFS/src/dfs.c | 61 | ||||
| -rw-r--r-- | CORE/SERVICES/DFS/src/dfs_debug.c | 2 | ||||
| -rw-r--r-- | CORE/SERVICES/DFS/src/dfs_init.c | 6 | ||||
| -rw-r--r-- | CORE/SERVICES/DFS/src/dfs_process_radarevent.c | 2 |
5 files changed, 66 insertions, 7 deletions
diff --git a/CORE/SERVICES/DFS/inc/dfs.h b/CORE/SERVICES/DFS/inc/dfs.h index 556de5b1a49f..b424e9167f1e 100644 --- a/CORE/SERVICES/DFS/inc/dfs.h +++ b/CORE/SERVICES/DFS/inc/dfs.h @@ -371,7 +371,7 @@ struct dfs_filter { #endif struct dfs_filtertype { - struct dfs_filter ft_filters[DFS_MAX_NUM_RADAR_FILTERS]; + struct dfs_filter *ft_filters[DFS_MAX_NUM_RADAR_FILTERS]; u_int32_t ft_filterdur; /* Duration of pulse which specifies filter type*/ u_int32_t ft_numfilters; /* Num filters of this type */ u_int64_t ft_last_ts; /* Last timestamp this filtertype was used diff --git a/CORE/SERVICES/DFS/src/dfs.c b/CORE/SERVICES/DFS/src/dfs.c index 803e99ecc1d4..313671fc2d05 100644 --- a/CORE/SERVICES/DFS/src/dfs.c +++ b/CORE/SERVICES/DFS/src/dfs.c @@ -222,6 +222,43 @@ static int dfs_get_debug_info(struct ieee80211com *ic, int type, void *data) return (int)dfs->dfs_proc_phyerr; } +/** + * dfs_alloc_mem_filter() - allocate memory for dfs ft_filters + * @radarf: pointer holding ft_filters + * + * Return: 0-success and 1-failure +*/ +static int dfs_alloc_mem_filter(struct dfs_filtertype *radarf) +{ + int status = 0, n, i; + + for (i = 0; i < DFS_MAX_NUM_RADAR_FILTERS; i++) { + radarf->ft_filters[i] = vos_mem_malloc( + sizeof(struct dfs_filter)); + if (NULL == radarf->ft_filters[i]) { + DFS_PRINTK("%s[%d]: mem alloc failed\n", + __func__, __LINE__); + status = 1; + goto error; + } + } + + return status; + +error: + /* free up allocated memory */ + for (n = 0; n < i; n++) { + if (radarf->ft_filters[n]) { + vos_mem_free(radarf->ft_filters[n]); + radarf->ft_filters[i] = NULL; + } + } + + DFS_PRINTK("%s[%d]: cannot allocate memory for radar filter types\n", + __func__, __LINE__); + + return status; +} int dfs_attach(struct ieee80211com *ic) @@ -314,8 +351,11 @@ dfs_attach(struct ieee80211com *ic) DFS_PRINTK("%s: cannot allocate memory for radar filter types\n", __func__); goto bad1; + } else { + vos_mem_zero(dfs->dfs_radarf[n], sizeof(struct dfs_filtertype)); + if (0 != dfs_alloc_mem_filter(dfs->dfs_radarf[n])) + goto bad1; } - OS_MEMZERO(dfs->dfs_radarf[n], sizeof(struct dfs_filtertype)); } /* Allocate memory for radar table */ dfs->dfs_radartable = (int8_t **)OS_MALLOC(NULL, 256*sizeof(int8_t *), GFP_ATOMIC); @@ -398,6 +438,24 @@ bad1: #undef N } +/** + * dfs_free_filter() - free memory allocated for dfs ft_filters + * @radarf: pointer holding ft_filters + * + * Return: NA +*/ +static void dfs_free_filter(struct dfs_filtertype *radarf) +{ + int i; + + for (i = 0; i < DFS_MAX_NUM_RADAR_FILTERS; i++) { + if (radarf->ft_filters[i]) { + vos_mem_free(radarf->ft_filters[i]); + radarf->ft_filters[i] = NULL; + } + } +} + void dfs_detach(struct ieee80211com *ic) { @@ -456,6 +514,7 @@ dfs_detach(struct ieee80211com *ic) for (n=0; n<DFS_MAX_RADAR_TYPES;n++) { if (dfs->dfs_radarf[n] != NULL) { + dfs_free_filter(dfs->dfs_radarf[n]); OS_FREE(dfs->dfs_radarf[n]); dfs->dfs_radarf[n] = NULL; } diff --git a/CORE/SERVICES/DFS/src/dfs_debug.c b/CORE/SERVICES/DFS/src/dfs_debug.c index 2590f6eec10d..d948f1598bfc 100644 --- a/CORE/SERVICES/DFS/src/dfs_debug.c +++ b/CORE/SERVICES/DFS/src/dfs_debug.c @@ -111,7 +111,7 @@ dfs_print_filters(struct ath_dfs *dfs) continue; DFS_PRINTK("===========ft->ft_numfilters=%u===========\n", ft->ft_numfilters); for (j=0; j<ft->ft_numfilters; j++) { - rf = &(ft->ft_filters[j]); + rf = ft->ft_filters[j]; DFS_PRINTK("filter[%d] filterID = %d rf_numpulses=%u; rf->rf_minpri=%u; rf->rf_maxpri=%u; rf->rf_threshold=%u; rf->rf_filterlen=%u; rf->rf_mindur=%u; rf->rf_maxdur=%u\n",j, rf->rf_pulseid, rf->rf_numpulses, rf->rf_minpri, rf->rf_maxpri, rf->rf_threshold, rf->rf_filterlen, rf->rf_mindur, rf->rf_maxdur); } diff --git a/CORE/SERVICES/DFS/src/dfs_init.c b/CORE/SERVICES/DFS/src/dfs_init.c index be4262fbc4aa..59e4bbf11400 100644 --- a/CORE/SERVICES/DFS/src/dfs_init.c +++ b/CORE/SERVICES/DFS/src/dfs_init.c @@ -105,7 +105,7 @@ void dfs_reset_alldelaylines(struct ath_dfs *dfs) ft = dfs->dfs_radarf[i]; if (NULL != ft) { for (j = 0; j < ft->ft_numfilters; j++) { - rf = &(ft->ft_filters[j]); + rf = ft->ft_filters[j]; dl = &(rf->rf_dl); if (dl != NULL) { OS_MEMZERO(dl, sizeof(struct dfs_delayline)); @@ -137,7 +137,7 @@ void dfs_reset_filter_delaylines(struct dfs_filtertype *dft) int i; struct dfs_filter *df; for (i=0; i< DFS_MAX_NUM_RADAR_FILTERS; i++) { - df = &dft->ft_filters[i]; + df = dft->ft_filters[i]; dfs_reset_delayline(&(df->rf_dl)); } } @@ -284,7 +284,7 @@ int dfs_init_radar_filters(struct ieee80211com *ic, } dfs->dfs_rinfo.rn_numradars++; } - rf = &(ft->ft_filters[ft->ft_numfilters++]); + rf = ft->ft_filters[ft->ft_numfilters++]; dfs_reset_delayline(&rf->rf_dl); numpulses = dfs_radars[p].rp_numpulses; diff --git a/CORE/SERVICES/DFS/src/dfs_process_radarevent.c b/CORE/SERVICES/DFS/src/dfs_process_radarevent.c index 23d66c257efc..cf20273a2c76 100644 --- a/CORE/SERVICES/DFS/src/dfs_process_radarevent.c +++ b/CORE/SERVICES/DFS/src/dfs_process_radarevent.c @@ -555,7 +555,7 @@ dfs_process_radarevent(struct ath_dfs *dfs, struct ieee80211_channel *chan) continue; } for (p=0, found = 0; (p<ft->ft_numfilters) && (!found); p++) { - rf = &(ft->ft_filters[p]); + rf = ft->ft_filters[p]; if ((re.re_dur >= rf->rf_mindur) && (re.re_dur <= rf->rf_maxdur)) { /* The above check is probably not necessary */ deltaT = (this_ts < rf->rf_dl.dl_last_ts) ? |
