[Nouveau] [RFC PATCH 07/13] clk: Check pm_runtime status before reclocking
Karol Herbst
karolherbst at gmail.com
Fri Jul 21 21:55:18 UTC 2017
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 <karolherbst at 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
More information about the Nouveau
mailing list