Skip to content

Commit 5b315d8

Browse files
pastaq1Naim
authored andcommitted
platform/x86: lenovo-wmi-other: Add missing CPU tunable attributes
Use an enum for all device ID's and CPU attribute feature ID's, add missing CPU attributes. Reviewed-by: Rong Zhang <i@rong.moe> Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca> Signed-off-by: Derek J. Clark <derekjohn.clark@gmail.com>
1 parent ca47ee5 commit 5b315d8

3 files changed

Lines changed: 107 additions & 6 deletions

File tree

Documentation/wmi/devices/lenovo-wmi-other.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,18 @@ Each attribute has the following properties:
6868
- type
6969

7070
The following firmware-attributes are implemented:
71+
- cpu_temp: CPU Thermal Load Limit
72+
- ppt_cpu_cl: CPU Cross Loading Power Limit
73+
- ppt_pl1_apu_spl: Platform Profile Tracking APU Sustained Power Limit
7174
- ppt_pl1_spl: Platform Profile Tracking Sustained Power Limit
75+
- ppt_pl1_spl_cl: Platform Profile Tracking Cross Loading Sustained Power Limit
76+
- ppt_pl1_tau: Exceed Duration for Platform Profile Tracking Sustained Power Limit
7277
- ppt_pl2_sppt: Platform Profile Tracking Slow Package Power Tracking
78+
- ppt_pl2_sppt_cl: Platform Profile Tracking Cross Loading Slow Package Tracking
7379
- ppt_pl3_fppt: Platform Profile Tracking Fast Package Power Tracking
80+
- ppt_pl3_fppt_cl: Platform Profile Tracking Cross Loading Fast Package Power Tracking
81+
- ppt_pl4_ipl: Platform Profile Tracking Instantaneous Power Limit
82+
- ppt_pl4_ipl_cl: Platform Profile Tracking Cross Loading Instantaneous Power Limit
7483

7584
LENOVO_FAN_TEST_DATA
7685
-------------------------

drivers/platform/x86/lenovo/wmi-capdata.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@
1818
#define LWMI_ATTR_MODE_ID_MASK GENMASK(15, 8)
1919
#define LWMI_ATTR_TYPE_ID_MASK GENMASK(7, 0)
2020

21-
#define LWMI_DEVICE_ID_FAN 0x04
21+
enum lwmi_device_id {
22+
LWMI_DEVICE_ID_CPU = 0x01,
23+
LWMI_DEVICE_ID_FAN = 0x04,
24+
};
2225

2326
#define LWMI_TYPE_ID_NONE 0x00
2427

drivers/platform/x86/lenovo/wmi-other.c

Lines changed: 94 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,21 @@
5050

5151
#define LENOVO_OTHER_MODE_GUID "DC2A8805-3A8C-41BA-A6F7-092E0089CD3B"
5252

53-
#define LWMI_DEVICE_ID_CPU 0x01
54-
55-
#define LWMI_FEATURE_ID_CPU_SPPT 0x01
56-
#define LWMI_FEATURE_ID_CPU_SPL 0x02
57-
#define LWMI_FEATURE_ID_CPU_FPPT 0x03
53+
enum lwmi_feature_id_cpu {
54+
LWMI_FEATURE_ID_CPU_SPPT = 0x01,
55+
LWMI_FEATURE_ID_CPU_SPL = 0x02,
56+
LWMI_FEATURE_ID_CPU_FPPT = 0x03,
57+
LWMI_FEATURE_ID_CPU_TEMP = 0x04,
58+
LWMI_FEATURE_ID_CPU_APU = 0x05,
59+
LWMI_FEATURE_ID_CPU_CL = 0x06,
60+
LWMI_FEATURE_ID_CPU_TAU = 0x07,
61+
LWMI_FEATURE_ID_CPU_IPL = 0x09,
62+
};
5863

5964
#define LWMI_FEATURE_ID_FAN_RPM 0x03
6065

