Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add initial support for DPTF adaptive performance policy #224

Closed
wants to merge 45 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
57b9e52
Don't hardcode the UUID for INT3400
mjg59 Apr 9, 2020
b5fd0d6
Allow the XML parser to be disabled
mjg59 Apr 9, 2020
81e76d4
Allow derived classes of thd_engine_default to set their own UUID
mjg59 Apr 9, 2020
68ecc48
Improve handling of large binary sysfs files
mjg59 Apr 9, 2020
1806ba0
Abstract get_ppcc_values
mjg59 Apr 9, 2020
6f1a3f2
Add support for passing adaptive target information to devices
mjg59 Apr 11, 2020
cf256d6
Allow the DRAM RAPL device to use PPCC
mjg59 Apr 11, 2020
e5e10a6
Add an adaptive target callback into RAPL code
mjg59 Apr 11, 2020
c7794ac
Allow engines to force the use of MMIO for RAPL
mjg59 Apr 11, 2020
ffa7c93
Make thd_engine_start() virtual
mjg59 Apr 11, 2020
84632fc
Call into engines to update their state
mjg59 Apr 11, 2020
bd0a77a
Enable and disable the INT3400 thermal zone
mjg59 Apr 11, 2020
c31212c
Add basic support for the DPTM adaptive power policy
mjg59 Apr 10, 2020
ae2c0c7
Add adaptive option
mjg59 Apr 10, 2020
e19ccf7
Add necessary kernel patches
mjg59 Apr 12, 2020
91cef64
Add an error when a compressed GDDV payload is detected.
mjg59 Apr 12, 2020
96af722
Handle compressed GDDV payloads
mjg59 Apr 12, 2020
a9f91cc
Harden PTTV parsing
mjg59 Apr 12, 2020
fce2afd
Fix offsets in APCT V2 table calculations
mjg59 Apr 12, 2020
5aab3b1
Don't make assumptions about key formatting
mjg59 Apr 12, 2020
d3ccd5e
Don't crash out as soon as hitting an unsupported condition.
Flameeyes Apr 12, 2020
1d61fba
Add support for APPC-based conditions
mjg59 Apr 12, 2020
2b712a4
Fix up some more incorrect offset calculations
mjg59 Apr 12, 2020
04df288
Harden APAT parsing
mjg59 Apr 12, 2020
0bf7e22
Handle multi-entry PSVT tables
mjg59 Apr 12, 2020
1a5893f
Add support for temperature comparisons
mjg59 Apr 12, 2020
8636b66
Harden against malformed APPC tables
mjg59 Apr 12, 2020
6fa65f9
Add support for reading lid state
mjg59 Apr 12, 2020
4c6386c
Add power source condition
mjg59 Apr 13, 2020
c9556ed
Add stub workload condition handler
mjg59 Apr 13, 2020
bb94fda
Add support for platform type
mjg59 Apr 13, 2020
3e354b8
Add missing build dependencies
SkUrRiEr Apr 13, 2020
bb75239
Fix build dependencies
mjg59 Apr 13, 2020
efd9261
Fix valgrind complaints
mjg59 Apr 14, 2020
3cc5e95
Remove trailing _ from zone names
mjg59 Apr 14, 2020
8f096ea
Don't try to match supported UUIDs if the firmware doesn't give us data
mjg59 Apr 14, 2020
4900993
Remove TMEM zone hack
mjg59 Apr 14, 2020
9db0434
Add support for setting the TCC offset
mjg59 Apr 14, 2020
030b538
Configure RAPL more correctly
mjg59 Apr 15, 2020
f3c9e03
Enforce RAPL limits immediately
mjg59 Apr 15, 2020
fb0350f
Set PL2 configuration
mjg59 Apr 15, 2020
3270db5
Add support for conditions with time constraints
mjg59 Apr 16, 2020
af56d7f
Add support for setting passive trip points
mjg59 Apr 16, 2020
e140a95
Fix RAPL sysfs detection
saleemrashid Apr 19, 2020
05493d3
Add some missing condition enum entries
mjg59 Apr 26, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ AM_CFLAGS = ${DBUS_CFLAGS}
AM_CXXFLAGS = \
${DBUS_CFLAGS} \
$(XML_CFLAGS) \
$(UPOWER_CFLAGS) \
$(EVDEV_CFLAGS) \
-DTDRUNDIR=\"$(tdrundir)\" \
-DTDCONFDIR=\"$(tdconfdir)\" \
$(CXXFLAGS) \
Expand All @@ -33,7 +35,10 @@ thermald_LDADD = \
$(LIBNL_LIBS) \
$(LIBM) \
$(LIBDL) \
$(XML_LIBS)
$(XML_LIBS) \
$(LZMA_LIBS) \
$(UPOWER_LIBS) \
$(EVDEV_LIBS)

BUILT_SOURCES = \
thd_dbus_interface.h
Expand All @@ -45,6 +50,7 @@ thermald_SOURCES = \
src/thd_cdev.cpp \
src/thd_cdev_therm_sys_fs.cpp \
src/thd_engine_default.cpp \
src/thd_engine_adaptive.cpp \
src/thd_sys_fs.cpp \
src/thd_trip_point.cpp \
src/thd_zone.cpp \
Expand Down
6 changes: 6 additions & 0 deletions README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ Install
yum install glib-devel
yum install dbus-glib-devel
yum install libxml2-devel
yum install upower-devel
yum install xz-devel
yum install libevdev-devel

Replace yum with dnf for later Fedora versions.

