1
0
mirror of https://github.com/hashcat/hashcat.git synced 2024-11-26 09:58:16 +00:00

Hardware-Management initialization refactor, to show HM related errors only once on startup

This commit is contained in:
jsteube 2016-11-21 15:58:44 +01:00
parent 9e1574a97b
commit 06c1d4a52e
4 changed files with 279 additions and 122 deletions

View File

@ -1066,8 +1066,18 @@ typedef struct hm_attrs
int od_version; int od_version;
bool fan_get_supported; bool buslanes_get_supported;
bool fan_set_supported; bool corespeed_get_supported;
bool fanspeed_get_supported;
bool fanspeed_set_supported;
bool fanpolicy_get_supported;
bool fanpolicy_set_supported;
bool memoryspeed_get_supported;
bool temperature_get_supported;
bool threshold_shutdown_get_supported;
bool threshold_slowdown_get_supported;
bool throttle_get_supported;
bool utilization_get_supported;
} hm_attrs_t; } hm_attrs_t;

View File

@ -1417,6 +1417,7 @@ static int hm_XNVCTRL_get_core_threshold (hashcat_ctx_t *hashcat_ctx, const int
} }
*/ */
/*
static int hm_XNVCTRL_get_fan_speed_current (hashcat_ctx_t *hashcat_ctx, const int gpu, int *val) static int hm_XNVCTRL_get_fan_speed_current (hashcat_ctx_t *hashcat_ctx, const int gpu, int *val)
{ {
hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx;
@ -1438,6 +1439,7 @@ static int hm_XNVCTRL_get_fan_speed_current (hashcat_ctx_t *hashcat_ctx, const i
return 0; return 0;
} }
*/
static int hm_XNVCTRL_get_fan_speed_target (hashcat_ctx_t *hashcat_ctx, const int gpu, int *val) static int hm_XNVCTRL_get_fan_speed_target (hashcat_ctx_t *hashcat_ctx, const int gpu, int *val)
{ {
@ -2527,11 +2529,11 @@ static int hm_check_fanspeed_control (hashcat_ctx_t *hashcat_ctx, hm_attrs_t *hm
if ((FanSpeedInfo.iFlags & ADL_DL_FANCTRL_SUPPORTS_PERCENT_READ) && if ((FanSpeedInfo.iFlags & ADL_DL_FANCTRL_SUPPORTS_PERCENT_READ) &&
(FanSpeedInfo.iFlags & ADL_DL_FANCTRL_SUPPORTS_PERCENT_WRITE)) (FanSpeedInfo.iFlags & ADL_DL_FANCTRL_SUPPORTS_PERCENT_WRITE))
{ {
hm_device[opencl_device_index].fan_get_supported = true; hm_device[opencl_device_index].fanspeed_get_supported = true;
} }
else else
{ {
hm_device[opencl_device_index].fan_get_supported = false; hm_device[opencl_device_index].fanspeed_get_supported = false;
} }
} }
else // od_version == 6 else // od_version == 6
@ -2546,11 +2548,11 @@ static int hm_check_fanspeed_control (hashcat_ctx_t *hashcat_ctx, hm_attrs_t *hm
if (faninfo.iSpeedType & ADL_OD6_FANSPEED_TYPE_PERCENT) if (faninfo.iSpeedType & ADL_OD6_FANSPEED_TYPE_PERCENT)
{ {
hm_device[opencl_device_index].fan_get_supported = true; hm_device[opencl_device_index].fanspeed_get_supported = true;
} }
else else
{ {
hm_device[opencl_device_index].fan_get_supported = false; hm_device[opencl_device_index].fanspeed_get_supported = false;
} }
} }
} }
@ -2625,6 +2627,8 @@ int hm_get_threshold_slowdown_with_device_id (hashcat_ctx_t *hashcat_ctx, const
if (hwmon_ctx->enabled == false) return -1; if (hwmon_ctx->enabled == false) return -1;
if (hwmon_ctx->hm_device[device_id].threshold_slowdown_get_supported == false) return -1;
if ((opencl_ctx->devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) return -1; if ((opencl_ctx->devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) return -1;
if (opencl_ctx->devices_param[device_id].device_vendor_id == VENDOR_ID_AMD) if (opencl_ctx->devices_param[device_id].device_vendor_id == VENDOR_ID_AMD)
@ -2661,6 +2665,8 @@ int hm_get_threshold_slowdown_with_device_id (hashcat_ctx_t *hashcat_ctx, const
} }
} }
hwmon_ctx->hm_device[device_id].threshold_slowdown_get_supported = false;
return -1; return -1;
} }
@ -2671,6 +2677,8 @@ int hm_get_threshold_shutdown_with_device_id (hashcat_ctx_t *hashcat_ctx, const
if (hwmon_ctx->enabled == false) return -1; if (hwmon_ctx->enabled == false) return -1;
if (hwmon_ctx->hm_device[device_id].threshold_shutdown_get_supported == false) return -1;
if ((opencl_ctx->devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) return -1; if ((opencl_ctx->devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) return -1;
if (opencl_ctx->devices_param[device_id].device_vendor_id == VENDOR_ID_AMD) if (opencl_ctx->devices_param[device_id].device_vendor_id == VENDOR_ID_AMD)
@ -2700,6 +2708,8 @@ int hm_get_threshold_shutdown_with_device_id (hashcat_ctx_t *hashcat_ctx, const
} }
} }
hwmon_ctx->hm_device[device_id].threshold_shutdown_get_supported = false;
return -1; return -1;
} }
@ -2710,6 +2720,8 @@ int hm_get_temperature_with_device_id (hashcat_ctx_t *hashcat_ctx, const u32 dev
if (hwmon_ctx->enabled == false) return -1; if (hwmon_ctx->enabled == false) return -1;
if (hwmon_ctx->hm_device[device_id].temperature_get_supported == false) return -1;
if ((opencl_ctx->devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) return -1; if ((opencl_ctx->devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) return -1;
if (opencl_ctx->devices_param[device_id].device_vendor_id == VENDOR_ID_AMD) if (opencl_ctx->devices_param[device_id].device_vendor_id == VENDOR_ID_AMD)
@ -2758,6 +2770,8 @@ int hm_get_temperature_with_device_id (hashcat_ctx_t *hashcat_ctx, const u32 dev
} }
} }
hwmon_ctx->hm_device[device_id].temperature_get_supported = false;
return -1; return -1;
} }
@ -2768,9 +2782,9 @@ int hm_get_fanpolicy_with_device_id (hashcat_ctx_t *hashcat_ctx, const u32 devic
if (hwmon_ctx->enabled == false) return -1; if (hwmon_ctx->enabled == false) return -1;
if ((opencl_ctx->devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) return -1; if (hwmon_ctx->hm_device[device_id].fanpolicy_get_supported == false) return -1;
if (hwmon_ctx->hm_device[device_id].fan_get_supported == false) return -1; if ((opencl_ctx->devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) return -1;
if (opencl_ctx->devices_param[device_id].device_vendor_id == VENDOR_ID_AMD) if (opencl_ctx->devices_param[device_id].device_vendor_id == VENDOR_ID_AMD)
{ {
@ -2806,6 +2820,8 @@ int hm_get_fanpolicy_with_device_id (hashcat_ctx_t *hashcat_ctx, const u32 devic
return 1; return 1;
} }
hwmon_ctx->hm_device[device_id].fanpolicy_get_supported = false;
return -1; return -1;
} }
@ -2816,9 +2832,9 @@ int hm_get_fanspeed_with_device_id (hashcat_ctx_t *hashcat_ctx, const u32 device
if (hwmon_ctx->enabled == false) return -1; if (hwmon_ctx->enabled == false) return -1;
if ((opencl_ctx->devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) return -1; if (hwmon_ctx->hm_device[device_id].fanspeed_get_supported == false) return -1;
if (hwmon_ctx->hm_device[device_id].fan_get_supported == false) return -1; if ((opencl_ctx->devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) return -1;
if (opencl_ctx->devices_param[device_id].device_vendor_id == VENDOR_ID_AMD) if (opencl_ctx->devices_param[device_id].device_vendor_id == VENDOR_ID_AMD)
{ {
@ -2872,6 +2888,8 @@ int hm_get_fanspeed_with_device_id (hashcat_ctx_t *hashcat_ctx, const u32 device
} }
} }
hwmon_ctx->hm_device[device_id].fanspeed_get_supported = false;
return -1; return -1;
} }
@ -2882,6 +2900,8 @@ int hm_get_buslanes_with_device_id (hashcat_ctx_t *hashcat_ctx, const u32 device
if (hwmon_ctx->enabled == false) return -1; if (hwmon_ctx->enabled == false) return -1;
if (hwmon_ctx->hm_device[device_id].buslanes_get_supported == false) return -1;
if ((opencl_ctx->devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) return -1; if ((opencl_ctx->devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) return -1;
if (opencl_ctx->devices_param[device_id].device_vendor_id == VENDOR_ID_AMD) if (opencl_ctx->devices_param[device_id].device_vendor_id == VENDOR_ID_AMD)
@ -2919,6 +2939,8 @@ int hm_get_buslanes_with_device_id (hashcat_ctx_t *hashcat_ctx, const u32 device
} }
} }
hwmon_ctx->hm_device[device_id].buslanes_get_supported = false;
return -1; return -1;
} }
@ -2929,6 +2951,8 @@ int hm_get_utilization_with_device_id (hashcat_ctx_t *hashcat_ctx, const u32 dev
if (hwmon_ctx->enabled == false) return -1; if (hwmon_ctx->enabled == false) return -1;
if (hwmon_ctx->hm_device[device_id].utilization_get_supported == false) return -1;
if ((opencl_ctx->devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) return -1; if ((opencl_ctx->devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) return -1;
if (opencl_ctx->devices_param[device_id].device_vendor_id == VENDOR_ID_AMD) if (opencl_ctx->devices_param[device_id].device_vendor_id == VENDOR_ID_AMD)
@ -2957,6 +2981,8 @@ int hm_get_utilization_with_device_id (hashcat_ctx_t *hashcat_ctx, const u32 dev
} }
} }
hwmon_ctx->hm_device[device_id].utilization_get_supported = false;
return -1; return -1;
} }
@ -2967,6 +2993,8 @@ int hm_get_memoryspeed_with_device_id (hashcat_ctx_t *hashcat_ctx, const u32 dev
if (hwmon_ctx->enabled == false) return -1; if (hwmon_ctx->enabled == false) return -1;
if (hwmon_ctx->hm_device[device_id].memoryspeed_get_supported == false) return -1;
if ((opencl_ctx->devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) return -1; if ((opencl_ctx->devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) return -1;
if (opencl_ctx->devices_param[device_id].device_vendor_id == VENDOR_ID_AMD) if (opencl_ctx->devices_param[device_id].device_vendor_id == VENDOR_ID_AMD)
@ -3004,6 +3032,8 @@ int hm_get_memoryspeed_with_device_id (hashcat_ctx_t *hashcat_ctx, const u32 dev
} }
} }
hwmon_ctx->hm_device[device_id].memoryspeed_get_supported = false;
return -1; return -1;
} }
@ -3014,6 +3044,8 @@ int hm_get_corespeed_with_device_id (hashcat_ctx_t *hashcat_ctx, const u32 devic
if (hwmon_ctx->enabled == false) return -1; if (hwmon_ctx->enabled == false) return -1;
if (hwmon_ctx->hm_device[device_id].corespeed_get_supported == false) return -1;
if ((opencl_ctx->devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) return -1; if ((opencl_ctx->devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) return -1;
if (opencl_ctx->devices_param[device_id].device_vendor_id == VENDOR_ID_AMD) if (opencl_ctx->devices_param[device_id].device_vendor_id == VENDOR_ID_AMD)
@ -3051,6 +3083,8 @@ int hm_get_corespeed_with_device_id (hashcat_ctx_t *hashcat_ctx, const u32 devic
} }
} }
hwmon_ctx->hm_device[device_id].corespeed_get_supported = false;
return -1; return -1;
} }
@ -3061,6 +3095,8 @@ int hm_get_throttle_with_device_id (hashcat_ctx_t *hashcat_ctx, const u32 device
if (hwmon_ctx->enabled == false) return -1; if (hwmon_ctx->enabled == false) return -1;
if (hwmon_ctx->hm_device[device_id].throttle_get_supported == false) return -1;
if ((opencl_ctx->devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) return -1; if ((opencl_ctx->devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) return -1;
if (opencl_ctx->devices_param[device_id].device_vendor_id == VENDOR_ID_AMD) if (opencl_ctx->devices_param[device_id].device_vendor_id == VENDOR_ID_AMD)
@ -3113,6 +3149,8 @@ int hm_get_throttle_with_device_id (hashcat_ctx_t *hashcat_ctx, const u32 device
} }
} }
hwmon_ctx->hm_device[device_id].throttle_get_supported = false;
return -1; return -1;
} }
@ -3122,7 +3160,7 @@ int hm_set_fanspeed_with_device_id_adl (hashcat_ctx_t *hashcat_ctx, const u32 de
if (hwmon_ctx->enabled == false) return -1; if (hwmon_ctx->enabled == false) return -1;
if (hwmon_ctx->hm_device[device_id].fan_set_supported == false) return -1; if (hwmon_ctx->hm_device[device_id].fanspeed_set_supported == false) return -1;
if (hwmon_ctx->hm_adl) if (hwmon_ctx->hm_adl)
{ {
@ -3174,6 +3212,8 @@ int hm_set_fanspeed_with_device_id_adl (hashcat_ctx_t *hashcat_ctx, const u32 de
} }
} }
hwmon_ctx->hm_device[device_id].fanspeed_set_supported = false;
return -1; return -1;
} }
@ -3183,7 +3223,7 @@ int hm_set_fanspeed_with_device_id_nvapi (hashcat_ctx_t *hashcat_ctx, const u32
if (hwmon_ctx->enabled == false) return -1; if (hwmon_ctx->enabled == false) return -1;
if (hwmon_ctx->hm_device[device_id].fan_set_supported == false) return -1; if (hwmon_ctx->hm_device[device_id].fanspeed_set_supported == false) return -1;
if (hwmon_ctx->hm_nvapi) if (hwmon_ctx->hm_nvapi)
{ {
@ -3219,6 +3259,8 @@ int hm_set_fanspeed_with_device_id_nvapi (hashcat_ctx_t *hashcat_ctx, const u32
} }
} }
hwmon_ctx->hm_device[device_id].fanspeed_set_supported = false;
return -1; return -1;
} }
@ -3228,7 +3270,7 @@ int hm_set_fanspeed_with_device_id_xnvctrl (hashcat_ctx_t *hashcat_ctx, const u3
if (hwmon_ctx->enabled == false) return -1; if (hwmon_ctx->enabled == false) return -1;
if (hwmon_ctx->hm_device[device_id].fan_set_supported == false) return -1; if (hwmon_ctx->hm_device[device_id].fanspeed_set_supported == false) return -1;
if (hwmon_ctx->hm_xnvctrl) if (hwmon_ctx->hm_xnvctrl)
{ {
@ -3237,6 +3279,8 @@ int hm_set_fanspeed_with_device_id_xnvctrl (hashcat_ctx_t *hashcat_ctx, const u3
return 0; return 0;
} }
hwmon_ctx->hm_device[device_id].fanspeed_set_supported = false;
return -1; return -1;
} }
@ -3246,7 +3290,7 @@ int hm_set_fanspeed_with_device_id_sysfs (hashcat_ctx_t *hashcat_ctx, const u32
if (hwmon_ctx->enabled == false) return -1; if (hwmon_ctx->enabled == false) return -1;
if (hwmon_ctx->hm_device[device_id].fan_set_supported == false) return -1; if (hwmon_ctx->hm_device[device_id].fanspeed_set_supported == false) return -1;
if (hwmon_ctx->hm_sysfs) if (hwmon_ctx->hm_sysfs)
{ {
@ -3255,6 +3299,8 @@ int hm_set_fanspeed_with_device_id_sysfs (hashcat_ctx_t *hashcat_ctx, const u32
return 0; return 0;
} }
hwmon_ctx->hm_device[device_id].fanspeed_set_supported = false;
return -1; return -1;
} }
@ -3264,7 +3310,7 @@ static int hm_set_fanctrl_with_device_id_xnvctrl (hashcat_ctx_t *hashcat_ctx, co
if (hwmon_ctx->enabled == false) return -1; if (hwmon_ctx->enabled == false) return -1;
if (hwmon_ctx->hm_device[device_id].fan_set_supported == false) return -1; if (hwmon_ctx->hm_device[device_id].fanpolicy_set_supported == false) return -1;
if (hwmon_ctx->hm_xnvctrl) if (hwmon_ctx->hm_xnvctrl)
{ {
@ -3273,6 +3319,8 @@ static int hm_set_fanctrl_with_device_id_xnvctrl (hashcat_ctx_t *hashcat_ctx, co
return 0; return 0;
} }
hwmon_ctx->hm_device[device_id].fanpolicy_set_supported = false;
return -1; return -1;
} }
@ -3282,7 +3330,7 @@ static int hm_set_fanctrl_with_device_id_sysfs (hashcat_ctx_t *hashcat_ctx, cons
if (hwmon_ctx->enabled == false) return -1; if (hwmon_ctx->enabled == false) return -1;
if (hwmon_ctx->hm_device[device_id].fan_set_supported == false) return -1; if (hwmon_ctx->hm_device[device_id].fanpolicy_set_supported == false) return -1;
if (hwmon_ctx->hm_sysfs) if (hwmon_ctx->hm_sysfs)
{ {
@ -3291,6 +3339,8 @@ static int hm_set_fanctrl_with_device_id_sysfs (hashcat_ctx_t *hashcat_ctx, cons
return 0; return 0;
} }
hwmon_ctx->hm_device[device_id].fanpolicy_set_supported = false;
return -1; return -1;
} }
@ -3410,9 +3460,14 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx)
{ {
hm_adapters_nvml[i].nvml = nvmlGPUHandle[i]; hm_adapters_nvml[i].nvml = nvmlGPUHandle[i];
unsigned int speed; hm_adapters_nvml[i].buslanes_get_supported = true;
hm_adapters_nvml[i].corespeed_get_supported = true;
if (hm_NVML_nvmlDeviceGetFanSpeed (hashcat_ctx, hm_adapters_nvml[i].nvml, &speed) == 0) hm_adapters_nvml[i].fan_get_supported = true; hm_adapters_nvml[i].fanspeed_get_supported = true;
hm_adapters_nvml[i].memoryspeed_get_supported = true;
hm_adapters_nvml[i].temperature_get_supported = true;
hm_adapters_nvml[i].threshold_shutdown_get_supported = true;
hm_adapters_nvml[i].threshold_slowdown_get_supported = true;
hm_adapters_nvml[i].utilization_get_supported = true;
// doesn't seem to create any advantages // doesn't seem to create any advantages
//hm_NVML_nvmlDeviceSetComputeMode (hashcat_ctx, hm_adapters_nvml[i].nvml, NVML_COMPUTEMODE_EXCLUSIVE_PROCESS); //hm_NVML_nvmlDeviceSetComputeMode (hashcat_ctx, hm_adapters_nvml[i].nvml, NVML_COMPUTEMODE_EXCLUSIVE_PROCESS);
@ -3434,6 +3489,11 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx)
for (int i = 0; i < tmp_in; i++) for (int i = 0; i < tmp_in; i++)
{ {
hm_adapters_nvapi[i].nvapi = nvGPUHandle[i]; hm_adapters_nvapi[i].nvapi = nvGPUHandle[i];
hm_adapters_nvapi[i].fanspeed_set_supported = true;
hm_adapters_nvapi[i].fanpolicy_get_supported = true;
hm_adapters_nvapi[i].fanpolicy_set_supported = true;
hm_adapters_nvapi[i].throttle_get_supported = true;
} }
hcfree (nvGPUHandle); hcfree (nvGPUHandle);
@ -3454,9 +3514,10 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx)
hm_adapters_xnvctrl[hm_adapters_id].xnvctrl = device_id; hm_adapters_xnvctrl[hm_adapters_id].xnvctrl = device_id;
int speed = 0; hm_adapters_xnvctrl[hm_adapters_id].fanspeed_get_supported = true;
hm_adapters_xnvctrl[hm_adapters_id].fanspeed_set_supported = true;
if (hm_XNVCTRL_get_fan_speed_current (hashcat_ctx, device_id, &speed) == 0) hm_adapters_xnvctrl[hm_adapters_id].fan_get_supported = true; hm_adapters_xnvctrl[hm_adapters_id].fanpolicy_get_supported = true;
hm_adapters_xnvctrl[hm_adapters_id].fanpolicy_set_supported = true;
hm_adapters_id++; hm_adapters_id++;
} }
@ -3487,6 +3548,20 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx)
u32 *valid_adl_device_list = hm_get_list_valid_adl_adapters (hm_adapters_num, &num_adl_adapters, lpAdapterInfo); u32 *valid_adl_device_list = hm_get_list_valid_adl_adapters (hm_adapters_num, &num_adl_adapters, lpAdapterInfo);
for (int i = 0; i < num_adl_adapters; i++)
{
hm_adapters_adl[i].buslanes_get_supported = true;
hm_adapters_adl[i].corespeed_get_supported = true;
hm_adapters_adl[i].fanspeed_get_supported = true;
hm_adapters_adl[i].fanspeed_set_supported = true;
hm_adapters_adl[i].fanpolicy_get_supported = true;
hm_adapters_adl[i].fanpolicy_set_supported = true;
hm_adapters_adl[i].memoryspeed_get_supported = true;
hm_adapters_adl[i].temperature_get_supported = true;
hm_adapters_adl[i].threshold_slowdown_get_supported = true;
hm_adapters_adl[i].utilization_get_supported = true;
}
if (num_adl_adapters > 0) if (num_adl_adapters > 0)
{ {
hm_get_adapter_index_adl (hashcat_ctx, valid_adl_device_list, num_adl_adapters, lpAdapterInfo); hm_get_adapter_index_adl (hashcat_ctx, valid_adl_device_list, num_adl_adapters, lpAdapterInfo);
@ -3516,9 +3591,14 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx)
hm_adapters_sysfs[hm_adapters_id].sysfs = device_id; hm_adapters_sysfs[hm_adapters_id].sysfs = device_id;
int speed = 0; hm_adapters_sysfs[hm_adapters_id].buslanes_get_supported = true;
hm_adapters_sysfs[hm_adapters_id].corespeed_get_supported = true;
if (hm_SYSFS_get_fan_speed_current (hashcat_ctx, device_id, &speed) == 0) hm_adapters_sysfs[hm_adapters_id].fan_get_supported = true; hm_adapters_sysfs[hm_adapters_id].fanspeed_get_supported = true;
hm_adapters_sysfs[hm_adapters_id].fanspeed_set_supported = true;
hm_adapters_sysfs[hm_adapters_id].fanpolicy_get_supported = true;
hm_adapters_sysfs[hm_adapters_id].fanpolicy_set_supported = true;
hm_adapters_sysfs[hm_adapters_id].memoryspeed_get_supported = true;
hm_adapters_sysfs[hm_adapters_id].temperature_get_supported = true;
hm_adapters_id++; hm_adapters_id++;
} }
@ -3562,30 +3642,119 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx)
if (device_param->device_vendor_id == VENDOR_ID_AMD) if (device_param->device_vendor_id == VENDOR_ID_AMD)
{ {
hwmon_ctx->hm_device[device_id].adl = hm_adapters_adl[platform_devices_id].adl; hwmon_ctx->hm_device[device_id].adl = hm_adapters_adl[platform_devices_id].adl;
hwmon_ctx->hm_device[device_id].sysfs = hm_adapters_sysfs[platform_devices_id].sysfs; hwmon_ctx->hm_device[device_id].sysfs = hm_adapters_sysfs[platform_devices_id].sysfs;
hwmon_ctx->hm_device[device_id].nvapi = 0; hwmon_ctx->hm_device[device_id].nvapi = 0;
hwmon_ctx->hm_device[device_id].nvml = 0; hwmon_ctx->hm_device[device_id].nvml = 0;
hwmon_ctx->hm_device[device_id].xnvctrl = 0; hwmon_ctx->hm_device[device_id].xnvctrl = 0;
hwmon_ctx->hm_device[device_id].od_version = hm_adapters_adl[platform_devices_id].od_version; hwmon_ctx->hm_device[device_id].od_version = 0;
if (hwmon_ctx->hm_adl) if (hwmon_ctx->hm_adl)
hwmon_ctx->hm_device[device_id].fan_get_supported = hm_adapters_adl[platform_devices_id].fan_get_supported; {
hwmon_ctx->hm_device[device_id].od_version = hm_adapters_adl[platform_devices_id].od_version;
hwmon_ctx->hm_device[device_id].buslanes_get_supported |= hm_adapters_adl[platform_devices_id].buslanes_get_supported;
hwmon_ctx->hm_device[device_id].corespeed_get_supported |= hm_adapters_adl[platform_devices_id].corespeed_get_supported;
hwmon_ctx->hm_device[device_id].fanspeed_get_supported |= hm_adapters_adl[platform_devices_id].fanspeed_get_supported;
hwmon_ctx->hm_device[device_id].fanspeed_set_supported |= hm_adapters_adl[platform_devices_id].fanspeed_set_supported;
hwmon_ctx->hm_device[device_id].fanpolicy_get_supported |= hm_adapters_adl[platform_devices_id].fanpolicy_get_supported;
hwmon_ctx->hm_device[device_id].fanpolicy_set_supported |= hm_adapters_adl[platform_devices_id].fanpolicy_set_supported;
hwmon_ctx->hm_device[device_id].memoryspeed_get_supported |= hm_adapters_adl[platform_devices_id].memoryspeed_get_supported;
hwmon_ctx->hm_device[device_id].temperature_get_supported |= hm_adapters_adl[platform_devices_id].temperature_get_supported;
hwmon_ctx->hm_device[device_id].threshold_shutdown_get_supported |= hm_adapters_adl[platform_devices_id].threshold_shutdown_get_supported;
hwmon_ctx->hm_device[device_id].threshold_slowdown_get_supported |= hm_adapters_adl[platform_devices_id].threshold_slowdown_get_supported;
hwmon_ctx->hm_device[device_id].throttle_get_supported |= hm_adapters_adl[platform_devices_id].throttle_get_supported;
hwmon_ctx->hm_device[device_id].utilization_get_supported |= hm_adapters_adl[platform_devices_id].utilization_get_supported;
}
if (hwmon_ctx->hm_sysfs) if (hwmon_ctx->hm_sysfs)
hwmon_ctx->hm_device[device_id].fan_get_supported = hm_adapters_sysfs[platform_devices_id].fan_get_supported; {
hwmon_ctx->hm_device[device_id].fan_set_supported = false; hwmon_ctx->hm_device[device_id].buslanes_get_supported |= hm_adapters_sysfs[platform_devices_id].buslanes_get_supported;
hwmon_ctx->hm_device[device_id].corespeed_get_supported |= hm_adapters_sysfs[platform_devices_id].corespeed_get_supported;
hwmon_ctx->hm_device[device_id].fanspeed_get_supported |= hm_adapters_sysfs[platform_devices_id].fanspeed_get_supported;
hwmon_ctx->hm_device[device_id].fanspeed_set_supported |= hm_adapters_sysfs[platform_devices_id].fanspeed_set_supported;
hwmon_ctx->hm_device[device_id].fanpolicy_get_supported |= hm_adapters_sysfs[platform_devices_id].fanpolicy_get_supported;
hwmon_ctx->hm_device[device_id].fanpolicy_set_supported |= hm_adapters_sysfs[platform_devices_id].fanpolicy_set_supported;
hwmon_ctx->hm_device[device_id].memoryspeed_get_supported |= hm_adapters_sysfs[platform_devices_id].memoryspeed_get_supported;
hwmon_ctx->hm_device[device_id].temperature_get_supported |= hm_adapters_sysfs[platform_devices_id].temperature_get_supported;
hwmon_ctx->hm_device[device_id].threshold_shutdown_get_supported |= hm_adapters_sysfs[platform_devices_id].threshold_shutdown_get_supported;
hwmon_ctx->hm_device[device_id].threshold_slowdown_get_supported |= hm_adapters_sysfs[platform_devices_id].threshold_slowdown_get_supported;
hwmon_ctx->hm_device[device_id].throttle_get_supported |= hm_adapters_sysfs[platform_devices_id].throttle_get_supported;
hwmon_ctx->hm_device[device_id].utilization_get_supported |= hm_adapters_sysfs[platform_devices_id].utilization_get_supported;
}
} }
if (device_param->device_vendor_id == VENDOR_ID_NV) if (device_param->device_vendor_id == VENDOR_ID_NV)
{ {
hwmon_ctx->hm_device[device_id].adl = 0; hwmon_ctx->hm_device[device_id].adl = 0;
hwmon_ctx->hm_device[device_id].sysfs = 0; hwmon_ctx->hm_device[device_id].sysfs = 0;
hwmon_ctx->hm_device[device_id].nvapi = hm_adapters_nvapi[platform_devices_id].nvapi; hwmon_ctx->hm_device[device_id].nvapi = hm_adapters_nvapi[platform_devices_id].nvapi;
hwmon_ctx->hm_device[device_id].nvml = hm_adapters_nvml[platform_devices_id].nvml; hwmon_ctx->hm_device[device_id].nvml = hm_adapters_nvml[platform_devices_id].nvml;
hwmon_ctx->hm_device[device_id].xnvctrl = hm_adapters_xnvctrl[platform_devices_id].xnvctrl; hwmon_ctx->hm_device[device_id].xnvctrl = hm_adapters_xnvctrl[platform_devices_id].xnvctrl;
hwmon_ctx->hm_device[device_id].od_version = 0; hwmon_ctx->hm_device[device_id].od_version = 0;
hwmon_ctx->hm_device[device_id].fan_get_supported = hm_adapters_nvml[platform_devices_id].fan_get_supported;
hwmon_ctx->hm_device[device_id].fan_set_supported = false; if (hwmon_ctx->hm_nvml)
{
hwmon_ctx->hm_device[device_id].buslanes_get_supported |= hm_adapters_nvml[platform_devices_id].buslanes_get_supported;
hwmon_ctx->hm_device[device_id].corespeed_get_supported |= hm_adapters_nvml[platform_devices_id].corespeed_get_supported;
hwmon_ctx->hm_device[device_id].fanspeed_get_supported |= hm_adapters_nvml[platform_devices_id].fanspeed_get_supported;
hwmon_ctx->hm_device[device_id].fanspeed_set_supported |= hm_adapters_nvml[platform_devices_id].fanspeed_set_supported;
hwmon_ctx->hm_device[device_id].fanpolicy_get_supported |= hm_adapters_nvml[platform_devices_id].fanpolicy_get_supported;
hwmon_ctx->hm_device[device_id].fanpolicy_set_supported |= hm_adapters_nvml[platform_devices_id].fanpolicy_set_supported;
hwmon_ctx->hm_device[device_id].memoryspeed_get_supported |= hm_adapters_nvml[platform_devices_id].memoryspeed_get_supported;
hwmon_ctx->hm_device[device_id].temperature_get_supported |= hm_adapters_nvml[platform_devices_id].temperature_get_supported;
hwmon_ctx->hm_device[device_id].threshold_shutdown_get_supported |= hm_adapters_nvml[platform_devices_id].threshold_shutdown_get_supported;
hwmon_ctx->hm_device[device_id].threshold_slowdown_get_supported |= hm_adapters_nvml[platform_devices_id].threshold_slowdown_get_supported;
hwmon_ctx->hm_device[device_id].throttle_get_supported |= hm_adapters_nvml[platform_devices_id].throttle_get_supported;
hwmon_ctx->hm_device[device_id].utilization_get_supported |= hm_adapters_nvml[platform_devices_id].utilization_get_supported;
}
if (hwmon_ctx->hm_nvapi)
{
hwmon_ctx->hm_device[device_id].buslanes_get_supported |= hm_adapters_nvapi[platform_devices_id].buslanes_get_supported;
hwmon_ctx->hm_device[device_id].corespeed_get_supported |= hm_adapters_nvapi[platform_devices_id].corespeed_get_supported;
hwmon_ctx->hm_device[device_id].fanspeed_get_supported |= hm_adapters_nvapi[platform_devices_id].fanspeed_get_supported;
hwmon_ctx->hm_device[device_id].fanspeed_set_supported |= hm_adapters_nvapi[platform_devices_id].fanspeed_set_supported;
hwmon_ctx->hm_device[device_id].fanpolicy_get_supported |= hm_adapters_nvapi[platform_devices_id].fanpolicy_get_supported;
hwmon_ctx->hm_device[device_id].fanpolicy_set_supported |= hm_adapters_nvapi[platform_devices_id].fanpolicy_set_supported;
hwmon_ctx->hm_device[device_id].memoryspeed_get_supported |= hm_adapters_nvapi[platform_devices_id].memoryspeed_get_supported;
hwmon_ctx->hm_device[device_id].temperature_get_supported |= hm_adapters_nvapi[platform_devices_id].temperature_get_supported;
hwmon_ctx->hm_device[device_id].threshold_shutdown_get_supported |= hm_adapters_nvapi[platform_devices_id].threshold_shutdown_get_supported;
hwmon_ctx->hm_device[device_id].threshold_slowdown_get_supported |= hm_adapters_nvapi[platform_devices_id].threshold_slowdown_get_supported;
hwmon_ctx->hm_device[device_id].throttle_get_supported |= hm_adapters_nvapi[platform_devices_id].throttle_get_supported;
hwmon_ctx->hm_device[device_id].utilization_get_supported |= hm_adapters_nvapi[platform_devices_id].utilization_get_supported;
}
if (hwmon_ctx->hm_xnvctrl)
{
hwmon_ctx->hm_device[device_id].buslanes_get_supported |= hm_adapters_xnvctrl[platform_devices_id].buslanes_get_supported;
hwmon_ctx->hm_device[device_id].corespeed_get_supported |= hm_adapters_xnvctrl[platform_devices_id].corespeed_get_supported;
hwmon_ctx->hm_device[device_id].fanspeed_get_supported |= hm_adapters_xnvctrl[platform_devices_id].fanspeed_get_supported;
hwmon_ctx->hm_device[device_id].fanspeed_set_supported |= hm_adapters_xnvctrl[platform_devices_id].fanspeed_set_supported;
hwmon_ctx->hm_device[device_id].fanpolicy_get_supported |= hm_adapters_xnvctrl[platform_devices_id].fanpolicy_get_supported;
hwmon_ctx->hm_device[device_id].fanpolicy_set_supported |= hm_adapters_xnvctrl[platform_devices_id].fanpolicy_set_supported;
hwmon_ctx->hm_device[device_id].memoryspeed_get_supported |= hm_adapters_xnvctrl[platform_devices_id].memoryspeed_get_supported;
hwmon_ctx->hm_device[device_id].temperature_get_supported |= hm_adapters_xnvctrl[platform_devices_id].temperature_get_supported;
hwmon_ctx->hm_device[device_id].threshold_shutdown_get_supported |= hm_adapters_xnvctrl[platform_devices_id].threshold_shutdown_get_supported;
hwmon_ctx->hm_device[device_id].threshold_slowdown_get_supported |= hm_adapters_xnvctrl[platform_devices_id].threshold_slowdown_get_supported;
hwmon_ctx->hm_device[device_id].throttle_get_supported |= hm_adapters_xnvctrl[platform_devices_id].throttle_get_supported;
hwmon_ctx->hm_device[device_id].utilization_get_supported |= hm_adapters_xnvctrl[platform_devices_id].utilization_get_supported;
}
} }
// by calling the different functions here this will disable them in case they will error out
// this will also reduce the error itself printed to the user to a single print on startup
hm_get_buslanes_with_device_id (hashcat_ctx, device_id);
hm_get_corespeed_with_device_id (hashcat_ctx, device_id);
hm_get_fanpolicy_with_device_id (hashcat_ctx, device_id);
hm_get_fanspeed_with_device_id (hashcat_ctx, device_id);
hm_get_memoryspeed_with_device_id (hashcat_ctx, device_id);
hm_get_temperature_with_device_id (hashcat_ctx, device_id);
hm_get_threshold_shutdown_with_device_id (hashcat_ctx, device_id);
hm_get_threshold_slowdown_with_device_id (hashcat_ctx, device_id);
hm_get_throttle_with_device_id (hashcat_ctx, device_id);
hm_get_utilization_with_device_id (hashcat_ctx, device_id);
} }
hcfree (hm_adapters_adl); hcfree (hm_adapters_adl);
@ -3827,59 +3996,35 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx)
if ((opencl_ctx->devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) continue; if ((opencl_ctx->devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) continue;
if (hwmon_ctx->hm_device[device_id].fan_get_supported == true) if (hwmon_ctx->hm_device[device_id].fanspeed_get_supported == false) continue;
if (hwmon_ctx->hm_device[device_id].fanspeed_set_supported == false) continue;
const int fanspeed = hm_get_fanspeed_with_device_id (hashcat_ctx, device_id);
if (fanspeed == -1) continue;
if (device_param->device_vendor_id == VENDOR_ID_AMD)
{ {
const int fanspeed = hm_get_fanspeed_with_device_id (hashcat_ctx, device_id); if (hwmon_ctx->hm_adl)
const int fanpolicy = hm_get_fanpolicy_with_device_id (hashcat_ctx, device_id);
// we also set it to tell the OS we take control over the fan and it's automatic controller
// if it was set to automatic. we do not control user-defined fanspeeds.
if (fanpolicy == 1)
{ {
hwmon_ctx->hm_device[device_id].fan_set_supported = true; hm_set_fanspeed_with_device_id_adl (hashcat_ctx, device_id, fanspeed, 1);
int rc = -1;
if (device_param->device_vendor_id == VENDOR_ID_AMD)
{
if (hwmon_ctx->hm_adl)
{
rc = hm_set_fanspeed_with_device_id_adl (hashcat_ctx, device_id, fanspeed, 1);
}
if (hwmon_ctx->hm_sysfs)
{
rc = hm_set_fanctrl_with_device_id_sysfs (hashcat_ctx, device_id, 1);
}
}
else if (device_param->device_vendor_id == VENDOR_ID_NV)
{
if (hwmon_ctx->hm_xnvctrl)
{
rc = hm_set_fanctrl_with_device_id_xnvctrl (hashcat_ctx, device_id, NV_CTRL_GPU_COOLER_MANUAL_CONTROL_TRUE);
}
if (hwmon_ctx->hm_nvapi)
{
rc = hm_set_fanspeed_with_device_id_nvapi (hashcat_ctx, device_id, fanspeed, 1);
}
}
if (rc == 0)
{
hwmon_ctx->hm_device[device_id].fan_set_supported = true;
}
else
{
//event_log_error (hashcat_ctx, "Failed to set initial fan speed for device #%u", device_id + 1);
hwmon_ctx->hm_device[device_id].fan_set_supported = false;
}
} }
else
if (hwmon_ctx->hm_sysfs)
{ {
hwmon_ctx->hm_device[device_id].fan_set_supported = false; hm_set_fanctrl_with_device_id_sysfs (hashcat_ctx, device_id, 1);
}
}
else if (device_param->device_vendor_id == VENDOR_ID_NV)
{
if (hwmon_ctx->hm_xnvctrl)
{
hm_set_fanctrl_with_device_id_xnvctrl (hashcat_ctx, device_id, NV_CTRL_GPU_COOLER_MANUAL_CONTROL_TRUE);
}
if (hwmon_ctx->hm_nvapi)
{
hm_set_fanspeed_with_device_id_nvapi (hashcat_ctx, device_id, fanspeed, 1);
} }
} }
} }
@ -3908,37 +4053,37 @@ void hwmon_ctx_destroy (hashcat_ctx_t *hashcat_ctx)
if ((opencl_ctx->devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) continue; if ((opencl_ctx->devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) continue;
if (hwmon_ctx->hm_device[device_id].fan_set_supported == true) if (hwmon_ctx->hm_device[device_id].fanspeed_get_supported == false) continue;
if (hwmon_ctx->hm_device[device_id].fanspeed_set_supported == false) continue;
int rc = -1;
if (device_param->device_vendor_id == VENDOR_ID_AMD)
{ {
int rc = -1; if (hwmon_ctx->hm_adl)
if (device_param->device_vendor_id == VENDOR_ID_AMD)
{ {
if (hwmon_ctx->hm_adl) rc = hm_set_fanspeed_with_device_id_adl (hashcat_ctx, device_id, 100, 0);
{
rc = hm_set_fanspeed_with_device_id_adl (hashcat_ctx, device_id, 100, 0);
}
if (hwmon_ctx->hm_sysfs)
{
rc = hm_set_fanctrl_with_device_id_sysfs (hashcat_ctx, device_id, 2);
}
}
else if (device_param->device_vendor_id == VENDOR_ID_NV)
{
if (hwmon_ctx->hm_xnvctrl)
{
rc = hm_set_fanctrl_with_device_id_xnvctrl (hashcat_ctx, device_id, NV_CTRL_GPU_COOLER_MANUAL_CONTROL_FALSE);
}
if (hwmon_ctx->hm_nvapi)
{
rc = hm_set_fanspeed_with_device_id_nvapi (hashcat_ctx, device_id, 100, 0);
}
} }
if (rc == -1) event_log_error (hashcat_ctx, "Failed to restore default fan speed and policy for device #%u", device_id + 1); if (hwmon_ctx->hm_sysfs)
{
rc = hm_set_fanctrl_with_device_id_sysfs (hashcat_ctx, device_id, 2);
}
} }
else if (device_param->device_vendor_id == VENDOR_ID_NV)
{
if (hwmon_ctx->hm_xnvctrl)
{
rc = hm_set_fanctrl_with_device_id_xnvctrl (hashcat_ctx, device_id, NV_CTRL_GPU_COOLER_MANUAL_CONTROL_FALSE);
}
if (hwmon_ctx->hm_nvapi)
{
rc = hm_set_fanspeed_with_device_id_nvapi (hashcat_ctx, device_id, 100, 0);
}
}
if (rc == -1) event_log_error (hashcat_ctx, "Failed to restore default fan speed and policy for device #%u", device_id + 1);
} }
} }

View File

@ -177,8 +177,8 @@ static int monitor (hashcat_ctx_t *hashcat_ctx)
myabort (hashcat_ctx); myabort (hashcat_ctx);
} }
if (hwmon_ctx->hm_device[device_id].fan_get_supported == false) continue; if (hwmon_ctx->hm_device[device_id].fanspeed_get_supported == false) continue;
if (hwmon_ctx->hm_device[device_id].fan_set_supported == false) continue; if (hwmon_ctx->hm_device[device_id].fanspeed_set_supported == false) continue;
const u32 gpu_temp_retain = user_options->gpu_temp_retain; const u32 gpu_temp_retain = user_options->gpu_temp_retain;

View File

@ -1633,10 +1633,12 @@ char *status_get_hwmon_dev (const hashcat_ctx_t *hashcat_ctx, const int device_i
{ {
// trims the trailing space // trims the trailing space
output_len--; output_buf[output_len - 1] = 0;
}
else
{
output_len = snprintf (output_buf, HCBUFSIZ_TINY - 1, "*ERROR*");
} }
output_buf[output_len] = 0;
hc_thread_mutex_unlock (status_ctx->mux_hwmon); hc_thread_mutex_unlock (status_ctx->mux_hwmon);