We don't want to change anything on the GPU if it's suspended. Also we need to increase the refcount on the pm_runtime counter so that the GPU won't be suspended while reclocking.
v2: convert to C style comments Signed-off-by: Karol Herbst <karolher...@gmail.com> --- drm/nouveau/nvkm/subdev/clk/base.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/drm/nouveau/nvkm/subdev/clk/base.c b/drm/nouveau/nvkm/subdev/clk/base.c index 54188d2b..81093e13 100644 --- a/drm/nouveau/nvkm/subdev/clk/base.c +++ b/drm/nouveau/nvkm/subdev/clk/base.c @@ -315,6 +315,7 @@ nvkm_clk_update_work(struct work_struct *work) { struct nvkm_clk *clk = container_of(work, typeof(*clk), work); struct nvkm_subdev *subdev = &clk->subdev; + struct device *dev = subdev->device->dev; int pstate; if (!atomic_xchg(&clk->waiting, 0)) @@ -337,8 +338,17 @@ nvkm_clk_update_work(struct work_struct *work) } nvkm_trace(subdev, "-> %d\n", pstate); - if (!clk->pstate || pstate != clk->pstate->pstate) { - int ret = nvkm_pstate_prog(clk, pstate); + + /* only call into the code if the GPU is powered on */ + if ((!clk->pstate || pstate != clk->pstate->pstate) + && !pm_runtime_suspended(dev)) { + int ret; + /* it would be a shame if the GPU goes into suspend while doing + * the reclock + */ + pm_runtime_get_sync(dev); + ret = nvkm_pstate_prog(clk, pstate); + pm_runtime_put(dev); if (ret) { nvkm_error(subdev, "error setting pstate %d: %d\n", pstate, ret); -- 2.13.2 _______________________________________________ Nouveau mailing list Nouveau@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/nouveau