wifi: fix wifi_driect cts fail & some panic issue
authorRongjun Chen <rongjun.chen@amlogic.com>
Mon, 28 May 2018 05:48:19 +0000 (13:48 +0800)
committerYang Xu <yang.xu@amlogic.com>
Tue, 5 Jun 2018 10:35:35 +0000 (03:35 -0700)
PD# 167139

fix cts fail and some panic issue
Change-Id: I55c10a60464f7dccd2428e03a6f05e8bc8633f95
Signed-off-by: Rongjun Chen <rongjun.chen@amlogic.com>
bcmdhd.1.579.77.41.1.cn/dhd_linux.c
bcmdhd.1.579.77.41.1.cn/wl_cfg80211.c
bcmdhd.1.579.77.41.1.cn/wl_linux_mon.c

index 0f3932823fba453d2a092af090392314cd15bac8..2bf3709eaf8a75a6d14f8eccd70915b29f364def 100644 (file)
@@ -9226,7 +9226,11 @@ dhd_allocate_if(dhd_pub_t *dhdpub, int ifidx, const char *name,
 #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0) */
        }
 #else
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 11, 0)
        ifp->net->destructor = free_netdev;
+#else
+       ifp->net->needs_free_netdev = true;
+#endif
 #endif /* WL_CFG80211 */
        strncpy(ifp->name, ifp->net->name, IFNAMSIZ);
        ifp->name[IFNAMSIZ - 1] = '\0';
@@ -19843,8 +19847,8 @@ static void dhd_sysfs_exit(dhd_info_t *dhd)
                DHD_ERROR(("%s(): dhd is NULL \r\n", __FUNCTION__));
                return;
        }
-
-       if (&dhd->dhd_kobj != NULL)
+       /* Releae the kobject */
+       if (dhd->dhd_kobj.state_initialized)
                kobject_put(&dhd->dhd_kobj);
 }
 
