[Nouveau] [PATCH 14/19] volt: add temperature parameter to nvkm_volt_map
Karol Herbst
nouveau at karolherbst.de
Thu Mar 17 23:03:51 UTC 2016
the voltage entries actually may map to a different voltage depending on the
current temperature.
Signed-off-by: Karol Herbst <nouveau at karolherbst.de>
---
bin/nv_cmp_volt.c | 2 +-
drm/nouveau/include/nvkm/subdev/volt.h | 2 +-
drm/nouveau/nvkm/subdev/volt/base.c | 14 ++++++++++----
3 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/bin/nv_cmp_volt.c b/bin/nv_cmp_volt.c
index 6147a7d..16aa7e6 100644
--- a/bin/nv_cmp_volt.c
+++ b/bin/nv_cmp_volt.c
@@ -108,7 +108,7 @@ main(int argc, char **argv)
new_voltage = nvkm_volt_get(volt);
new_temp = nvkm_rd32(device, 0x20400);//nvkm_therm_temp_get(therm);
- new_nouveau_voltage = max(nvkm_volt_map(volt, best_cstate->voltage), nvkm_volt_map(volt, best_pstate->base.voltage));
+ new_nouveau_voltage = max(nvkm_volt_map(volt, best_cstate->voltage, new_temp), nvkm_volt_map(volt, best_pstate->base.voltage, new_temp));
new_pstate = best_pstate->pstate;
new_cstate = best_cstate->cstate;
diff --git a/drm/nouveau/include/nvkm/subdev/volt.h b/drm/nouveau/include/nvkm/subdev/volt.h
index e8637b9..3b94ab0 100644
--- a/drm/nouveau/include/nvkm/subdev/volt.h
+++ b/drm/nouveau/include/nvkm/subdev/volt.h
@@ -19,7 +19,7 @@ struct nvkm_volt {
u8 max1_vid;
};
-int nvkm_volt_map(struct nvkm_volt *volt, u8 id);
+int nvkm_volt_map(struct nvkm_volt *volt, u8 id, u8 temperature);
int nvkm_volt_map_min(struct nvkm_volt *volt, u8 id);
int nvkm_volt_get(struct nvkm_volt *);
int nvkm_volt_set_id(struct nvkm_volt *, u8 id, u8 min_id, int condition);
diff --git a/drm/nouveau/nvkm/subdev/volt/base.c b/drm/nouveau/nvkm/subdev/volt/base.c
index c4fde8f..e741383 100644
--- a/drm/nouveau/nvkm/subdev/volt/base.c
+++ b/drm/nouveau/nvkm/subdev/volt/base.c
@@ -26,6 +26,7 @@
#include <subdev/bios.h>
#include <subdev/bios/vmap.h>
#include <subdev/bios/volt.h>
+#include <subdev/therm.h>
int
nvkm_volt_get(struct nvkm_volt *volt)
@@ -88,7 +89,7 @@ nvkm_volt_map_min(struct nvkm_volt *volt, u8 id)
}
int
-nvkm_volt_map(struct nvkm_volt *volt, u8 id)
+nvkm_volt_map(struct nvkm_volt *volt, u8 id, u8 temp)
{
struct nvkm_bios *bios = volt->subdev.device->bios;
struct nvbios_vmap_entry info;
@@ -98,7 +99,7 @@ nvkm_volt_map(struct nvkm_volt *volt, u8 id)
vmap = nvbios_vmap_entry_parse(bios, id, &ver, &len, &info);
if (vmap) {
if (info.link != 0xff) {
- int ret = nvkm_volt_map(volt, info.link);
+ int ret = nvkm_volt_map(volt, info.link, temp);
if (ret < 0)
return ret;
info.min += ret;
@@ -112,18 +113,23 @@ nvkm_volt_map(struct nvkm_volt *volt, u8 id)
int
nvkm_volt_set_id(struct nvkm_volt *volt, u8 id, u8 min_id, int condition)
{
+ struct nvkm_therm *therm = volt->subdev.device->therm;
int ret;
+ int temp = 0;
+
+ if (therm)
+ temp = nvkm_therm_temp_get(therm);
if (volt->func->set_id)
return volt->func->set_id(volt, id, condition);
- ret = nvkm_volt_map(volt, id);
+ ret = nvkm_volt_map(volt, id, max(temp, 0));
if (ret >= 0) {
int prev = nvkm_volt_get(volt);
if (!condition || prev < 0 ||
(condition < 0 && ret < prev) ||
(condition > 0 && ret > prev)) {
- int min = nvkm_volt_map(volt, min_id);
+ int min = nvkm_volt_map(volt, min_id, max(temp, 0));
if (min >= 0)
ret = max(min, ret);
ret = nvkm_volt_set(volt, ret);
--
2.7.3
More information about the Nouveau
mailing list