From a9f8754922002109498b6fe7de456703bf2171b8 Mon Sep 17 00:00:00 2001 From: moosecrap Date: Thu, 27 Mar 2025 04:32:38 -0700 Subject: [PATCH] Added support for latest kernel i2c sysfs --- evga-card.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/evga-card.c b/evga-card.c index 1f0bd6f..377d411 100644 --- a/evga-card.c +++ b/evga-card.c @@ -10,9 +10,10 @@ and respond with the correct iCX3 version information */ int find_evga_gpu_i2cs(struct card_info *infos, int max_gpus, int i2c_bus) { - char i2c_devices_path[NAME_MAX]; - char device_path[NAME_MAX]; - char dev_file[NAME_MAX]; + char i2c_devices_path[PATH_MAX]; + char device_path[PATH_MAX]; + char dev_file[PATH_MAX]; + char pci_path[PATH_MAX]; char *pci_addr; FILE *test_fd; @@ -55,10 +56,14 @@ int find_evga_gpu_i2cs(struct card_info *infos, int max_gpus, int i2c_bus) continue; /* Read the PCI info for the underlying device */ - pci_vendor = read_pci_id(device_path, "/device/vendor"); - pci_device = read_pci_id(device_path, "/device/device"); - pci_subsystem_vendor = read_pci_id(device_path, "/device/subsystem_vendor"); - pci_subsystem_device = read_pci_id(device_path, "/device/subsystem_device"); + strcat(device_path, "/../"); + if (realpath(device_path, pci_path) == NULL) + continue; + + pci_vendor = read_pci_id(pci_path, "/vendor"); + pci_device = read_pci_id(pci_path, "/device"); + pci_subsystem_vendor = read_pci_id(pci_path, "/subsystem_vendor"); + pci_subsystem_device = read_pci_id(pci_path, "/subsystem_device"); /* See if it's a matching device for a supported EVGA card */ for (int i = 0; i < (sizeof(evga_pci_ids) / sizeof(struct gpu_pci_info)); i++) { @@ -97,7 +102,7 @@ int find_evga_gpu_i2cs(struct card_info *infos, int max_gpus, int i2c_bus) unsigned short read_pci_id(char *device_path, char *field) { char buf[16]; - char file_path[NAME_MAX]; + char file_path[PATH_MAX]; strcpy(file_path, device_path); strcat(file_path, field); @@ -119,7 +124,7 @@ unsigned short read_pci_id(char *device_path, char *field) char *read_nvidia_pci_address(char *device_path) { - char file_path[NAME_MAX]; + char file_path[PATH_MAX]; char *ret = calloc(16 + 1, sizeof(char)); /* assuming pci ids could look as large as 00000000:0C:00.0 */