Karol Herbst
2019-Jun-18 11:01 UTC
[Nouveau] [PATCH] 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: Karol Herbst <kherbst at redhat.com> --- drm/nouveau/nouveau_hwmon.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drm/nouveau/nouveau_hwmon.c b/drm/nouveau/nouveau_hwmon.c index 618d8b780..d445c6f3f 100644 --- a/drm/nouveau/nouveau_hwmon.c +++ b/drm/nouveau/nouveau_hwmon.c @@ -426,6 +426,8 @@ nouveau_temp_read(struct device *dev, u32 attr, int channel, long *val) switch (attr) { case hwmon_temp_input: + if (drm_dev->switch_power_state != DRM_SWITCH_POWER_ON) + return -EINVAL; ret = nvkm_therm_temp_get(therm); *val = ret < 0 ? ret : (ret * 1000); break; @@ -472,6 +474,8 @@ nouveau_fan_read(struct device *dev, u32 attr, int channel, long *val) switch (attr) { case hwmon_fan_input: + if (drm_dev->switch_power_state != DRM_SWITCH_POWER_ON) + return -EINVAL; *val = nvkm_therm_fan_sense(therm); break; default: @@ -494,6 +498,8 @@ nouveau_in_read(struct device *dev, u32 attr, int channel, long *val) switch (attr) { case hwmon_in_input: + if (drm_dev->switch_power_state != DRM_SWITCH_POWER_ON) + return -EINVAL; ret = nvkm_volt_get(volt); *val = ret < 0 ? ret : (ret / 1000); break; @@ -525,6 +531,8 @@ nouveau_pwm_read(struct device *dev, u32 attr, int channel, long *val) *val = therm->attr_get(therm, NVKM_THERM_ATTR_FAN_MODE); break; case hwmon_pwm_input: + if (drm_dev->switch_power_state != DRM_SWITCH_POWER_ON) + return -EINVAL; *val = therm->fan_get(therm); break; default: @@ -546,6 +554,8 @@ nouveau_power_read(struct device *dev, u32 attr, int channel, long *val) switch (attr) { case hwmon_power_input: + if (drm_dev->switch_power_state != DRM_SWITCH_POWER_ON) + return -EINVAL; *val = nvkm_iccsense_read_all(iccsense); break; case hwmon_power_max: -- 2.21.0
Rhys Kidd
2019-Jun-22 03:35 UTC
[Nouveau] [PATCH] hwmon: return EINVAL if the GPU is powered down for sensors reads
On Tue, 18 Jun 2019 at 21:01, Karol Herbst <kherbst at redhat.com> wrote:> fixes bogus values userspace gets from hwmon while the GPU is powered down > > Signed-off-by: Karol Herbst <kherbst at redhat.com> >Looks good to me and successfully tested on my GP107M with runtime power management fixes, so Reviewed-by: Rhys Kidd <rhyskidd at gmail.com>> --- > drm/nouveau/nouveau_hwmon.c | 10 ++++++++++ > 1 file changed, 10 insertions(+) > > diff --git a/drm/nouveau/nouveau_hwmon.c b/drm/nouveau/nouveau_hwmon.c > index 618d8b780..d445c6f3f 100644 > --- a/drm/nouveau/nouveau_hwmon.c > +++ b/drm/nouveau/nouveau_hwmon.c > @@ -426,6 +426,8 @@ nouveau_temp_read(struct device *dev, u32 attr, int > channel, long *val) > > switch (attr) { > case hwmon_temp_input: > + if (drm_dev->switch_power_state != DRM_SWITCH_POWER_ON) > + return -EINVAL; > ret = nvkm_therm_temp_get(therm); > *val = ret < 0 ? ret : (ret * 1000); > break; > @@ -472,6 +474,8 @@ nouveau_fan_read(struct device *dev, u32 attr, int > channel, long *val) > > switch (attr) { > case hwmon_fan_input: > + if (drm_dev->switch_power_state != DRM_SWITCH_POWER_ON) > + return -EINVAL; > *val = nvkm_therm_fan_sense(therm); > break; > default: > @@ -494,6 +498,8 @@ nouveau_in_read(struct device *dev, u32 attr, int > channel, long *val) > > switch (attr) { > case hwmon_in_input: > + if (drm_dev->switch_power_state != DRM_SWITCH_POWER_ON) > + return -EINVAL; > ret = nvkm_volt_get(volt); > *val = ret < 0 ? ret : (ret / 1000); > break; > @@ -525,6 +531,8 @@ nouveau_pwm_read(struct device *dev, u32 attr, int > channel, long *val) > *val = therm->attr_get(therm, NVKM_THERM_ATTR_FAN_MODE); > break; > case hwmon_pwm_input: > + if (drm_dev->switch_power_state != DRM_SWITCH_POWER_ON) > + return -EINVAL; > *val = therm->fan_get(therm); > break; > default: > @@ -546,6 +554,8 @@ nouveau_power_read(struct device *dev, u32 attr, int > channel, long *val) > > switch (attr) { > case hwmon_power_input: > + if (drm_dev->switch_power_state != DRM_SWITCH_POWER_ON) > + return -EINVAL; > *val = nvkm_iccsense_read_all(iccsense); > break; > case hwmon_power_max: > -- > 2.21.0 > > _______________________________________________ > Nouveau mailing list > Nouveau at lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/nouveau-------------- next part -------------- An HTML attachment was scrubbed... URL: <https://lists.freedesktop.org/archives/nouveau/attachments/20190622/d6ed6c87/attachment.html>
Maybe Matching Threads
- [PATCH] drm/nouveau: Add fine-grain temperature reporting
- [PATCH v2 1/2] drm/nouveau: return temperatures in temp_get() via parameter
- [PATCH v2 1/2] drm/nouveau: return temperatures in temp_get() via parameter
- [PATCH v2 4/4] drm/nouveau: gpu lockup recovery
- [PATCH] [RFC] drm/nouveau: bring back hdmi audio device after switcheroo power down