powercap/drivers/dtpm: Add CPU energy model based support
authorDaniel Lezcano <daniel.lezcano@linaro.org>
Tue, 8 Dec 2020 16:41:45 +0000 (17:41 +0100)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Tue, 22 Dec 2020 18:50:40 +0000 (19:50 +0100)
commit0e8f68d7f04856a9e2ad4817b477fa35124888bd
treed8cdbc56271ff22951954daef5adf7f970f85b12
parenta20d0ef97abf486a917aff066c457bdb930425af
powercap/drivers/dtpm: Add CPU energy model based support

With the powercap dtpm controller, we are able to plug devices with
power limitation features in the tree.

The following patch introduces the CPU power limitation based on the
energy model and the performance states.

The power limitation is done at the performance domain level. If some
CPUs are unplugged, the corresponding power will be subtracted from
the performance domain total power.

It is up to the platform to initialize the dtpm tree and add the CPU.

Here is an example to create a simple tree with one root node called
"pkg" and the CPU's performance domains.

static int dtpm_register_pkg(struct dtpm_descr *descr)
{
struct dtpm *pkg;
int ret;

pkg = dtpm_alloc(NULL);
if (!pkg)
return -ENOMEM;

ret = dtpm_register(descr->name, pkg, descr->parent);
if (ret)
return ret;

return dtpm_register_cpu(pkg);
}

static struct dtpm_descr descr = {
.name = "pkg",
.init = dtpm_register_pkg,
};
DTPM_DECLARE(descr);

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Reviewed-by: Lukasz Luba <lukasz.luba@arm.com>
Tested-by: Lukasz Luba <lukasz.luba@arm.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/powercap/Kconfig
drivers/powercap/Makefile
drivers/powercap/dtpm_cpu.c [new file with mode: 0644]
include/linux/cpuhotplug.h
include/linux/dtpm.h