bcmdhd: if driver is not yet initialized, wait and retry
authorkszaq <kszaquitto@gmail.com>
Thu, 5 Oct 2017 20:04:11 +0000 (22:04 +0200)
committerBruno Martins <bgcngm@gmail.com>
Thu, 25 Apr 2024 00:35:48 +0000 (01:35 +0100)
Change-Id: Ic2970c5f34d2b3e351919db206c7beac31731b08

bcmdhd.100.10.545.x/dhd_linux.c
bcmdhd.101.10.240.x/dhd_linux.c
bcmdhd.101.10.361.x/dhd_linux.c

index 54fa3ca05c527b77e69595baabb80b9b459ae333..1ca2afa1c93aba2719dafe9e1193e449c2877320 100644 (file)
@@ -6878,6 +6878,7 @@ dhd_open(struct net_device *net)
 #if defined(WL_EXT_IAPSTA) && defined(ISAM_PREINIT)
        int bytes_written = 0;
 #endif
+       int retry;
 
        mutex_lock(&dhd->pub.ndev_op_sync);
 
@@ -6888,11 +6889,17 @@ dhd_open(struct net_device *net)
                return BCME_OK;
        }
 
-       if (!dhd_download_fw_on_driverload) {
-               if (!dhd_driver_init_done) {
+       for (retry = 0; ++retry; ) {
+               if (!dhd_download_fw_on_driverload && !dhd_driver_init_done) {
                        DHD_ERROR(("%s: WLAN driver is not initialized\n", __FUNCTION__));
-                       mutex_unlock(&dhd->pub.ndev_op_sync);
-                       return -1;
+                       if (retry > 3) {
+                               mutex_unlock(&dhd->pub.ndev_op_sync);
+                               return -1;
+                       } else {
+                               OSL_SLEEP(1000);
+                       }
+               } else {
+                       break;
                }
        }
 
index 0f0e403e8e00ac72965c4523f7e30b5f7232e169..a3f81cefb6c53372e0fd393c1205533fc3653adb 100644 (file)
@@ -7570,6 +7570,7 @@ dhd_open(struct net_device *net)
 #if defined(WL_EXT_IAPSTA) && defined(ISAM_PREINIT)
        int bytes_written = 0;
 #endif
+       int retry;
 
 #if defined(PREVENT_REOPEN_DURING_HANG)
        /* WAR : to prevent calling dhd_open abnormally in quick succession after hang event */
@@ -7604,10 +7605,18 @@ dhd_open(struct net_device *net)
                        return -1;
                }
 #endif /* WLAN_ACCEL_BOOT */
-               if (!dhd_driver_init_done) {
-                       DHD_ERROR(("%s: WLAN driver is not initialized\n", __FUNCTION__));
-                       mutex_unlock(&dhd->pub.ndev_op_sync);
-                       return -1;
+               for (retry_init = 0; ++retry_init; ) {
+                       if (!dhd_download_fw_on_driverload && !dhd_driver_init_done) {
+                               DHD_ERROR(("%s: WLAN driver is not initialized\n", __FUNCTION__));
+                               if (retry_init > 3) {
+                                       mutex_unlock(&dhd->pub.ndev_op_sync);
+                                       return -1;
+                               } else {
+                                       OSL_SLEEP(1000);
+                               }
+                       } else {
+                               break;
+                       }
                }
        }
 
index f2ab2832126a36cdf80424841e8ca0656b6ca7d9..732399c1a0122cd7bf774f9525b0e4bad4f6b58b 100755 (executable)
@@ -9177,6 +9177,7 @@ dhd_open(struct net_device *net)
        int bytes_written = 0;
 #endif
        int retry = POWERUP_MAX_RETRY;
+       int retry_init;
 
 #if defined(PREVENT_REOPEN_DURING_HANG)
        /* WAR : to prevent calling dhd_open abnormally in quick succession after hang event */
@@ -9223,10 +9224,18 @@ dhd_open(struct net_device *net)
                        dhd->wl_accel_force_reg_on = TRUE;
                }
 #endif /* WLAN_ACCEL_BOOT */
-               if (!dhd_driver_init_done) {
-                       DHD_ERROR(("%s: WLAN driver is not initialized\n", __FUNCTION__));
-                       mutex_unlock(&dhd->pub.ndev_op_sync);
-                       return -1;
+               for (retry_init = 0; ++retry_init; ) {
+                       if (!dhd_download_fw_on_driverload && !dhd_driver_init_done) {
+                               DHD_ERROR(("%s: WLAN driver is not initialized\n", __FUNCTION__));
+                               if (retry_init > 3) {
+                                       mutex_unlock(&dhd->pub.ndev_op_sync);
+                                       return -1;
+                               } else {
+                                       OSL_SLEEP(1000);
+                               }
+                       } else {
+                               break;
+                       }
                }
        }