Use an enum for all GPU attribute feature ID's and add GPU attributes.
Signed-off-by: Derek J. Clark <derekjohn.clark@gmail.com>
---
.../wmi/devices/lenovo-wmi-other.rst | 11 ++
drivers/platform/x86/lenovo/wmi-capdata.h | 1 +
drivers/platform/x86/lenovo/wmi-other.c | 114 ++++++++++++++++++
3 files changed, 126 insertions(+)
diff --git a/Documentation/wmi/devices/lenovo-wmi-other.rst b/Documentation/wmi/devices/lenovo-wmi-other.rst
index f4763ed66cc6d..f7564b23bb7f0 100644
--- a/Documentation/wmi/devices/lenovo-wmi-other.rst
+++ b/Documentation/wmi/devices/lenovo-wmi-other.rst
@@ -70,6 +70,17 @@ Each attribute has the following properties:
The following firmware-attributes are implemented:
- cpu_oc_stat: CPU Overlocking Status
- cpu_temp: CPU Thermal Load Limit
+ - dgpu_boost_clk: Dedicated GPU Boost Clock
+ - dgpu_enable: Dedicated GPU Enabled Status
+ - gpu_didvid: GPU Device Identifier and Vendor Identifier
+ - gpu_mode: GPU Mode by Power Limit
+ - gpu_nv_ac_offset: Nvidia GPU AC Total Processing Power Baseline Offset
+ - gpu_nv_bpl: Nvidia GPU Base Power Limit
+ - gpu_nv_cpu_boost: Nvidia GPU to CPU Dynamic Boost Limit
+ - gpu_nv_ctgp: Nvidia GPU Configurable Total Graphics Power
+ - gpu_nv_ppab: Nvidia GPU Power Performance Aware Boost Limit
+ - gpu_oc_stat: GPU Overclocking Status
+ - gpu_temp: GPU Thermal Load Limit
- ppt_cpu_cl: CPU Cross Loading Power Limit
- ppt_pl1_apu_spl: Platform Profile Tracking APU Sustained Power Limit
- ppt_pl1_spl: Platform Profile Tracking Sustained Power Limit
diff --git a/drivers/platform/x86/lenovo/wmi-capdata.h b/drivers/platform/x86/lenovo/wmi-capdata.h
index aa48f43cbb43b..b7f9ee7b301a5 100644
--- a/drivers/platform/x86/lenovo/wmi-capdata.h
+++ b/drivers/platform/x86/lenovo/wmi-capdata.h
@@ -25,6 +25,7 @@
enum lwmi_device_id {
LWMI_DEVICE_ID_CPU = 0x01,
+ LWMI_DEVICE_ID_GPU = 0x02,
LWMI_DEVICE_ID_FAN = 0x04,
};
diff --git a/drivers/platform/x86/lenovo/wmi-other.c b/drivers/platform/x86/lenovo/wmi-other.c
index 7713a096077dd..cc024cb369b0f 100644
--- a/drivers/platform/x86/lenovo/wmi-other.c
+++ b/drivers/platform/x86/lenovo/wmi-other.c
@@ -66,6 +66,20 @@ enum lwmi_feature_id_cpu {
LWMI_FEATURE_ID_CPU_IPL = 0x09,
};
+enum lwmi_feature_id_gpu {
+ LWMI_FEATURE_ID_GPU_NV_PPAB = 0x01,
+ LWMI_FEATURE_ID_GPU_NV_CTGP = 0x02,
+ LWMI_FEATURE_ID_GPU_TEMP = 0x03,
+ LWMI_FEATURE_ID_GPU_AC_OFFSET = 0x04,
+ LWMI_FEATURE_ID_GPU_OC = 0x05,
+ LWMI_FEATURE_ID_DGPU_BOOST_CLK = 0x06,
+ LWMI_FEATURE_ID_DGPU_EN = 0x07,
+ LWMI_FEATURE_ID_GPU_MODE = 0x08,
+ LWMI_FEATURE_ID_DGPU_DIDVID = 0x09,
+ LWMI_FEATURE_ID_GPU_NV_BPL = 0x0a,
+ LWMI_FEATURE_ID_GPU_NV_CPU_BOOST = 0x0b,
+};
+
#define LWMI_FEATURE_ID_FAN_RPM 0x03
#define LWMI_TYPE_ID_NONE 0x00
@@ -638,6 +652,72 @@ static struct tunable_attr_01 ppt_pl4_ipl_cl = {
.type_id = LWMI_TYPE_ID_CROSSLOAD,
};
+static struct tunable_attr_01 gpu_nv_ppab = {
+ .device_id = LWMI_DEVICE_ID_GPU,
+ .feature_id = LWMI_FEATURE_ID_GPU_NV_PPAB,
+ .type_id = LWMI_TYPE_ID_NONE,
+};
+
+static struct tunable_attr_01 gpu_nv_ctgp = {
+ .device_id = LWMI_DEVICE_ID_GPU,
+ .feature_id = LWMI_FEATURE_ID_GPU_NV_CTGP,
+ .type_id = LWMI_TYPE_ID_NONE,
+};
+
+static struct tunable_attr_01 gpu_temp = {
+ .device_id = LWMI_DEVICE_ID_GPU,
+ .feature_id = LWMI_FEATURE_ID_GPU_TEMP,
+ .type_id = LWMI_TYPE_ID_NONE,
+};
+
+static struct tunable_attr_01 gpu_nv_ac_offset = {
+ .device_id = LWMI_DEVICE_ID_GPU,
+ .feature_id = LWMI_FEATURE_ID_GPU_AC_OFFSET,
+ .type_id = LWMI_TYPE_ID_NONE,
+};
+
+static struct tunable_attr_01 gpu_oc_stat = {
+ .device_id = LWMI_DEVICE_ID_GPU,
+ .feature_id = LWMI_FEATURE_ID_GPU_OC,
+ .type_id = LWMI_TYPE_ID_NONE,
+};
+
+static struct tunable_attr_01 dgpu_boost_clk = {
+ .device_id = LWMI_DEVICE_ID_GPU,
+ .feature_id = LWMI_FEATURE_ID_DGPU_BOOST_CLK,
+ .type_id = LWMI_TYPE_ID_NONE,
+};
+
+static struct tunable_attr_01 dgpu_enable = {
+ .device_id = LWMI_DEVICE_ID_GPU,
+ .feature_id = LWMI_FEATURE_ID_DGPU_EN,
+ .type_id = LWMI_TYPE_ID_NONE,
+};
+
+static struct tunable_attr_01 gpu_mode = {
+ .device_id = LWMI_DEVICE_ID_GPU,
+ .feature_id = LWMI_FEATURE_ID_GPU_MODE,
+ .type_id = LWMI_TYPE_ID_NONE,
+};
+
+static struct tunable_attr_01 dgpu_didvid = {
+ .device_id = LWMI_DEVICE_ID_GPU,
+ .feature_id = LWMI_FEATURE_ID_DGPU_DIDVID,
+ .type_id = LWMI_TYPE_ID_NONE,
+};
+
+static struct tunable_attr_01 gpu_nv_bpl = {
+ .device_id = LWMI_DEVICE_ID_GPU,
+ .feature_id = LWMI_FEATURE_ID_GPU_NV_BPL,
+ .type_id = LWMI_TYPE_ID_NONE,
+};
+
+static struct tunable_attr_01 gpu_nv_cpu_boost = {
+ .device_id = LWMI_DEVICE_ID_GPU,
+ .feature_id = LWMI_FEATURE_ID_GPU_NV_CPU_BOOST,
+ .type_id = LWMI_TYPE_ID_NONE,
+};
+
struct capdata01_attr_group {
const struct attribute_group *attr_group;
struct tunable_attr_01 *tunable_attr;
@@ -1076,6 +1156,7 @@ static int lwmi_attr_01_is_supported(struct tunable_attr_01 *tunable_attr)
.name = _fsname, .attrs = _attrname##_attrs \
}
+/* CPU tunable attributes */
LWMI_ATTR_GROUP_TUNABLE_CAP01(ppt_pl1_spl, "ppt_pl1_spl",
"Set the CPU sustained power limit");
LWMI_ATTR_GROUP_TUNABLE_CAP01(ppt_pl1_spl_cl, "ppt_pl1_spl_cl",
@@ -1103,6 +1184,29 @@ LWMI_ATTR_GROUP_TUNABLE_CAP01(ppt_pl4_ipl, "ppt_pl4_ipl",
LWMI_ATTR_GROUP_TUNABLE_CAP01(ppt_pl4_ipl_cl, "ppt_pl4_ipl_cl",
"Set the CPU cross loading instantaneous power limit");
+/* GPU tunable attributes */
+LWMI_ATTR_GROUP_TUNABLE_CAP01(gpu_nv_ppab, "gpu_nv_ppab",
+ "Set the Nvidia GPU power performance aware boost limit");
+LWMI_ATTR_GROUP_TUNABLE_CAP01(gpu_nv_ctgp, "gpu_nv_ctgp",
+ "Set the GPU configurable total graphics power");
+LWMI_ATTR_GROUP_TUNABLE_CAP01(gpu_temp, "gpu_temp",
+ "Set the GPU thermal load limit");
+LWMI_ATTR_GROUP_TUNABLE_CAP01(gpu_nv_ac_offset, "gpu_nv_ac_offset",
+ "Set the Nvidia GPU AC total processing power baseline offset");
+LWMI_ATTR_GROUP_TUNABLE_CAP01(gpu_oc_stat, "gpu_oc_stat",
+ "Set the GPU overclocking status");
+LWMI_ATTR_GROUP_TUNABLE_CAP01(dgpu_boost_clk, "gpu_boost_clk",
+ "Set the dedicated GPU boost clock");
+LWMI_ATTR_GROUP_TUNABLE_CAP01(dgpu_enable, "dgpu_enable",
+ "Set the dedicated Nvidia GPU enabled status");
+LWMI_ATTR_GROUP_TUNABLE_CAP01(gpu_mode, "gpu_mode",
+ "Set the GPU mode by power limit");
+LWMI_ATTR_GROUP_TUNABLE_CAP01(dgpu_didvid, "gpu_didvid",
+ "Get the GPU device identifier and vendor identifier");
+LWMI_ATTR_GROUP_TUNABLE_CAP01(gpu_nv_bpl, "gpu_nv_bpl",
+ "Set the Nvidia GPU base power limit");
+LWMI_ATTR_GROUP_TUNABLE_CAP01(gpu_nv_cpu_boost, "gpu_nv_cpu_boost",
+ "Set the Nvidia GPU to CPU dynamic boost limit");
static struct capdata01_attr_group cd01_attr_groups[] = {
{ &ppt_pl1_spl_attr_group, &ppt_pl1_spl },
@@ -1118,6 +1222,16 @@ static struct capdata01_attr_group cd01_attr_groups[] = {
{ &cpu_oc_stat_attr_group, &cpu_oc_stat },
{ &ppt_pl4_ipl_attr_group, &ppt_pl4_ipl },
{ &ppt_pl4_ipl_cl_attr_group, &ppt_pl4_ipl_cl },
+ { &gpu_nv_ppab_attr_group, &gpu_nv_ppab },
+ { &gpu_nv_ctgp_attr_group, &gpu_nv_ctgp },
+ { &gpu_temp_attr_group, &gpu_temp },
+ { &gpu_nv_ac_offset_attr_group, &gpu_nv_ac_offset },
+ { &gpu_oc_stat_attr_group, &gpu_oc_stat },
+ { &dgpu_boost_clk_attr_group, &dgpu_boost_clk },
+ { &dgpu_enable_attr_group, &dgpu_enable },
+ { &dgpu_didvid_attr_group, &dgpu_didvid },
+ { &gpu_nv_bpl_attr_group, &gpu_nv_bpl },
+ { &gpu_nv_cpu_boost_attr_group, &gpu_nv_cpu_boost },
{},
};
--
2.52.0
Hi Derek,
kernel test robot noticed the following build warnings:
[auto build test WARNING on next-20260212]
[cannot apply to linus/master v6.19 v6.19-rc8 v6.19-rc7 v6.19]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Derek-J-Clark/platform-x86-lenovo-wmi-other-Add-LWMI_ATTR_ID-Macro/20260213-161603
base: next-20260212
patch link: https://lore.kernel.org/r/20260213081243.794288-5-derekjohn.clark%40gmail.com
patch subject: [PATCH 4/5] platform/x86: lenovo-wmi-other: Add GPU tunable attributes
config: i386-randconfig-003-20260213 (https://download.01.org/0day-ci/archive/20260214/202602140438.FqccdLwp-lkp@intel.com/config)
compiler: gcc-14 (Debian 14.2.0-19) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260214/202602140438.FqccdLwp-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202602140438.FqccdLwp-lkp@intel.com/
All warnings (new ones prefixed by >>):
>> drivers/platform/x86/lenovo/wmi-other.c:1202:31: warning: 'gpu_mode_attr_group' defined but not used [-Wunused-const-variable=]
1202 | LWMI_ATTR_GROUP_TUNABLE_CAP01(gpu_mode, "gpu_mode",
| ^~~~~~~~
drivers/platform/x86/lenovo/wmi-other.c:1155:45: note: in definition of macro 'LWMI_ATTR_GROUP_TUNABLE_CAP01'
1155 | static const struct attribute_group _attrname##_attr_group = { \
| ^~~~~~~~~
vim +/gpu_mode_attr_group +1202 drivers/platform/x86/lenovo/wmi-other.c
1081
1082 /* Lenovo WMI Other Mode Attribute macros */
1083 #define __LWMI_ATTR_RO(_func, _name) \
1084 { \
1085 .attr = { .name = __stringify(_name), .mode = 0444 }, \
1086 .show = _func##_##_name##_show, \
1087 }
1088
1089 #define __LWMI_ATTR_RO_AS(_name, _show) \
1090 { \
1091 .attr = { .name = __stringify(_name), .mode = 0444 }, \
1092 .show = _show, \
1093 }
1094
1095 #define __LWMI_ATTR_RW(_func, _name) \
1096 __ATTR(_name, 0644, _func##_##_name##_show, _func##_##_name##_store)
1097
1098 /* Shows a formatted static variable */
1099 #define __LWMI_ATTR_SHOW_FMT(_prop, _attrname, _fmt, _val) \
1100 static ssize_t _attrname##_##_prop##_show( \
1101 struct kobject *kobj, struct kobj_attribute *kattr, char *buf) \
1102 { \
1103 return sysfs_emit(buf, _fmt, _val); \
1104 } \
1105 static struct kobj_attribute attr_##_attrname##_##_prop = \
1106 __LWMI_ATTR_RO(_attrname, _prop)
1107
1108 /* Attribute current value read/write */
1109 #define __LWMI_TUNABLE_CURRENT_VALUE_CAP01(_attrname) \
1110 static ssize_t _attrname##_current_value_store( \
1111 struct kobject *kobj, struct kobj_attribute *kattr, \
1112 const char *buf, size_t count) \
1113 { \
1114 return attr_current_value_store(kobj, kattr, buf, count, \
1115 &_attrname); \
1116 } \
1117 static ssize_t _attrname##_current_value_show( \
1118 struct kobject *kobj, struct kobj_attribute *kattr, char *buf) \
1119 { \
1120 return attr_current_value_show(kobj, kattr, buf, &_attrname); \
1121 } \
1122 static struct kobj_attribute attr_##_attrname##_current_value = \
1123 __LWMI_ATTR_RW(_attrname, current_value)
1124
1125 /* Attribute property read only */
1126 #define __LWMI_TUNABLE_RO_CAP01(_prop, _attrname, _prop_type) \
1127 static ssize_t _attrname##_##_prop##_show( \
1128 struct kobject *kobj, struct kobj_attribute *kattr, char *buf) \
1129 { \
1130 return attr_capdata01_show(kobj, kattr, buf, &_attrname, \
1131 _prop_type); \
1132 } \
1133 static struct kobj_attribute attr_##_attrname##_##_prop = \
1134 __LWMI_ATTR_RO(_attrname, _prop)
1135
1136 #define LWMI_ATTR_GROUP_TUNABLE_CAP01(_attrname, _fsname, _dispname) \
1137 __LWMI_TUNABLE_CURRENT_VALUE_CAP01(_attrname); \
1138 __LWMI_TUNABLE_RO_CAP01(default_value, _attrname, DEFAULT_VAL); \
1139 __LWMI_ATTR_SHOW_FMT(display_name, _attrname, "%s\n", _dispname); \
1140 __LWMI_TUNABLE_RO_CAP01(max_value, _attrname, MAX_VAL); \
1141 __LWMI_TUNABLE_RO_CAP01(min_value, _attrname, MIN_VAL); \
1142 __LWMI_TUNABLE_RO_CAP01(scalar_increment, _attrname, STEP_VAL); \
1143 static struct kobj_attribute attr_##_attrname##_type = \
1144 __LWMI_ATTR_RO_AS(type, int_type_show); \
1145 static struct attribute *_attrname##_attrs[] = { \
1146 &attr_##_attrname##_current_value.attr, \
1147 &attr_##_attrname##_default_value.attr, \
1148 &attr_##_attrname##_display_name.attr, \
1149 &attr_##_attrname##_max_value.attr, \
1150 &attr_##_attrname##_min_value.attr, \
1151 &attr_##_attrname##_scalar_increment.attr, \
1152 &attr_##_attrname##_type.attr, \
1153 NULL, \
1154 }; \
1155 static const struct attribute_group _attrname##_attr_group = { \
1156 .name = _fsname, .attrs = _attrname##_attrs \
1157 }
1158
1159 /* CPU tunable attributes */
1160 LWMI_ATTR_GROUP_TUNABLE_CAP01(ppt_pl1_spl, "ppt_pl1_spl",
1161 "Set the CPU sustained power limit");
1162 LWMI_ATTR_GROUP_TUNABLE_CAP01(ppt_pl1_spl_cl, "ppt_pl1_spl_cl",
1163 "Set the CPU cross loading sustained power limit");
1164 LWMI_ATTR_GROUP_TUNABLE_CAP01(ppt_pl2_sppt, "ppt_pl2_sppt",
1165 "Set the CPU slow package power tracking limit");
1166 LWMI_ATTR_GROUP_TUNABLE_CAP01(ppt_pl2_sppt_cl, "ppt_pl2_sppt_cl",
1167 "Set the CPU cross loading slow package power tracking limit");
1168 LWMI_ATTR_GROUP_TUNABLE_CAP01(ppt_pl3_fppt, "ppt_pl3_fppt",
1169 "Set the CPU fast package power tracking limit");
1170 LWMI_ATTR_GROUP_TUNABLE_CAP01(ppt_pl3_fppt_cl, "ppt_pl3_fppt_cl",
1171 "Set the CPU cross loading fast package power tracking limit");
1172 LWMI_ATTR_GROUP_TUNABLE_CAP01(cpu_temp, "cpu_temp",
1173 "Set the CPU thermal load limit");
1174 LWMI_ATTR_GROUP_TUNABLE_CAP01(ppt_pl1_apu_spl, "ppt_pl1_apu_spl",
1175 "Set the APU sustained power limit");
1176 LWMI_ATTR_GROUP_TUNABLE_CAP01(ppt_cpu_cl, "ppt_cpu_cl",
1177 "Set the CPU cross loading power limit");
1178 LWMI_ATTR_GROUP_TUNABLE_CAP01(ppt_pl1_tau, "ppt_pl1_tau",
1179 "Set the CPU sustained power limit exceed duration");
1180 LWMI_ATTR_GROUP_TUNABLE_CAP01(cpu_oc_stat, "cpu_oc_stat",
1181 "Set the CPU overclocking status");
1182 LWMI_ATTR_GROUP_TUNABLE_CAP01(ppt_pl4_ipl, "ppt_pl4_ipl",
1183 "Set the CPU instantaneous power limit");
1184 LWMI_ATTR_GROUP_TUNABLE_CAP01(ppt_pl4_ipl_cl, "ppt_pl4_ipl_cl",
1185 "Set the CPU cross loading instantaneous power limit");
1186
1187 /* GPU tunable attributes */
1188 LWMI_ATTR_GROUP_TUNABLE_CAP01(gpu_nv_ppab, "gpu_nv_ppab",
1189 "Set the Nvidia GPU power performance aware boost limit");
1190 LWMI_ATTR_GROUP_TUNABLE_CAP01(gpu_nv_ctgp, "gpu_nv_ctgp",
1191 "Set the GPU configurable total graphics power");
1192 LWMI_ATTR_GROUP_TUNABLE_CAP01(gpu_temp, "gpu_temp",
1193 "Set the GPU thermal load limit");
1194 LWMI_ATTR_GROUP_TUNABLE_CAP01(gpu_nv_ac_offset, "gpu_nv_ac_offset",
1195 "Set the Nvidia GPU AC total processing power baseline offset");
1196 LWMI_ATTR_GROUP_TUNABLE_CAP01(gpu_oc_stat, "gpu_oc_stat",
1197 "Set the GPU overclocking status");
1198 LWMI_ATTR_GROUP_TUNABLE_CAP01(dgpu_boost_clk, "gpu_boost_clk",
1199 "Set the dedicated GPU boost clock");
1200 LWMI_ATTR_GROUP_TUNABLE_CAP01(dgpu_enable, "dgpu_enable",
1201 "Set the dedicated Nvidia GPU enabled status");
> 1202 LWMI_ATTR_GROUP_TUNABLE_CAP01(gpu_mode, "gpu_mode",
1203 "Set the GPU mode by power limit");
1204 LWMI_ATTR_GROUP_TUNABLE_CAP01(dgpu_didvid, "gpu_didvid",
1205 "Get the GPU device identifier and vendor identifier");
1206 LWMI_ATTR_GROUP_TUNABLE_CAP01(gpu_nv_bpl, "gpu_nv_bpl",
1207 "Set the Nvidia GPU base power limit");
1208 LWMI_ATTR_GROUP_TUNABLE_CAP01(gpu_nv_cpu_boost, "gpu_nv_cpu_boost",
1209 "Set the Nvidia GPU to CPU dynamic boost limit");
1210
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
Hi Derek,
kernel test robot noticed the following build warnings:
[auto build test WARNING on next-20260212]
[cannot apply to linus/master v6.19 v6.19-rc8 v6.19-rc7 v6.19]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Derek-J-Clark/platform-x86-lenovo-wmi-other-Add-LWMI_ATTR_ID-Macro/20260213-161603
base: next-20260212
patch link: https://lore.kernel.org/r/20260213081243.794288-5-derekjohn.clark%40gmail.com
patch subject: [PATCH 4/5] platform/x86: lenovo-wmi-other: Add GPU tunable attributes
config: x86_64-randconfig-011-20260214 (https://download.01.org/0day-ci/archive/20260214/202602140321.pfFQKWKX-lkp@intel.com/config)
compiler: clang version 20.1.8 (https://github.com/llvm/llvm-project 87f0227cb60147a26a1eeb4fb06e3b505e9c7261)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260214/202602140321.pfFQKWKX-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202602140321.pfFQKWKX-lkp@intel.com/
All warnings (new ones prefixed by >>):
>> drivers/platform/x86/lenovo/wmi-other.c:1202:1: warning: unused variable 'gpu_mode_attr_group' [-Wunused-const-variable]
1202 | LWMI_ATTR_GROUP_TUNABLE_CAP01(gpu_mode, "gpu_mode",
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1203 | "Set the GPU mode by power limit");
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/platform/x86/lenovo/wmi-other.c:1155:38: note: expanded from macro 'LWMI_ATTR_GROUP_TUNABLE_CAP01'
1155 | static const struct attribute_group _attrname##_attr_group = { \
| ^~~~~~~~~~~~~~~~~~~~~~
<scratch space>:155:1: note: expanded from here
155 | gpu_mode_attr_group
| ^~~~~~~~~~~~~~~~~~~
1 warning generated.
vim +/gpu_mode_attr_group +1202 drivers/platform/x86/lenovo/wmi-other.c
1081
1082 /* Lenovo WMI Other Mode Attribute macros */
1083 #define __LWMI_ATTR_RO(_func, _name) \
1084 { \
1085 .attr = { .name = __stringify(_name), .mode = 0444 }, \
1086 .show = _func##_##_name##_show, \
1087 }
1088
1089 #define __LWMI_ATTR_RO_AS(_name, _show) \
1090 { \
1091 .attr = { .name = __stringify(_name), .mode = 0444 }, \
1092 .show = _show, \
1093 }
1094
1095 #define __LWMI_ATTR_RW(_func, _name) \
1096 __ATTR(_name, 0644, _func##_##_name##_show, _func##_##_name##_store)
1097
1098 /* Shows a formatted static variable */
1099 #define __LWMI_ATTR_SHOW_FMT(_prop, _attrname, _fmt, _val) \
1100 static ssize_t _attrname##_##_prop##_show( \
1101 struct kobject *kobj, struct kobj_attribute *kattr, char *buf) \
1102 { \
1103 return sysfs_emit(buf, _fmt, _val); \
1104 } \
1105 static struct kobj_attribute attr_##_attrname##_##_prop = \
1106 __LWMI_ATTR_RO(_attrname, _prop)
1107
1108 /* Attribute current value read/write */
1109 #define __LWMI_TUNABLE_CURRENT_VALUE_CAP01(_attrname) \
1110 static ssize_t _attrname##_current_value_store( \
1111 struct kobject *kobj, struct kobj_attribute *kattr, \
1112 const char *buf, size_t count) \
1113 { \
1114 return attr_current_value_store(kobj, kattr, buf, count, \
1115 &_attrname); \
1116 } \
1117 static ssize_t _attrname##_current_value_show( \
1118 struct kobject *kobj, struct kobj_attribute *kattr, char *buf) \
1119 { \
1120 return attr_current_value_show(kobj, kattr, buf, &_attrname); \
1121 } \
1122 static struct kobj_attribute attr_##_attrname##_current_value = \
1123 __LWMI_ATTR_RW(_attrname, current_value)
1124
1125 /* Attribute property read only */
1126 #define __LWMI_TUNABLE_RO_CAP01(_prop, _attrname, _prop_type) \
1127 static ssize_t _attrname##_##_prop##_show( \
1128 struct kobject *kobj, struct kobj_attribute *kattr, char *buf) \
1129 { \
1130 return attr_capdata01_show(kobj, kattr, buf, &_attrname, \
1131 _prop_type); \
1132 } \
1133 static struct kobj_attribute attr_##_attrname##_##_prop = \
1134 __LWMI_ATTR_RO(_attrname, _prop)
1135
1136 #define LWMI_ATTR_GROUP_TUNABLE_CAP01(_attrname, _fsname, _dispname) \
1137 __LWMI_TUNABLE_CURRENT_VALUE_CAP01(_attrname); \
1138 __LWMI_TUNABLE_RO_CAP01(default_value, _attrname, DEFAULT_VAL); \
1139 __LWMI_ATTR_SHOW_FMT(display_name, _attrname, "%s\n", _dispname); \
1140 __LWMI_TUNABLE_RO_CAP01(max_value, _attrname, MAX_VAL); \
1141 __LWMI_TUNABLE_RO_CAP01(min_value, _attrname, MIN_VAL); \
1142 __LWMI_TUNABLE_RO_CAP01(scalar_increment, _attrname, STEP_VAL); \
1143 static struct kobj_attribute attr_##_attrname##_type = \
1144 __LWMI_ATTR_RO_AS(type, int_type_show); \
1145 static struct attribute *_attrname##_attrs[] = { \
1146 &attr_##_attrname##_current_value.attr, \
1147 &attr_##_attrname##_default_value.attr, \
1148 &attr_##_attrname##_display_name.attr, \
1149 &attr_##_attrname##_max_value.attr, \
1150 &attr_##_attrname##_min_value.attr, \
1151 &attr_##_attrname##_scalar_increment.attr, \
1152 &attr_##_attrname##_type.attr, \
1153 NULL, \
1154 }; \
1155 static const struct attribute_group _attrname##_attr_group = { \
1156 .name = _fsname, .attrs = _attrname##_attrs \
1157 }
1158
1159 /* CPU tunable attributes */
1160 LWMI_ATTR_GROUP_TUNABLE_CAP01(ppt_pl1_spl, "ppt_pl1_spl",
1161 "Set the CPU sustained power limit");
1162 LWMI_ATTR_GROUP_TUNABLE_CAP01(ppt_pl1_spl_cl, "ppt_pl1_spl_cl",
1163 "Set the CPU cross loading sustained power limit");
1164 LWMI_ATTR_GROUP_TUNABLE_CAP01(ppt_pl2_sppt, "ppt_pl2_sppt",
1165 "Set the CPU slow package power tracking limit");
1166 LWMI_ATTR_GROUP_TUNABLE_CAP01(ppt_pl2_sppt_cl, "ppt_pl2_sppt_cl",
1167 "Set the CPU cross loading slow package power tracking limit");
1168 LWMI_ATTR_GROUP_TUNABLE_CAP01(ppt_pl3_fppt, "ppt_pl3_fppt",
1169 "Set the CPU fast package power tracking limit");
1170 LWMI_ATTR_GROUP_TUNABLE_CAP01(ppt_pl3_fppt_cl, "ppt_pl3_fppt_cl",
1171 "Set the CPU cross loading fast package power tracking limit");
1172 LWMI_ATTR_GROUP_TUNABLE_CAP01(cpu_temp, "cpu_temp",
1173 "Set the CPU thermal load limit");
1174 LWMI_ATTR_GROUP_TUNABLE_CAP01(ppt_pl1_apu_spl, "ppt_pl1_apu_spl",
1175 "Set the APU sustained power limit");
1176 LWMI_ATTR_GROUP_TUNABLE_CAP01(ppt_cpu_cl, "ppt_cpu_cl",
1177 "Set the CPU cross loading power limit");
1178 LWMI_ATTR_GROUP_TUNABLE_CAP01(ppt_pl1_tau, "ppt_pl1_tau",
1179 "Set the CPU sustained power limit exceed duration");
1180 LWMI_ATTR_GROUP_TUNABLE_CAP01(cpu_oc_stat, "cpu_oc_stat",
1181 "Set the CPU overclocking status");
1182 LWMI_ATTR_GROUP_TUNABLE_CAP01(ppt_pl4_ipl, "ppt_pl4_ipl",
1183 "Set the CPU instantaneous power limit");
1184 LWMI_ATTR_GROUP_TUNABLE_CAP01(ppt_pl4_ipl_cl, "ppt_pl4_ipl_cl",
1185 "Set the CPU cross loading instantaneous power limit");
1186
1187 /* GPU tunable attributes */
1188 LWMI_ATTR_GROUP_TUNABLE_CAP01(gpu_nv_ppab, "gpu_nv_ppab",
1189 "Set the Nvidia GPU power performance aware boost limit");
1190 LWMI_ATTR_GROUP_TUNABLE_CAP01(gpu_nv_ctgp, "gpu_nv_ctgp",
1191 "Set the GPU configurable total graphics power");
1192 LWMI_ATTR_GROUP_TUNABLE_CAP01(gpu_temp, "gpu_temp",
1193 "Set the GPU thermal load limit");
1194 LWMI_ATTR_GROUP_TUNABLE_CAP01(gpu_nv_ac_offset, "gpu_nv_ac_offset",
1195 "Set the Nvidia GPU AC total processing power baseline offset");
1196 LWMI_ATTR_GROUP_TUNABLE_CAP01(gpu_oc_stat, "gpu_oc_stat",
1197 "Set the GPU overclocking status");
1198 LWMI_ATTR_GROUP_TUNABLE_CAP01(dgpu_boost_clk, "gpu_boost_clk",
1199 "Set the dedicated GPU boost clock");
1200 LWMI_ATTR_GROUP_TUNABLE_CAP01(dgpu_enable, "dgpu_enable",
1201 "Set the dedicated Nvidia GPU enabled status");
> 1202 LWMI_ATTR_GROUP_TUNABLE_CAP01(gpu_mode, "gpu_mode",
1203 "Set the GPU mode by power limit");
1204 LWMI_ATTR_GROUP_TUNABLE_CAP01(dgpu_didvid, "gpu_didvid",
1205 "Get the GPU device identifier and vendor identifier");
1206 LWMI_ATTR_GROUP_TUNABLE_CAP01(gpu_nv_bpl, "gpu_nv_bpl",
1207 "Set the Nvidia GPU base power limit");
1208 LWMI_ATTR_GROUP_TUNABLE_CAP01(gpu_nv_cpu_boost, "gpu_nv_cpu_boost",
1209 "Set the Nvidia GPU to CPU dynamic boost limit");
1210
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
© 2016 - 2026 Red Hat, Inc.