All of lore.kernel.org
 help / color / mirror / Atom feed
From: Martin Peres <martin.peres-GANU6spQydw@public.gmane.org>
To: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
Subject: Re: [PATCH v4 32/37] clk: only do partial reclocks as required
Date: Thu, 21 Apr 2016 01:17:13 +0300	[thread overview]
Message-ID: <5717FFE9.8030607@free.fr> (raw)
In-Reply-To: <1461006851-5007-33-git-send-email-nouveau-lIBOoy2+GI7scQ4cX5LuPg@public.gmane.org>

On 18/04/16 22:14, Karol Herbst wrote:
> we don't want to reclock to the same pstate or cstate over and over again, so
> only do things we actually have to do.
>
> v4: move into gf100

Reviewed-by: Martin Peres <martin.peres@free.fr>

>
> Signed-off-by: Karol Herbst <nouveau@karolherbst.de>
> ---
>   drm/nouveau/nvkm/subdev/clk/base.c  | 11 +++++--
>   drm/nouveau/nvkm/subdev/clk/gf100.c | 62 ++++++++++++++++++++++++++++++++++++-
>   drm/nouveau/nvkm/subdev/clk/gk104.c |  2 +-
>   drm/nouveau/nvkm/subdev/clk/nv40.c  |  3 ++
>   drm/nouveau/nvkm/subdev/clk/priv.h  |  4 +++
>   5 files changed, 77 insertions(+), 5 deletions(-)
>
> diff --git a/drm/nouveau/nvkm/subdev/clk/base.c b/drm/nouveau/nvkm/subdev/clk/base.c
> index 3c40f67..2776d79 100644
> --- a/drm/nouveau/nvkm/subdev/clk/base.c
> +++ b/drm/nouveau/nvkm/subdev/clk/base.c
> @@ -107,7 +107,7 @@ nvkm_cstate_valid(struct nvkm_clk *clk, struct nvkm_cstate *cstate, u32 max_volt
>   	       voltage >= volt->min_uv;
>   }
>   
> -static struct nvkm_cstate *
> +struct nvkm_cstate *
>   nvkm_cstate_find_best(struct nvkm_clk *clk, struct nvkm_pstate *pstate,
>   		      struct nvkm_cstate *start)
>   {
> @@ -148,7 +148,7 @@ nvkm_cstate_find_best(struct nvkm_clk *clk, struct nvkm_pstate *pstate,
>   	return cstate;
>   }
>   
> -static struct nvkm_cstate *
> +struct nvkm_cstate *
>   nvkm_cstate_get(struct nvkm_clk *clk, struct nvkm_pstate *pstate, int cstatei)
>   {
>   	struct nvkm_cstate *cstate;
> @@ -168,7 +168,7 @@ nvkm_cstate_get(struct nvkm_clk *clk, struct nvkm_pstate *pstate, int cstatei)
>   	return NULL;
>   }
>   
> -static int
> +int
>   nvkm_cstate_prog(struct nvkm_clk *clk, struct nvkm_pstate *pstate, int cstatei)
>   {
>   	struct nvkm_subdev *subdev = &clk->subdev;
> @@ -188,6 +188,11 @@ nvkm_cstate_prog(struct nvkm_clk *clk, struct nvkm_pstate *pstate, int cstatei)
>   		cstate = &pstate->base;
>   	}
>   
> +	if (!cstate) {
> +		nvkm_error(subdev, "failed to set cstate %d\n", cstatei);
> +		return -EINVAL;
> +	}
> +
>   	if (therm) {
>   		ret = nvkm_therm_cstate(therm, pstate->fanspeed, +1);
>   		if (ret && ret != -ENODEV) {
> diff --git a/drm/nouveau/nvkm/subdev/clk/gf100.c b/drm/nouveau/nvkm/subdev/clk/gf100.c
> index 808e1ed..5025dcc 100644
> --- a/drm/nouveau/nvkm/subdev/clk/gf100.c
> +++ b/drm/nouveau/nvkm/subdev/clk/gf100.c
> @@ -28,6 +28,7 @@
>   #include <subdev/bios.h>
>   #include <subdev/bios/pll.h>
>   #include <subdev/timer.h>
> +#include <subdev/volt.h>
>   
>   struct gf100_clk_info {
>   	u32 freq;
> @@ -431,13 +432,72 @@ gf100_clk_tidy(struct nvkm_clk *base)
>   	memset(clk->eng, 0x00, sizeof(clk->eng));
>   }
>   
> +static int
> +gf100_clk_update_volt(struct nvkm_clk *clk)
> +{
> +	struct nvkm_subdev *subdev = &clk->subdev;
> +	struct nvkm_volt *volt = subdev->device->volt;
> +	struct nvkm_therm *therm = subdev->device->therm;
> +
> +	if (!volt || !therm || !clk->pstate || !clk->set_cstate)
> +		return -EINVAL;
> +
> +	return nvkm_volt_set_id(volt, clk->set_cstate->voltage,
> +				clk->pstate->base.voltage, 0);
> +}
> +
> +void
> +gf100_clk_update(struct nvkm_clk *clk, int pstate)
> +{
> +	struct nvkm_subdev *subdev = &clk->subdev;
> +	int ret;
> +
> +	if (!clk->pstate || clk->pstate->pstate != pstate) {
> +		nvkm_trace(subdev, "-> P %d\n", pstate);
> +		ret = nvkm_pstate_prog(clk, pstate);
> +		if (ret) {
> +			nvkm_error(subdev, "error setting pstate %d: %d\n",
> +				   pstate, ret);
> +		}
> +	} else if (!clk->set_cstate ||
> +		   clk->set_cstate->cstate != clk->exp_cstate) {
> +
> +		struct nvkm_cstate *cstate = nvkm_cstate_get(clk, clk->pstate, clk->exp_cstate);
> +		if (!cstate) {
> +			nvkm_error(subdev, "can't find cstate %i\n",
> +				   clk->exp_cstate);
> +			return;
> +		}
> +
> +		cstate = nvkm_cstate_find_best(clk, clk->pstate, cstate);
> +		if (!cstate) {
> +			nvkm_error(subdev, "can't find best cstate for %i\n",
> +				   cstate->cstate);
> +			return;
> +		}
> +
> +		if (cstate != clk->set_cstate) {
> +			nvkm_trace(subdev, "-> C %d\n", cstate->cstate);
> +			ret = nvkm_cstate_prog(clk, clk->pstate, cstate->cstate);
> +			if (ret) {
> +				nvkm_error(subdev, "error setting cstate %d: %d\n",
> +					   cstate->cstate, ret);
> +			}
> +		} else {
> +			gf100_clk_update_volt(clk);
> +		}
> +	} else {
> +		gf100_clk_update_volt(clk);
> +	}
> +}
> +
>   static const struct nvkm_clk_func
>   gf100_clk = {
>   	.read = gf100_clk_read,
>   	.calc = gf100_clk_calc,
>   	.prog = gf100_clk_prog,
>   	.tidy = gf100_clk_tidy,
> -	.update = nv40_clk_update,
> +	.update = gf100_clk_update,
>   	.domains = {
>   		{ nv_clk_src_crystal, 0xff },
>   		{ nv_clk_src_href   , 0xff },
> diff --git a/drm/nouveau/nvkm/subdev/clk/gk104.c b/drm/nouveau/nvkm/subdev/clk/gk104.c
> index 8448a88..abf1d76 100644
> --- a/drm/nouveau/nvkm/subdev/clk/gk104.c
> +++ b/drm/nouveau/nvkm/subdev/clk/gk104.c
> @@ -482,7 +482,7 @@ gk104_clk = {
>   	.calc = gk104_clk_calc,
>   	.prog = gk104_clk_prog,
>   	.tidy = gk104_clk_tidy,
> -	.update = nv40_clk_update,
> +	.update = gf100_clk_update,
>   	.domains = {
>   		{ nv_clk_src_crystal, 0xff },
>   		{ nv_clk_src_href   , 0xff },
> diff --git a/drm/nouveau/nvkm/subdev/clk/nv40.c b/drm/nouveau/nvkm/subdev/clk/nv40.c
> index a808319..5b10ee2 100644
> --- a/drm/nouveau/nvkm/subdev/clk/nv40.c
> +++ b/drm/nouveau/nvkm/subdev/clk/nv40.c
> @@ -207,6 +207,9 @@ nv40_clk_update(struct nvkm_clk *clk, int pstate)
>   	struct nvkm_subdev *subdev = &clk->subdev;
>   	int ret;
>   
> +	if (clk->pstate && clk->pstate->pstate == pstate)
> +		return;
> +
>   	nvkm_trace(subdev, "-> %d\n", pstate);
>   	ret = nvkm_pstate_prog(clk, pstate);
>   	if (ret) {
> diff --git a/drm/nouveau/nvkm/subdev/clk/priv.h b/drm/nouveau/nvkm/subdev/clk/priv.h
> index 958f5e3..e2f15c4 100644
> --- a/drm/nouveau/nvkm/subdev/clk/priv.h
> +++ b/drm/nouveau/nvkm/subdev/clk/priv.h
> @@ -22,10 +22,14 @@ int nvkm_clk_new_(const struct nvkm_clk_func *, struct nvkm_device *, int,
>   		  bool allow_reclock, struct nvkm_clk **);
>   
>   int nvkm_pstate_prog(struct nvkm_clk *, int pstateid);
> +int nvkm_cstate_prog(struct nvkm_clk *, struct nvkm_pstate *, int cstatei);
> +struct nvkm_cstate * nvkm_cstate_get(struct nvkm_clk *, struct nvkm_pstate *, int cstatei);
> +struct nvkm_cstate * nvkm_cstate_find_best(struct nvkm_clk *, struct nvkm_pstate *, struct nvkm_cstate *start);
>   
>   int nv04_clk_pll_calc(struct nvkm_clk *, struct nvbios_pll *, int clk,
>   		      struct nvkm_pll_vals *);
>   int nv04_clk_pll_prog(struct nvkm_clk *, u32 reg1, struct nvkm_pll_vals *);
>   
>   void nv40_clk_update(struct nvkm_clk *, int pstate);
> +void gf100_clk_update(struct nvkm_clk *, int pstate);
>   #endif

_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau

  parent reply	other threads:[~2016-04-20 22:17 UTC|newest]

Thread overview: 69+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-18 19:13 [PATCH v4 00/37] Volting/Clocking improvements for Fermi and newer Karol Herbst
     [not found] ` <1461006851-5007-1-git-send-email-nouveau-lIBOoy2+GI7scQ4cX5LuPg@public.gmane.org>
2016-04-18 19:13   ` [PATCH v4 01/37] bios/volt: handle voltage table version 0x50 with 0ed header Karol Herbst
2016-04-18 19:13   ` [PATCH v4 02/37] volt: properly detect entry based voltage tables Karol Herbst
2016-04-18 19:13   ` [PATCH v4 03/37] volt: save the voltage range we are able to set Karol Herbst
2016-04-18 19:13   ` [PATCH v4 04/37] volt: add nvkm_volt_map_min function Karol Herbst
2016-04-18 19:13   ` [PATCH v4 05/37] clk: don't create cstates whit voltages higher than what the gpu can do Karol Herbst
2016-04-18 19:13   ` [PATCH v4 06/37] volt: parse the max voltage map entries Karol Herbst
     [not found]     ` <1461006851-5007-7-git-send-email-nouveau-lIBOoy2+GI7scQ4cX5LuPg@public.gmane.org>
2016-04-19 19:46       ` Martin Peres
2016-04-18 19:13   ` [PATCH v4 07/37] volt: add min_id parameter to nvkm_volt_set_id Karol Herbst
2016-04-18 19:13   ` [PATCH v4 08/37] clk: export nvkm_volt_map Karol Herbst
     [not found]     ` <1461006851-5007-9-git-send-email-nouveau-lIBOoy2+GI7scQ4cX5LuPg@public.gmane.org>
2016-04-19 19:54       ` Martin Peres
2016-04-18 19:13   ` [PATCH v4 09/37] clk: add index field to nvkm_cstate Karol Herbst
2016-04-18 19:13   ` [PATCH v4 10/37] add daemon to compare nouveau with blob voltage Karol Herbst
     [not found]     ` <1461006851-5007-11-git-send-email-nouveau-lIBOoy2+GI7scQ4cX5LuPg@public.gmane.org>
2016-04-19 20:26       ` Martin Peres
2016-04-18 19:13   ` [PATCH v4 11/37] volt: add temperature parameter to nvkm_volt_map Karol Herbst
     [not found]     ` <1461006851-5007-12-git-send-email-nouveau-lIBOoy2+GI7scQ4cX5LuPg@public.gmane.org>
2016-04-19 20:06       ` Martin Peres
2016-04-18 19:13   ` [PATCH v4 12/37] clk: fixup cstate selection Karol Herbst
2016-04-18 19:13   ` [PATCH v4 13/37] clk: respect voltage limits in nvkm_cstate_prog Karol Herbst
     [not found]     ` <1461006851-5007-14-git-send-email-nouveau-lIBOoy2+GI7scQ4cX5LuPg@public.gmane.org>
2016-04-19 21:04       ` Martin Peres
2016-04-18 19:13   ` [PATCH v4 14/37] bios: add parsing of BASE CLOCK table Karol Herbst
2016-04-18 19:13   ` [PATCH v4 15/37] clk: allow boosting only when NvBoost is set Karol Herbst
     [not found]     ` <1461006851-5007-16-git-send-email-nouveau-lIBOoy2+GI7scQ4cX5LuPg@public.gmane.org>
2016-04-19 21:06       ` Martin Peres
2016-04-18 19:13   ` [PATCH v4 16/37] volt: don't require perfect fit Karol Herbst
     [not found]     ` <1461006851-5007-17-git-send-email-nouveau-lIBOoy2+GI7scQ4cX5LuPg@public.gmane.org>
2016-04-19 21:10       ` Martin Peres
2016-04-18 19:13   ` [PATCH v4 17/37] bios/vmap: unk0 field is the mode Karol Herbst
     [not found]     ` <1461006851-5007-18-git-send-email-nouveau-lIBOoy2+GI7scQ4cX5LuPg@public.gmane.org>
2016-04-19 21:11       ` Martin Peres
2016-04-18 19:13   ` [PATCH v4 18/37] volt: add speedo Karol Herbst
     [not found]     ` <1461006851-5007-19-git-send-email-nouveau-lIBOoy2+GI7scQ4cX5LuPg@public.gmane.org>
2016-04-19 21:17       ` Martin Peres
2016-04-18 19:13   ` [PATCH v4 19/37] volt: add gf100 subdev with speedo Karol Herbst
     [not found]     ` <1461006851-5007-20-git-send-email-nouveau-lIBOoy2+GI7scQ4cX5LuPg@public.gmane.org>
2016-04-19 21:43       ` Martin Peres
2016-04-18 19:13   ` [PATCH v4 20/37] volt: add coefficients Karol Herbst
     [not found]     ` <1461006851-5007-21-git-send-email-nouveau-lIBOoy2+GI7scQ4cX5LuPg@public.gmane.org>
2016-04-19 21:52       ` Martin Peres
     [not found]         ` <5716A8B4.6020208-GANU6spQydw@public.gmane.org>
2016-04-19 21:54           ` Ilia Mirkin
     [not found]             ` <CAKb7UvhkH732AfCDRtkWG7GMzgXQYmf0XLzc0w7vfR7R9VuQ9A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-04-19 22:06               ` Martin Peres
2016-04-18 19:13   ` [PATCH v4 21/37] clk: save the max clock we can set Karol Herbst
     [not found]     ` <1461006851-5007-22-git-send-email-nouveau-lIBOoy2+GI7scQ4cX5LuPg@public.gmane.org>
2016-04-19 22:07       ` Martin Peres
2016-04-18 19:13   ` [PATCH v4 22/37] clk: rename nvkm_pstate_calc to nvkm_clk_update Karol Herbst
     [not found]     ` <1461006851-5007-23-git-send-email-nouveau-lIBOoy2+GI7scQ4cX5LuPg@public.gmane.org>
2016-04-20 20:12       ` Martin Peres
2016-04-18 19:13   ` [PATCH v4 23/37] nvif: add boost info and set operations Karol Herbst
2016-04-18 19:13   ` [PATCH v4 24/37] debugfs: add boost interface to change the boost_mode Karol Herbst
2016-04-18 19:13   ` [PATCH v4 25/37] clk: remove dstate and tstate Karol Herbst
     [not found]     ` <1461006851-5007-26-git-send-email-nouveau-lIBOoy2+GI7scQ4cX5LuPg@public.gmane.org>
2016-04-20 20:45       ` Martin Peres
     [not found]         ` <5717EA51.8040605-GANU6spQydw@public.gmane.org>
2016-04-20 20:45           ` Martin Peres
2016-04-18 19:14   ` [PATCH v4 26/37] therm: don't cancel the timer Karol Herbst
     [not found]     ` <1461006851-5007-27-git-send-email-nouveau-lIBOoy2+GI7scQ4cX5LuPg@public.gmane.org>
2016-04-20 20:47       ` Martin Peres
2016-04-18 19:14   ` [PATCH v4 27/37] clk: make pstate a pointer to nvkm_pstate Karol Herbst
     [not found]     ` <1461006851-5007-28-git-send-email-nouveau-lIBOoy2+GI7scQ4cX5LuPg@public.gmane.org>
2016-04-20 20:53       ` Martin Peres
     [not found]         ` <5717EC47.4040605-GANU6spQydw@public.gmane.org>
2016-04-20 21:46           ` karol herbst
     [not found]             ` <CAEXux-b+kaXYRt4BiOLbPWHY+jjpac2EXxuhetxR4-NER_DNsA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-04-20 22:56               ` Martin Peres
2016-04-18 19:14   ` [PATCH v4 28/37] clk: hold information about the current cstate status Karol Herbst
     [not found]     ` <1461006851-5007-29-git-send-email-nouveau-lIBOoy2+GI7scQ4cX5LuPg@public.gmane.org>
2016-04-20 21:38       ` Martin Peres
2016-04-18 19:14   ` [PATCH v4 29/37] clk: we should pass the pstate id around not the index in the list Karol Herbst
     [not found]     ` <1461006851-5007-30-git-send-email-nouveau-lIBOoy2+GI7scQ4cX5LuPg@public.gmane.org>
2016-04-20 21:59       ` Martin Peres
2016-04-18 19:14   ` [PATCH v4 30/37] clk: seperate the locking from the implementation in nvkm_clk_update Karol Herbst
     [not found]     ` <1461006851-5007-31-git-send-email-nouveau-lIBOoy2+GI7scQ4cX5LuPg@public.gmane.org>
2016-04-20 22:00       ` Martin Peres
2016-04-18 19:14   ` [PATCH v4 31/37] clk: split out update code to nv40 Karol Herbst
     [not found]     ` <1461006851-5007-32-git-send-email-nouveau-lIBOoy2+GI7scQ4cX5LuPg@public.gmane.org>
2016-04-20 22:08       ` Martin Peres
2016-04-18 19:14   ` [PATCH v4 32/37] clk: only do partial reclocks as required Karol Herbst
     [not found]     ` <1461006851-5007-33-git-send-email-nouveau-lIBOoy2+GI7scQ4cX5LuPg@public.gmane.org>
2016-04-20 22:17       ` Martin Peres [this message]
2016-04-18 19:14   ` [PATCH v4 33/37] therm: trigger reclock in temperature daemon Karol Herbst
     [not found]     ` <1461006851-5007-34-git-send-email-nouveau-lIBOoy2+GI7scQ4cX5LuPg@public.gmane.org>
2016-04-20 22:18       ` Martin Peres
2016-04-18 19:14   ` [PATCH v4 34/37] mc: fix NULL pointer access in libnouveau Karol Herbst
     [not found]     ` <1461006851-5007-35-git-send-email-nouveau-lIBOoy2+GI7scQ4cX5LuPg@public.gmane.org>
2016-04-20 22:21       ` Martin Peres
2016-04-18 19:14   ` [PATCH v4 35/37] clk: set clocks to pre suspend state after suspend Karol Herbst
     [not found]     ` <1461006851-5007-36-git-send-email-nouveau-lIBOoy2+GI7scQ4cX5LuPg@public.gmane.org>
2016-04-20 22:23       ` Martin Peres
2016-04-18 19:14   ` [PATCH v4 36/37] WIP volt/gk104: readout speedo Karol Herbst
     [not found]     ` <1461006851-5007-37-git-send-email-nouveau-lIBOoy2+GI7scQ4cX5LuPg@public.gmane.org>
2016-04-20 22:39       ` Martin Peres
2016-04-18 19:14   ` [PATCH v4 37/37] volt: add NvVoltOffsetmV option Karol Herbst
     [not found]     ` <1461006851-5007-38-git-send-email-nouveau-lIBOoy2+GI7scQ4cX5LuPg@public.gmane.org>
2016-04-20 22:55       ` Martin Peres

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=5717FFE9.8030607@free.fr \
    --to=martin.peres-ganu6spqydw@public.gmane.org \
    --cc=nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.