]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
PM / devfreq: add devfreq_suspend/resume() functions
authorLukasz Luba <l.luba@partner.samsung.com>
Wed, 5 Dec 2018 11:05:54 +0000 (12:05 +0100)
committerMyungJoo Ham <myungjoo.ham@samsung.com>
Tue, 11 Dec 2018 02:40:13 +0000 (11:40 +0900)
This patch adds implementation for global suspend/resume for
devfreq framework. System suspend will next use these functions.

Suggested-by: Tobias Jakobi <tjakobi@math.uni-bielefeld.de>
Suggested-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Lukasz Luba <l.luba@partner.samsung.com>
Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
drivers/devfreq/devfreq.c
include/linux/devfreq.h

index 46517b61b3a2ab64c04ace580691b866a5879282..0ae3de76833b7da0c16f01ca79e482ec66217594 100644 (file)
@@ -934,6 +934,50 @@ int devfreq_resume_device(struct devfreq *devfreq)
 }
 EXPORT_SYMBOL(devfreq_resume_device);
 
+/**
+ * devfreq_suspend() - Suspend devfreq governors and devices
+ *
+ * Called during system wide Suspend/Hibernate cycles for suspending governors
+ * and devices preserving the state for resume. On some platforms the devfreq
+ * device must have precise state (frequency) after resume in order to provide
+ * fully operating setup.
+ */
+void devfreq_suspend(void)
+{
+       struct devfreq *devfreq;
+       int ret;
+
+       mutex_lock(&devfreq_list_lock);
+       list_for_each_entry(devfreq, &devfreq_list, node) {
+               ret = devfreq_suspend_device(devfreq);
+               if (ret)
+                       dev_err(&devfreq->dev,
+                               "failed to suspend devfreq device\n");
+       }
+       mutex_unlock(&devfreq_list_lock);
+}
+
+/**
+ * devfreq_resume() - Resume devfreq governors and devices
+ *
+ * Called during system wide Suspend/Hibernate cycle for resuming governors and
+ * devices that are suspended with devfreq_suspend().
+ */
+void devfreq_resume(void)
+{
+       struct devfreq *devfreq;
+       int ret;
+
+       mutex_lock(&devfreq_list_lock);
+       list_for_each_entry(devfreq, &devfreq_list, node) {
+               ret = devfreq_resume_device(devfreq);
+               if (ret)
+                       dev_warn(&devfreq->dev,
+                                "failed to resume devfreq device\n");
+       }
+       mutex_unlock(&devfreq_list_lock);
+}
+
 /**
  * devfreq_add_governor() - Add devfreq governor
  * @governor:  the devfreq governor to be added
index d985199969279cad16f6fcdb8a47f18c83ffd56f..fbffa74bfc1bb94c5099a21f438da2c95f251a5e 100644 (file)
@@ -205,6 +205,9 @@ extern void devm_devfreq_remove_device(struct device *dev,
 extern int devfreq_suspend_device(struct devfreq *devfreq);
 extern int devfreq_resume_device(struct devfreq *devfreq);
 
+extern void devfreq_suspend(void);
+extern void devfreq_resume(void);
+
 /**
  * update_devfreq() - Reevaluate the device and configure frequency
  * @devfreq:   the devfreq device
@@ -331,6 +334,9 @@ static inline int devfreq_resume_device(struct devfreq *devfreq)
        return 0;
 }
 
+static inline void devfreq_suspend(void) {}
+static inline void devfreq_resume(void) {}
+
 static inline struct dev_pm_opp *devfreq_recommended_opp(struct device *dev,
                                           unsigned long *freq, u32 flags)
 {