powercap/drivers/dtpm: Export the symbols for the modules
Subsystems (2)
PATCH 1/2 powercap/drivers/dtpm: Export the symbols for the modules
The DTPM framework provides a generic API to register devices which power capable. The devices may be compiled as modules while the framework is not.
Export the necessary API to let the drivers register themselves.
--- drivers/powercap/dtpm.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/powercap/dtpm.c +8 -0
@@ -202,6 +202,7 @@ struct dtpm *dtpm_get(const char *name)return dtpm; } +EXPORT_SYMBOL_GPL (dtpm_get);static void dtpm_release (struct kref *kref) {
@@ -221,6 +222,7 @@ void dtpm_put(struct dtpm *dtpm) {kref_put (&dtpm->kref, dtpm_release); } +EXPORT_SYMBOL_GPL (dtpm_put);/** * dtpm_register - Register the dtpm in the dtpm list
@@ -266,6 +268,7 @@ int dtpm_register(const char *name, struct dtpm *dtpm)return ret; } +EXPORT_SYMBOL_GPL (dtpm_register);/** * dtpm_unregister - Remove the dtpm device from the list
@@ -295,6 +298,7 @@ void dtpm_unregister(const char *name)mutex_unlock (&dtpm_lock); } +EXPORT_SYMBOL_GPL (dtpm_unregister);/** * dtpm_update_power - Update the power on the dtpm
@@ -315,6 +319,7 @@ int dtpm_update_power(struct dtpm *dtpm)return ret; } +EXPORT_SYMBOL_GPL (dtpm_update_power);/** * dtpm_release_zone - Cleanup when the node is released
@@ -515,6 +520,7 @@ void dtpm_init(struct dtpm *dtpm, struct dtpm_ops *ops) dtpm->ops = ops; } } +EXPORT_SYMBOL_GPL (dtpm_init);/** * dtpm_destroy - Destroy a dtpm node from the hierarchy tree
@@ -530,6 +536,7 @@ void dtpm_destroy(struct dtpm *dtpm)pr_info ("Destroyed dtpm node '%s'\n" , dtpm->zone.name); } +EXPORT_SYMBOL_GPL (dtpm_destroy);/** * dtpm_create - Create a dtpm node in the hierarchy tree
@@ -604,6 +611,7 @@ int dtpm_create(const char *name, struct dtpm *dtpm, struct dtpm *parent)return 0 ; } +EXPORT_SYMBOL_GPL (dtpm_create);static int __init init_dtpm (void ) {
Signature · 1 line
2.17.1
PATCH 2/2 powercap/drivers/dtpm: Allow dtpm node device creation through configfs
The DTPM framework is built on top of the powercap framework as a new controller to act on the power of the devices. The approach is to provide an unified API to do power limitation on devices which are capable of that with different techniques.
In addition, the DTPM framework allows to create a hierarchical representation of the devices in order to reflect the dependencies of the power constraints we want to apply to a group of devices.
The hierarchy can be different for the same platform as it will depend on the form factor (tablet, notebook, phone, ...), on other components and/or a policy, and application scenario.
The kernel can not have such knowledge and only the SoC vendor can setup its platform to fulfill the objectives of its hardware.
This patch adds the ability to create a DTPM hierarchy via configfs. All DTPM capable devices are registered in a list, and the creation of a configfs directory with the name of one of this device will create a DTPM node in the DTPM powercap sysfs. If the name is not in the list, a virtual node will be created instead. This virtual node in the DTPM semantic is to aggregate the power characteristics of the children.
In order to do the connection between the configfs and sysfs easily, a 'device' file contains the path to the corresponding DTPM powercap node in sysfs (cross filesystems symlink is not supported by configfs).
In order to not block any new features in the future, the hierarchical constraints are stored under a top folder 'constraints', so sibling can be created for other purposes if needed.
When the configfs was populated, the module can not be unloaded until all the elements in the tree have been removed.
1) Resulting creation via mkdir:
root@rock960:/sys/kernel/config# tree dtpm/
dtpm/
└── constraints
└── platform
├── device
└── soc
├── device
└── pkg
├── device
├── cpu0-cpufreq
│ └── device
├── cpu4-cpufreq
│ └── device
└── panfrost-devfreq
└── device2) The content of the 'device' file above
root@rock960:/sys/kernel/config# find dtpm/constraints -name "device" -exec cat {} \;
/devices/virtual/powercap/dtpm/dtpm:0/dtpm:0:0/dtpm:0:0:1
/devices/virtual/powercap/dtpm/dtpm:0/dtpm:0:0/dtpm:0:0:0/dtpm:0:0:0:2
/devices/virtual/powercap/dtpm/dtpm:0/dtpm:0:0/dtpm:0:0:0/dtpm:0:0:0:1
/devices/virtual/powercap/dtpm/dtpm:0/dtpm:0:0/dtpm:0:0:0/dtpm:0:0:0:0
/devices/virtual/powercap/dtpm/dtpm:0/dtpm:0:0/dtpm:0:0:0
/devices/virtual/powercap/dtpm/dtpm:0/dtpm:0:0
/devices/virtual/powercap/dtpm/dtpm:03) The dtpm device creation node is reflected in sysfs:
root@rock960:/sys/devices/virtual/powercap/dtpm# find . -type d | grep dtpm ./dtpm:0 ./dtpm:0/power ./dtpm:0/dtpm:0:0 ./dtpm:0/dtpm:0:0/power ./dtpm:0/dtpm:0:0/dtpm:0:0:0 ./dtpm:0/dtpm:0:0/dtpm:0:0:0/dtpm:0:0:0:1 ./dtpm:0/dtpm:0:0/dtpm:0:0:0/dtpm:0:0:0:1/power ./dtpm:0/dtpm:0:0/dtpm:0:0:0/power ./dtpm:0/dtpm:0:0/dtpm:0:0:0/dtpm:0:0:0:2 ./dtpm:0/dtpm:0:0/dtpm:0:0:0/dtpm:0:0:0:2/power ./dtpm:0/dtpm:0:0/dtpm:0:0:0/dtpm:0:0:0:0 ./dtpm:0/dtpm:0:0/dtpm:0:0:0/dtpm:0:0:0:0/power ./dtpm:0/dtpm:0:0/dtpm:0:0:1 ./dtpm:0/dtpm:0:0/dtpm:0:0:1/power
--- drivers/powercap/Kconfig | 8 + drivers/powercap/Makefile | 1 + drivers/powercap/dtpm_configfs.c | 247 +++++++++++++++++++++++++++++++ include/linux/dtpm.h | 2 + 4 files changed, 258 insertions(+) create mode 100644 drivers/powercap/dtpm_configfs.c
drivers/powercap/Kconfig +8 -0
@@ -50,6 +50,14 @@ config DTPM This enables support for the power capping for the dynamic thermal power management userspace engine. +config DTPM_CONFIGFS + tristate "Dynamic Thermal Power Management configuration via configfs" + depends on DTPM && CONFIGFS_FS + help + This enables support for creating the DTPM device hierarchy + via configfs giving the userspace full control of the + thermal constraint representation. + config DTPM_CPU bool "Add CPU power capping based on the energy model" depends on DTPM && ENERGY_MODEL
drivers/powercap/Makefile +1 -0
@@ -1,5 +1,6 @@ # SPDX-License-Identifier: GPL-2.0-only obj-$(CONFIG_DTPM) += dtpm.o +obj-$(CONFIG_DTPM_CONFIGFS) += dtpm_configfs.o obj-$(CONFIG_DTPM_CPU) += dtpm_cpu.o obj-$(CONFIG_POWERCAP) += powercap_sys.o obj-$(CONFIG_INTEL_RAPL_CORE) += intel_rapl_common.o
drivers/powercap/dtpm_configfs.c new file +247 -0
247 lines not on this page · raw message
include/linux/dtpm.h +2 -0
@@ -8,11 +8,13 @@#define ___DTPM_H__#include <linux/powercap.h> +#include <linux/configfs.h> #define MAX_DTPM_DESCR 8#define MAX_DTPM_CONSTRAINTS 1struct dtpm { +struct config_group cfg;struct powercap_zone zone;struct kref kref;struct dtpm *parent;
Signature · 1 line
2.17.1