<div dir="ltr"><div dir="ltr">On Tue, 18 Jun 2019 at 21:01, Karol Herbst <<a href="mailto:kherbst@redhat.com">kherbst@redhat.com</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">fixes bogus values userspace gets from hwmon while the GPU is powered down<br>
<br>
Signed-off-by: Karol Herbst <<a href="mailto:kherbst@redhat.com" target="_blank">kherbst@redhat.com</a>><br></blockquote><div><br></div><div>Looks good to me and successfully tested on my GP107M with runtime power management fixes, so<br></div><div><br></div><div>Reviewed-by: Rhys Kidd <<a href="mailto:rhyskidd@gmail.com">rhyskidd@gmail.com</a>></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
---<br>
drm/nouveau/nouveau_hwmon.c | 10 ++++++++++<br>
1 file changed, 10 insertions(+)<br>
<br>
diff --git a/drm/nouveau/nouveau_hwmon.c b/drm/nouveau/nouveau_hwmon.c<br>
index 618d8b780..d445c6f3f 100644<br>
--- a/drm/nouveau/nouveau_hwmon.c<br>
+++ b/drm/nouveau/nouveau_hwmon.c<br>
@@ -426,6 +426,8 @@ nouveau_temp_read(struct device *dev, u32 attr, int channel, long *val)<br>
<br>
switch (attr) {<br>
case hwmon_temp_input:<br>
+ if (drm_dev->switch_power_state != DRM_SWITCH_POWER_ON)<br>
+ return -EINVAL;<br>
ret = nvkm_therm_temp_get(therm);<br>
*val = ret < 0 ? ret : (ret * 1000);<br>
break;<br>
@@ -472,6 +474,8 @@ nouveau_fan_read(struct device *dev, u32 attr, int channel, long *val)<br>
<br>
switch (attr) {<br>
case hwmon_fan_input:<br>
+ if (drm_dev->switch_power_state != DRM_SWITCH_POWER_ON)<br>
+ return -EINVAL;<br>
*val = nvkm_therm_fan_sense(therm);<br>
break;<br>
default:<br>
@@ -494,6 +498,8 @@ nouveau_in_read(struct device *dev, u32 attr, int channel, long *val)<br>
<br>
switch (attr) {<br>
case hwmon_in_input:<br>
+ if (drm_dev->switch_power_state != DRM_SWITCH_POWER_ON)<br>
+ return -EINVAL;<br>
ret = nvkm_volt_get(volt);<br>
*val = ret < 0 ? ret : (ret / 1000);<br>
break;<br>
@@ -525,6 +531,8 @@ nouveau_pwm_read(struct device *dev, u32 attr, int channel, long *val)<br>
*val = therm->attr_get(therm, NVKM_THERM_ATTR_FAN_MODE);<br>
break;<br>
case hwmon_pwm_input:<br>
+ if (drm_dev->switch_power_state != DRM_SWITCH_POWER_ON)<br>
+ return -EINVAL;<br>
*val = therm->fan_get(therm);<br>
break;<br>
default:<br>
@@ -546,6 +554,8 @@ nouveau_power_read(struct device *dev, u32 attr, int channel, long *val)<br>
<br>
switch (attr) {<br>
case hwmon_power_input:<br>
+ if (drm_dev->switch_power_state != DRM_SWITCH_POWER_ON)<br>
+ return -EINVAL;<br>
*val = nvkm_iccsense_read_all(iccsense);<br>
break;<br>
case hwmon_power_max:<br>
-- <br>
2.21.0<br>
<br>
_______________________________________________<br>
Nouveau mailing list<br>
<a href="mailto:Nouveau@lists.freedesktop.org" target="_blank">Nouveau@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/nouveau" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/nouveau</a></blockquote></div></div>