Skip to content

Commit 8190b9e

Browse files
spandruvadarafaeljw
authored andcommitted
thermal: intel: selftests: workload_hint: Support slow workload hints
Add option to enable slow workload type hints. User can specify "slow" as the command line argument to enable slow workload type hints. There are two slow workload type hints: "power" and "performance". Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Link: https://patch.msgid.link/20251218222559.4110027-3-srinivas.pandruvada@linux.intel.com Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent a499c24 commit 8190b9e

1 file changed

Lines changed: 52 additions & 22 deletions

File tree

tools/testing/selftests/thermal/intel/workload_hint/workload_hint_test.c

Lines changed: 52 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
#define WORKLOAD_NOTIFICATION_DELAY_ATTRIBUTE "/sys/bus/pci/devices/0000:00:04.0/workload_hint/notification_delay_ms"
1414
#define WORKLOAD_ENABLE_ATTRIBUTE "/sys/bus/pci/devices/0000:00:04.0/workload_hint/workload_hint_enable"
15+
#define WORKLOAD_SLOW_ENABLE_ATTRIBUTE "/sys/bus/pci/devices/0000:00:04.0/workload_hint/workload_slow_hint_enable"
1516
#define WORKLOAD_TYPE_INDEX_ATTRIBUTE "/sys/bus/pci/devices/0000:00:04.0/workload_hint/workload_type_index"
1617

1718
static const char * const workload_types[] = {
@@ -22,6 +23,9 @@ static const char * const workload_types[] = {
2223
NULL
2324
};
2425

26+
static int wlt_slow;
27+
static char *wlt_enable_attr;
28+
2529
#define WORKLOAD_TYPE_MAX_INDEX 3
2630

2731
void workload_hint_exit(int signum)
@@ -30,7 +34,7 @@ void workload_hint_exit(int signum)
3034

3135
/* Disable feature via sysfs knob */
3236

33-
fd = open(WORKLOAD_ENABLE_ATTRIBUTE, O_RDWR);
37+
fd = open(wlt_enable_attr, O_RDWR);
3438
if (fd < 0) {
3539
perror("Unable to open workload type feature enable file");
3640
exit(1);
@@ -46,6 +50,26 @@ void workload_hint_exit(int signum)
4650
close(fd);
4751
}
4852

53+
static void update_delay(char *delay_str)
54+
{
55+
int fd;
56+
57+
printf("Setting notification delay in ms to %s\n", delay_str);
58+
59+
fd = open(WORKLOAD_NOTIFICATION_DELAY_ATTRIBUTE, O_RDWR);
60+
if (fd < 0) {
61+
perror("Unable to open workload notification delay");
62+
exit(1);
63+
}
64+
65+
if (write(fd, delay_str, strlen(delay_str)) < 0) {
66+
perror("Can't set delay");
67+
exit(1);
68+
}
69+
70+
close(fd);
71+
}
72+
4973
int main(int argc, char **argv)
5074
{
5175
struct pollfd ufd;
@@ -54,32 +78,26 @@ int main(int argc, char **argv)
5478
char delay_str[64];
5579
int delay = 0;
5680

57-
printf("Usage: workload_hint_test [notification delay in milli seconds]\n");
81+
printf("Usage: workload_hint_test [notification delay in milli seconds][slow]\n");
5882

5983
if (argc > 1) {
60-
ret = sscanf(argv[1], "%d", &delay);
61-
if (ret < 0) {
62-
printf("Invalid delay\n");
63-
exit(1);
64-
}
84+
int i;
6585

66-
printf("Setting notification delay to %d ms\n", delay);
67-
if (delay < 0)
68-
exit(1);
86+
for (i = 1; i < argc; ++i) {
87+
if (!strcmp(argv[i], "slow")) {
88+
wlt_slow = 1;
89+
continue;
90+
}
6991

70-
sprintf(delay_str, "%s\n", argv[1]);
71-
fd = open(WORKLOAD_NOTIFICATION_DELAY_ATTRIBUTE, O_RDWR);
72-
if (fd < 0) {
73-
perror("Unable to open workload notification delay");
74-
exit(1);
75-
}
92+
ret = sscanf(argv[1], "%d", &delay);
93+
if (ret < 0) {
94+
printf("Invalid delay\n");
95+
exit(1);
96+
}
7697

77-
if (write(fd, delay_str, strlen(delay_str)) < 0) {
78-
perror("Can't set delay");
79-
exit(1);
98+
sprintf(delay_str, "%s\n", argv[1]);
99+
update_delay(delay_str);
80100
}
81-
82-
close(fd);
83101
}
84102

85103
if (signal(SIGINT, workload_hint_exit) == SIG_IGN)
@@ -89,8 +107,13 @@ int main(int argc, char **argv)
89107
if (signal(SIGTERM, workload_hint_exit) == SIG_IGN)
90108
signal(SIGTERM, SIG_IGN);
91109

110+
if (wlt_slow)
111+
wlt_enable_attr = WORKLOAD_SLOW_ENABLE_ATTRIBUTE;
112+
else
113+
wlt_enable_attr = WORKLOAD_ENABLE_ATTRIBUTE;
114+
92115
/* Enable feature via sysfs knob */
93-
fd = open(WORKLOAD_ENABLE_ATTRIBUTE, O_RDWR);
116+
fd = open(wlt_enable_attr, O_RDWR);
94117
if (fd < 0) {
95118
perror("Unable to open workload type feature enable file");
96119
exit(1);
@@ -145,6 +168,13 @@ int main(int argc, char **argv)
145168
if (ret < 0)
146169
break;
147170

171+
if (wlt_slow) {
172+
if (index & 0x10)
173+
printf("workload type slow:%s\n", "power");
174+
else
175+
printf("workload type slow:%s\n", "performance");
176+
}
177+
148178
index &= 0x0f;
149179
if (index > WORKLOAD_TYPE_MAX_INDEX)
150180
printf("Invalid workload type index\n");

0 commit comments

Comments
 (0)