Expand Down Expand Up @@ -64,6 +67,9 @@ Building on Ubuntu
sudo apt-get install libdbus-1-dev
sudo apt-get install libdbus-glib-1-dev
sudo apt-get install libxml2-dev
sudo apt-get install libupower-glib-dev
sudo apt-get install liblzma-dev
sudo apt-get install libevdev-dev

2
Build
Expand Down
6 changes: 6 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ AC_SUBST(GLIB_LIBS)

PKG_CHECK_MODULES(XML, libxml-2.0 >= 2.4)

PKG_CHECK_MODULES(LZMA, liblzma)

PKG_CHECK_MODULES(UPOWER, upower-glib)

PKG_CHECK_MODULES(EVDEV, libevdev)

AC_PROG_CC
AC_PROG_CPP
AC_PROG_CXX
Expand Down
115 changes: 115 additions & 0 deletions patches/0001-thermal-int340x_thermal-Export-GDDV.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
From 38bca68953e268e389aafac1be70067fe88ff8d3 Mon Sep 17 00:00:00 2001
From: Matthew Garrett <mjg59@google.com>
Date: Fri, 27 Mar 2020 20:35:51 -0700
Subject: [PATCH 1/2] thermal/int340x_thermal: Export GDDV

Implementing DPTF properly requires making use of firmware-provided
information associated with the INT3400 device. Calling GDDV provides a
buffer of information which userland can then interpret to determine
appropriate DPTF policy.

Signed-off-by: Matthew Garrett <mjg59@google.com>
---
.../intel/int340x_thermal/int3400_thermal.c | 47 +++++++++++++++++++
1 file changed, 47 insertions(+)

diff --git a/drivers/thermal/intel/int340x_thermal/int3400_thermal.c b/drivers/thermal/intel/int340x_thermal/int3400_thermal.c
index efae0c02d898..5785c0b09e54 100644
--- a/drivers/thermal/intel/int340x_thermal/int3400_thermal.c
+++ b/drivers/thermal/intel/int340x_thermal/int3400_thermal.c
@@ -52,6 +52,25 @@ struct int3400_thermal_priv {
u8 uuid_bitmap;
int rel_misc_dev_res;
int current_uuid_index;
+ char *data_vault;
+};
+
+static ssize_t data_vault_read(struct file *file, struct kobject *kobj,
+ struct bin_attribute *attr, char *buf, loff_t off, size_t count)
+{
+ memcpy(buf, attr->private + off, count);
+ return count;
+}
+
+static BIN_ATTR_RO(data_vault, 0);
+
+static struct bin_attribute *data_attributes[] = {
+ &bin_attr_data_vault,
+ NULL,
+};
+
+static const struct attribute_group data_attribute_group = {
+ .bin_attrs = data_attributes,
};

static ssize_t available_uuids_show(struct device *dev,
@@ -280,8 +299,11 @@ static struct thermal_zone_params int3400_thermal_params = {

static int int3400_thermal_probe(struct platform_device *pdev)
{
+ struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
struct acpi_device *adev = ACPI_COMPANION(&pdev->dev);
struct int3400_thermal_priv *priv;
+ union acpi_object *obj;
+ acpi_status status;
int result;

if (!adev)
@@ -309,6 +331,19 @@ static int int3400_thermal_probe(struct platform_device *pdev)

platform_set_drvdata(pdev, priv);

+ status = acpi_evaluate_object(priv->adev->handle, "GDDV", NULL, &buffer);
+ if (ACPI_SUCCESS(status) && buffer.length) {
+ obj = buffer.pointer;
+ if (obj->type == ACPI_TYPE_PACKAGE && obj->package.count == 1
+ && obj->package.elements[0].type == ACPI_TYPE_BUFFER) {
+ priv->data_vault = kmemdup(obj->package.elements[0].buffer.pointer, obj->package.elements[0].buffer.length, GFP_KERNEL);
+ bin_attr_data_vault.private = priv->data_vault;
+ bin_attr_data_vault.size = obj->package.elements[0].buffer.length;
+ }
+
+ kfree(buffer.pointer);
+ }
+
int3400_thermal_ops.get_mode = int3400_thermal_get_mode;
int3400_thermal_ops.set_mode = int3400_thermal_set_mode;

@@ -327,6 +362,12 @@ static int int3400_thermal_probe(struct platform_device *pdev)
if (result)
goto free_rel_misc;

+ if (priv->data_vault) {
+ result = sysfs_create_group(&pdev->dev.kobj, &data_attribute_group);
+ if (result)
+ goto free_uuid;
+ }
+
result = acpi_install_notify_handler(
priv->adev->handle, ACPI_DEVICE_NOTIFY, int3400_notify,
(void *)priv);
@@ -336,6 +377,9 @@ static int int3400_thermal_probe(struct platform_device *pdev)
return 0;

free_sysfs:
+ if (priv->data_vault)
+ sysfs_remove_group(&pdev->dev.kobj, &data_attribute_group);
+free_uuid:
sysfs_remove_group(&pdev->dev.kobj, &uuid_attribute_group);
free_rel_misc:
if (!priv->rel_misc_dev_res)
@@ -360,8 +404,11 @@ static int int3400_thermal_remove(struct platform_device *pdev)
if (!priv->rel_misc_dev_res)
acpi_thermal_rel_misc_device_remove(priv->adev->handle);

+ if (priv->data_vault)
+ sysfs_remove_group(&pdev->dev.kobj, &data_attribute_group);
sysfs_remove_group(&pdev->dev.kobj, &uuid_attribute_group);
thermal_zone_device_unregister(priv->thermal);
+ kfree(priv->data_vault);
kfree(priv->trts);
kfree(priv->arts);
kfree(priv);
--
2.24.1

Loading