index c46d30cabbfc414bf5eb01b7527e5d34d7400e03..d926602be66b03b6fd44e2df3280e69d2add16a2 100644 (file)
@@ -9545,7 +9545,7 @@ wl_cfg80211_del_station(
        } else {
 #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 19, 0)) */
 #endif /* CUSTOM_BLOCK_DEAUTH_AT_EAP_FAILURE */
-       dhd_wait_pend8021x(dev);
+//     dhd_wait_pend8021x(dev);
        scb_val.val = DOT11_RC_DEAUTH_LEAVING;
        err = wldev_ioctl_set(dev, WLC_SCB_DEAUTHENTICATE_FOR_REASON, &scb_val,
                sizeof(scb_val_t));
@@ -14420,6 +14420,7 @@ static s32 wl_create_event_handler(struct bcm_cfg80211 *cfg)
        }
 
        if (!cfg->event_workq) {
+               WL_ERR(("event_workq alloc_workqueue failed\n"));
                ret = -ENOMEM;
        } else {
                INIT_WORK(&cfg->event_work, wl_event_handler);
@@ -15630,20 +15631,21 @@ static s32 wl_init_priv(struct bcm_cfg80211 *cfg)
        init_waitqueue_head(&cfg->netif_change_event);
        init_completion(&cfg->send_af_done);
        init_completion(&cfg->iface_disable);
-       wl_init_eq(cfg);
-       err = wl_init_priv_mem(cfg);
-       if (err)
-               return err;
-       if (wl_create_event_handler(cfg))
-               return -ENOMEM;
-       wl_init_event_handler(cfg);
        mutex_init(&cfg->usr_sync);
        mutex_init(&cfg->event_sync);
        mutex_init(&cfg->scan_complete);
        mutex_init(&cfg->if_sync);
+       mutex_init(&cfg->pm_sync);
 #ifdef WLTDLS
        mutex_init(&cfg->tdls_sync);
 #endif /* WLTDLS */
+       wl_init_eq(cfg);
+       err = wl_init_priv_mem(cfg);
+       if (err)
+               return err;
+       if (wl_create_event_handler(cfg))
+               return -ENOMEM;
+       wl_init_event_handler(cfg);
        err = wl_init_scan(cfg);
        if (err)
                return err;
@@ -15670,9 +15672,11 @@ static void wl_deinit_priv(struct bcm_cfg80211 *cfg)
        wl_destroy_event_handler(cfg);
        wl_flush_eq(cfg);
        wl_link_down(cfg);
-       del_timer_sync(&cfg->scan_timeout);
+       if (cfg->scan_timeout.function)
+               del_timer_sync(&cfg->scan_timeout);
 #ifdef DHD_LOSSLESS_ROAMING
-       del_timer_sync(&cfg->roam_timeout);
+       if (cfg->roam_timeout.function)
+               del_timer_sync(&cfg->roam_timeout);
 #endif
        wl_deinit_priv_mem(cfg);
        if (wl_cfg80211_netdev_notifier_registered) {
@@ -15783,7 +15787,7 @@ struct bcm_cfg80211 *wl_get_cfg(struct net_device *ndev)
 {
        struct wireless_dev *wdev = ndev->ieee80211_ptr;
 
-       if (!wdev)
+       if (!wdev || !wdev->wiphy)
                return NULL;
 
        return wiphy_priv(wdev->wiphy);
@@ -15832,14 +15836,14 @@ s32 wl_cfg80211_attach(struct net_device *ndev, void *context)
        SET_NETDEV_DEV(ndev, wiphy_dev(wdev->wiphy));
        wdev->netdev = ndev;
        cfg->state_notifier = wl_notifier_change_state;
-       err = wl_alloc_netinfo(cfg, ndev, wdev, wdev->iftype, PM_ENABLE, 0);
+       err = wl_init_priv(cfg);
        if (err) {
-               WL_ERR(("Failed to alloc net_info (%d)\n", err));
+               WL_ERR(("Failed to init iwm_priv (%d)\n", err));
                goto cfg80211_attach_out;
        }
-       err = wl_init_priv(cfg);
+       err = wl_alloc_netinfo(cfg, ndev, wdev, wdev->iftype, PM_ENABLE, 0);
        if (err) {
-               WL_ERR(("Failed to init iwm_priv (%d)\n", err));
+               WL_ERR(("Failed to alloc net_info (%d)\n", err));
                goto cfg80211_attach_out;
        }
 
@@ -15884,7 +15888,6 @@ s32 wl_cfg80211_attach(struct net_device *ndev, void *context)
 #endif 
 
        INIT_DELAYED_WORK(&cfg->pm_enable_work, wl_cfg80211_work_handler);
-       mutex_init(&cfg->pm_sync);
 
 #if defined(STAT_REPORT)
        err = wl_attach_stat_report(cfg);
@@ -15895,8 +15898,7 @@ s32 wl_cfg80211_attach(struct net_device *ndev, void *context)
        return err;
 
 cfg80211_attach_out:
-       wl_setup_rfkill(cfg, FALSE);
-       wl_free_wdev(cfg);
+       wl_cfg80211_detach(cfg);
        return err;
 }
 
@@ -16693,12 +16695,14 @@ static s32 __wl_cfg80211_up(struct bcm_cfg80211 *cfg)
 
        WL_DBG(("In\n"));
 
-       err = wl_create_event_handler(cfg);
-       if (err) {
-               WL_ERR(("wl_create_event_handler failed\n"));
-               return err;
+       if (!dhd_download_fw_on_driverload) {
+               err = wl_create_event_handler(cfg);
+               if (err) {
+                       WL_ERR(("wl_create_event_handler failed\n"));
+                       return err;
+               }
+               wl_init_event_handler(cfg);
        }
-       wl_init_event_handler(cfg);
 
        err = dhd_config_dongle(cfg);
        if (unlikely(err))
@@ -16726,19 +16730,7 @@ static s32 __wl_cfg80211_up(struct bcm_cfg80211 *cfg)
                        return err;
                }
        }
-       if (!dhd_download_fw_on_driverload) {
-               err = wl_create_event_handler(cfg);
-               if (err) {
-                       WL_ERR(("wl_create_event_handler failed\n"));
-                       return err;
-               }
-               wl_init_event_handler(cfg);
-       }
-       err = wl_init_scan(cfg);
-       if (err) {
-               WL_ERR(("wl_init_scan failed\n"));
-               return err;
-       }
+
 #ifdef DHD_LOSSLESS_ROAMING
        if (timer_pending(&cfg->roam_timeout)) {
                del_timer_sync(&cfg->roam_timeout);
@@ -17082,17 +17074,12 @@ int wl_cfg80211_hang(struct net_device *dev, u16 reason)
 
 s32 wl_cfg80211_down(struct net_device *dev)
 {
+       struct bcm_cfg80211 *cfg = wl_get_cfg(dev);
        s32 err = 0;
-       struct bcm_cfg80211 *cfg = NULL;
-       if (dev == NULL)
-               return err;
-
-       cfg = wl_get_cfg(dev);
 
        WL_DBG(("In\n"));
        if (cfg == NULL)
                return err;
-
        mutex_lock(&cfg->usr_sync);
 #if defined(RSSIAVG)
        wl_free_rssi_cache(&g_rssi_cache_ctrl);
index e90fa5d1679aeda5a2f06e925d5129c508e8a9cf..75a417ba905c438bccbd7b269de3c890afa5b5ca 100644 (file)
@@ -388,8 +388,8 @@ int dhd_monitor_uninit(void)
 {
        int i;
        struct net_device *ndev;
-       mutex_lock(&g_monitor.lock);
        if (g_monitor.monitor_state != MONITOR_STATE_DEINIT) {
+               mutex_lock(&g_monitor.lock);
                for (i = 0; i < DHD_MAX_IFS; i++) {
                        ndev = g_monitor.mon_if[i].mon_ndev;
                        if (ndev) {
@@ -400,7 +400,7 @@ int dhd_monitor_uninit(void)
                        }
                }
                g_monitor.monitor_state = MONITOR_STATE_DEINIT;
+               mutex_unlock(&g_monitor.lock);
        }
-       mutex_unlock(&g_monitor.lock);
        return 0;
 }