Commit 68bf8b57 authored by Karol Herbst's avatar Karol Herbst Committed by Ben Skeggs

drm/nouveau/hwmon: return EINVAL if the GPU is powered down for sensors reads

fixes bogus values userspace gets from hwmon while the GPU is powered down
Signed-off-by: default avatarKarol Herbst <kherbst@redhat.com>
Reviewed-by: default avatarRhys Kidd <rhyskidd@gmail.com>
Signed-off-by: default avatarBen Skeggs <bskeggs@redhat.com>
parent b0f84a84
...@@ -428,6 +428,8 @@ nouveau_temp_read(struct device *dev, u32 attr, int channel, long *val) ...@@ -428,6 +428,8 @@ nouveau_temp_read(struct device *dev, u32 attr, int channel, long *val)
switch (attr) { switch (attr) {
case hwmon_temp_input: case hwmon_temp_input:
if (drm_dev->switch_power_state != DRM_SWITCH_POWER_ON)
return -EINVAL;
ret = nvkm_therm_temp_get(therm); ret = nvkm_therm_temp_get(therm);
*val = ret < 0 ? ret : (ret * 1000); *val = ret < 0 ? ret : (ret * 1000);
break; break;
...@@ -474,6 +476,8 @@ nouveau_fan_read(struct device *dev, u32 attr, int channel, long *val) ...@@ -474,6 +476,8 @@ nouveau_fan_read(struct device *dev, u32 attr, int channel, long *val)
switch (attr) { switch (attr) {
case hwmon_fan_input: case hwmon_fan_input:
if (drm_dev->switch_power_state != DRM_SWITCH_POWER_ON)
return -EINVAL;
*val = nvkm_therm_fan_sense(therm); *val = nvkm_therm_fan_sense(therm);
break; break;
default: default:
...@@ -496,6 +500,8 @@ nouveau_in_read(struct device *dev, u32 attr, int channel, long *val) ...@@ -496,6 +500,8 @@ nouveau_in_read(struct device *dev, u32 attr, int channel, long *val)
switch (attr) { switch (attr) {
case hwmon_in_input: case hwmon_in_input:
if (drm_dev->switch_power_state != DRM_SWITCH_POWER_ON)
return -EINVAL;
ret = nvkm_volt_get(volt); ret = nvkm_volt_get(volt);
*val = ret < 0 ? ret : (ret / 1000); *val = ret < 0 ? ret : (ret / 1000);
break; break;
...@@ -527,6 +533,8 @@ nouveau_pwm_read(struct device *dev, u32 attr, int channel, long *val) ...@@ -527,6 +533,8 @@ nouveau_pwm_read(struct device *dev, u32 attr, int channel, long *val)
*val = therm->attr_get(therm, NVKM_THERM_ATTR_FAN_MODE); *val = therm->attr_get(therm, NVKM_THERM_ATTR_FAN_MODE);
break; break;
case hwmon_pwm_input: case hwmon_pwm_input:
if (drm_dev->switch_power_state != DRM_SWITCH_POWER_ON)
return -EINVAL;
*val = therm->fan_get(therm); *val = therm->fan_get(therm);
break; break;
default: default:
...@@ -548,6 +556,8 @@ nouveau_power_read(struct device *dev, u32 attr, int channel, long *val) ...@@ -548,6 +556,8 @@ nouveau_power_read(struct device *dev, u32 attr, int channel, long *val)
switch (attr) { switch (attr) {
case hwmon_power_input: case hwmon_power_input:
if (drm_dev->switch_power_state != DRM_SWITCH_POWER_ON)
return -EINVAL;
*val = nvkm_iccsense_read_all(iccsense); *val = nvkm_iccsense_read_all(iccsense);
break; break;
case hwmon_power_max: case hwmon_power_max:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment