From e43be7aba38daf43d64f2d3f3223f3f7fa741bfb Mon Sep 17 00:00:00 2001 From: jsteube Date: Sat, 18 Jun 2016 11:26:51 +0200 Subject: [PATCH] Do not try to set fanspeed if connection to X11 failed --- src/ext_xnvctrl.c | 14 ++++++++++++++ src/hashcat.c | 6 +++--- src/shared.c | 11 ----------- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/ext_xnvctrl.c b/src/ext_xnvctrl.c index 7c97e792a..582b86ff6 100644 --- a/src/ext_xnvctrl.c +++ b/src/ext_xnvctrl.c @@ -82,6 +82,8 @@ int hm_XNVCTRL_XOpenDisplay (XNVCTRL_PTR *xnvctrl) if (dpy == NULL) { + xnvctrl->dpy = NULL; + return -1; } @@ -92,11 +94,15 @@ int hm_XNVCTRL_XOpenDisplay (XNVCTRL_PTR *xnvctrl) void hm_XNVCTRL_XCloseDisplay (XNVCTRL_PTR *xnvctrl) { + if (xnvctrl->dpy == NULL) return; + xnvctrl->XCloseDisplay (xnvctrl->dpy); } int get_fan_control (XNVCTRL_PTR *xnvctrl, int gpu, int *val) { + if (xnvctrl->dpy == NULL) return -1; + int rc = xnvctrl->XNVCTRLQueryTargetAttribute (xnvctrl->dpy, NV_CTRL_TARGET_TYPE_GPU, gpu, 0, NV_CTRL_GPU_COOLER_MANUAL_CONTROL, val); if (!rc) return -1; @@ -106,6 +112,8 @@ int get_fan_control (XNVCTRL_PTR *xnvctrl, int gpu, int *val) int set_fan_control (XNVCTRL_PTR *xnvctrl, int gpu, int val) { + if (xnvctrl->dpy == NULL) return -1; + xnvctrl->XNVCTRLSetTargetAttribute (xnvctrl->dpy, NV_CTRL_TARGET_TYPE_GPU, gpu, 0, NV_CTRL_GPU_COOLER_MANUAL_CONTROL, val); int cur; @@ -121,6 +129,8 @@ int set_fan_control (XNVCTRL_PTR *xnvctrl, int gpu, int val) int get_core_threshold (XNVCTRL_PTR *xnvctrl, int gpu, int *val) { + if (xnvctrl->dpy == NULL) return -1; + int rc = xnvctrl->XNVCTRLQueryTargetAttribute (xnvctrl->dpy, NV_CTRL_TARGET_TYPE_GPU, gpu, 0, NV_CTRL_GPU_CORE_THRESHOLD, val); if (!rc) return -1; @@ -139,6 +149,8 @@ int get_fan_speed_current (XNVCTRL_PTR *xnvctrl, int gpu, int *val) int get_fan_speed_target (XNVCTRL_PTR *xnvctrl, int gpu, int *val) { + if (xnvctrl->dpy == NULL) return -1; + int rc = xnvctrl->XNVCTRLQueryTargetAttribute (xnvctrl->dpy, NV_CTRL_TARGET_TYPE_COOLER, gpu, 0, NV_CTRL_THERMAL_COOLER_LEVEL, val); if (!rc) return -1; @@ -148,6 +160,8 @@ int get_fan_speed_target (XNVCTRL_PTR *xnvctrl, int gpu, int *val) int set_fan_speed_target (XNVCTRL_PTR *xnvctrl, int gpu, int val) { + if (xnvctrl->dpy == NULL) return -1; + xnvctrl->XNVCTRLSetTargetAttribute (xnvctrl->dpy, NV_CTRL_TARGET_TYPE_COOLER, gpu, 0, NV_CTRL_THERMAL_COOLER_LEVEL, val); int cur; diff --git a/src/hashcat.c b/src/hashcat.c index dec206573..0cf7d2d25 100644 --- a/src/hashcat.c +++ b/src/hashcat.c @@ -14512,7 +14512,7 @@ int main (int argc, char **argv) } } - if (data.hm_adl == NULL && data.hm_nvml == NULL && data.hm_xnvctrl) + if (data.hm_adl == NULL && data.hm_nvml == NULL && data.hm_xnvctrl == NULL) { gpu_temp_disable = 1; } @@ -14654,7 +14654,7 @@ int main (int argc, char **argv) data.hm_device[device_id].xnvctrl = 0; data.hm_device[device_id].od_version = hm_adapters_adl[platform_devices_id].od_version; data.hm_device[device_id].fan_get_supported = hm_adapters_adl[platform_devices_id].fan_get_supported; - data.hm_device[device_id].fan_set_supported = hm_adapters_adl[platform_devices_id].fan_set_supported; + data.hm_device[device_id].fan_set_supported = 0; } if (device_param->device_vendor_id == VENDOR_ID_NV) @@ -16181,7 +16181,7 @@ int main (int argc, char **argv) else if (device_param->device_vendor_id == VENDOR_ID_NV) { #ifdef _POSIX - rc = hm_set_fanspeed_with_device_id_xnvctrl (device_id, fanspeed); + rc = set_fan_control (data.hm_xnvctrl, data.hm_device[device_id].xnvctrl, NV_CTRL_GPU_COOLER_MANUAL_CONTROL_TRUE); #endif } diff --git a/src/shared.c b/src/shared.c index 43aded474..6b5051cea 100644 --- a/src/shared.c +++ b/src/shared.c @@ -3194,18 +3194,7 @@ int hm_get_fanpolicy_with_device_id (const uint device_id) if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_NV) { - #if defined(LINUX) - if (data.hm_xnvctrl) - { - if (set_fan_control (data.hm_xnvctrl, data.hm_device[device_id].xnvctrl, NV_CTRL_GPU_COOLER_MANUAL_CONTROL_TRUE) != 0) return -1; - - return 1; - } - #endif - - #if defined(WIN) return 1; - #endif } }