From 8a63a431c4ab42e8531614fd69e460b7fdc5e31f Mon Sep 17 00:00:00 2001 From: Lakshmanan M Date: Tue, 8 Nov 2016 11:15:56 +0530 Subject: [PATCH] gpu: nvgpu: Add thermal alert limit IOCTL for UMD Added the thermal alert lmit IOCTL for UMD JIRA DNVGPU-130 Bug 200231080 Change-Id: I4a84157d90b12b576fa144567a3bdd5d39f5278e Signed-off-by: Lakshmanan M Reviewed-on: http://git-master/r/1249483 (cherry picked from commit d3458008cc3dd98d3a51841b6ed8cea1aed9eb89) Reviewed-on: http://git-master/r/1253457 GVS: Gerrit_Virtual_Submit Reviewed-by: Vijayakumar Subbu --- drivers/gpu/nvgpu/gk20a/ctrl_gk20a.c | 29 ++++++++++++++++++++++++++++ include/uapi/linux/nvgpu.h | 13 ++++++++++++- 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/nvgpu/gk20a/ctrl_gk20a.c b/drivers/gpu/nvgpu/gk20a/ctrl_gk20a.c index 9ee06bf39..a7f61c8cd 100644 --- a/drivers/gpu/nvgpu/gk20a/ctrl_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/ctrl_gk20a.c @@ -1298,6 +1298,30 @@ static int nvgpu_gpu_get_temperature(struct gk20a *g, } #endif +static int nvgpu_gpu_set_therm_alert_limit(struct gk20a *g, + struct nvgpu_gpu_set_therm_alert_limit_args *args) +{ + int err; + + gk20a_dbg_fn(""); + + if (args->reserved[0] || args->reserved[1] || args->reserved[2]) + return -EINVAL; + + if (!g->ops.therm.configure_therm_alert) + return -EINVAL; + + err = gk20a_busy(g->dev); + if (err) + return err; + + err = g->ops.therm.configure_therm_alert(g, args->temp_f24_8); + + gk20a_idle(g->dev); + + return err; +} + long gk20a_ctrl_dev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) { struct gk20a_ctrl_priv *priv = filp->private_data; @@ -1606,6 +1630,11 @@ long gk20a_ctrl_dev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg break; #endif + case NVGPU_GPU_IOCTL_SET_THERM_ALERT_LIMIT: + err = nvgpu_gpu_set_therm_alert_limit(g, + (struct nvgpu_gpu_set_therm_alert_limit_args *)buf); + break; + default: dev_dbg(dev_from_gk20a(g), "unrecognized gpu ioctl cmd: 0x%x", cmd); err = -ENOTTY; diff --git a/include/uapi/linux/nvgpu.h b/include/uapi/linux/nvgpu.h index 25c0472ca..1fb633c80 100644 --- a/include/uapi/linux/nvgpu.h +++ b/include/uapi/linux/nvgpu.h @@ -777,6 +777,14 @@ struct nvgpu_gpu_get_temperature_args { __s32 temp_f24_8; }; +struct nvgpu_gpu_set_therm_alert_limit_args { + __u32 reserved[3]; + /* Temperature in signed fixed point format SFXP24.8 + * Celsius = temp_f24_8 / 256. + */ + __s32 temp_f24_8; +}; + #define NVGPU_GPU_IOCTL_ZCULL_GET_CTX_SIZE \ _IOR(NVGPU_GPU_IOCTL_MAGIC, 1, struct nvgpu_gpu_zcull_get_ctx_size_args) #define NVGPU_GPU_IOCTL_ZCULL_GET_INFO \ @@ -858,8 +866,11 @@ struct nvgpu_gpu_get_temperature_args { _IOWR(NVGPU_GPU_IOCTL_MAGIC, 37, struct nvgpu_gpu_get_temperature_args) #define NVGPU_GPU_IOCTL_GET_FBP_L2_MASKS \ _IOWR(NVGPU_GPU_IOCTL_MAGIC, 38, struct nvgpu_gpu_get_fbp_l2_masks_args) +#define NVGPU_GPU_IOCTL_SET_THERM_ALERT_LIMIT \ + _IOWR(NVGPU_GPU_IOCTL_MAGIC, 39, \ + struct nvgpu_gpu_set_therm_alert_limit_args) #define NVGPU_GPU_IOCTL_LAST \ - _IOC_NR(NVGPU_GPU_IOCTL_GET_FBP_L2_MASKS) + _IOC_NR(NVGPU_GPU_IOCTL_SET_THERM_ALERT_LIMIT) #define NVGPU_GPU_IOCTL_MAX_ARG_SIZE \ sizeof(struct nvgpu_gpu_get_cpu_time_correlation_info_args)