66+
#define LWMI_TYPE_ID_CROSSLOAD 0x01
67+
6168
#define LWMI_FEATURE_VALUE_GET 17
6269
#define LWMI_FEATURE_VALUE_SET 18
6370

@@ -551,18 +558,72 @@ static struct tunable_attr_01 ppt_pl1_spl = {
551558
.type_id = LWMI_TYPE_ID_NONE,
552559
};
553560

561+
static struct tunable_attr_01 ppt_pl1_spl_cl = {
562+
.device_id = LWMI_DEVICE_ID_CPU,
563+
.feature_id = LWMI_FEATURE_ID_CPU_SPL,
564+
.type_id = LWMI_TYPE_ID_CROSSLOAD,
565+
};
566+
554567
static struct tunable_attr_01 ppt_pl2_sppt = {
555568
.device_id = LWMI_DEVICE_ID_CPU,
556569
.feature_id = LWMI_FEATURE_ID_CPU_SPPT,
557570
.type_id = LWMI_TYPE_ID_NONE,
558571
};
559572

573+
static struct tunable_attr_01 ppt_pl2_sppt_cl = {
574+
.device_id = LWMI_DEVICE_ID_CPU,
575+
.feature_id = LWMI_FEATURE_ID_CPU_SPPT,
576+
.type_id = LWMI_TYPE_ID_CROSSLOAD,
577+
};
578+
560579
static struct tunable_attr_01 ppt_pl3_fppt = {
561580
.device_id = LWMI_DEVICE_ID_CPU,
562581
.feature_id = LWMI_FEATURE_ID_CPU_FPPT,
563582
.type_id = LWMI_TYPE_ID_NONE,
564583
};
565584

585+
static struct tunable_attr_01 ppt_pl3_fppt_cl = {
586+
.device_id = LWMI_DEVICE_ID_CPU,
587+
.feature_id = LWMI_FEATURE_ID_CPU_FPPT,
588+
.type_id = LWMI_TYPE_ID_CROSSLOAD,
589+
};
590+
591+
static struct tunable_attr_01 cpu_temp = {
592+
.device_id = LWMI_DEVICE_ID_CPU,
593+
.feature_id = LWMI_FEATURE_ID_CPU_TEMP,
594+
.type_id = LWMI_TYPE_ID_NONE,
595+
};
596+
597+
static struct tunable_attr_01 ppt_pl1_apu_spl = {
598+
.device_id = LWMI_DEVICE_ID_CPU,
599+
.feature_id = LWMI_FEATURE_ID_CPU_APU,
600+
.type_id = LWMI_TYPE_ID_NONE,
601+
};
602+
603+
static struct tunable_attr_01 ppt_cpu_cl = {
604+
.device_id = LWMI_DEVICE_ID_CPU,
605+
.feature_id = LWMI_FEATURE_ID_CPU_CL,
606+
.type_id = LWMI_TYPE_ID_NONE,
607+
};
608+
609+
static struct tunable_attr_01 ppt_pl1_tau = {
610+
.device_id = LWMI_DEVICE_ID_CPU,
611+
.feature_id = LWMI_FEATURE_ID_CPU_TAU,
612+
.type_id = LWMI_TYPE_ID_NONE,
613+
};
614+
615+
static struct tunable_attr_01 ppt_pl4_ipl = {
616+
.device_id = LWMI_DEVICE_ID_CPU,
617+
.feature_id = LWMI_FEATURE_ID_CPU_IPL,
618+
.type_id = LWMI_TYPE_ID_NONE,
619+
};
620+
621+
static struct tunable_attr_01 ppt_pl4_ipl_cl = {
622+
.device_id = LWMI_DEVICE_ID_CPU,
623+
.feature_id = LWMI_FEATURE_ID_CPU_IPL,
624+
.type_id = LWMI_TYPE_ID_CROSSLOAD,
625+
};
626+
566627
struct capdata01_attr_group {
567628
const struct attribute_group *attr_group;
568629
struct tunable_attr_01 *tunable_attr;
@@ -898,17 +959,45 @@ static bool lwmi_attr_01_is_supported(struct tunable_attr_01 *tunable_attr)
898959
.name = _fsname, .attrs = _attrname##_attrs \
899960
}
900961

