Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ed62d901 authored by Sahitya Tummala's avatar Sahitya Tummala
Browse files

PM / devfreq: Add new flag to do simple clock scaling



Add new flag "simple_scaling" to on demand governor so that
the clocks can be scaled up only when the load is more than
up threshold and can be scaled down only when the load is less
than down differential data as provided within
struct devfreq_simple_ondemand_data.

Change-Id: Ibc6ab6297c1b64b6e6eaaa76d735d0b9ae0f6477
Signed-off-by: default avatarSahitya Tummala <stummala@codeaurora.org>
parent 2f8fb2e9
Loading
Loading
Loading
Loading
+19 −6
Original line number Original line Diff line number Diff line
@@ -29,6 +29,7 @@ static int devfreq_simple_ondemand_func(struct devfreq *df,
	unsigned int dfso_downdifferential = DFSO_DOWNDIFFERENCTIAL;
	unsigned int dfso_downdifferential = DFSO_DOWNDIFFERENCTIAL;
	struct devfreq_simple_ondemand_data *data = df->data;
	struct devfreq_simple_ondemand_data *data = df->data;
	unsigned long max = (df->max_freq) ? df->max_freq : UINT_MAX;
	unsigned long max = (df->max_freq) ? df->max_freq : UINT_MAX;
	unsigned long min = (df->min_freq) ? df->min_freq : 0;


	if (err)
	if (err)
		return err;
		return err;
@@ -43,18 +44,30 @@ static int devfreq_simple_ondemand_func(struct devfreq *df,
	    dfso_upthreshold < dfso_downdifferential)
	    dfso_upthreshold < dfso_downdifferential)
		return -EINVAL;
		return -EINVAL;


	/* Assume MAX if it is going to be divided by zero */
	if (stat.total_time == 0) {
		*freq = max;
		return 0;
	}

	/* Prevent overflow */
	/* Prevent overflow */
	if (stat.busy_time >= (1 << 24) || stat.total_time >= (1 << 24)) {
	if (stat.busy_time >= (1 << 24) || stat.total_time >= (1 << 24)) {
		stat.busy_time >>= 7;
		stat.busy_time >>= 7;
		stat.total_time >>= 7;
		stat.total_time >>= 7;
	}
	}


	if (data && data->simple_scaling) {
		if (stat.busy_time * 100 >
		    stat.total_time * dfso_upthreshold)
			*freq = max;
		else if (stat.busy_time * 100 <
		    stat.total_time * dfso_downdifferential)
			*freq = min;
		else
			*freq = df->previous_freq;
		return 0;
	}

	/* Assume MAX if it is going to be divided by zero */
	if (stat.total_time == 0) {
		*freq = max;
		return 0;
	}

	/* Set MAX if it's busy enough */
	/* Set MAX if it's busy enough */
	if (stat.busy_time * 100 >
	if (stat.busy_time * 100 >
	    stat.total_time * dfso_upthreshold) {
	    stat.total_time * dfso_upthreshold) {
+4 −0
Original line number Original line Diff line number Diff line
@@ -228,6 +228,9 @@ extern int devfreq_unregister_opp_notifier(struct device *dev,
 *			the governor may consider slowing the frequency down.
 *			the governor may consider slowing the frequency down.
 *			Specify 0 to use the default. Valid value = 0 to 100.
 *			Specify 0 to use the default. Valid value = 0 to 100.
 *			downdifferential < upthreshold must hold.
 *			downdifferential < upthreshold must hold.
 * @simple_scaling:	Setting this flag will scale the clocks up only if the
 *			load is above @upthreshold and will scale the clocks
 *			down only if the load is below @downdifferential.
 *
 *
 * If the fed devfreq_simple_ondemand_data pointer is NULL to the governor,
 * If the fed devfreq_simple_ondemand_data pointer is NULL to the governor,
 * the governor uses the default values.
 * the governor uses the default values.
@@ -235,6 +238,7 @@ extern int devfreq_unregister_opp_notifier(struct device *dev,
struct devfreq_simple_ondemand_data {
struct devfreq_simple_ondemand_data {
	unsigned int upthreshold;
	unsigned int upthreshold;
	unsigned int downdifferential;
	unsigned int downdifferential;
	unsigned int simple_scaling;
};
};
#endif
#endif