wifi: update dhd_static_buf
authorRongjun Chen <rongjun.chen@amlogic.com>
Tue, 12 Sep 2017 08:35:05 +0000 (16:35 +0800)
committerRongjun Chen <rongjun.chen@amlogic.com>
Tue, 12 Sep 2017 08:35:05 +0000 (16:35 +0800)
PD# 146454

update dhd_static_buf to fix prealloc mem issue

Change-Id: I5d61a4ae54a70a42a23e97b33b5f8894b9e31f93

bcmdhd.1.579.77.41.1.cn/dhd.h
bcmdhd.1.579.77.41.1.cn/dhd_debug.c
bcmdhd.1.579.77.41.1.cn/dhd_linux.c
bcmdhd.1.579.77.41.1.cn/include/osl.h
bcmdhd.1.579.77.41.1.cn/wl_escan.c

index 808c489fedc6b383da6746c544248aea3bfa4450..99af8b3c2924c75311549a849dd37476aa044aac 100644 (file)
@@ -361,7 +361,12 @@ enum dhd_prealloc_index {
        DHD_PREALLOC_DHD_LOG_DUMP_BUF = 15,
        DHD_PREALLOC_DHD_LOG_DUMP_BUF_EX = 16,
        DHD_PREALLOC_DHD_PKTLOG_DUMP_BUF = 17,
-       DHD_PREALLOC_STAT_REPORT_BUF = 18
+       DHD_PREALLOC_STAT_REPORT_BUF = 18,
+       DHD_PREALLOC_WL_ESCAN_INFO = 19,
+       DHD_PREALLOC_FW_VERBOSE_RING = 20,
+       DHD_PREALLOC_FW_EVENT_RING = 21,
+       DHD_PREALLOC_DHD_EVENT_RING = 22,
+       DHD_PREALLOC_NAN_EVENT_RING = 23
 };
 
 enum dhd_dongledump_mode {
index b0be8dc7aeadc7b072a7e6b2c537a0e7fd718dbe..c5c1e59016779c6f6e8ba537d0ed4bd952c9e28e 100644 (file)
@@ -1169,12 +1169,15 @@ dhd_dbg_trace_evnt_handler(dhd_pub_t *dhdp, void *event_data,
 #endif /* MACOSX_DHD */
 static int
 dhd_dbg_ring_init(dhd_pub_t *dhdp, dhd_dbg_ring_t *ring, uint16 id, uint8 *name,
-               uint32 ring_sz)
+               uint32 ring_sz, int section)
 {
        void *buf;
        unsigned long flags;
-
+#ifdef CONFIG_DHD_USE_STATIC_BUF
+       buf = bcm_wlan_prealloc(section, ring_sz);
+#else
        buf = MALLOCZ(dhdp->osh, ring_sz);
+#endif
        if (!buf)
                return BCME_NOMEM;
 
@@ -1220,8 +1223,9 @@ dhd_dbg_ring_deinit(dhd_pub_t *dhdp, dhd_dbg_ring_t *ring)
        dhd_os_spin_unlock(ring->lock, flags);
 
        dhd_os_spin_lock_deinit(dhdp->osh, ring->lock);
-
+#ifndef CONFIG_DHD_USE_STATIC_BUF
        MFREE(dhdp->osh, buf, ring_sz);
+#endif
 }
 
 uint8
@@ -2264,22 +2268,22 @@ dhd_dbg_attach(dhd_pub_t *dhdp, dbg_pullreq_t os_pullreq,
                return BCME_NOMEM;
 
        ret = dhd_dbg_ring_init(dhdp, &dbg->dbg_rings[FW_VERBOSE_RING_ID], FW_VERBOSE_RING_ID,
-                       (uint8 *)FW_VERBOSE_RING_NAME, FW_VERBOSE_RING_SIZE);
+                       (uint8 *)FW_VERBOSE_RING_NAME, FW_VERBOSE_RING_SIZE, DHD_PREALLOC_FW_VERBOSE_RING);
        if (ret)
                goto error;
 
        ret = dhd_dbg_ring_init(dhdp, &dbg->dbg_rings[FW_EVENT_RING_ID], FW_EVENT_RING_ID,
-                       (uint8 *)FW_EVENT_RING_NAME, FW_EVENT_RING_SIZE);
+                       (uint8 *)FW_EVENT_RING_NAME, FW_EVENT_RING_SIZE, DHD_PREALLOC_FW_EVENT_RING);
        if (ret)
                goto error;
 
        ret = dhd_dbg_ring_init(dhdp, &dbg->dbg_rings[DHD_EVENT_RING_ID], DHD_EVENT_RING_ID,
-                       (uint8 *)DHD_EVENT_RING_NAME, DHD_EVENT_RING_SIZE);
+                       (uint8 *)DHD_EVENT_RING_NAME, DHD_EVENT_RING_SIZE, DHD_PREALLOC_DHD_EVENT_RING);
        if (ret)
                goto error;
 
        ret = dhd_dbg_ring_init(dhdp, &dbg->dbg_rings[NAN_EVENT_RING_ID], NAN_EVENT_RING_ID,
-                       (uint8 *)NAN_EVENT_RING_NAME, NAN_EVENT_RING_SIZE);
+                       (uint8 *)NAN_EVENT_RING_NAME, NAN_EVENT_RING_SIZE, DHD_PREALLOC_NAN_EVENT_RING);
        if (ret)
                goto error;
 
