[Nouveau] [RFC PATCH 16/29] clk: parse thermal policies for throttling thresholds

Karol Herbst karolherbst at gmail.com
Sun Oct 8 18:58:21 UTC 2017


On Sun, Oct 8, 2017 at 8:36 PM, Pierre Moreau <pierre.morrow at free.fr> wrote:
> On 2017-09-15 — 17:11, Karol Herbst wrote:
>> v2: use min_t
>>
>> Signed-off-by: Karol Herbst <karolherbst at 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.

just a hack to properly check if we set any values we can use and make
available.

>
>> +
>> +     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 at lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/nouveau


More information about the Nouveau mailing list