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:27:42 +0000 (01:27 +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 8eae191333024adeefe6b65fdfe33c155355ebeb..89583f50fc52a1e09e495baaa3671b8d9251cc2e 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 b27c232cb94587ce03a9fdcb4b02ca9ddf7d4eda..42ea79ce9efb33235917fdc6763f3d65872f8fb4 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 a4289c0db8e3401f695ee061e17a0707f6091b66..5323f4f0f061d6d47cd3aebbb93c0abdf79c60bc 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;
+                       }
                }
        }