All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] hwmon: return EINVAL if the GPU is powered down for sensors reads
@ 2019-06-18 11:01 Karol Herbst
       [not found] ` <20190618110133.9526-1-kherbst-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
  0 siblings, 1 reply; 2+ messages in thread
From: Karol Herbst @ 2019-06-18 11:01 UTC (permalink / raw)
  To: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

fixes bogus values userspace gets from hwmon while the GPU is powered down

Signed-off-by: Karol Herbst <kherbst@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

_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] hwmon: return EINVAL if the GPU is powered down for sensors reads
       [not found] ` <20190618110133.9526-1-kherbst-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
@ 2019-06-22  3:35   ` Rhys Kidd
  0 siblings, 0 replies; 2+ messages in thread
From: Rhys Kidd @ 2019-06-22  3:35 UTC (permalink / raw)
  To: Karol Herbst; +Cc: nouveau


[-- Attachment #1.1: Type: text/plain, Size: 2906 bytes --]

On Tue, 18 Jun 2019 at 21:01, Karol Herbst <kherbst-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> wrote:

> fixes bogus values userspace gets from hwmon while the GPU is powered down
>
> Signed-off-by: Karol Herbst <kherbst-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
>

Looks good to me and successfully tested on my GP107M with runtime power
management fixes, so

Reviewed-by: Rhys Kidd <rhyskidd-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>


> ---
>  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-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
> https://lists.freedesktop.org/mailman/listinfo/nouveau

[-- Attachment #1.2: Type: text/html, Size: 4193 bytes --]

[-- Attachment #2: Type: text/plain, Size: 153 bytes --]

_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-06-22  3:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-18 11:01 [PATCH] hwmon: return EINVAL if the GPU is powered down for sensors reads Karol Herbst
     [not found] ` <20190618110133.9526-1-kherbst-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2019-06-22  3:35   ` Rhys Kidd

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.