Compare commits
3
Commits
v1.0
..
73f7038eaa
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
73f7038eaa | ||
|
|
113e296347 | ||
|
|
9f29076d52 |
@@ -38,6 +38,7 @@ Available options:
|
||||
[+/-]N to set that fan to an RPM offset from the GPU-controlled speed
|
||||
--reset : Reset all fans to their default mode
|
||||
--sensors : Print sensor readings even if setting a fan speed
|
||||
--compact : Print sensor reading in a compact one-line per card format
|
||||
```
|
||||
|
||||
### Examples:
|
||||
@@ -45,19 +46,19 @@ Read sensors:
|
||||
```text
|
||||
$ ./evga-icx
|
||||
#0: EVGA GeForce RTX 3090 FTW3 Ultra v2 (/dev/i2c-3) @ c:00.0
|
||||
Fan 0: 1094 RPM (36/0%, Auto)
|
||||
Fan 1: 1164 RPM (38/0%, Auto)
|
||||
Fan 2: 1161 RPM (38/0%, Offset)
|
||||
Fan 0: 1934 RPM (64/0%, Auto)
|
||||
Fan 1: 1930 RPM (64/0%, Auto)
|
||||
Fan 2: 1944 RPM (64/0%, Offset)
|
||||
Ext. fan: 0 RPM (0/0%, Offset)
|
||||
GPU2: 35.8 C
|
||||
MEM1: 35.3 C
|
||||
MEM2: 35.6 C
|
||||
MEM3: 35.9 C
|
||||
PWR1: 35.0 C
|
||||
PWR2: 35.6 C
|
||||
PWR3: 36.3 C
|
||||
PWR4: 36.9 C
|
||||
PWR5: 36.3 C
|
||||
GPU2: +64.1°C
|
||||
MEM1: +62.2°C
|
||||
MEM2: +58.2°C
|
||||
MEM3: +62.2°C
|
||||
PWR1: +54.3°C
|
||||
PWR2: +59.4°C
|
||||
PWR3: +66.0°C
|
||||
PWR4: +64.3°C
|
||||
PWR5: +57.6°C
|
||||
```
|
||||
|
||||
Set external fan to follow Nvidia driver controlled speed with a -500 RPM offset:
|
||||
|
||||
@@ -84,6 +84,7 @@ struct card_info {
|
||||
char *card_name;
|
||||
char *pci_id;
|
||||
char *i2c_dev_path;
|
||||
int fd;
|
||||
};
|
||||
|
||||
struct gpu_pci_info {
|
||||
|
||||
+21
-9
@@ -19,15 +19,17 @@ static const char helpstring[] = "Available options:\n"
|
||||
" N to set the fan to that manual % speed\n"
|
||||
" [+/-]N to set that fan to an RPM offset from the GPU-controlled speed\n"
|
||||
"--reset : Reset all fans to their default mode\n"
|
||||
"--sensors : Print sensor readings even if setting a fan speed \n";
|
||||
"--sensors : Print sensor readings even if setting a fan speed \n"
|
||||
"--compact : Print sensor reading in a compact one-line per card format\n";
|
||||
|
||||
void print_gpu_info(int gpu_num, struct card_info gpus[]);
|
||||
void print_gpu_info(int gpu_num, struct card_info gpus[], int compact);
|
||||
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
struct card_info gpus[MAX_GPUS];
|
||||
int gpu_count;
|
||||
int print_info = 0;
|
||||
int compact = 0;
|
||||
int gpu_num = -1; /* Card to control */
|
||||
char *fan_speed[ICX3_MAX_FANS] = {NULL};
|
||||
|
||||
@@ -65,6 +67,8 @@ int main (int argc, char **argv)
|
||||
fan_speed[j] = "auto";
|
||||
} else if (strcmp(argv[i], "--sensors") == 0) {
|
||||
print_info = 1;
|
||||
} else if (strcmp(argv[i], "--compact") == 0) {
|
||||
compact = 1;
|
||||
} else {
|
||||
printf(helpstring);
|
||||
return 0;
|
||||
@@ -117,19 +121,27 @@ int main (int argc, char **argv)
|
||||
if (print_info) {
|
||||
if (gpu_num == -1) {
|
||||
for (int i = 0; i < gpu_count; i++){
|
||||
print_gpu_info(i, gpus);
|
||||
print_gpu_info(i, gpus, compact);
|
||||
}
|
||||
} else if (gpu_num <= gpu_count - 1) {
|
||||
print_gpu_info(gpu_num, gpus);
|
||||
print_gpu_info(gpu_num, gpus, compact);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void print_gpu_info(int gpu_num, struct card_info gpus[]) {
|
||||
printf("#%d: %s (%s) @ %s\n", gpu_num, gpus[gpu_num].card_name, gpus[gpu_num].i2c_dev_path, gpus[gpu_num].pci_id);
|
||||
print_icx3_fans(gpus[gpu_num].i2c_dev_path);
|
||||
print_icx3_temps(gpus[gpu_num].i2c_dev_path);
|
||||
printf("\n");
|
||||
void print_gpu_info(int gpu_num, struct card_info gpus[], int compact) {
|
||||
if (compact) {
|
||||
printf("#%d ", gpu_num);
|
||||
print_icx3_fans_oneline(gpus[gpu_num].i2c_dev_path);
|
||||
print_icx3_temps_oneline(gpus[gpu_num].i2c_dev_path);
|
||||
printf("\n");
|
||||
} else {
|
||||
printf("#%d: %s (%s) @ %s\n", gpu_num, gpus[gpu_num].card_name, gpus[gpu_num].i2c_dev_path, gpus[gpu_num].pci_id);
|
||||
print_icx3_fans(gpus[gpu_num].i2c_dev_path);
|
||||
print_icx3_temps(gpus[gpu_num].i2c_dev_path);
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -33,72 +33,59 @@ enum icx3_product_id check_for_icx3(char *i2c_dev_path)
|
||||
|
||||
void print_icx3_fans(char *i2c_dev_path)
|
||||
{
|
||||
char data[I2C_SMBUS_BLOCK_MAX] = {};
|
||||
int fd, read_result;
|
||||
|
||||
struct icx3_fan_control *fan_status;
|
||||
|
||||
/* First thing is to check for the product ID to figure out how many fans we have */
|
||||
char fans_avail[ICX3_MAX_FANS] = {0};
|
||||
get_available_fans(i2c_dev_path, fans_avail);
|
||||
|
||||
fd = open_i2c_dev(i2c_dev_path);
|
||||
if (fd == -1)
|
||||
return;
|
||||
struct icx3_fan_control fans[ICX3_MAX_FANS];
|
||||
get_fan_status(fans, i2c_dev_path);
|
||||
|
||||
for (int i=0; i < ICX3_MAX_FANS; i++) {
|
||||
if (!fans_avail[i])
|
||||
continue;
|
||||
|
||||
read_result = i2c_smbus_read_i2c_block_data(fd, ICX3_REG_FANCONTROL + i, ICX3_FANCONTROL_SIZE, data);
|
||||
if (read_result != ICX3_FANCONTROL_SIZE) {
|
||||
close(fd);
|
||||
return;
|
||||
}
|
||||
fan_status = (struct icx3_fan_control*) &data;
|
||||
printf("%s: %d RPM (%d/%d%%, %s)\n",
|
||||
icx3_fan_names[i],
|
||||
fan_status->rpm_status,
|
||||
fan_status->duty_status,
|
||||
fan_status->duty,
|
||||
icx3_fan_mode_names[fan_status->fanmode]
|
||||
fans[i].rpm_status,
|
||||
fans[i].duty_status,
|
||||
fans[i].duty,
|
||||
icx3_fan_mode_names[fans[i].fanmode]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
close(fd);
|
||||
void print_icx3_fans_oneline(char *i2c_dev_path)
|
||||
{
|
||||
struct icx3_fan_control fans[ICX3_MAX_FANS];
|
||||
get_fan_status(fans, i2c_dev_path);
|
||||
|
||||
printf("FAN");
|
||||
for (int i=0; i < ICX3_MAX_FANS; i++) {
|
||||
printf(" %3d", fans[i].duty_status);
|
||||
}
|
||||
printf("%%");
|
||||
}
|
||||
|
||||
void print_icx3_temps(char *i2c_dev_path)
|
||||
{
|
||||
char data[I2C_SMBUS_BLOCK_MAX] = {};
|
||||
int fd, read_result;
|
||||
struct icx3_temp_sensors *temp_sensors;
|
||||
float temps[ICX3_NUM_TEMP_SENSORS];
|
||||
|
||||
fd = open_i2c_dev(i2c_dev_path);
|
||||
if (fd == -1)
|
||||
return;
|
||||
|
||||
read_result = i2c_smbus_read_i2c_block_data(fd, ICX3_REG_TEMPSENSOR, ICX3_TEMPSENSOR_SIZE, data);
|
||||
if (read_result != ICX3_TEMPSENSOR_SIZE) {
|
||||
close(fd);
|
||||
return;
|
||||
}
|
||||
temp_sensors = (struct icx3_temp_sensors*) &data;
|
||||
|
||||
float cur_temp;
|
||||
short cur_data;
|
||||
get_temp_sensors(temps, i2c_dev_path);
|
||||
|
||||
for (int i=0; i<ICX3_NUM_TEMP_SENSORS; i++) {
|
||||
/* endian swap */
|
||||
cur_data = (short)(temp_sensors->data[2*i+1] << 8) | (short)(temp_sensors->data[2*i]);
|
||||
/* temp is reported in tenths of deg C */
|
||||
cur_temp = (float)cur_data/10;
|
||||
printf("%s: %.1f C\n",
|
||||
printf("%s: %+.1f°C\n",
|
||||
icx3_temp_sensor_names[i],
|
||||
cur_temp);
|
||||
temps[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void print_icx3_temps_oneline(char *i2c_dev_path)
|
||||
{
|
||||
float temps[ICX3_NUM_TEMP_SENSORS];
|
||||
|
||||
get_temp_sensors(temps, i2c_dev_path);
|
||||
|
||||
for (int i=0; i<ICX3_NUM_TEMP_SENSORS; i++) {
|
||||
if (i == 0 || strncmp(icx3_temp_sensor_names[i], icx3_temp_sensor_names[i-1], 3))
|
||||
printf(" %.3s", icx3_temp_sensor_names[i]);
|
||||
printf(" %3.0f", temps[i]);
|
||||
}
|
||||
printf("°C");
|
||||
}
|
||||
|
||||
void get_available_fans(char *i2c_dev_path, char *fans_avail)
|
||||
{
|
||||
int product_id = check_for_icx3(i2c_dev_path);
|
||||
@@ -155,6 +142,62 @@ void get_available_fans(char *i2c_dev_path, char *fans_avail)
|
||||
}
|
||||
}
|
||||
|
||||
void get_fan_status(struct icx3_fan_control *fans, char *i2c_dev_path)
|
||||
{
|
||||
char data[I2C_SMBUS_BLOCK_MAX] = {};
|
||||
int fd, read_result;
|
||||
|
||||
/* First thing is to check for the product ID to figure out how many fans we have */
|
||||
char fans_avail[ICX3_MAX_FANS] = {0};
|
||||
get_available_fans(i2c_dev_path, fans_avail);
|
||||
|
||||
fd = open_i2c_dev(i2c_dev_path);
|
||||
if (fd == -1)
|
||||
return;
|
||||
|
||||
for (int i=0; i < ICX3_MAX_FANS; i++) {
|
||||
if (!fans_avail[i]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
read_result = i2c_smbus_read_i2c_block_data(fd, ICX3_REG_FANCONTROL + i, ICX3_FANCONTROL_SIZE, data);
|
||||
if (read_result != ICX3_FANCONTROL_SIZE) {
|
||||
close(fd);
|
||||
return;
|
||||
}
|
||||
memcpy(&fans[i], &data, sizeof(struct icx3_fan_control));
|
||||
}
|
||||
|
||||
close(fd);
|
||||
}
|
||||
|
||||
void get_temp_sensors(float *temps, char *i2c_dev_path)
|
||||
{
|
||||
char data[I2C_SMBUS_BLOCK_MAX] = {};
|
||||
int fd, read_result;
|
||||
struct icx3_temp_sensors *temp_sensors;
|
||||
|
||||
fd = open_i2c_dev(i2c_dev_path);
|
||||
if (fd == -1)
|
||||
return;
|
||||
|
||||
read_result = i2c_smbus_read_i2c_block_data(fd, ICX3_REG_TEMPSENSOR, ICX3_TEMPSENSOR_SIZE, data);
|
||||
close(fd);
|
||||
if (read_result != ICX3_TEMPSENSOR_SIZE)
|
||||
return;
|
||||
temp_sensors = (struct icx3_temp_sensors*) &data;
|
||||
|
||||
float cur_temp;
|
||||
short cur_data;
|
||||
|
||||
for (int i=0; i<ICX3_NUM_TEMP_SENSORS; i++) {
|
||||
/* endian swap */
|
||||
cur_data = (short)(temp_sensors->data[2*i+1] << 8) | (short)(temp_sensors->data[2*i]);
|
||||
/* temp is reported in tenths of deg C */
|
||||
temps[i] = (float)cur_data/10;
|
||||
}
|
||||
}
|
||||
|
||||
int open_i2c_dev(char *i2c_dev_path)
|
||||
{
|
||||
int fd = open(i2c_dev_path, O_RDONLY);
|
||||
|
||||
@@ -113,8 +113,12 @@ static char *icx3_temp_sensor_names[] = {
|
||||
|
||||
enum icx3_product_id check_for_icx3(char *i2c_dev_path);
|
||||
void print_icx3_fans(char *i2c_dev_path);
|
||||
void print_icx3_fans_oneline(char *i2c_dev_path);
|
||||
void print_icx3_temps(char *i2c_dev_path);
|
||||
void print_icx3_temps_oneline(char *i2c_dev_path);
|
||||
void get_available_fans(char *i2c_dev_path, char *fans_avail);
|
||||
void get_fan_status(struct icx3_fan_control *fans, char *i2c_dev_path);
|
||||
void get_temp_sensors(float *temps, char *i2c_dev_path);
|
||||
int open_i2c_dev(char *i2c_dev_path);
|
||||
void enable_write(int enable, char *i2c_dev_path);
|
||||
void set_fan(int fan, char *setting, char *i2c_dev_path);
|
||||
Reference in New Issue
Block a user