962+
LWMI_ATTR_GROUP_TUNABLE_CAP01(cpu_temp, "cpu_temp",
963+
"Set the CPU thermal load limit");
964+
LWMI_ATTR_GROUP_TUNABLE_CAP01(ppt_cpu_cl, "ppt_cpu_cl",
965+
"Set the CPU cross loading power limit");
966+
LWMI_ATTR_GROUP_TUNABLE_CAP01(ppt_pl1_apu_spl, "ppt_pl1_apu_spl",
967+
"Set the APU sustained power limit");
901968
LWMI_ATTR_GROUP_TUNABLE_CAP01(ppt_pl1_spl, "ppt_pl1_spl",
902969
"Set the CPU sustained power limit");
970+
LWMI_ATTR_GROUP_TUNABLE_CAP01(ppt_pl1_spl_cl, "ppt_pl1_spl_cl",
971+
"Set the CPU cross loading sustained power limit");
903972
LWMI_ATTR_GROUP_TUNABLE_CAP01(ppt_pl2_sppt, "ppt_pl2_sppt",
904973
"Set the CPU slow package power tracking limit");
974+
LWMI_ATTR_GROUP_TUNABLE_CAP01(ppt_pl2_sppt_cl, "ppt_pl2_sppt_cl",
975+
"Set the CPU cross loading slow package power tracking limit");
905976
LWMI_ATTR_GROUP_TUNABLE_CAP01(ppt_pl3_fppt, "ppt_pl3_fppt",
906977
"Set the CPU fast package power tracking limit");
978+
LWMI_ATTR_GROUP_TUNABLE_CAP01(ppt_pl3_fppt_cl, "ppt_pl3_fppt_cl",
979+
"Set the CPU cross loading fast package power tracking limit");
980+
LWMI_ATTR_GROUP_TUNABLE_CAP01(ppt_pl1_tau, "ppt_pl1_tau",
981+
"Set the CPU sustained power limit exceed duration");
982+
LWMI_ATTR_GROUP_TUNABLE_CAP01(ppt_pl4_ipl, "ppt_pl4_ipl",
983+
"Set the CPU instantaneous power limit");
984+
LWMI_ATTR_GROUP_TUNABLE_CAP01(ppt_pl4_ipl_cl, "ppt_pl4_ipl_cl",
985+
"Set the CPU cross loading instantaneous power limit");
986+
907987

908988
static struct capdata01_attr_group cd01_attr_groups[] = {
989+
{ &cpu_temp_attr_group, &cpu_temp },
990+
{ &ppt_cpu_cl_attr_group, &ppt_cpu_cl },
991+
{ &ppt_pl1_apu_spl_attr_group, &ppt_pl1_apu_spl },
909992
{ &ppt_pl1_spl_attr_group, &ppt_pl1_spl },
993+
{ &ppt_pl1_spl_cl_attr_group, &ppt_pl1_spl_cl },
994+
{ &ppt_pl1_tau_attr_group, &ppt_pl1_tau },
910995
{ &ppt_pl2_sppt_attr_group, &ppt_pl2_sppt },
996+
{ &ppt_pl2_sppt_cl_attr_group, &ppt_pl2_sppt_cl },
911997
{ &ppt_pl3_fppt_attr_group, &ppt_pl3_fppt },
998+
{ &ppt_pl3_fppt_cl_attr_group, &ppt_pl3_fppt_cl },
999+
{ &ppt_pl4_ipl_attr_group, &ppt_pl4_ipl },
1000+
{ &ppt_pl4_ipl_cl_attr_group, &ppt_pl4_ipl_cl },
9121001
{},
9131002
};
9141003

0 commit comments

Comments
 (0)