Browse Source

qcacmn: Do not request runtime PM resume for system resume

Firmware will trigger WAKE MSI for both runtime PM and system
resume. There is no need to request runtime PM resume again if
it is a system resume. Check the flags to avoid doing so.

Change-Id: I70bdfadf1d7c0ffd4e2849458c6aee6931037cd3
CRs-fixed: 2479631
Yue Ma 5 years ago
parent
commit
fab77ad949
4 changed files with 68 additions and 1 deletions
  1. 12 0
      hif/inc/hif.h
  2. 5 1
      hif/src/hif_main.c
  3. 50 0
      hif/src/pcie/if_pci.c
  4. 1 0
      hif/src/pcie/if_pci.h

+ 12 - 0
hif/inc/hif.h

@@ -864,6 +864,10 @@ int hif_pm_runtime_allow_suspend(struct hif_opaque_softc *ol_sc,
 		struct hif_pm_runtime_lock *lock);
 int hif_pm_runtime_prevent_suspend_timeout(struct hif_opaque_softc *ol_sc,
 		struct hif_pm_runtime_lock *lock, unsigned int delay);
+bool hif_pm_runtime_is_suspended(struct hif_opaque_softc *hif_ctx);
+int hif_pm_runtime_get_monitor_wake_intr(struct hif_opaque_softc *hif_ctx);
+void hif_pm_runtime_set_monitor_wake_intr(struct hif_opaque_softc *hif_ctx,
+					  int val);
 #else
 struct hif_pm_runtime_lock {
 	const char *name;
@@ -898,6 +902,14 @@ static inline int
 hif_pm_runtime_prevent_suspend_timeout(struct hif_opaque_softc *ol_sc,
 		struct hif_pm_runtime_lock *lock, unsigned int delay)
 { return 0; }
+static inline bool hif_pm_runtime_is_suspended(struct hif_opaque_softc *hif_ctx)
+{ return false; }
+static inline int
+hif_pm_runtime_get_monitor_wake_intr(struct hif_opaque_softc *hif_ctx)
+{ return 0; }
+static inline void
+hif_pm_runtime_set_monitor_wake_intr(struct hif_opaque_softc *hif_ctx, int val)
+{ return; }
 #endif
 
 void hif_enable_power_management(struct hif_opaque_softc *hif_ctx,

+ 5 - 1
hif/src/hif_main.c

@@ -1275,7 +1275,11 @@ irqreturn_t hif_wake_interrupt_handler(int irq, void *context)
 	if (scn->initial_wakeup_cb)
 		scn->initial_wakeup_cb(scn->initial_wakeup_priv);
 
-	hif_pm_runtime_request_resume(hif_ctx);
+	if (hif_pm_runtime_get_monitor_wake_intr(hif_ctx) &&
+	    hif_pm_runtime_is_suspended(hif_ctx)) {
+		hif_pm_runtime_set_monitor_wake_intr(hif_ctx, 0);
+		hif_pm_runtime_request_resume(hif_ctx);
+	}
 
 	return IRQ_HANDLED;
 }

+ 50 - 0
hif/src/pcie/if_pci.c

@@ -2799,6 +2799,7 @@ void hif_process_runtime_suspend_success(struct hif_opaque_softc *hif_ctx)
 	struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx);
 
 	hif_runtime_pm_set_state_suspended(scn);
+	hif_pm_runtime_set_monitor_wake_intr(hif_ctx, 1);
 	hif_log_runtime_suspend_success(scn);
 }
 
@@ -2811,6 +2812,7 @@ void hif_pre_runtime_resume(struct hif_opaque_softc *hif_ctx)
 {
 	struct hif_softc *scn = HIF_GET_SOFTC(hif_ctx);
 
+	hif_pm_runtime_set_monitor_wake_intr(hif_ctx, 0);
 	hif_runtime_pm_set_state_inprogress(scn);
 }
 
@@ -4358,6 +4360,54 @@ void hif_runtime_lock_deinit(struct hif_opaque_softc *hif_ctx,
 
 	qdf_mem_free(context);
 }
+
+/**
+ * hif_pm_runtime_is_suspended() - API to check if driver has runtime suspended
+ * @hif_ctx: HIF context
+ *
+ * Return: true for runtime suspended, otherwise false
+ */
+bool hif_pm_runtime_is_suspended(struct hif_opaque_softc *hif_ctx)
+{
+	struct hif_pci_softc *sc = HIF_GET_PCI_SOFTC(hif_ctx);
+
+	return qdf_atomic_read(&sc->pm_state) ==
+		HIF_PM_RUNTIME_STATE_SUSPENDED;
+}
+
+/**
+ * hif_pm_runtime_get_monitor_wake_intr() - API to get monitor_wake_intr
+ * @hif_ctx: HIF context
+ *
+ * monitor_wake_intr variable can be used to indicate if driver expects wake
+ * MSI for runtime PM
+ *
+ * Return: monitor_wake_intr variable
+ */
+int hif_pm_runtime_get_monitor_wake_intr(struct hif_opaque_softc *hif_ctx)
+{
+	struct hif_pci_softc *sc = HIF_GET_PCI_SOFTC(hif_ctx);
+
+	return qdf_atomic_read(&sc->monitor_wake_intr);
+}
+
+/**
+ * hif_pm_runtime_set_monitor_wake_intr() - API to set monitor_wake_intr
+ * @hif_ctx: HIF context
+ * @val: value to set
+ *
+ * monitor_wake_intr variable can be used to indicate if driver expects wake
+ * MSI for runtime PM
+ *
+ * Return: void
+ */
+void hif_pm_runtime_set_monitor_wake_intr(struct hif_opaque_softc *hif_ctx,
+					  int val)
+{
+	struct hif_pci_softc *sc = HIF_GET_PCI_SOFTC(hif_ctx);
+
+	qdf_atomic_set(&sc->monitor_wake_intr, val);
+}
 #endif /* FEATURE_RUNTIME_PM */
 
 int hif_pci_legacy_map_ce_to_irq(struct hif_softc *scn, int ce_id)

+ 1 - 0
hif/src/pcie/if_pci.h

@@ -130,6 +130,7 @@ struct hif_pci_softc {
 	uint32_t lcr_val;
 #ifdef FEATURE_RUNTIME_PM
 	atomic_t pm_state;
+	atomic_t monitor_wake_intr;
 	uint32_t prevent_suspend_cnt;
 	struct hif_pci_pm_stats pm_stats;
 	struct work_struct pm_work;