Add devfreq suspend/resume apis for devfreq users. This patch supports suspend and resume of devfreq load monitoring, required for devices which can idle.
Signed-off-by: Rajagopal Venkat rajagopal.venkat@linaro.org
Rather than letting device driver be responsible to call devfreq_suspend_device() or devfreq_dev_suspend(),would there be any problems in using pm notifier here? (calling the event handler with DEVFREQ_GOV_SUSPEND/RESUME at pm notifier, stopping them earlier and resuming tham later)
What devfreq-core and devfreq-governors do with suspend/resume is handling the delayed workqueue and it does not have anything to do with device-specific tasks. Thus, having each device driver handle device-specifics with its own pm_ops and having devfreq-core stop sampling seem appropriate.
Putting another burden to each device driver (to call devfreq_suspend/resume_device() at its pm_ops) for an obvious task that could be done at core doesn't seem fair.
Thank you.
Cheers! MyungJoo
drivers/devfreq/devfreq.c | 26 ++++++++++++++++++++++++++ drivers/devfreq/governor.h | 2 ++ drivers/devfreq/governor_simpleondemand.c | 9 +++++++++ include/linux/devfreq.h | 12 ++++++++++++ 4 files changed, 49 insertions(+)
diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c index be524c7..3a5f126 100644 --- a/drivers/devfreq/devfreq.c +++ b/drivers/devfreq/devfreq.c @@ -365,6 +365,32 @@ int devfreq_remove_device(struct devfreq *devfreq) } EXPORT_SYMBOL(devfreq_remove_device); +/**
- devfreq_suspend_device() - Suspend devfreq of a device.
- @devfreq the devfreq instance to be suspended
- */
+int devfreq_suspend_device(struct devfreq *devfreq) +{
- if (!devfreq)
return -EINVAL;
- return devfreq->governor->event_handler(devfreq, DEVFREQ_GOV_SUSPEND);
+} +EXPORT_SYMBOL(devfreq_suspend_device);
+/**
- devfreq_resume_device() - Resume devfreq of a device.
- @devfreq the devfreq instance to be resumed
- */
+int devfreq_resume_device(struct devfreq *devfreq) +{
- if (!devfreq)
return -EINVAL;
- return devfreq->governor->event_handler(devfreq, DEVFREQ_GOV_RESUME);
+} +EXPORT_SYMBOL(devfreq_resume_device);
static ssize_t show_governor(struct device *dev, struct device_attribute *attr, char *buf) { diff --git a/drivers/devfreq/governor.h b/drivers/devfreq/governor.h index 4a86af7..7dbbdfc 100644 --- a/drivers/devfreq/governor.h +++ b/drivers/devfreq/governor.h @@ -22,6 +22,8 @@ #define DEVFREQ_GOV_START 0x1 #define DEVFREQ_GOV_STOP 0x2 #define DEVFREQ_GOV_INTERVAL 0x3 +#define DEVFREQ_GOV_SUSPEND 0x4 +#define DEVFREQ_GOV_RESUME 0x5 /* Caution: devfreq->lock must be locked before calling update_devfreq */ extern int update_devfreq(struct devfreq *devfreq); diff --git a/drivers/devfreq/governor_simpleondemand.c b/drivers/devfreq/governor_simpleondemand.c index 9802bf9..35b8e8e 100644 --- a/drivers/devfreq/governor_simpleondemand.c +++ b/drivers/devfreq/governor_simpleondemand.c @@ -113,6 +113,15 @@ int devfreq_simple_ondemand_handler(struct devfreq *devfreq, else ret = devfreq_monitor_resume(devfreq); break;
- case DEVFREQ_GOV_SUSPEND:
ret = devfreq_monitor_suspend(devfreq);
break;
- case DEVFREQ_GOV_RESUME:
ret = devfreq_monitor_resume(devfreq);
break;
- default: break; }
diff --git a/include/linux/devfreq.h b/include/linux/devfreq.h index 7a11c3e..7c7e179 100644 --- a/include/linux/devfreq.h +++ b/include/linux/devfreq.h @@ -155,6 +155,8 @@ extern struct devfreq *devfreq_add_device(struct device *dev, const struct devfreq_governor *governor, void *data); extern int devfreq_remove_device(struct devfreq *devfreq); +extern int devfreq_suspend_device(struct devfreq *devfreq); +extern int devfreq_resume_device(struct devfreq *devfreq); /* Helper functions for devfreq user device driver with OPP. */ extern struct opp *devfreq_recommended_opp(struct device *dev, @@ -208,6 +210,16 @@ static int devfreq_remove_device(struct devfreq *devfreq) return 0; } +static int devfreq_suspend_device(struct devfreq *devfreq) +{
- return 0;
+}
+static int devfreq_resume_device(struct devfreq *devfreq) +{
- return 0;
+}
static struct opp *devfreq_recommended_opp(struct device *dev, unsigned long *freq, u32 flags) { -- 1.7.11.3