On 2017-09-15 — 17:11, Karol Herbst wrote:
> v2: use min_t
> 
> Signed-off-by: Karol Herbst <karolher...@gmail.com>
> ---
>  drm/nouveau/include/nvkm/subdev/clk.h |  2 ++
>  drm/nouveau/nvkm/subdev/clk/base.c    | 42 
> +++++++++++++++++++++++++++++++++++
>  2 files changed, 44 insertions(+)
> 
> diff --git a/drm/nouveau/include/nvkm/subdev/clk.h 
> b/drm/nouveau/include/nvkm/subdev/clk.h
> index f35518c3..f5ff1fd9 100644
> --- a/drm/nouveau/include/nvkm/subdev/clk.h
> +++ b/drm/nouveau/include/nvkm/subdev/clk.h
> @@ -104,6 +104,8 @@ struct nvkm_clk {
>       struct nvkm_cstate *cstate;
>       int exp_cstateid;
>       u8  temp;
> +     u8  max_temp;
> +     u8  relax_temp;

I guess those should be int, similar to the changes you made in patch 1.

>  
>       bool allow_reclock;
>  #define NVKM_CLK_BOOST_NONE 0x0
> diff --git a/drm/nouveau/nvkm/subdev/clk/base.c 
> b/drm/nouveau/nvkm/subdev/clk/base.c
> index 54188d2b..54e14936 100644
> --- a/drm/nouveau/nvkm/subdev/clk/base.c
> +++ b/drm/nouveau/nvkm/subdev/clk/base.c
> @@ -27,6 +27,7 @@
>  #include <subdev/bios/boost.h>
>  #include <subdev/bios/cstep.h>
>  #include <subdev/bios/perf.h>
> +#include <subdev/bios/thermal_policies.h>
>  #include <subdev/bios/vpstate.h>
>  #include <subdev/fb.h>
>  #include <subdev/therm.h>
> @@ -659,6 +660,44 @@ nvkm_clk = {
>       .fini = nvkm_clk_fini,
>  };
>  
> +static void
> +nvkm_clk_parse_max_temp(struct nvkm_clk *clk)
> +{
> +     struct nvkm_subdev *subdev = &clk->subdev;
> +     struct nvkm_bios *bios = subdev->device->bios;
> +     struct nvbios_thermal_policies_header header;
> +     struct nvbios_thermal_policies_entry entry;
> +     u8 i;
> +     s16 mt = 0xff;
> +     s16 rt = 0xff;

Why 0xff? I mean, sure, there is a high possibility that the GPU won’t like
temperatures above 255℃, but still.

> +
> +     if (nvbios_thermal_policies_parse(bios, &header))
> +             return;
> +
> +     if (!header.ecount)
> +             return;
> +
> +     for (i = 0; i < header.ecount; i++) {
> +             if (nvbios_thermal_policies_entry(bios, &header, i, &entry))
> +                     return;
> +
> +             if (entry.mode != 1)
> +                     continue;
> +
> +             mt = min_t(s16, mt, (entry.t0 + entry.down_offset) / 32);
> +             rt = min_t(s16, rt, (entry.t0 + entry.up_offset) / 32);
> +     }
> +
> +     if (mt == 0xff || rt == 0xff)
> +             return;
> +
> +     clk->max_temp = mt;
> +     clk->relax_temp = rt;
> +
> +     nvkm_debug(subdev, "setting up sw throttling thresholds (%u/%u°C)\n",
> +                clk->max_temp, clk->relax_temp);
> +}
> +
>  int
>  nvkm_clk_ctor(const struct nvkm_clk_func *func, struct nvkm_device *device,
>             int index, bool allow_reclock, struct nvkm_clk *clk)
> @@ -733,6 +772,9 @@ nvkm_clk_ctor(const struct nvkm_clk_func *func, struct 
> nvkm_device *device,
>  
>       clk->boost_mode = nvkm_longopt(device->cfgopt, "NvBoost",
>                                      NVKM_CLK_BOOST_NONE);
> +
> +     nvkm_clk_parse_max_temp(clk);
> +
>       return 0;
>  }
>  
> -- 
> 2.14.1
> 
> _______________________________________________
> Nouveau mailing list
> Nouveau@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/nouveau

Attachment: signature.asc
Description: PGP signature

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

Reply via email to