Skip to content

Commit c8d15ab

Browse files
pastaq1Naim
authored andcommitted
platform/x86: lenovo-wmi-other: Add GPU tunable attributes
Use an enum for all GPU attribute feature ID's and add GPU 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 5b315d8 commit c8d15ab

3 files changed

Lines changed: 116 additions & 0 deletions

File tree

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,16 @@ Each attribute has the following properties:
6969

7070
The following firmware-attributes are implemented:
7171
- cpu_temp: CPU Thermal Load Limit
72+
- dgpu_boost_clk: Dedicated GPU Boost Clock
73+
- dgpu_enable: Dedicated GPU Enabled Status
74+
- gpu_didvid: GPU Device Identifier and Vendor Identifier
75+
- gpu_mode: GPU Mode by Power Limit
76+
- gpu_nv_ac_offset: Nvidia GPU AC Total Processing Power Baseline Offset
77+
- gpu_nv_bpl: Nvidia GPU Base Power Limit
78+
- gpu_nv_cpu_boost: Nvidia GPU to CPU Dynamic Boost Limit
79+
- gpu_nv_ctgp: Nvidia GPU Configurable Total Graphics Power
80+
- gpu_nv_ppab: Nvidia GPU Power Performance Aware Boost Limit
81+
- gpu_temp: GPU Thermal Load Limit
7282
- ppt_cpu_cl: CPU Cross Loading Power Limit
7383
- ppt_pl1_apu_spl: Platform Profile Tracking APU Sustained Power Limit
7484
- ppt_pl1_spl: Platform Profile Tracking Sustained Power Limit

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
enum lwmi_device_id {
2222
LWMI_DEVICE_ID_CPU = 0x01,
23+
LWMI_DEVICE_ID_GPU = 0x02,
2324
LWMI_DEVICE_ID_FAN = 0x04,
2425
};
2526

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

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,19 @@ enum lwmi_feature_id_cpu {
6161
LWMI_FEATURE_ID_CPU_IPL = 0x09,
6262
};
6363

64+
enum lwmi_feature_id_gpu {
65+
LWMI_FEATURE_ID_GPU_NV_PPAB = 0x01,
66+
LWMI_FEATURE_ID_GPU_NV_CTGP = 0x02,
67+
LWMI_FEATURE_ID_GPU_TEMP = 0x03,
68+
LWMI_FEATURE_ID_GPU_AC_OFFSET = 0x04,
69+
LWMI_FEATURE_ID_DGPU_BOOST_CLK = 0x06,
70+
LWMI_FEATURE_ID_DGPU_EN = 0x07,
71+
LWMI_FEATURE_ID_GPU_MODE = 0x08,
72+
LWMI_FEATURE_ID_DGPU_DIDVID = 0x09,
73+
LWMI_FEATURE_ID_GPU_NV_BPL = 0x0a,
74+
LWMI_FEATURE_ID_GPU_NV_CPU_BOOST = 0x0b,
75+
};
76+
6477
#define LWMI_FEATURE_ID_FAN_RPM 0x03
6578

6679
#define LWMI_TYPE_ID_CROSSLOAD 0x01
@@ -624,6 +637,66 @@ static struct tunable_attr_01 ppt_pl4_ipl_cl = {
624637
.type_id = LWMI_TYPE_ID_CROSSLOAD,
625638
};
626639

640+
static struct tunable_attr_01 gpu_nv_ppab = {
641+
.device_id = LWMI_DEVICE_ID_GPU,
642+
.feature_id = LWMI_FEATURE_ID_GPU_NV_PPAB,
643+
.type_id = LWMI_TYPE_ID_NONE,
644+
};
645+
646+
static struct tunable_attr_01 gpu_nv_ctgp = {
647+
.device_id = LWMI_DEVICE_ID_GPU,
648+
.feature_id = LWMI_FEATURE_ID_GPU_NV_CTGP,
649+
.type_id = LWMI_TYPE_ID_NONE,
650+
};
651+
652+
static struct tunable_attr_01 gpu_temp = {
653+
.device_id = LWMI_DEVICE_ID_GPU,
654+
.feature_id = LWMI_FEATURE_ID_GPU_TEMP,
655+
.type_id = LWMI_TYPE_ID_NONE,
656+
};
657+
658+
static struct tunable_attr_01 gpu_nv_ac_offset = {
659+
.device_id = LWMI_DEVICE_ID_GPU,
660+
.feature_id = LWMI_FEATURE_ID_GPU_AC_OFFSET,
661+
.type_id = LWMI_TYPE_ID_NONE,
662+
};
663+
664+
static struct tunable_attr_01 dgpu_boost_clk = {
665+
.device_id = LWMI_DEVICE_ID_GPU,
666+
.feature_id = LWMI_FEATURE_ID_DGPU_BOOST_CLK,
667+
.type_id = LWMI_TYPE_ID_NONE,
668+
};
669+
670+
static struct tunable_attr_01 dgpu_enable = {
671+
.device_id = LWMI_DEVICE_ID_GPU,
672+
.feature_id = LWMI_FEATURE_ID_DGPU_EN,
673+
.type_id = LWMI_TYPE_ID_NONE,
674+
};
675+
676+
static struct tunable_attr_01 gpu_mode = {
677+
.device_id = LWMI_DEVICE_ID_GPU,
678+
.feature_id = LWMI_FEATURE_ID_GPU_MODE,
679+
.type_id = LWMI_TYPE_ID_NONE,
680+
};
681+
682+
static struct tunable_attr_01 dgpu_didvid = {
683+
.device_id = LWMI_DEVICE_ID_GPU,
684+
.feature_id = LWMI_FEATURE_ID_DGPU_DIDVID,
685+
.type_id = LWMI_TYPE_ID_NONE,
686+
};
687+
688+
static struct tunable_attr_01 gpu_nv_bpl = {
689+
.device_id = LWMI_DEVICE_ID_GPU,
690+
.feature_id = LWMI_FEATURE_ID_GPU_NV_BPL,
691+
.type_id = LWMI_TYPE_ID_NONE,
692+
};
693+
694+
static struct tunable_attr_01 gpu_nv_cpu_boost = {
695+
.device_id = LWMI_DEVICE_ID_GPU,
696+
.feature_id = LWMI_FEATURE_ID_GPU_NV_CPU_BOOST,
697+
.type_id = LWMI_TYPE_ID_NONE,
698+
};
699+
627700
struct capdata01_attr_group {
628701
const struct attribute_group *attr_group;
629702
struct tunable_attr_01 *tunable_attr;
@@ -959,6 +1032,7 @@ static bool lwmi_attr_01_is_supported(struct tunable_attr_01 *tunable_attr)
9591032
.name = _fsname, .attrs = _attrname##_attrs \
9601033
}
9611034

