drm/nouveau/volt: Add min_id parameter to nvkm_volt_set_id
authorKarol Herbst <karolherbst@gmail.com>
Tue, 12 Jul 2016 19:36:08 +0000 (21:36 +0200)
committerBen Skeggs <bskeggs@redhat.com>
Wed, 12 Oct 2016 07:29:21 +0000 (17:29 +1000)
Each pstate has its own voltage map entry like each cstate has.

The voltages of those entries act as a floor value for the currently
selected pstate and nvidia never sets a voltage below them.

Signed-off-by: Karol Herbst <karolherbst@gmail.com>
Reviewed-by: Martin Peres <martin.peres@free.fr>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
drivers/gpu/drm/nouveau/include/nvkm/subdev/volt.h
drivers/gpu/drm/nouveau/nvkm/subdev/clk/base.c
drivers/gpu/drm/nouveau/nvkm/subdev/volt/base.c

index 2612a04c49bbd0b9a4a720f2ddc233b264343cc9..06d45934b6a0c5b2faff8db3aa329bc6490a931c 100644 (file)
@@ -29,7 +29,7 @@ struct nvkm_volt {
 
 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, int condition);
+int nvkm_volt_set_id(struct nvkm_volt *, u8 id, u8 min_id, int condition);
 
 int nv40_volt_new(struct nvkm_device *, int, struct nvkm_volt **);
 int gk104_volt_new(struct nvkm_device *, int, struct nvkm_volt **);
index 2881b2ceda329e0459618928e6ae98cc4e14bfff..9ee24ec2869b654cd0d90de5424c67e42ea40912 100644 (file)
@@ -99,7 +99,8 @@ nvkm_cstate_prog(struct nvkm_clk *clk, struct nvkm_pstate *pstate, int cstatei)
        }
 
        if (volt) {
-               ret = nvkm_volt_set_id(volt, cstate->voltage, +1);
+               ret = nvkm_volt_set_id(volt, cstate->voltage,
+                                      pstate->base.voltage, +1);
                if (ret && ret != -ENODEV) {
                        nvkm_error(subdev, "failed to raise voltage: %d\n", ret);
                        return ret;
@@ -113,7 +114,8 @@ nvkm_cstate_prog(struct nvkm_clk *clk, struct nvkm_pstate *pstate, int cstatei)
        }
 
        if (volt) {
-               ret = nvkm_volt_set_id(volt, cstate->voltage, -1);
+               ret = nvkm_volt_set_id(volt, cstate->voltage,
+                                      pstate->base.voltage, -1);
                if (ret && ret != -ENODEV)
                        nvkm_error(subdev, "failed to lower voltage: %d\n", ret);
        }
index 8445e4c9fe5492a0b4217f516c5d0953f70d80f0..960505be5e280d549880d202591f7e5ad8888756 100644 (file)
@@ -110,7 +110,7 @@ nvkm_volt_map(struct nvkm_volt *volt, u8 id)
 }
 
 int
-nvkm_volt_set_id(struct nvkm_volt *volt, u8 id, int condition)
+nvkm_volt_set_id(struct nvkm_volt *volt, u8 id, u8 min_id, int condition)
 {
        int ret;
 
@@ -123,6 +123,9 @@ nvkm_volt_set_id(struct nvkm_volt *volt, u8 id, int condition)
                if (!condition || prev < 0 ||
                    (condition < 0 && ret < prev) ||
                    (condition > 0 && ret > prev)) {
+                       int min = nvkm_volt_map(volt, min_id);
+                       if (min >= 0)
+                               ret = max(min, ret);
                        ret = nvkm_volt_set(volt, ret);
                } else {
                        ret = 0;