Эх сурвалжийг харах

qcacmn: Cleanup and refine runtime PM open/close logic

Runtime PM code has been refactoring multiple times so some open/close
logic may be duplicated and messed up. Cleanup and refine the logic.
In other to align both runtime PM enable and disable cases, make sure
default usage count is always 2 and sanitize the same when runtime PM
exit. hif_pm_runtime_stop() should always happen from HDD disable power
management APIs so clean it up from hif_pm_runtime_close().

Change-Id: I3b64369608c2d9aa4b3353503c12e0d05a57b592
CRs-fixed: 2666196
Yue Ma 5 жил өмнө
parent
commit
c81a71e488
1 өөрчлөгдсөн 11 нэмэгдсэн , 14 устгасан
  1. 11 14
      hif/src/pcie/if_pci.c

+ 11 - 14
hif/src/pcie/if_pci.c

@@ -1178,6 +1178,8 @@ static void hif_runtime_exit(struct device *dev)
 {
 	pm_runtime_get_noresume(dev);
 	pm_runtime_set_active(dev);
+	/* Symmetric call to make sure default usage count == 2 */
+	pm_runtime_forbid(dev);
 }
 
 static void hif_pm_runtime_lock_timeout_fn(void *data);
@@ -1244,7 +1246,6 @@ static void hif_pm_runtime_stop(struct hif_pci_softc *sc)
 
 	hif_runtime_pm_debugfs_remove(sc);
 	qdf_timer_free(&sc->runtime_timer);
-	/* doesn't wait for penting trafic unlike cld-2.0 */
 }
 
 /**
@@ -1288,8 +1289,8 @@ static void hif_pm_runtime_sanitize_on_exit(struct hif_pci_softc *sc)
 {
 	struct hif_pm_runtime_lock *ctx, *tmp;
 
-	if (atomic_read(&sc->dev->power.usage_count) != 1)
-		hif_pci_runtime_pm_warn(sc, "Driver UnLoaded");
+	if (atomic_read(&sc->dev->power.usage_count) != 2)
+		hif_pci_runtime_pm_warn(sc, "Driver Module Closing");
 	else
 		return;
 
@@ -1301,14 +1302,14 @@ static void hif_pm_runtime_sanitize_on_exit(struct hif_pci_softc *sc)
 	}
 	spin_unlock_bh(&sc->runtime_lock);
 
-	/* ensure 1 and only 1 usage count so that when the wlan
-	 * driver is re-insmodded runtime pm won't be
-	 * disabled also ensures runtime pm doesn't get
-	 * broken on by being less than 1.
+	/* Since default usage count is 2 so ensure 2 and only 2 usage count
+	 * when exit so that when the WLAN driver module is re-enabled runtime
+	 * PM won't be disabled also ensures runtime PM doesn't get broken on
+	 * by being less than 2.
 	 */
-	if (atomic_read(&sc->dev->power.usage_count) <= 0)
-		atomic_set(&sc->dev->power.usage_count, 1);
-	while (atomic_read(&sc->dev->power.usage_count) > 1)
+	if (atomic_read(&sc->dev->power.usage_count) <= 1)
+		atomic_set(&sc->dev->power.usage_count, 2);
+	while (atomic_read(&sc->dev->power.usage_count) > 2)
 		hif_pm_runtime_put_auto(sc->dev);
 }
 
@@ -1345,10 +1346,6 @@ static void hif_pm_runtime_close(struct hif_pci_softc *sc)
 	struct hif_softc *scn = HIF_GET_SOFTC(sc);
 
 	qdf_runtime_lock_deinit(&sc->prevent_linkdown_lock);
-	if (qdf_atomic_read(&sc->pm_state) == HIF_PM_RUNTIME_STATE_NONE)
-		return;
-
-	hif_pm_runtime_stop(sc);
 
 	hif_is_recovery_in_progress(scn) ?
 		hif_pm_runtime_sanitize_on_ssr_exit(sc) :