From 979f9e98686280a1c1c082aa944c14b6db4e923a Mon Sep 17 00:00:00 2001 From: Jens Steube Date: Fri, 9 Jul 2021 20:48:10 +0200 Subject: [PATCH] Rename hardware monitor interface sysfs to sysfs_amdgpu --- include/ext_sysfs.h | 38 ------- include/ext_sysfs_amdgpu.h | 38 +++++++ include/types.h | 16 +-- src/Makefile | 2 +- src/backend.c | 47 +++++---- src/{ext_sysfs.c => ext_sysfs_amdgpu.c} | 48 ++++----- src/hwmon.c | 130 ++++++++++++------------ 7 files changed, 163 insertions(+), 156 deletions(-) delete mode 100644 include/ext_sysfs.h create mode 100644 include/ext_sysfs_amdgpu.h rename src/{ext_sysfs.c => ext_sysfs_amdgpu.c} (77%) diff --git a/include/ext_sysfs.h b/include/ext_sysfs.h deleted file mode 100644 index 02dfd6177..000000000 --- a/include/ext_sysfs.h +++ /dev/null @@ -1,38 +0,0 @@ -/** - * Author......: See docs/credits.txt - * License.....: MIT - */ - -#ifndef _EXT_SYSFS_H -#define _EXT_SYSFS_H - -#include - -static const char SYS_BUS_PCI_DEVICES[] = "/sys/bus/pci/devices"; - -typedef int HM_ADAPTER_SYSFS; - -typedef void *SYSFS_LIB; - -typedef struct hm_sysfs_lib -{ - // currently not using libudev, because it can only read values, not set them, so using /sys instead - - SYSFS_LIB lib; - -} hm_sysfs_lib_t; - -typedef hm_sysfs_lib_t SYSFS_PTR; - -bool sysfs_init (void *hashcat_ctx); -void sysfs_close (void *hashcat_ctx); -char *hm_SYSFS_get_syspath_device (void *hashcat_ctx, const int backend_device_idx); -char *hm_SYSFS_get_syspath_hwmon (void *hashcat_ctx, const int backend_device_idx); -int hm_SYSFS_get_fan_speed_current (void *hashcat_ctx, const int backend_device_idx, int *val); -int hm_SYSFS_get_temperature_current (void *hashcat_ctx, const int backend_device_idx, int *val); -int hm_SYSFS_get_pp_dpm_sclk (void *hashcat_ctx, const int backend_device_idx, int *val); -int hm_SYSFS_get_pp_dpm_mclk (void *hashcat_ctx, const int backend_device_idx, int *val); -int hm_SYSFS_get_pp_dpm_pcie (void *hashcat_ctx, const int backend_device_idx, int *val); -int hm_SYSFS_get_gpu_busy_percent (void *hashcat_ctx, const int backend_device_idx, int *val); - -#endif // _EXT_SYSFS_H diff --git a/include/ext_sysfs_amdgpu.h b/include/ext_sysfs_amdgpu.h new file mode 100644 index 000000000..ef8be1791 --- /dev/null +++ b/include/ext_sysfs_amdgpu.h @@ -0,0 +1,38 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#ifndef _EXT_SYSFS_AMDGPU_H +#define _EXT_SYSFS_AMDGPU_H + +#include + +static const char SYS_BUS_PCI_DEVICES[] = "/sys/bus/pci/devices"; + +typedef int HM_ADAPTER_SYSFS_AMDGPU; + +typedef void *SYSFS_AMDGPU_LIB; + +typedef struct hm_sysfs_amdgpu_lib +{ + // currently not using libudev, because it can only read values, not set them, so using /sys instead + + SYSFS_AMDGPU_LIB lib; + +} hm_sysfs_amdgpu_lib_t; + +typedef hm_sysfs_amdgpu_lib_t SYSFS_AMDGPU_PTR; + +bool sysfs_amdgpu_init (void *hashcat_ctx); +void sysfs_amdgpu_close (void *hashcat_ctx); +char *hm_SYSFS_AMDGPU_get_syspath_device (void *hashcat_ctx, const int backend_device_idx); +char *hm_SYSFS_AMDGPU_get_syspath_hwmon (void *hashcat_ctx, const int backend_device_idx); +int hm_SYSFS_AMDGPU_get_fan_speed_current (void *hashcat_ctx, const int backend_device_idx, int *val); +int hm_SYSFS_AMDGPU_get_temperature_current (void *hashcat_ctx, const int backend_device_idx, int *val); +int hm_SYSFS_AMDGPU_get_pp_dpm_sclk (void *hashcat_ctx, const int backend_device_idx, int *val); +int hm_SYSFS_AMDGPU_get_pp_dpm_mclk (void *hashcat_ctx, const int backend_device_idx, int *val); +int hm_SYSFS_AMDGPU_get_pp_dpm_pcie (void *hashcat_ctx, const int backend_device_idx, int *val); +int hm_SYSFS_AMDGPU_get_gpu_busy_percent (void *hashcat_ctx, const int backend_device_idx, int *val); + +#endif // _EXT_SYSFS_AMDGPU_H diff --git a/include/types.h b/include/types.h index 99a766689..0e5cc625d 100644 --- a/include/types.h +++ b/include/types.h @@ -1598,7 +1598,7 @@ typedef struct backend_ctx bool need_adl; bool need_nvml; bool need_nvapi; - bool need_sysfs; + bool need_sysfs_amdgpu; bool need_iokit; int comptime; @@ -1642,16 +1642,16 @@ typedef enum kernel_workload #include "ext_ADL.h" #include "ext_nvapi.h" #include "ext_nvml.h" -#include "ext_sysfs.h" +#include "ext_sysfs_amdgpu.h" #include "ext_iokit.h" typedef struct hm_attrs { - HM_ADAPTER_ADL adl; - HM_ADAPTER_NVML nvml; - HM_ADAPTER_NVAPI nvapi; - HM_ADAPTER_SYSFS sysfs; - HM_ADAPTER_IOKIT iokit; + HM_ADAPTER_ADL adl; + HM_ADAPTER_NVML nvml; + HM_ADAPTER_NVAPI nvapi; + HM_ADAPTER_SYSFS_AMDGPU sysfs_amdgpu; + HM_ADAPTER_IOKIT iokit; int od_version; @@ -1675,7 +1675,7 @@ typedef struct hwmon_ctx void *hm_adl; void *hm_nvml; void *hm_nvapi; - void *hm_sysfs; + void *hm_sysfs_amdgpu; void *hm_iokit; hm_attrs_t *hm_device; diff --git a/src/Makefile b/src/Makefile index 4f99425e6..bc5db37f1 100644 --- a/src/Makefile +++ b/src/Makefile @@ -360,7 +360,7 @@ EMU_OBJS_ALL += emu_inc_rp emu_inc_rp_optimized EMU_OBJS_ALL += emu_inc_hash_md4 emu_inc_hash_md5 emu_inc_hash_ripemd160 emu_inc_hash_sha1 emu_inc_hash_sha256 emu_inc_hash_sha384 emu_inc_hash_sha512 emu_inc_hash_streebog256 emu_inc_hash_streebog512 emu_inc_ecc_secp256k1 EMU_OBJS_ALL += emu_inc_cipher_aes emu_inc_cipher_camellia emu_inc_cipher_des emu_inc_cipher_kuznyechik emu_inc_cipher_serpent emu_inc_cipher_twofish -OBJS_ALL := affinity autotune backend benchmark bitmap bitops combinator common convert cpt cpu_crc32 debugfile dictstat dispatch dynloader event ext_ADL ext_cuda ext_nvapi ext_nvml ext_nvrtc ext_OpenCL ext_sysfs ext_iokit ext_lzma filehandling folder hashcat hashes hlfmt hwmon induct interface keyboard_layout locking logfile loopback memory monitor mpsp outfile_check outfile pidfile potfile restore rp rp_cpu selftest slow_candidates shared status stdout straight terminal thread timer tuningdb usage user_options wordlist $(EMU_OBJS_ALL) +OBJS_ALL := affinity autotune backend benchmark bitmap bitops combinator common convert cpt cpu_crc32 debugfile dictstat dispatch dynloader event ext_ADL ext_cuda ext_nvapi ext_nvml ext_nvrtc ext_OpenCL ext_sysfs_amdgpu ext_iokit ext_lzma filehandling folder hashcat hashes hlfmt hwmon induct interface keyboard_layout locking logfile loopback memory monitor mpsp outfile_check outfile pidfile potfile restore rp rp_cpu selftest slow_candidates shared status stdout straight terminal thread timer tuningdb usage user_options wordlist $(EMU_OBJS_ALL) ifeq ($(ENABLE_BRAIN),1) OBJS_ALL += brain diff --git a/src/backend.c b/src/backend.c index 8896c74ef..ac0ba4f2d 100644 --- a/src/backend.c +++ b/src/backend.c @@ -5680,11 +5680,11 @@ int backend_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) hc_device_param_t *devices_param = backend_ctx->devices_param; - bool need_adl = false; - bool need_nvml = false; - bool need_nvapi = false; - bool need_sysfs = false; - bool need_iokit = false; + bool need_adl = false; + bool need_nvml = false; + bool need_nvapi = false; + bool need_sysfs_amdgpu = false; + bool need_iokit = false; int backend_devices_idx = 0; @@ -6716,12 +6716,18 @@ int backend_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) // vendor specific - #if defined (__APPLE__) - if (device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) + if (device_param->opencl_device_type & CL_DEVICE_TYPE_CPU) { - if (device_param->skipped == false) need_iokit = true; + #if defined (__APPLE__) + if (device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) + { + if (device_param->skipped == false) + { + need_iokit = true; + } + } + #endif } - #endif if (device_param->opencl_device_type & CL_DEVICE_TYPE_GPU) { @@ -6730,7 +6736,7 @@ int backend_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) need_adl = true; #if defined (__linux__) - need_sysfs = true; + need_sysfs_amdgpu = true; #endif } @@ -7393,13 +7399,13 @@ int backend_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) backend_ctx->target_msec = TARGET_MSEC_PROFILE[user_options->workload_profile - 1]; - backend_ctx->need_adl = need_adl; - backend_ctx->need_nvml = need_nvml; - backend_ctx->need_nvapi = need_nvapi; - backend_ctx->need_sysfs = need_sysfs; - backend_ctx->need_iokit = need_iokit; + backend_ctx->need_adl = need_adl; + backend_ctx->need_nvml = need_nvml; + backend_ctx->need_nvapi = need_nvapi; + backend_ctx->need_sysfs_amdgpu = need_sysfs_amdgpu; + backend_ctx->need_iokit = need_iokit; - backend_ctx->comptime = comptime; + backend_ctx->comptime = comptime; return 0; } @@ -7440,10 +7446,11 @@ void backend_ctx_devices_destroy (hashcat_ctx_t *hashcat_ctx) backend_ctx->opencl_devices_cnt = 0; backend_ctx->opencl_devices_active = 0; - backend_ctx->need_adl = false; - backend_ctx->need_nvml = false; - backend_ctx->need_nvapi = false; - backend_ctx->need_sysfs = false; + backend_ctx->need_adl = false; + backend_ctx->need_nvml = false; + backend_ctx->need_nvapi = false; + backend_ctx->need_sysfs_amdgpu = false; + backend_ctx->need_iokit = false; } void backend_ctx_devices_sync_tuning (hashcat_ctx_t *hashcat_ctx) diff --git a/src/ext_sysfs.c b/src/ext_sysfs_amdgpu.c similarity index 77% rename from src/ext_sysfs.c rename to src/ext_sysfs_amdgpu.c index fc50ea388..1aa53b210 100644 --- a/src/ext_sysfs.c +++ b/src/ext_sysfs_amdgpu.c @@ -9,15 +9,15 @@ #include "shared.h" #include "event.h" #include "folder.h" -#include "ext_sysfs.h" +#include "ext_sysfs_amdgpu.h" -bool sysfs_init (void *hashcat_ctx) +bool sysfs_amdgpu_init (void *hashcat_ctx) { hwmon_ctx_t *hwmon_ctx = ((hashcat_ctx_t *) hashcat_ctx)->hwmon_ctx; - SYSFS_PTR *sysfs = (SYSFS_PTR *) hwmon_ctx->hm_sysfs; + SYSFS_AMDGPU_PTR *sysfs_amdgpu = (SYSFS_AMDGPU_PTR *) hwmon_ctx->hm_sysfs_amdgpu; - memset (sysfs, 0, sizeof (SYSFS_PTR)); + memset (sysfs_amdgpu, 0, sizeof (SYSFS_AMDGPU_PTR)); char *path; @@ -30,19 +30,19 @@ bool sysfs_init (void *hashcat_ctx) return r; } -void sysfs_close (void *hashcat_ctx) +void sysfs_amdgpu_close (void *hashcat_ctx) { hwmon_ctx_t *hwmon_ctx = ((hashcat_ctx_t *) hashcat_ctx)->hwmon_ctx; - SYSFS_PTR *sysfs = (SYSFS_PTR *) hwmon_ctx->hm_sysfs; + SYSFS_AMDGPU_PTR *sysfs_amdgpu = (SYSFS_AMDGPU_PTR *) hwmon_ctx->hm_sysfs_amdgpu; - if (sysfs) + if (sysfs_amdgpu) { - hcfree (sysfs); + hcfree (sysfs_amdgpu); } } -char *hm_SYSFS_get_syspath_device (void *hashcat_ctx, const int backend_device_idx) +char *hm_SYSFS_AMDGPU_get_syspath_device (void *hashcat_ctx, const int backend_device_idx) { backend_ctx_t *backend_ctx = ((hashcat_ctx_t *) hashcat_ctx)->backend_ctx; @@ -55,13 +55,13 @@ char *hm_SYSFS_get_syspath_device (void *hashcat_ctx, const int backend_device_i return syspath; } -char *hm_SYSFS_get_syspath_hwmon (void *hashcat_ctx, const int backend_device_idx) +char *hm_SYSFS_AMDGPU_get_syspath_hwmon (void *hashcat_ctx, const int backend_device_idx) { - char *syspath = hm_SYSFS_get_syspath_device (hashcat_ctx, backend_device_idx); + char *syspath = hm_SYSFS_AMDGPU_get_syspath_device (hashcat_ctx, backend_device_idx); if (syspath == NULL) { - event_log_error (hashcat_ctx, "hm_SYSFS_get_syspath_device() failed."); + event_log_error (hashcat_ctx, "hm_SYSFS_AMDGPU_get_syspath_device() failed."); return NULL; } @@ -93,9 +93,9 @@ char *hm_SYSFS_get_syspath_hwmon (void *hashcat_ctx, const int backend_device_id return hwmon; } -int hm_SYSFS_get_fan_speed_current (void *hashcat_ctx, const int backend_device_idx, int *val) +int hm_SYSFS_AMDGPU_get_fan_speed_current (void *hashcat_ctx, const int backend_device_idx, int *val) { - char *syspath = hm_SYSFS_get_syspath_hwmon (hashcat_ctx, backend_device_idx); + char *syspath = hm_SYSFS_AMDGPU_get_syspath_hwmon (hashcat_ctx, backend_device_idx); if (syspath == NULL) return -1; @@ -185,9 +185,9 @@ int hm_SYSFS_get_fan_speed_current (void *hashcat_ctx, const int backend_device_ return 0; } -int hm_SYSFS_get_temperature_current (void *hashcat_ctx, const int backend_device_idx, int *val) +int hm_SYSFS_AMDGPU_get_temperature_current (void *hashcat_ctx, const int backend_device_idx, int *val) { - char *syspath = hm_SYSFS_get_syspath_hwmon (hashcat_ctx, backend_device_idx); + char *syspath = hm_SYSFS_AMDGPU_get_syspath_hwmon (hashcat_ctx, backend_device_idx); if (syspath == NULL) return -1; @@ -230,9 +230,9 @@ int hm_SYSFS_get_temperature_current (void *hashcat_ctx, const int backend_devic return 0; } -int hm_SYSFS_get_pp_dpm_sclk (void *hashcat_ctx, const int backend_device_idx, int *val) +int hm_SYSFS_AMDGPU_get_pp_dpm_sclk (void *hashcat_ctx, const int backend_device_idx, int *val) { - char *syspath = hm_SYSFS_get_syspath_device (hashcat_ctx, backend_device_idx); + char *syspath = hm_SYSFS_AMDGPU_get_syspath_device (hashcat_ctx, backend_device_idx); if (syspath == NULL) return -1; @@ -285,9 +285,9 @@ int hm_SYSFS_get_pp_dpm_sclk (void *hashcat_ctx, const int backend_device_idx, i return 0; } -int hm_SYSFS_get_pp_dpm_mclk (void *hashcat_ctx, const int backend_device_idx, int *val) +int hm_SYSFS_AMDGPU_get_pp_dpm_mclk (void *hashcat_ctx, const int backend_device_idx, int *val) { - char *syspath = hm_SYSFS_get_syspath_device (hashcat_ctx, backend_device_idx); + char *syspath = hm_SYSFS_AMDGPU_get_syspath_device (hashcat_ctx, backend_device_idx); if (syspath == NULL) return -1; @@ -340,9 +340,9 @@ int hm_SYSFS_get_pp_dpm_mclk (void *hashcat_ctx, const int backend_device_idx, i return 0; } -int hm_SYSFS_get_pp_dpm_pcie (void *hashcat_ctx, const int backend_device_idx, int *val) +int hm_SYSFS_AMDGPU_get_pp_dpm_pcie (void *hashcat_ctx, const int backend_device_idx, int *val) { - char *syspath = hm_SYSFS_get_syspath_device (hashcat_ctx, backend_device_idx); + char *syspath = hm_SYSFS_AMDGPU_get_syspath_device (hashcat_ctx, backend_device_idx); if (syspath == NULL) return -1; @@ -391,9 +391,9 @@ int hm_SYSFS_get_pp_dpm_pcie (void *hashcat_ctx, const int backend_device_idx, i return 0; } -int hm_SYSFS_get_gpu_busy_percent (void *hashcat_ctx, const int backend_device_idx, int *val) +int hm_SYSFS_AMDGPU_get_gpu_busy_percent (void *hashcat_ctx, const int backend_device_idx, int *val) { - char *syspath = hm_SYSFS_get_syspath_device (hashcat_ctx, backend_device_idx); + char *syspath = hm_SYSFS_AMDGPU_get_syspath_device (hashcat_ctx, backend_device_idx); if (syspath == NULL) return -1; diff --git a/src/hwmon.c b/src/hwmon.c index 0810d7956..6c7862b2e 100644 --- a/src/hwmon.c +++ b/src/hwmon.c @@ -334,11 +334,11 @@ int hm_get_temperature_with_devices_idx (hashcat_ctx_t *hashcat_ctx, const int b } } - if (hwmon_ctx->hm_sysfs) + if (hwmon_ctx->hm_sysfs_amdgpu) { int temperature = 0; - if (hm_SYSFS_get_temperature_current (hashcat_ctx, backend_device_idx, &temperature) == -1) + if (hm_SYSFS_AMDGPU_get_temperature_current (hashcat_ctx, backend_device_idx, &temperature) == -1) { hwmon_ctx->hm_device[backend_device_idx].temperature_get_supported = false; @@ -421,7 +421,7 @@ int hm_get_fanpolicy_with_devices_idx (hashcat_ctx_t *hashcat_ctx, const int bac } } - if (hwmon_ctx->hm_sysfs) + if (hwmon_ctx->hm_sysfs_amdgpu) { return 1; } @@ -530,11 +530,11 @@ int hm_get_fanspeed_with_devices_idx (hashcat_ctx_t *hashcat_ctx, const int back } } - if (hwmon_ctx->hm_sysfs) + if (hwmon_ctx->hm_sysfs_amdgpu) { int speed = 0; - if (hm_SYSFS_get_fan_speed_current (hashcat_ctx, backend_device_idx, &speed) == -1) + if (hm_SYSFS_AMDGPU_get_fan_speed_current (hashcat_ctx, backend_device_idx, &speed) == -1) { hwmon_ctx->hm_device[backend_device_idx].fanspeed_get_supported = false; @@ -617,11 +617,11 @@ int hm_get_buslanes_with_devices_idx (hashcat_ctx_t *hashcat_ctx, const int back return PMActivity.iCurrentBusLanes; } - if (hwmon_ctx->hm_sysfs) + if (hwmon_ctx->hm_sysfs_amdgpu) { int lanes; - if (hm_SYSFS_get_pp_dpm_pcie (hashcat_ctx, backend_device_idx, &lanes) == -1) + if (hm_SYSFS_AMDGPU_get_pp_dpm_pcie (hashcat_ctx, backend_device_idx, &lanes) == -1) { hwmon_ctx->hm_device[backend_device_idx].buslanes_get_supported = false; @@ -704,11 +704,11 @@ int hm_get_utilization_with_devices_idx (hashcat_ctx_t *hashcat_ctx, const int b return PMActivity.iActivityPercent; } - if (hwmon_ctx->hm_sysfs) + if (hwmon_ctx->hm_sysfs_amdgpu) { int util; - if (hm_SYSFS_get_gpu_busy_percent (hashcat_ctx, backend_device_idx, &util) == -1) + if (hm_SYSFS_AMDGPU_get_gpu_busy_percent (hashcat_ctx, backend_device_idx, &util) == -1) { hwmon_ctx->hm_device[backend_device_idx].utilization_get_supported = false; @@ -791,11 +791,11 @@ int hm_get_memoryspeed_with_devices_idx (hashcat_ctx_t *hashcat_ctx, const int b return PMActivity.iMemoryClock / 100; } - if (hwmon_ctx->hm_sysfs) + if (hwmon_ctx->hm_sysfs_amdgpu) { int clockfreq; - if (hm_SYSFS_get_pp_dpm_mclk (hashcat_ctx, backend_device_idx, &clockfreq) == -1) + if (hm_SYSFS_AMDGPU_get_pp_dpm_mclk (hashcat_ctx, backend_device_idx, &clockfreq) == -1) { hwmon_ctx->hm_device[backend_device_idx].memoryspeed_get_supported = false; @@ -878,11 +878,11 @@ int hm_get_corespeed_with_devices_idx (hashcat_ctx_t *hashcat_ctx, const int bac return PMActivity.iEngineClock / 100; } - if (hwmon_ctx->hm_sysfs) + if (hwmon_ctx->hm_sysfs_amdgpu) { int clockfreq; - if (hm_SYSFS_get_pp_dpm_sclk (hashcat_ctx, backend_device_idx, &clockfreq) == -1) + if (hm_SYSFS_AMDGPU_get_pp_dpm_sclk (hashcat_ctx, backend_device_idx, &clockfreq) == -1) { hwmon_ctx->hm_device[backend_device_idx].corespeed_get_supported = false; @@ -1062,19 +1062,19 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) * Initialize shared libraries */ - hm_attrs_t *hm_adapters_adl = (hm_attrs_t *) hccalloc (DEVICES_MAX, sizeof (hm_attrs_t)); - hm_attrs_t *hm_adapters_nvapi = (hm_attrs_t *) hccalloc (DEVICES_MAX, sizeof (hm_attrs_t)); - hm_attrs_t *hm_adapters_nvml = (hm_attrs_t *) hccalloc (DEVICES_MAX, sizeof (hm_attrs_t)); - hm_attrs_t *hm_adapters_sysfs = (hm_attrs_t *) hccalloc (DEVICES_MAX, sizeof (hm_attrs_t)); - hm_attrs_t *hm_adapters_iokit = (hm_attrs_t *) hccalloc (DEVICES_MAX, sizeof (hm_attrs_t)); - - #define FREE_ADAPTERS \ - do { \ - hcfree (hm_adapters_adl); \ - hcfree (hm_adapters_nvapi); \ - hcfree (hm_adapters_nvml); \ - hcfree (hm_adapters_sysfs); \ - hcfree (hm_adapters_iokit); \ + hm_attrs_t *hm_adapters_adl = (hm_attrs_t *) hccalloc (DEVICES_MAX, sizeof (hm_attrs_t)); + hm_attrs_t *hm_adapters_nvapi = (hm_attrs_t *) hccalloc (DEVICES_MAX, sizeof (hm_attrs_t)); + hm_attrs_t *hm_adapters_nvml = (hm_attrs_t *) hccalloc (DEVICES_MAX, sizeof (hm_attrs_t)); + hm_attrs_t *hm_adapters_sysfs_amdgpu = (hm_attrs_t *) hccalloc (DEVICES_MAX, sizeof (hm_attrs_t)); + hm_attrs_t *hm_adapters_iokit = (hm_attrs_t *) hccalloc (DEVICES_MAX, sizeof (hm_attrs_t)); + + #define FREE_ADAPTERS \ + do { \ + hcfree (hm_adapters_adl); \ + hcfree (hm_adapters_nvapi); \ + hcfree (hm_adapters_nvml); \ + hcfree (hm_adapters_sysfs_amdgpu); \ + hcfree (hm_adapters_iokit); \ } while (0) if (backend_ctx->need_nvml == true) @@ -1113,24 +1113,24 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) } } - if (backend_ctx->need_sysfs == true) + if (backend_ctx->need_sysfs_amdgpu == true) { - hwmon_ctx->hm_sysfs = (SYSFS_PTR *) hcmalloc (sizeof (SYSFS_PTR)); + hwmon_ctx->hm_sysfs_amdgpu = (SYSFS_AMDGPU_PTR *) hcmalloc (sizeof (SYSFS_AMDGPU_PTR)); - if (sysfs_init (hashcat_ctx) == false) + if (sysfs_amdgpu_init (hashcat_ctx) == false) { - hcfree (hwmon_ctx->hm_sysfs); + hcfree (hwmon_ctx->hm_sysfs_amdgpu); - hwmon_ctx->hm_sysfs = NULL; + hwmon_ctx->hm_sysfs_amdgpu = NULL; } - // also if there's ADL, we don't need sysfs + // also if there's ADL, we don't need sysfs_amdgpu if (hwmon_ctx->hm_adl) { - hcfree (hwmon_ctx->hm_sysfs); + hcfree (hwmon_ctx->hm_sysfs_amdgpu); - hwmon_ctx->hm_sysfs = NULL; + hwmon_ctx->hm_sysfs_amdgpu = NULL; } } @@ -1378,7 +1378,7 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) } } - if (hwmon_ctx->hm_sysfs || hwmon_ctx->hm_iokit) + if (hwmon_ctx->hm_sysfs_amdgpu || hwmon_ctx->hm_iokit) { if (true) { @@ -1410,15 +1410,15 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) if ((device_param->opencl_device_type & CL_DEVICE_TYPE_GPU) == 0) continue; - if (hwmon_ctx->hm_sysfs) + if (hwmon_ctx->hm_sysfs_amdgpu) { - hm_adapters_sysfs[device_id].buslanes_get_supported = true; - hm_adapters_sysfs[device_id].corespeed_get_supported = true; - hm_adapters_sysfs[device_id].fanspeed_get_supported = true; - hm_adapters_sysfs[device_id].fanpolicy_get_supported = true; - hm_adapters_sysfs[device_id].memoryspeed_get_supported = true; - hm_adapters_sysfs[device_id].temperature_get_supported = true; - hm_adapters_sysfs[device_id].utilization_get_supported = true; + hm_adapters_sysfs_amdgpu[device_id].buslanes_get_supported = true; + hm_adapters_sysfs_amdgpu[device_id].corespeed_get_supported = true; + hm_adapters_sysfs_amdgpu[device_id].fanspeed_get_supported = true; + hm_adapters_sysfs_amdgpu[device_id].fanpolicy_get_supported = true; + hm_adapters_sysfs_amdgpu[device_id].memoryspeed_get_supported = true; + hm_adapters_sysfs_amdgpu[device_id].temperature_get_supported = true; + hm_adapters_sysfs_amdgpu[device_id].utilization_get_supported = true; } } } @@ -1440,7 +1440,7 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) #endif - if (hwmon_ctx->hm_adl == NULL && hwmon_ctx->hm_nvml == NULL && hwmon_ctx->hm_sysfs == NULL && hwmon_ctx->hm_iokit == NULL) + if (hwmon_ctx->hm_adl == NULL && hwmon_ctx->hm_nvml == NULL && hwmon_ctx->hm_sysfs_amdgpu == NULL && hwmon_ctx->hm_iokit == NULL) { FREE_ADAPTERS; @@ -1471,12 +1471,12 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) const u32 device_id = device_param->device_id; - hwmon_ctx->hm_device[backend_devices_idx].adl = 0; - hwmon_ctx->hm_device[backend_devices_idx].sysfs = 0; - hwmon_ctx->hm_device[backend_devices_idx].iokit = 0; - hwmon_ctx->hm_device[backend_devices_idx].nvapi = 0; - hwmon_ctx->hm_device[backend_devices_idx].nvml = 0; - hwmon_ctx->hm_device[backend_devices_idx].od_version = 0; + hwmon_ctx->hm_device[backend_devices_idx].adl = 0; + hwmon_ctx->hm_device[backend_devices_idx].sysfs_amdgpu = 0; + hwmon_ctx->hm_device[backend_devices_idx].iokit = 0; + hwmon_ctx->hm_device[backend_devices_idx].nvapi = 0; + hwmon_ctx->hm_device[backend_devices_idx].nvml = 0; + hwmon_ctx->hm_device[backend_devices_idx].od_version = 0; if (device_param->is_cuda == true) { @@ -1562,8 +1562,8 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) if (device_param->opencl_device_vendor_id == VENDOR_ID_AMD) { - hwmon_ctx->hm_device[backend_devices_idx].adl = hm_adapters_adl[device_id].adl; - hwmon_ctx->hm_device[backend_devices_idx].sysfs = hm_adapters_sysfs[device_id].sysfs; + hwmon_ctx->hm_device[backend_devices_idx].adl = hm_adapters_adl[device_id].adl; + hwmon_ctx->hm_device[backend_devices_idx].sysfs_amdgpu = hm_adapters_sysfs_amdgpu[device_id].sysfs_amdgpu; if (hwmon_ctx->hm_adl) { @@ -1581,18 +1581,18 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) hwmon_ctx->hm_device[backend_devices_idx].utilization_get_supported |= hm_adapters_adl[device_id].utilization_get_supported; } - if (hwmon_ctx->hm_sysfs) + if (hwmon_ctx->hm_sysfs_amdgpu) { - hwmon_ctx->hm_device[backend_devices_idx].buslanes_get_supported |= hm_adapters_sysfs[device_id].buslanes_get_supported; - hwmon_ctx->hm_device[backend_devices_idx].corespeed_get_supported |= hm_adapters_sysfs[device_id].corespeed_get_supported; - hwmon_ctx->hm_device[backend_devices_idx].fanspeed_get_supported |= hm_adapters_sysfs[device_id].fanspeed_get_supported; - hwmon_ctx->hm_device[backend_devices_idx].fanpolicy_get_supported |= hm_adapters_sysfs[device_id].fanpolicy_get_supported; - hwmon_ctx->hm_device[backend_devices_idx].memoryspeed_get_supported |= hm_adapters_sysfs[device_id].memoryspeed_get_supported; - hwmon_ctx->hm_device[backend_devices_idx].temperature_get_supported |= hm_adapters_sysfs[device_id].temperature_get_supported; - hwmon_ctx->hm_device[backend_devices_idx].threshold_shutdown_get_supported |= hm_adapters_sysfs[device_id].threshold_shutdown_get_supported; - hwmon_ctx->hm_device[backend_devices_idx].threshold_slowdown_get_supported |= hm_adapters_sysfs[device_id].threshold_slowdown_get_supported; - hwmon_ctx->hm_device[backend_devices_idx].throttle_get_supported |= hm_adapters_sysfs[device_id].throttle_get_supported; - hwmon_ctx->hm_device[backend_devices_idx].utilization_get_supported |= hm_adapters_sysfs[device_id].utilization_get_supported; + hwmon_ctx->hm_device[backend_devices_idx].buslanes_get_supported |= hm_adapters_sysfs_amdgpu[device_id].buslanes_get_supported; + hwmon_ctx->hm_device[backend_devices_idx].corespeed_get_supported |= hm_adapters_sysfs_amdgpu[device_id].corespeed_get_supported; + hwmon_ctx->hm_device[backend_devices_idx].fanspeed_get_supported |= hm_adapters_sysfs_amdgpu[device_id].fanspeed_get_supported; + hwmon_ctx->hm_device[backend_devices_idx].fanpolicy_get_supported |= hm_adapters_sysfs_amdgpu[device_id].fanpolicy_get_supported; + hwmon_ctx->hm_device[backend_devices_idx].memoryspeed_get_supported |= hm_adapters_sysfs_amdgpu[device_id].memoryspeed_get_supported; + hwmon_ctx->hm_device[backend_devices_idx].temperature_get_supported |= hm_adapters_sysfs_amdgpu[device_id].temperature_get_supported; + hwmon_ctx->hm_device[backend_devices_idx].threshold_shutdown_get_supported |= hm_adapters_sysfs_amdgpu[device_id].threshold_shutdown_get_supported; + hwmon_ctx->hm_device[backend_devices_idx].threshold_slowdown_get_supported |= hm_adapters_sysfs_amdgpu[device_id].threshold_slowdown_get_supported; + hwmon_ctx->hm_device[backend_devices_idx].throttle_get_supported |= hm_adapters_sysfs_amdgpu[device_id].throttle_get_supported; + hwmon_ctx->hm_device[backend_devices_idx].utilization_get_supported |= hm_adapters_sysfs_amdgpu[device_id].utilization_get_supported; } } @@ -1681,9 +1681,9 @@ void hwmon_ctx_destroy (hashcat_ctx_t *hashcat_ctx) adl_close (hashcat_ctx); } - if (hwmon_ctx->hm_sysfs) + if (hwmon_ctx->hm_sysfs_amdgpu) { - sysfs_close (hashcat_ctx); + sysfs_amdgpu_close (hashcat_ctx); } #if defined (__APPLE__)