All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Jernej Škrabec" <jernej.skrabec@gmail.com>
To: Roman Stratiienko <r.stratiienko@gmail.com>
Cc: "Samuel Holland" <samuel@sholland.org>,
	"Clément Péron" <peron.clem@gmail.com>,
	"Michael Turquette" <mturquette@baylibre.com>,
	sboyd@kernel.org, mripard@kernel.org, wens@csie.org,
	linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: Re: [PATCH v2] clk: sunxi-ng: sun50i: h6: Modify GPU clock configuration to support DFS
Date: Mon, 04 Jul 2022 19:34:43 +0200	[thread overview]
Message-ID: <5835545.lOV4Wx5bFT@kista> (raw)
In-Reply-To: <CAGphcdkZzjw-6oSnpiDM5YgPkuSV3VPX4nKo_FfPeg36MzT8Ew@mail.gmail.com>

Dne ponedeljek, 04. julij 2022 ob 11:54:06 CEST je Roman Stratiienko 
napisal(a):
> Hi Jernej,
> 
> вс, 3 июл. 2022 г. в 21:43, Jernej Škrabec <jernej.skrabec@gmail.com>:
> >
> > Dne nedelja, 03. julij 2022 ob 18:45:14 CEST je Roman Stratiienko 
napisal(a):
> > > Using simple bash script it was discovered that not all CCU registers
> > > can be safely used for DFS, e.g.:
> > >
> > >     while true
> > >     do
> > >         devmem 0x3001030 4 0xb0003e02
> > >         devmem 0x3001030 4 0xb0001e02
> > >     done
> > >
> > > Script above changes the GPU_PLL multiplier register value. While the
> > > script is running, the user should interact with the user interface.
> > >
> > > Using this method the following results were obtained:
> > > | Register  | Name           | Bits  | Values | Result |
> > > | --        | --             | --    | --     | --     |
> > > | 0x3001030 | GPU_PLL.MULT   | 15..8 | 20-62  | OK     |
> > > | 0x3001030 | GPU_PLL.INDIV  |     1 | 0-1    | OK     |
> > > | 0x3001030 | GPU_PLL.OUTDIV |     0 | 0-1    | FAIL   |
> > > | 0x3001670 | GPU_CLK.DIV    |  3..0 | ANY    | FAIL   |
> > >
> > > DVFS started to work seamlessly once dividers which caused the
> > > glitches were set to fixed values.
> > >
> > > Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
> > >
> > > ---
> > >
> > > Changelog:
> > >
> > > V2:
> > > - Drop changes related to mux
> > > - Drop frequency limiting
> > > - Add unused dividers initialization
> > > ---
> > >  drivers/clk/sunxi-ng/ccu-sun50i-h6.c | 16 +++++++++++++---
> > >  1 file changed, 13 insertions(+), 3 deletions(-)
> > >
> > > diff --git a/drivers/clk/sunxi-ng/ccu-sun50i-h6.c
> > > b/drivers/clk/sunxi-ng/ccu-sun50i-h6.c index 2ddf0a0da526f..1b0205ff24108
> > > 100644
> > > --- a/drivers/clk/sunxi-ng/ccu-sun50i-h6.c
> > > +++ b/drivers/clk/sunxi-ng/ccu-sun50i-h6.c
> > > @@ -95,13 +95,13 @@ static struct ccu_nkmp pll_periph1_clk = {
> > >       },
> > >  };
> > >
> > > +/* For GPU PLL, using an output divider for DFS causes system to fail 
*/
> > >  #define SUN50I_H6_PLL_GPU_REG                0x030
> > >  static struct ccu_nkmp pll_gpu_clk = {
> > >       .enable         = BIT(31),
> > >       .lock           = BIT(28),
> > >       .n              = _SUNXI_CCU_MULT_MIN(8, 8, 12),
> > >       .m              = _SUNXI_CCU_DIV(1, 1), /* input divider */
> > > -     .p              = _SUNXI_CCU_DIV(0, 1), /* output divider
> > */
> >
> > Having minimum (288 MHz) as per vendor GPU driver and maximum, either max. 
opp
> > or max. from datasheet is equally good. I know that both are basically 
limited
> > with opp table, but people like to play with these, so it's good to have 
them
> > in.
> >
> > >       .common         = {
> > >               .reg            = 0x030,
> > >               .hw.init        = CLK_HW_INIT("pll-gpu", "osc24M",
> > > @@ -294,9 +294,9 @@ static SUNXI_CCU_M_WITH_MUX_GATE(deinterlace_clk,
> > > "deinterlace", static SUNXI_CCU_GATE(bus_deinterlace_clk,
> > > "bus-deinterlace", "psi-ahb1-ahb2", 0x62c, BIT(0), 0);
> > >
> > > +/* Keep GPU_CLK divider const to avoid DFS instability. */
> > >  static const char * const gpu_parents[] = { "pll-gpu" };
> > > -static SUNXI_CCU_M_WITH_MUX_GATE(gpu_clk, "gpu", gpu_parents, 0x670,
> > > -                                    0, 3,    /* M */
> > > +static SUNXI_CCU_MUX_WITH_GATE(gpu_clk, "gpu", gpu_parents, 0x670,
> > >                                      24, 1,   /* mux */
> > >                                      BIT(31), /* gate */
> > >                                      CLK_SET_RATE_PARENT);
> > > @@ -1193,6 +1193,16 @@ static int sun50i_h6_ccu_probe(struct 
platform_device
> > > *pdev) if (IS_ERR(reg))
> > >               return PTR_ERR(reg);
> > >
> > > +     /* Force PLL_GPU output divider to 0 */
> >
> > Divider  0 here
> >
> > > +     val = readl(reg + SUN50I_H6_PLL_GPU_REG);
> > > +     val &= ~BIT(0);
> > > +     writel(val, reg + SUN50I_H6_PLL_GPU_REG);
> > > +
> > > +     /* Force GPU_CLK divider to 0 */
> >
> > and here sounds wrong, since division by zero is not defined. Using 1 is 
more
> > intuitive and correct, since that's what HW actually uses.
> >
> 
> You're right but a few lines below there is already a similar message
> (see below) , so I used similar formulation to avoid confusion.

Right. But there is another block of code below:

/*
 * Force the post-divider of pll-audio to 12 and the output divider
 * of it to 2, so 24576000 and 22579200 rates can be set exactly.
 */
...
writel(val | (11 << 16) | BIT(0), reg + SUN50I_H6_PLL_AUDIO_REG);

Let's follow better practice. Eventually video PLL comment should be fixed by 
somebody.

> 
>         /*
>          * Force the output divider of video PLLs to 0.
>          *
>          * See the comment before pll-video0 definition for the reason.
>          */
> 
> > Patch looks good otherwise.
> 
> May I have your r-b?

Yes.

Best regards,
Jernej

> 
> Best regards,
> Roman
> 
> >
> > Best regards,
> > Jernej
> >
> > > +     val = readl(reg + gpu_clk.common.reg);
> > > +     val &= ~GENMASK(3, 0);
> > > +     writel(val, reg + gpu_clk.common.reg);
> > > +
> > >       /* Enable the lock bits on all PLLs */
> > >       for (i = 0; i < ARRAY_SIZE(pll_regs); i++) {
> > >               val = readl(reg + pll_regs[i]);
> >
> >
> >
> >
> 



WARNING: multiple messages have this Message-ID (diff)
From: "Jernej Škrabec" <jernej.skrabec@gmail.com>
To: Roman Stratiienko <r.stratiienko@gmail.com>
Cc: "Samuel Holland" <samuel@sholland.org>,
	"Clément Péron" <peron.clem@gmail.com>,
	"Michael Turquette" <mturquette@baylibre.com>,
	sboyd@kernel.org, mripard@kernel.org, wens@csie.org,
	linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: Re: [PATCH v2] clk: sunxi-ng: sun50i: h6: Modify GPU clock configuration to support DFS
Date: Mon, 04 Jul 2022 19:34:43 +0200	[thread overview]
Message-ID: <5835545.lOV4Wx5bFT@kista> (raw)
In-Reply-To: <CAGphcdkZzjw-6oSnpiDM5YgPkuSV3VPX4nKo_FfPeg36MzT8Ew@mail.gmail.com>

Dne ponedeljek, 04. julij 2022 ob 11:54:06 CEST je Roman Stratiienko 
napisal(a):
> Hi Jernej,
> 
> вс, 3 июл. 2022 г. в 21:43, Jernej Škrabec <jernej.skrabec@gmail.com>:
> >
> > Dne nedelja, 03. julij 2022 ob 18:45:14 CEST je Roman Stratiienko 
napisal(a):
> > > Using simple bash script it was discovered that not all CCU registers
> > > can be safely used for DFS, e.g.:
> > >
> > >     while true
> > >     do
> > >         devmem 0x3001030 4 0xb0003e02
> > >         devmem 0x3001030 4 0xb0001e02
> > >     done
> > >
> > > Script above changes the GPU_PLL multiplier register value. While the
> > > script is running, the user should interact with the user interface.
> > >
> > > Using this method the following results were obtained:
> > > | Register  | Name           | Bits  | Values | Result |
> > > | --        | --             | --    | --     | --     |
> > > | 0x3001030 | GPU_PLL.MULT   | 15..8 | 20-62  | OK     |
> > > | 0x3001030 | GPU_PLL.INDIV  |     1 | 0-1    | OK     |
> > > | 0x3001030 | GPU_PLL.OUTDIV |     0 | 0-1    | FAIL   |
> > > | 0x3001670 | GPU_CLK.DIV    |  3..0 | ANY    | FAIL   |
> > >
> > > DVFS started to work seamlessly once dividers which caused the
> > > glitches were set to fixed values.
> > >
> > > Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
> > >
> > > ---
> > >
> > > Changelog:
> > >
> > > V2:
> > > - Drop changes related to mux
> > > - Drop frequency limiting
> > > - Add unused dividers initialization
> > > ---
> > >  drivers/clk/sunxi-ng/ccu-sun50i-h6.c | 16 +++++++++++++---
> > >  1 file changed, 13 insertions(+), 3 deletions(-)
> > >
> > > diff --git a/drivers/clk/sunxi-ng/ccu-sun50i-h6.c
> > > b/drivers/clk/sunxi-ng/ccu-sun50i-h6.c index 2ddf0a0da526f..1b0205ff24108
> > > 100644
> > > --- a/drivers/clk/sunxi-ng/ccu-sun50i-h6.c
> > > +++ b/drivers/clk/sunxi-ng/ccu-sun50i-h6.c
> > > @@ -95,13 +95,13 @@ static struct ccu_nkmp pll_periph1_clk = {
> > >       },
> > >  };
> > >
> > > +/* For GPU PLL, using an output divider for DFS causes system to fail 
*/
> > >  #define SUN50I_H6_PLL_GPU_REG                0x030
> > >  static struct ccu_nkmp pll_gpu_clk = {
> > >       .enable         = BIT(31),
> > >       .lock           = BIT(28),
> > >       .n              = _SUNXI_CCU_MULT_MIN(8, 8, 12),
> > >       .m              = _SUNXI_CCU_DIV(1, 1), /* input divider */
> > > -     .p              = _SUNXI_CCU_DIV(0, 1), /* output divider
> > */
> >
> > Having minimum (288 MHz) as per vendor GPU driver and maximum, either max. 
opp
> > or max. from datasheet is equally good. I know that both are basically 
limited
> > with opp table, but people like to play with these, so it's good to have 
them
> > in.
> >
> > >       .common         = {
> > >               .reg            = 0x030,
> > >               .hw.init        = CLK_HW_INIT("pll-gpu", "osc24M",
> > > @@ -294,9 +294,9 @@ static SUNXI_CCU_M_WITH_MUX_GATE(deinterlace_clk,
> > > "deinterlace", static SUNXI_CCU_GATE(bus_deinterlace_clk,
> > > "bus-deinterlace", "psi-ahb1-ahb2", 0x62c, BIT(0), 0);
> > >
> > > +/* Keep GPU_CLK divider const to avoid DFS instability. */
> > >  static const char * const gpu_parents[] = { "pll-gpu" };
> > > -static SUNXI_CCU_M_WITH_MUX_GATE(gpu_clk, "gpu", gpu_parents, 0x670,
> > > -                                    0, 3,    /* M */
> > > +static SUNXI_CCU_MUX_WITH_GATE(gpu_clk, "gpu", gpu_parents, 0x670,
> > >                                      24, 1,   /* mux */
> > >                                      BIT(31), /* gate */
> > >                                      CLK_SET_RATE_PARENT);
> > > @@ -1193,6 +1193,16 @@ static int sun50i_h6_ccu_probe(struct 
platform_device
> > > *pdev) if (IS_ERR(reg))
> > >               return PTR_ERR(reg);
> > >
> > > +     /* Force PLL_GPU output divider to 0 */
> >
> > Divider  0 here
> >
> > > +     val = readl(reg + SUN50I_H6_PLL_GPU_REG);
> > > +     val &= ~BIT(0);
> > > +     writel(val, reg + SUN50I_H6_PLL_GPU_REG);
> > > +
> > > +     /* Force GPU_CLK divider to 0 */
> >
> > and here sounds wrong, since division by zero is not defined. Using 1 is 
more
> > intuitive and correct, since that's what HW actually uses.
> >
> 
> You're right but a few lines below there is already a similar message
> (see below) , so I used similar formulation to avoid confusion.

Right. But there is another block of code below:

/*
 * Force the post-divider of pll-audio to 12 and the output divider
 * of it to 2, so 24576000 and 22579200 rates can be set exactly.
 */
...
writel(val | (11 << 16) | BIT(0), reg + SUN50I_H6_PLL_AUDIO_REG);

Let's follow better practice. Eventually video PLL comment should be fixed by 
somebody.

> 
>         /*
>          * Force the output divider of video PLLs to 0.
>          *
>          * See the comment before pll-video0 definition for the reason.
>          */
> 
> > Patch looks good otherwise.
> 
> May I have your r-b?

Yes.

Best regards,
Jernej

> 
> Best regards,
> Roman
> 
> >
> > Best regards,
> > Jernej
> >
> > > +     val = readl(reg + gpu_clk.common.reg);
> > > +     val &= ~GENMASK(3, 0);
> > > +     writel(val, reg + gpu_clk.common.reg);
> > > +
> > >       /* Enable the lock bits on all PLLs */
> > >       for (i = 0; i < ARRAY_SIZE(pll_regs); i++) {
> > >               val = readl(reg + pll_regs[i]);
> >
> >
> >
> >
> 



_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2022-07-04 17:34 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-03 16:45 [PATCH v2] clk: sunxi-ng: sun50i: h6: Modify GPU clock configuration to support DFS Roman Stratiienko
2022-07-03 16:45 ` Roman Stratiienko
2022-07-03 18:43 ` Jernej Škrabec
2022-07-03 18:43   ` Jernej Škrabec
2022-07-04  9:54   ` Roman Stratiienko
2022-07-04  9:54     ` Roman Stratiienko
2022-07-04 17:34     ` Jernej Škrabec [this message]
2022-07-04 17:34       ` Jernej Škrabec

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=5835545.lOV4Wx5bFT@kista \
    --to=jernej.skrabec@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sunxi@lists.linux.dev \
    --cc=mripard@kernel.org \
    --cc=mturquette@baylibre.com \
    --cc=peron.clem@gmail.com \
    --cc=r.stratiienko@gmail.com \
    --cc=samuel@sholland.org \
    --cc=sboyd@kernel.org \
    --cc=wens@csie.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.