1035+
/* CPU tunable attributes */
9621036
LWMI_ATTR_GROUP_TUNABLE_CAP01(cpu_temp, "cpu_temp",
9631037
"Set the CPU thermal load limit");
9641038
LWMI_ATTR_GROUP_TUNABLE_CAP01(ppt_cpu_cl, "ppt_cpu_cl",
@@ -984,9 +1058,40 @@ LWMI_ATTR_GROUP_TUNABLE_CAP01(ppt_pl4_ipl, "ppt_pl4_ipl",
9841058
LWMI_ATTR_GROUP_TUNABLE_CAP01(ppt_pl4_ipl_cl, "ppt_pl4_ipl_cl",
9851059
"Set the CPU cross loading instantaneous power limit");
9861060

1061+
/* GPU tunable attributes */
1062+
LWMI_ATTR_GROUP_TUNABLE_CAP01(dgpu_boost_clk, "dgpu_boost_clk",
1063+
"Set the dedicated GPU boost clock");
1064+
LWMI_ATTR_GROUP_TUNABLE_CAP01(dgpu_didvid, "gpu_didvid",
1065+
"Get the GPU device identifier and vendor identifier");
1066+
LWMI_ATTR_GROUP_TUNABLE_CAP01(dgpu_enable, "dgpu_enable",
1067+
"Set the dedicated Nvidia GPU enabled status");
1068+
LWMI_ATTR_GROUP_TUNABLE_CAP01(gpu_mode, "gpu_mode",
1069+
"Set the GPU mode by power limit");
1070+
LWMI_ATTR_GROUP_TUNABLE_CAP01(gpu_nv_ac_offset, "gpu_nv_ac_offset",
1071+
"Set the Nvidia GPU AC total processing power baseline offset");
1072+
LWMI_ATTR_GROUP_TUNABLE_CAP01(gpu_nv_bpl, "gpu_nv_bpl",
1073+
"Set the Nvidia GPU base power limit");
1074+
LWMI_ATTR_GROUP_TUNABLE_CAP01(gpu_nv_cpu_boost, "gpu_nv_cpu_boost",
1075+
"Set the Nvidia GPU to CPU dynamic boost limit");
1076+
LWMI_ATTR_GROUP_TUNABLE_CAP01(gpu_nv_ctgp, "gpu_nv_ctgp",
1077+
"Set the GPU configurable total graphics power");
1078+
LWMI_ATTR_GROUP_TUNABLE_CAP01(gpu_nv_ppab, "gpu_nv_ppab",
1079+
"Set the Nvidia GPU power performance aware boost limit");
1080+
LWMI_ATTR_GROUP_TUNABLE_CAP01(gpu_temp, "gpu_temp",
1081+
"Set the GPU thermal load limit");
9871082

9881083
static struct capdata01_attr_group cd01_attr_groups[] = {
9891084
{ &cpu_temp_attr_group, &cpu_temp },
1085+
{ &dgpu_boost_clk_attr_group, &dgpu_boost_clk },
1086+
{ &dgpu_didvid_attr_group, &dgpu_didvid },
1087+
{ &dgpu_enable_attr_group, &dgpu_enable },
1088+
{ &gpu_mode_attr_group, &gpu_mode },
1089+
{ &gpu_nv_ac_offset_attr_group, &gpu_nv_ac_offset },
1090+
{ &gpu_nv_bpl_attr_group, &gpu_nv_bpl },
1091+
{ &gpu_nv_cpu_boost_attr_group, &gpu_nv_cpu_boost },
1092+
{ &gpu_nv_ctgp_attr_group, &gpu_nv_ctgp },
1093+
{ &gpu_nv_ppab_attr_group, &gpu_nv_ppab },
1094+
{ &gpu_temp_attr_group, &gpu_temp },
9901095
{ &ppt_cpu_cl_attr_group, &ppt_cpu_cl },
9911096
{ &ppt_pl1_apu_spl_attr_group, &ppt_pl1_apu_spl },
9921097
{ &ppt_pl1_spl_attr_group, &ppt_pl1_spl },

0 commit comments

Comments
 (0)