index f235fb494155b470364b74c02c8d7f1dde2837d0..09928601b0a5c4107e996fb18d9c2dd4a06fb69d 100644 (file)
@@ -19117,9 +19117,8 @@ static void dhd_sysfs_exit(dhd_info_t *dhd)
                DHD_ERROR(("%s(): dhd is NULL \r\n", __FUNCTION__));
                return;
        }
-
-       /* Releae the kobject */
-       kobject_put(&dhd->dhd_kobj);
+       if (&dhd->dhd_kobj != NULL)
+               kobject_put(&dhd->dhd_kobj);
 }
 
 #ifdef DHD_DEBUG_UART
index 082b301522663a4c819d1414f64339e77b95c87a..d3b11615c1f1607f9b37e14f93622806cad2a657 100644 (file)
@@ -67,7 +67,9 @@ typedef void  (*osl_wreg_fn_t)(void *ctx, volatile void *reg, unsigned int val,
 #ifndef OR_REG
 #define OR_REG(osh, r, v)              W_REG(osh, (r), R_REG(osh, r) | (v))
 #endif   /* !OR_REG */
-
+#ifdef CONFIG_DHD_USE_STATIC_BUF
+void* bcm_wlan_prealloc(int section, unsigned long size);
+#endif
 #if !defined(OSL_SYSUPTIME)
 #define OSL_SYSUPTIME() (0)
 #define OSL_SYSUPTIME_SUPPORT FALSE
index d2bafa41b004ce04a0bfc9f52201d2c65e22362f..d6425b9eb9422f28f0f18ee58f7c7512f1707ebb 100644 (file)
@@ -4,7 +4,6 @@
 #include <typedefs.h>
 #include <linuxver.h>
 #include <osl.h>
-
 #include <bcmutils.h>
 #include <bcmendian.h>
 #include <ethernet.h>
@@ -1411,8 +1410,9 @@ void wl_escan_detach(void)
                kfree(escan->escan_ioctl_buf);
                escan->escan_ioctl_buf = NULL;
        }
-
+#ifndef CONFIG_DHD_USE_STATIC_BUF
        kfree(escan);
+#endif
        g_escan = NULL;
 }
 
@@ -1425,8 +1425,11 @@ wl_escan_attach(struct net_device *dev, void * dhdp)
 
        if (!dev)
                return 0;
-
+#ifdef CONFIG_DHD_USE_STATIC_BUF
+       escan = bcm_wlan_prealloc(DHD_PREALLOC_WL_ESCAN_INFO, sizeof(struct wl_escan_info));
+#else
        escan = kmalloc(sizeof(struct wl_escan_info), GFP_KERNEL);
+#endif
        if (!escan)
                return -ENOMEM;
        memset(escan, 0, sizeof(struct wl_escan_info));