Re: [PATCH v2 2/3] PM / DEVFREQ: add example governors

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



2011/5/18 Rafael J. Wysocki <rjw@xxxxxxx>:
> On Wednesday, May 11, 2011, MyungJoo Ham wrote:
>> Three CPUFREQ-like governors are provided as examples.
>>
>> powersave: use the lowest frequency possible. The user (device) should
>> set the polling_ms as 0 because polling is useless for this governor.
>>
>> performance: use the highest freqeuncy possible. The user (device)
>> should set the polling_ms as 0 because polling is useless for this
>> governor.
>>
>> simple_ondemand: simplified version of CPUFREQ's ONDEMAND governor.
>>
>> When a user updates OPP entries (enable/disable/add), OPP framework
>> automatically notifies DEVFREQ to update operating frequency
>> accordingly. Thus, DEVFREQ users (device drivers) do not need to update
>> DEVFREQ manually with OPP entry updates or set polling_ms for powersave
>> , performance, or any other "static" governors.
>
> Well, do you expect anyone to actually use them? ÂIf not, it would make
> more sense to put them into a doc.

According to our experiences of DVFS(although this "DEVFREQ" is not
applied to them, yet) in memory-bus and GPU,
I expect most DEVFREQ users might use "simple_ondemand" and
expect "powersave" and "performance" will probably mostly used while
testing and debugging.
("userspace"-like governor would be also useful for that purpose, but
I'd add it later)


Cheers!
- MyungJoo

>
> Thanks,
> Rafael
>
>
>> Signed-off-by: MyungJoo Ham <myungjoo.ham@xxxxxxxxxxx>
>> Signed-off-by: Kyungmin Park <kyungmin.park@xxxxxxxxxxx>
>> ---
>> Âdrivers/base/power/devfreq.c | Â 69 ++++++++++++++++++++++++++++++++++++++++++
>> Âinclude/linux/devfreq.h   Â|  Â5 +++
>> Â2 files changed, 74 insertions(+), 0 deletions(-)
>>
>> diff --git a/drivers/base/power/devfreq.c b/drivers/base/power/devfreq.c
>> index 8e2e45b..251d761 100644
>> --- a/drivers/base/power/devfreq.c
>> +++ b/drivers/base/power/devfreq.c
>> @@ -351,3 +351,72 @@ static int __init devfreq_init(void)
>> Â Â Â return 0;
>> Â}
>> Âlate_initcall(devfreq_init);
>> +
>> +static int devfreq_powersave_func(struct devfreq *df,
>> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â unsigned long *freq)
>> +{
>> + Â Â *freq = 0; /* devfreq_do will run "ceiling" to 0 */
>> + Â Â return 0;
>> +}
>> +
>> +struct devfreq_governor devfreq_powersave = {
>> + Â Â .get_target_freq = devfreq_powersave_func,
>> +};
>> +
>> +static int devfreq_performance_func(struct devfreq *df,
>> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â unsigned long *freq)
>> +{
>> + Â Â *freq = UINT_MAX; /* devfreq_do will run "floor" */
>> + Â Â return 0;
>> +}
>> +
>> +struct devfreq_governor devfreq_performance = {
>> + Â Â .get_target_freq = devfreq_performance_func,
>> +};
>> +
>> +/* Constants for DevFreq-Simple-Ondemand (DFSO) */
>> +#define DFSO_UPTHRESHOLD Â Â (90)
>> +#define DFSO_DOWNDIFFERENCTIAL Â Â Â (5)
>> +static int devfreq_simple_ondemand_func(struct devfreq *df,
>> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â unsigned long *freq)
>> +{
>> + Â Â struct devfreq_dev_status stat;
>> + Â Â int err = df->profile->get_dev_status(df->dev, &stat);
>> + Â Â unsigned long long a, b;
>> +
>> + Â Â if (err)
>> + Â Â Â Â Â Â return err;
>> +
>> + Â Â /* Set MAX if it's busy enough */
>> + Â Â if (stat.busy_time * 100 >
>> + Â Â Â Â stat.total_time * DFSO_UPTHRESHOLD) {
>> + Â Â Â Â Â Â *freq = UINT_MAX;
>> + Â Â Â Â Â Â return 0;
>> + Â Â }
>> +
>> + Â Â /* Set MAX if we do not know the initial frequency */
>> + Â Â if (stat.current_frequency == 0) {
>> + Â Â Â Â Â Â *freq = UINT_MAX;
>> + Â Â Â Â Â Â return 0;
>> + Â Â }
>> +
>> + Â Â /* Keep the current frequency */
>> + Â Â if (stat.busy_time * 100 >
>> + Â Â Â Â stat.total_time * (DFSO_UPTHRESHOLD - DFSO_DOWNDIFFERENCTIAL)) {
>> + Â Â Â Â Â Â *freq = stat.current_frequency;
>> + Â Â Â Â Â Â return 0;
>> + Â Â }
>> +
>> + Â Â /* Set the desired frequency based on the load */
>> + Â Â a = (unsigned long long) stat.busy_time * stat.current_frequency;
>> + Â Â b = div_u64(a, stat.total_time);
>> + Â Â b *= 100;
>> + Â Â b = div_u64(b, (DFSO_UPTHRESHOLD - DFSO_DOWNDIFFERENCTIAL / 2));
>> + Â Â *freq = (unsigned long) b;
>> +
>> + Â Â return 0;
>> +}
>> +
>> +struct devfreq_governor devfreq_simple_ondemand = {
>> + Â Â .get_target_freq = devfreq_simple_ondemand_func,
>> +};
>> diff --git a/include/linux/devfreq.h b/include/linux/devfreq.h
>> index d08e9f5..ec41ba6 100644
>> --- a/include/linux/devfreq.h
>> +++ b/include/linux/devfreq.h
>> @@ -81,6 +81,11 @@ extern int devfreq_add_device(struct device *dev,
>> Âextern int devfreq_remove_device(struct device *dev);
>> Âextern int devfreq_update(struct device *dev, bool may_not_exist);
>> Âextern int devfreq_tickle_device(struct device *dev, unsigned long duration_ms);
>> +
>> +extern struct devfreq_governor devfreq_powersave;
>> +extern struct devfreq_governor devfreq_performance;
>> +extern struct devfreq_governor devfreq_simple_ondemand;
>> +
>> Â#else /* !CONFIG_PM_DEVFREQ */
>> Âstatic int devfreq_add_device(struct device *dev,
>> Â Â Â Â Â Â Â Â Â Â Â Â Âstruct devfreq_dev_profile *profile,
>>
>
>



-- 
MyungJoo Ham (íëì), Ph.D.
Mobile Software Platform Lab,
Digital Media and Communications (DMC) Business
Samsung Electronics
cell: 82-10-6714-2858
_______________________________________________
linux-pm mailing list
linux-pm@xxxxxxxxxxxxxxxxxxxxxxxxxx
https://lists.linux-foundation.org/mailman/listinfo/linux-pm



[Index of Archives]     [Linux ACPI]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [CPU Freq]     [Kernel Newbies]     [Fedora Kernel]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux