From ba035ec95336d794ca0285fe3abdf187806eecdd Mon Sep 17 00:00:00 2001 From: Will Huang Date: Thu, 5 Jul 2018 11:13:30 +0800 Subject: [PATCH] qcacld-3.0: Fix deadlock of rmmod and wlan start module On cnss2 platform, the cnss callbacks in wlan driver are called with serialization, and in wlan driver stop module and start module has mutex of iface_change_lock, it might hit deadlock if race condition happen of rmmod and start module, because start module might call pld_power_on for this case. Fix by setting unload flag earlier in __hdd_module_exit which in different context of cnss serialized work queue, it prevents new interface open at this point and wait for external thread complete after it, it close race window before call wlan_hdd_pld_remove. Change-Id: I8eb3740701070428c59f1fe3e8d2f439d9173413 CRs-Fixed: 2265691 --- core/hdd/src/wlan_hdd_main.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/core/hdd/src/wlan_hdd_main.c b/core/hdd/src/wlan_hdd_main.c index 1ab42d63df82..590aee1005ec 100644 --- a/core/hdd/src/wlan_hdd_main.c +++ b/core/hdd/src/wlan_hdd_main.c @@ -12403,6 +12403,13 @@ static void __hdd_module_exit(void) if (!hdd_wait_for_recovery_completion()) return; + cds_set_driver_loaded(false); + cds_set_unload_in_progress(true); + + if (!cds_wait_for_external_threads_completion(__func__)) + hdd_warn("External threads are still active attempting " + "driver unload anyway"); + if (hdd_ctx) qdf_cancel_delayed_work(&hdd_ctx->iface_idle_work);