mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: lyude@redhat.com
To: Francesco Magazzu <postadelmaga@gmail.com>,
	Danilo Krummrich <dakr@kernel.org>
Cc: dri-devel@lists.freedesktop.org, nouveau@lists.freedesktop.org,
	 linux-kernel@vger.kernel.org,
	Dan Carpenter <dan.carpenter@linaro.org>,
	Karol Herbst <kherbst@redhat.com>
Subject: Re: [PATCH v2 4/4] drm/nouveau/clk: don't clobber reclock status when restoring volt/fan
Date: Thu, 17 Sep 2026 17:15:35 -0400	[thread overview]
Message-ID: <67d769ba8addf5a1c4aa052fa5907453a0d5f529.camel@redhat.com> (raw)
In-Reply-To: <20260712123616.1180830-5-postadelmaga@gmail.com>

Reviewed-by: Lyude Paul <lyude@redhat.com>

On Sun, 2026-07-12 at 14:36 +0200, Francesco Magazzu wrote:
> nvkm_cstate_prog() reuses 'ret' for the voltage and fan-speed restore
> calls it makes after reprogramming the clocks.  Those calls almost
> always
> succeed, so the status of the reclock itself is overwritten and the
> function reports success even when clk->func->calc() or clk->func-
> >prog()
> failed.  The converse is also true: a successful reclock is reported
> as an
> error if the final restore call fails, even though that failure is
> only
> logged and otherwise ignored.
> 
> The only consumer of the return value is the error message in
> nvkm_pstate_work(), so in practice a failing reclock is simply never
> reported.  Nothing else changes, but a function that returns success
> on
> failure is a trap for the next caller.
> 
> Keep the calc/prog status in 'ret' and use a separate local for the
> restore calls.
> 
> Fixes: 3eca809b3c05 ("drm/nouveau/clk: cosmetic changes")
> Signed-off-by: Francesco Magazzu <postadelmaga@gmail.com>
> ---
>  drivers/gpu/drm/nouveau/nvkm/subdev/clk/base.c | 16 +++++++++-------
>  1 file changed, 9 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/clk/base.c
> b/drivers/gpu/drm/nouveau/nvkm/subdev/clk/base.c
> index 4d546b07f..05336fc7d 100644
> --- a/drivers/gpu/drm/nouveau/nvkm/subdev/clk/base.c
> +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/clk/base.c
> @@ -199,16 +199,18 @@ nvkm_cstate_prog(struct nvkm_clk *clk, struct
> nvkm_pstate *pstate, int cstatei)
>  	}
>  
>  	if (volt) {
> -		ret = nvkm_volt_set_id(volt, cstate->voltage,
> -				       pstate->base.voltage, clk-
> >temp, -1);
> -		if (ret && ret != -ENODEV)
> -			nvkm_error(subdev, "failed to lower voltage:
> %d\n", ret);
> +		int err = nvkm_volt_set_id(volt, cstate->voltage,
> +					   pstate->base.voltage,
> clk->temp, -1);
> +
> +		if (err && err != -ENODEV)
> +			nvkm_error(subdev, "failed to lower voltage:
> %d\n", err);
>  	}
>  
>  	if (therm) {
> -		ret = nvkm_therm_cstate(therm, pstate->fanspeed, -
> 1);
> -		if (ret && ret != -ENODEV)
> -			nvkm_error(subdev, "failed to lower fan
> speed: %d\n", ret);
> +		int err = nvkm_therm_cstate(therm, pstate->fanspeed,
> -1);
> +
> +		if (err && err != -ENODEV)
> +			nvkm_error(subdev, "failed to lower fan
> speed: %d\n", err);
>  	}
>  
>  	return ret;


      reply	other threads:[~2026-09-17 21:15 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-12 12:36 [PATCH v2 0/4] drm/nouveau: fix list cursor use after loop in the clk pstate paths Francesco Magazzu
2026-07-12 12:36 ` [PATCH v2 1/4] drm/nouveau/clk: fix list cursor use after loop in nvkm_clk_ustate_update Francesco Magazzu
2026-09-17 20:56   ` lyude
2026-07-12 12:36 ` [PATCH v2 2/4] drm/nouveau/clk: don't use the pstate cursor after the loop Francesco Magazzu
2026-09-17 21:15   ` lyude
2026-07-12 12:36 ` [PATCH v2 3/4] drm/nouveau/device: " Francesco Magazzu
2026-09-17 21:13   ` lyude
2026-07-12 12:36 ` [PATCH v2 4/4] drm/nouveau/clk: don't clobber reclock status when restoring volt/fan Francesco Magazzu
2026-09-17 21:15   ` lyude [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=67d769ba8addf5a1c4aa052fa5907453a0d5f529.camel@redhat.com \
    --to=lyude@redhat.com \
    --cc=dakr@kernel.org \
    --cc=dan.carpenter@linaro.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=kherbst@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nouveau@lists.freedesktop.org \
    --cc=postadelmaga@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®