rpcd: iwinfo plugin fixes
[openwrt/svn-archive/archive.git] / package / kernel / mac80211 / patches / 344-0002-brcmfmac-Limit-memory-allocs-to-64K.patch
1 From: Hante Meuleman <meuleman@broadcom.com>
2 Date: Wed, 17 Feb 2016 11:26:51 +0100
3 Subject: [PATCH] brcmfmac: Limit memory allocs to <64K
4
5 Some systems have problems with allocating memory allocation larger
6 then 64K. Often on unload/load or suspend/resume a failure is
7 reported: Could not allocate wiphy device. This patch makes the
8 escan intermediate storage buf dynamically allocated, and smaller
9 than 64K.
10
11 Reviewed-by: Arend Van Spriel <arend@broadcom.com>
12 Reviewed-by: Franky (Zhenhui) Lin <frankyl@broadcom.com>
13 Reviewed-by: Pieter-Paul Giesberts <pieterpg@broadcom.com>
14 Signed-off-by: Hante Meuleman <meuleman@broadcom.com>
15 Signed-off-by: Arend van Spriel <arend@broadcom.com>
16 Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
17 ---
18
19 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
20 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
21 @@ -1125,7 +1125,7 @@ brcmf_cfg80211_escan(struct wiphy *wiphy
22
23 /* Arm scan timeout timer */
24 mod_timer(&cfg->escan_timeout, jiffies +
25 - WL_ESCAN_TIMER_INTERVAL_MS * HZ / 1000);
26 + BRCMF_ESCAN_TIMER_INTERVAL_MS * HZ / 1000);
27
28 return 0;
29
30 @@ -3020,7 +3020,7 @@ brcmf_cfg80211_escan_handler(struct brcm
31
32 list = (struct brcmf_scan_results *)
33 cfg->escan_info.escan_buf;
34 - if (bi_length > WL_ESCAN_BUF_SIZE - list->buflen) {
35 + if (bi_length > BRCMF_ESCAN_BUF_SIZE - list->buflen) {
36 brcmf_err("Buffer is too small: ignoring\n");
37 goto exit;
38 }
39 @@ -3033,8 +3033,8 @@ brcmf_cfg80211_escan_handler(struct brcm
40 bss_info_le))
41 goto exit;
42 }
43 - memcpy(&(cfg->escan_info.escan_buf[list->buflen]),
44 - bss_info_le, bi_length);
45 + memcpy(&cfg->escan_info.escan_buf[list->buflen], bss_info_le,
46 + bi_length);
47 list->version = le32_to_cpu(bss_info_le->version);
48 list->buflen += bi_length;
49 list->count++;
50 @@ -5402,14 +5402,14 @@ static void brcmf_deinit_priv_mem(struct
51 {
52 kfree(cfg->conf);
53 cfg->conf = NULL;
54 - kfree(cfg->escan_ioctl_buf);
55 - cfg->escan_ioctl_buf = NULL;
56 kfree(cfg->extra_buf);
57 cfg->extra_buf = NULL;
58 kfree(cfg->wowl.nd);
59 cfg->wowl.nd = NULL;
60 kfree(cfg->wowl.nd_info);
61 cfg->wowl.nd_info = NULL;
62 + kfree(cfg->escan_info.escan_buf);
63 + cfg->escan_info.escan_buf = NULL;
64 }
65
66 static s32 brcmf_init_priv_mem(struct brcmf_cfg80211_info *cfg)
67 @@ -5417,9 +5417,6 @@ static s32 brcmf_init_priv_mem(struct br
68 cfg->conf = kzalloc(sizeof(*cfg->conf), GFP_KERNEL);
69 if (!cfg->conf)
70 goto init_priv_mem_out;
71 - cfg->escan_ioctl_buf = kzalloc(BRCMF_DCMD_MEDLEN, GFP_KERNEL);
72 - if (!cfg->escan_ioctl_buf)
73 - goto init_priv_mem_out;
74 cfg->extra_buf = kzalloc(WL_EXTRA_BUF_MAX, GFP_KERNEL);
75 if (!cfg->extra_buf)
76 goto init_priv_mem_out;
77 @@ -5431,6 +5428,9 @@ static s32 brcmf_init_priv_mem(struct br
78 GFP_KERNEL);
79 if (!cfg->wowl.nd_info)
80 goto init_priv_mem_out;
81 + cfg->escan_info.escan_buf = kzalloc(BRCMF_ESCAN_BUF_SIZE, GFP_KERNEL);
82 + if (!cfg->escan_info.escan_buf)
83 + goto init_priv_mem_out;
84
85 return 0;
86
87 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.h
88 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.h
89 @@ -28,8 +28,11 @@
90 #define WL_ROAM_TRIGGER_LEVEL -75
91 #define WL_ROAM_DELTA 20
92
93 -#define WL_ESCAN_BUF_SIZE (1024 * 64)
94 -#define WL_ESCAN_TIMER_INTERVAL_MS 10000 /* E-Scan timeout */
95 +/* Keep BRCMF_ESCAN_BUF_SIZE below 64K (65536). Allocing over 64K can be
96 + * problematic on some systems and should be avoided.
97 + */
98 +#define BRCMF_ESCAN_BUF_SIZE 65000
99 +#define BRCMF_ESCAN_TIMER_INTERVAL_MS 10000 /* E-Scan timeout */
100
101 #define WL_ESCAN_ACTION_START 1
102 #define WL_ESCAN_ACTION_CONTINUE 2
103 @@ -205,7 +208,7 @@ enum wl_escan_state {
104
105 struct escan_info {
106 u32 escan_state;
107 - u8 escan_buf[WL_ESCAN_BUF_SIZE];
108 + u8 *escan_buf;
109 struct wiphy *wiphy;
110 struct brcmf_if *ifp;
111 s32 (*run)(struct brcmf_cfg80211_info *cfg, struct brcmf_if *ifp,
112 @@ -278,7 +281,6 @@ struct brcmf_cfg80211_wowl {
113 * @escan_info: escan information.
114 * @escan_timeout: Timer for catch scan timeout.
115 * @escan_timeout_work: scan timeout worker.
116 - * @escan_ioctl_buf: dongle command buffer for escan commands.
117 * @vif_list: linked list of vif instances.
118 * @vif_cnt: number of vif instances.
119 * @vif_event: vif event signalling.
120 @@ -309,7 +311,6 @@ struct brcmf_cfg80211_info {
121 struct escan_info escan_info;
122 struct timer_list escan_timeout;
123 struct work_struct escan_timeout_work;
124 - u8 *escan_ioctl_buf;
125 struct list_head vif_list;
126 struct brcmf_cfg80211_vif_event vif_event;
127 struct completion vif_disabled;