[PATCH 1/2] drm/nouveau/clk: don't ignore RAM clock programming errors in nvkm_pstate_prog

From: Francesco Magazzu

Date: Mon Jul 27 2026 - 11:49:31 EST


The RAM reclock loop discards its own return value: once the do-while
exits, ram->func->tidy() runs and the function falls straight into
nvkm_cstate_prog(), whose result becomes the return value regardless of
whether ram->func->calc()/prog() failed. A negative ret from RAM
programming is silently dropped, so a failed memory clock transition is
never reported and the core clock still gets reprogrammed on top of it.

Return the RAM error (after tidy() has still run) instead of falling
through to the core clock path.

Found by Sashiko AI review (https://sashiko.dev) while reviewing
"[PATCH v2 2/4] drm/nouveau/clk: don't use the pstate cursor after the
loop" (20260712123616.1180830-1-postadelmaga@xxxxxxxxx) as a
pre-existing issue.

Signed-off-by: Francesco Magazzu <postadelmaga@xxxxxxxxx>
---
nvkm/subdev/clk/base.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/nvkm/subdev/clk/base.c b/nvkm/subdev/clk/base.c
index 44dc86b..737bec8 100644
--- a/nvkm/subdev/clk/base.c
+++ b/nvkm/subdev/clk/base.c
@@ -298,6 +298,8 @@ nvkm_pstate_prog(struct nvkm_clk *clk, int pstatei)
ret = ram->func->prog(ram);
} while (ret > 0);
ram->func->tidy(ram);
+ if (ret < 0)
+ return ret;
}

return nvkm_cstate_prog(clk, pstate, NVKM_CLK_CSTATE_HIGHEST);
--
2.55.0