@@ -124,4 +124,12 @@ static inline int devfreq_update_stats(struct devfreq *df)
return df->profile->get_dev_status(df->dev.parent, &df->last_status);
}
+
+static inline int devfreq_update_dev(struct devfreq *df, void *data)
+{
+ if (!df->profile->update)
+ return -EINVAL;
+
+ return df->profile->update(df->dev.parent, data);
+}
#endif /* _GOVERNOR_H */
@@ -92,6 +92,8 @@ struct devfreq_dev_status {
* devfreq.last_status.
* @get_cur_freq: The device should provide the current frequency
* at which it is operating.
+ * @update: An optional function to allow governors send data back
+ * to the devfreq driver to update the device settings.
* @exit: An optional callback that is called when devfreq
* is removing the devfreq object due to error or
* from devfreq_remove_device() call. If the user
@@ -114,6 +116,7 @@ struct devfreq_dev_profile {
int (*get_dev_status)(struct device *dev,
struct devfreq_dev_status *stat);
int (*get_cur_freq)(struct device *dev, unsigned long *freq);
+ int (*update)(struct device *dev, void *data);
void (*exit)(struct device *dev);
unsigned long *freq_table;
@@ -451,6 +454,11 @@ static inline int devfreq_update_stats(struct devfreq *df)
{
return -EINVAL;
}
+
+static inline int devfreq_update_dev(struct devfreq *df)
+{
+ return -EINVAL;
+}
#endif /* CONFIG_PM_DEVFREQ */
#endif /* __LINUX_DEVFREQ_H__ */
To realize interrupt-driven closed-loop governors, governors need to be able to send data to the underlying devfreq driver to ask for updating the device settings, such as hardware registers for frequency limits. Since governors might export several tunable parameters, users can enforce different policies for the control logics. Under different policies, governors need to send different information to inform the devfreq driver to configure the device accordingly. The introduced update function improves the flexibility of governors and acts as a communication interface between governors and devfreq drivers. Signed-off-by: Johnny Liu <johnliu@nvidia.com> --- drivers/devfreq/governor.h | 8 ++++++++ include/linux/devfreq.h | 8 ++++++++ 2 files changed, 16 insertions(+) -- 2.17.1