From 85aab3c8626a8fef552b726dfdc93f451207c836 Mon Sep 17 00:00:00 2001 From: kszaq Date: Thu, 5 Oct 2017 22:04:11 +0200 Subject: [PATCH] bcmdhd: if driver is not yet initialized, wait and retry Change-Id: Ic2970c5f34d2b3e351919db206c7beac31731b08 --- bcmdhd.100.10.545.x/dhd_linux.c | 15 +++++++++++---- bcmdhd.101.10.240.x/dhd_linux.c | 17 +++++++++++++---- bcmdhd.101.10.361.x/dhd_linux.c | 17 +++++++++++++---- 3 files changed, 37 insertions(+), 12 deletions(-) diff --git a/bcmdhd.100.10.545.x/dhd_linux.c b/bcmdhd.100.10.545.x/dhd_linux.c index 8eae191..89583f5 100644 --- a/bcmdhd.100.10.545.x/dhd_linux.c +++ b/bcmdhd.100.10.545.x/dhd_linux.c @@ -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; } } diff --git a/bcmdhd.101.10.240.x/dhd_linux.c b/bcmdhd.101.10.240.x/dhd_linux.c index b27c232..42ea79c 100644 --- a/bcmdhd.101.10.240.x/dhd_linux.c +++ b/bcmdhd.101.10.240.x/dhd_linux.c @@ -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; + } } } diff --git a/bcmdhd.101.10.361.x/dhd_linux.c b/bcmdhd.101.10.361.x/dhd_linux.c index a4289c0..5323f4f 100755 --- a/bcmdhd.101.10.361.x/dhd_linux.c +++ b/bcmdhd.101.10.361.x/dhd_linux.c @@ -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; + } } } -- 2.20.1