Re: [Nouveau] [RFC PATCH 03/29] subdev/volt/gk104: return error when read fails

2017-10-08 Thread Karol Herbst
On Sun, Oct 8, 2017 at 12:29 PM, Pierre Moreau  wrote:
> On 2017-09-15 — 17:11, Karol Herbst wrote:
>> While my gpu was powered off, hwmon returned 0.6V as the current voltage.
>> If nvkm_rd32 fails for any reason, return the error.
>>
>> With that sensors will display a "N/A" instead of 0.6V.
>
> Small nitpick, add a comma between “that” and “sensors”.
> Otherwise,
>
> Reviewed-by: Pierre Moreau 
>

I think in the end I am not _that_ happy with that change. nvkm_rd32
can't return an error code, but as we interpret the full register as
the value, values above 0x7fff are most likely an error on either
our side or the hardware side. When the GPU is suspended we get
0x out, but this code shouldn't be called in the first place
when the GPU is suspended. We can't really trust runpm as well due to
race conditions, waking up the GPU is another terrible idea.

>>
>> Signed-off-by: Karol Herbst 
>> ---
>>  drm/nouveau/nvkm/subdev/volt/gk104.c | 7 ++-
>>  1 file changed, 6 insertions(+), 1 deletion(-)
>>
>> diff --git a/drm/nouveau/nvkm/subdev/volt/gk104.c 
>> b/drm/nouveau/nvkm/subdev/volt/gk104.c
>> index 1c744e02..53a7af9d 100644
>> --- a/drm/nouveau/nvkm/subdev/volt/gk104.c
>> +++ b/drm/nouveau/nvkm/subdev/volt/gk104.c
>> @@ -40,10 +40,15 @@ gk104_volt_get(struct nvkm_volt *base)
>>  {
>>   struct nvbios_volt *bios = _volt(base)->bios;
>>   struct nvkm_device *device = base->subdev.device;
>> - u32 div, duty;
>> + int div, duty;
>>
>>   div  = nvkm_rd32(device, 0x20340);
>> + if (div < 0)
>> + return div;
>> +
>>   duty = nvkm_rd32(device, 0x20344);
>> + if (duty < 0)
>> + return duty;
>>
>>   return bios->base + bios->pwm_range * duty / div;
>>  }
>> --
>> 2.14.1
>>
>> ___
>> Nouveau mailing list
>> Nouveau@lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/nouveau
___
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau


Re: [Nouveau] [RFC PATCH 03/29] subdev/volt/gk104: return error when read fails

2017-10-08 Thread Pierre Moreau
On 2017-09-15 — 17:11, Karol Herbst wrote:
> While my gpu was powered off, hwmon returned 0.6V as the current voltage.
> If nvkm_rd32 fails for any reason, return the error.
> 
> With that sensors will display a "N/A" instead of 0.6V.

Small nitpick, add a comma between “that” and “sensors”.
Otherwise,

Reviewed-by: Pierre Moreau 

> 
> Signed-off-by: Karol Herbst 
> ---
>  drm/nouveau/nvkm/subdev/volt/gk104.c | 7 ++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/drm/nouveau/nvkm/subdev/volt/gk104.c 
> b/drm/nouveau/nvkm/subdev/volt/gk104.c
> index 1c744e02..53a7af9d 100644
> --- a/drm/nouveau/nvkm/subdev/volt/gk104.c
> +++ b/drm/nouveau/nvkm/subdev/volt/gk104.c
> @@ -40,10 +40,15 @@ gk104_volt_get(struct nvkm_volt *base)
>  {
>   struct nvbios_volt *bios = _volt(base)->bios;
>   struct nvkm_device *device = base->subdev.device;
> - u32 div, duty;
> + int div, duty;
>  
>   div  = nvkm_rd32(device, 0x20340);
> + if (div < 0)
> + return div;
> +
>   duty = nvkm_rd32(device, 0x20344);
> + if (duty < 0)
> + return duty;
>  
>   return bios->base + bios->pwm_range * duty / div;
>  }
> -- 
> 2.14.1
> 
> ___
> Nouveau mailing list
> Nouveau@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/nouveau


signature.asc
Description: PGP signature
___
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau