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

Commit d01b1f48 authored by Kristen Carlson Accardi's avatar Kristen Carlson Accardi Committed by Rafael J. Wysocki
Browse files

intel_pstate: expose turbo range to sysfs



This patch adds "turbo_pct" to the intel_pstate sysfs interface.
turbo_pct will display the percentage of the total supported
pstates that are in the turbo range.  This value is independent
of whether turbo has been disabled or not.

Signed-off-by: default avatarKristen Carlson Accardi <kristen@linux.intel.com>
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent 7ab0256e
Loading
Loading
Loading
Loading
+4 −0
Original line number Original line Diff line number Diff line
@@ -37,6 +37,10 @@ controlling P state selection. These files have been added to
      no_turbo: limits the driver to selecting P states below the turbo
      no_turbo: limits the driver to selecting P states below the turbo
      frequency range.
      frequency range.


      turbo_pct: displays the percentage of the total performance that
      is supported by hardware that is in the turbo range.  This number
      is independent of whether turbo has been disabled or not.

For contemporary Intel processors, the frequency is controlled by the
For contemporary Intel processors, the frequency is controlled by the
processor itself and the P-states exposed to software are related to
processor itself and the P-states exposed to software are related to
performance levels.  The idea that frequency can be set to a single
performance levels.  The idea that frequency can be set to a single
+18 −0
Original line number Original line Diff line number Diff line
@@ -338,6 +338,22 @@ static void __init intel_pstate_debug_expose_params(void)
		return sprintf(buf, "%u\n", limits.object);		\
		return sprintf(buf, "%u\n", limits.object);		\
	}
	}


static ssize_t show_turbo_pct(struct kobject *kobj,
				struct attribute *attr, char *buf)
{
	struct cpudata *cpu;
	int total, no_turbo, turbo_pct;
	uint32_t turbo_fp;

	cpu = all_cpu_data[0];

	total = cpu->pstate.turbo_pstate - cpu->pstate.min_pstate + 1;
	no_turbo = cpu->pstate.max_pstate - cpu->pstate.min_pstate + 1;
	turbo_fp = div_fp(int_tofp(no_turbo), int_tofp(total));
	turbo_pct = 100 - fp_toint(mul_fp(turbo_fp, int_tofp(100)));
	return sprintf(buf, "%u\n", turbo_pct);
}

static ssize_t show_no_turbo(struct kobject *kobj,
static ssize_t show_no_turbo(struct kobject *kobj,
			     struct attribute *attr, char *buf)
			     struct attribute *attr, char *buf)
{
{
@@ -418,11 +434,13 @@ show_one(min_perf_pct, min_perf_pct);
define_one_global_rw(no_turbo);
define_one_global_rw(no_turbo);
define_one_global_rw(max_perf_pct);
define_one_global_rw(max_perf_pct);
define_one_global_rw(min_perf_pct);
define_one_global_rw(min_perf_pct);
define_one_global_ro(turbo_pct);


static struct attribute *intel_pstate_attributes[] = {
static struct attribute *intel_pstate_attributes[] = {
	&no_turbo.attr,
	&no_turbo.attr,
	&max_perf_pct.attr,
	&max_perf_pct.attr,
	&min_perf_pct.attr,
	&min_perf_pct.attr,
	&turbo_pct.attr,
	NULL
	NULL
};
};