Ver Fonte

qcacmn: Export API to change delay for RTPM timeout

Store ini config delay value and current delay value in RTPM
context
Export API to update delay and get current delay in ms for RTPM
timeout.
Export API to restore delay to default value.

Change-Id: I53e9e17d983c2cc6fe317159c8c46d792e56c04e
CRs-Fixed: 3332132
Ananya Gupta há 2 anos atrás
pai
commit
f1f6845bfb
3 ficheiros alterados com 87 adições e 2 exclusões
  1. 32 0
      hif/inc/hif.h
  2. 37 2
      hif/src/hif_runtime_pm.c
  3. 18 0
      hif/src/hif_runtime_pm.h

+ 32 - 0
hif/inc/hif.h

@@ -1296,6 +1296,28 @@ QDF_STATUS hif_rtpm_register(uint32_t id, void (*hif_rpm_cbk)(void));
  */
 QDF_STATUS hif_rtpm_deregister(uint32_t id);
 
+/**
+ * hif_rtpm_set_autosuspend_delay() - Set delay to trigger RTPM suspend
+ * @delay: delay in ms to be set
+ *
+ * Return: Success if delay is set successfully
+ */
+QDF_STATUS hif_rtpm_set_autosuspend_delay(int delay);
+
+/**
+ * hif_rtpm_restore_autosuspend_delay() - Restore delay value to default value
+ *
+ * Return: Success if reset done. E_ALREADY if delay same as config value
+ */
+QDF_STATUS hif_rtpm_restore_autosuspend_delay(void);
+
+/**
+ * hif_rtpm_get_autosuspend_delay() -Get delay to trigger RTPM suspend
+ *
+ * Return: Delay in ms
+ */
+int hif_rtpm_get_autosuspend_delay(void);
+
 /**
  * hif_runtime_lock_init() - API to initialize Runtime PM context
  * @lock: QDF lock context
@@ -1566,6 +1588,16 @@ static inline
 QDF_STATUS hif_rtpm_deregister(uint32_t id)
 { return QDF_STATUS_SUCCESS; }
 
+static inline
+QDF_STATUS hif_rtpm_set_autosuspend_delay(int delay)
+{ return QDF_STATUS_SUCCESS; }
+
+static inline QDF_STATUS hif_rtpm_restore_autosuspend_delay(void)
+{ return QDF_STATUS_SUCCESS; }
+
+static inline int hif_rtpm_get_autosuspend_delay(void)
+{ return 0; }
+
 static inline
 int hif_runtime_lock_init(qdf_runtime_lock_t *lock, const char *name)
 { return 0; }

+ 37 - 2
hif/src/hif_runtime_pm.c

@@ -374,6 +374,8 @@ void hif_rtpm_start(struct hif_softc *scn)
 
 	qdf_atomic_set(&gp_hif_rtpm_ctx->pm_state, HIF_RTPM_STATE_ON);
 	hif_rtpm_init(gp_hif_rtpm_ctx->dev, scn->hif_config.runtime_pm_delay);
+	gp_hif_rtpm_ctx->cfg_delay = scn->hif_config.runtime_pm_delay;
+	gp_hif_rtpm_ctx->delay = gp_hif_rtpm_ctx->cfg_delay;
 	hif_rtpm_debugfs_create();
 }
 
@@ -459,6 +461,41 @@ QDF_STATUS hif_rtpm_deregister(uint32_t id)
 	return QDF_STATUS_SUCCESS;
 }
 
+QDF_STATUS hif_rtpm_set_autosuspend_delay(int delay)
+{
+	if (delay < HIF_RTPM_DELAY_MIN || delay > HIF_RTPM_DELAY_MAX) {
+		hif_err("Invalid delay value %d ms", delay);
+		return QDF_STATUS_E_INVAL;
+	}
+
+	__hif_rtpm_set_autosuspend_delay(gp_hif_rtpm_ctx->dev, delay);
+	gp_hif_rtpm_ctx->delay = delay;
+	hif_info_high("RTPM delay set: %d ms", delay);
+
+	return QDF_STATUS_SUCCESS;
+}
+
+QDF_STATUS hif_rtpm_restore_autosuspend_delay(void)
+{
+	if (gp_hif_rtpm_ctx->delay == gp_hif_rtpm_ctx->cfg_delay) {
+		hif_info_rl("RTPM delay already default: %d",
+			    gp_hif_rtpm_ctx->delay);
+		return QDF_STATUS_E_ALREADY;
+	}
+
+	__hif_rtpm_set_autosuspend_delay(gp_hif_rtpm_ctx->dev,
+					 gp_hif_rtpm_ctx->cfg_delay);
+	gp_hif_rtpm_ctx->delay = gp_hif_rtpm_ctx->cfg_delay;
+	hif_info_rl("RTPM delay set: %d ms", gp_hif_rtpm_ctx->delay);
+
+	return QDF_STATUS_SUCCESS;
+}
+
+int hif_rtpm_get_autosuspend_delay(void)
+{
+	return gp_hif_rtpm_ctx->delay;
+}
+
 int hif_runtime_lock_init(qdf_runtime_lock_t *lock, const char *name)
 {
 	struct hif_pm_runtime_lock *context;
@@ -657,7 +694,6 @@ QDF_STATUS hif_rtpm_put(uint8_t type, uint32_t id)
 	gp_hif_rtpm_ctx->stats.last_busy_ts = client->put_ts;
 
 	return QDF_STATUS_SUCCESS;
-
 }
 
 /**
@@ -739,7 +775,6 @@ static int __hif_pm_runtime_allow_suspend(struct hif_pm_runtime_lock *lock)
 	return ret;
 }
 
-
 int hif_pm_runtime_prevent_suspend(struct hif_pm_runtime_lock *lock)
 {
 	if (!hif_rtpm_enabled() || !lock)

+ 18 - 0
hif/src/hif_runtime_pm.h

@@ -118,8 +118,13 @@ struct hif_rtpm_ctx {
 	qdf_atomic_t monitor_wake_intr;
 	struct hif_rtpm_state_stats stats;
 	struct dentry *pm_dentry;
+	int cfg_delay;
+	int delay;
 };
 
+#define HIF_RTPM_DELAY_MIN 100
+#define HIF_RTPM_DELAY_MAX 10000
+
 /**
  * __hif_rtpm_enabled() - Check if runtime pm is enabled from kernel
  * @dev: device structure
@@ -204,6 +209,19 @@ static inline int __hif_rtpm_put_sync_suspend(struct device *dev)
 	return pm_runtime_put_sync_suspend(dev);
 }
 
+/**
+ * __hif_rtpm_set_autosuspend_delay() - Set delay to trigger RTPM suspend
+ * @dev: device structure
+ * @delay: delay in ms to be set
+ *
+ * Return: None
+ */
+static inline
+void __hif_rtpm_set_autosuspend_delay(struct device *dev, int delay)
+{
+	pm_runtime_set_autosuspend_delay(dev, delay);
+}
+
 /**
  * __hif_rtpm_mark_last_busy() - Mark last busy timestamp
  * @dev: device structure