From: Frank Oltmanns <frank@oltmanns.dev>
To: Frank Oltmanns <frank@oltmanns.dev>
Cc: linux-arm-kernel@lists.infradead.org, linux-clk@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-sunxi@lists.linux.dev,
Andre Przywara <andre.przywara@arm.com>,
Chen-Yu Tsai <wens@csie.org>, Icenowy Zheng <icenowy@aosc.io>,
Jernej Skrabec <jernej.skrabec@gmail.com>,
Maxime Ripard <mripard@kernel.org>,
Michael Turquette <mturquette@baylibre.com>,
Rob Herring <robh@kernel.org>,
Samuel Holland <samuel@sholland.org>,
Stephen Boyd <sboyd@kernel.org>
Subject: Re: [RFC PATCH 2/3] clk: sunxi-ng: Implement precalculated NKM rate selection
Date: Sun, 28 May 2023 16:11:02 +0200 [thread overview]
Message-ID: <87o7m4wneg.fsf@oltmanns.dev> (raw)
In-Reply-To: <20230527132747.83196-3-frank@oltmanns.dev>
On 2023-05-27 at 15:27:46 +0200, Frank Oltmanns <frank@oltmanns.dev> wrote:
[...]
> diff --git a/drivers/clk/sunxi-ng/ccu_nkm.c b/drivers/clk/sunxi-ng/ccu_nkm.c
> index 94d2a83992b2..9652f6df17bd 100644
> --- a/drivers/clk/sunxi-ng/ccu_nkm.c
> +++ b/drivers/clk/sunxi-ng/ccu_nkm.c
[...]
> @@ -157,14 +205,18 @@ static int ccu_nkm_set_rate(struct clk_hw *hw, unsigned long rate,
> if (nkm->common.features & CCU_FEATURE_FIXED_POSTDIV)
> rate *= nkm->fixed_post_div;
>
> - _nkm.min_n = nkm->n.min ?: 1;
> - _nkm.max_n = nkm->n.max ?: 1 << nkm->n.width;
> - _nkm.min_k = nkm->k.min ?: 1;
> - _nkm.max_k = nkm->k.max ?: 1 << nkm->k.width;
> - _nkm.min_m = 1;
> - _nkm.max_m = nkm->m.max ?: 1 << nkm->m.width;
> -
> - ccu_nkm_find_best(parent_rate, rate, &_nkm);
> + if (nkm->table.num)
> + rate = ccu_nkm_find_best_precalc(*parent_rate, rate, &_nkm,
Ugh! s/*parent_rate/parent_rate/
Sorry! Thanks to intel kernel test robot for pointing it out:
https://lore.kernel.org/oe-kbuild-all/202305280405.bUAMrEtn-lkp@intel.com/
Cheers,
Frank
> + &nkm->table);
> + else {
> + _nkm.min_n = nkm->n.min ?: 1;
> + _nkm.max_n = nkm->n.max ?: 1 << nkm->n.width;
> + _nkm.min_k = nkm->k.min ?: 1;
> + _nkm.max_k = nkm->k.max ?: 1 << nkm->k.width;
> + _nkm.min_m = 1;
> + _nkm.max_m = nkm->m.max ?: 1 << nkm->m.width;
> + ccu_nkm_find_best(parent_rate, rate, &_nkm);
> + }
>
> spin_lock_irqsave(nkm->common.lock, flags);
>
> diff --git a/drivers/clk/sunxi-ng/ccu_nkm.h b/drivers/clk/sunxi-ng/ccu_nkm.h
> index 6601defb3f38..fa5551724921 100644
> --- a/drivers/clk/sunxi-ng/ccu_nkm.h
> +++ b/drivers/clk/sunxi-ng/ccu_nkm.h
> @@ -12,6 +12,30 @@
> #include "ccu_div.h"
> #include "ccu_mult.h"
>
> +struct clk_nkm_combo {
> + u8 n;
> + u8 k;
> + u8 m;
> +};
> +
> +/**
> + * struct clk_nkm_table - Table of all meaningful combinations for n, k, and m
> + *
> + * @num: Number of entries in the table
> + * @combos: Array of combos (of size num) that are supported by this clock.
> + *
> + * This table shall contain all meaningful combinations of n, k, and m. That
> + * means that combinations that result in the same clock rate shall only be
> + * listed once. For example, if both
> + * { .n = 1, .k = 2, .m = 2} and { .n = 2, .k = 2, .m = 4}
> + * are valid values for n, k, and m, only one of them would be allowed because
> + * both result in a factor of 1.0.
> + */
> +struct clk_nkm_table {
> + size_t num;
> + struct clk_nkm_combo *combos;
> +};
> +
> /*
> * struct ccu_nkm - Definition of an N-K-M clock
> *
> @@ -29,6 +53,8 @@ struct ccu_nkm {
> unsigned int fixed_post_div;
>
> struct ccu_common common;
> +
> + struct clk_nkm_table table;
> };
>
> #define SUNXI_CCU_NKM_WITH_MUX_GATE_LOCK(_struct, _name, _parents, _reg, \
next prev parent reply other threads:[~2023-05-28 14:18 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-27 13:27 [RFC PATCH 0/3] clk: sunxi-ng: Optimize rate selection for NKM clocks Frank Oltmanns
2023-05-27 13:27 ` [RFC PATCH 1/3] clk: sunxi-ng: nkm: Minimize difference when finding rate Frank Oltmanns
2023-05-27 13:27 ` [RFC PATCH 2/3] clk: sunxi-ng: Implement precalculated NKM rate selection Frank Oltmanns
2023-05-27 23:19 ` Julian Calaby
2023-05-28 9:12 ` Frank Oltmanns
2023-05-28 15:32 ` Julian Calaby
2023-05-28 17:12 ` Frank Oltmanns
2023-05-28 14:11 ` Frank Oltmanns [this message]
2023-05-27 13:27 ` [RFC PATCH 3/3] clk: sunxi-ng: sun50i-a64: Precalculate NKM combinations for pll-mipi Frank Oltmanns
2023-05-31 13:48 ` [RFC PATCH 0/3] clk: sunxi-ng: Optimize rate selection for NKM clocks Maxime Ripard
2023-06-01 5:16 ` Frank Oltmanns
2023-06-01 19:41 ` Jernej Škrabec
2023-06-02 7:34 ` Maxime Ripard
2023-06-05 11:41 ` Frank Oltmanns
2023-06-02 7:31 ` Maxime Ripard
2023-06-05 10:31 ` Frank Oltmanns
2023-06-06 14:02 ` Maxime Ripard
2023-06-06 20:40 ` Frank Oltmanns
2023-06-07 11:42 ` Maxime Ripard
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=87o7m4wneg.fsf@oltmanns.dev \
--to=frank@oltmanns.dev \
--cc=andre.przywara@arm.com \
--cc=icenowy@aosc.io \
--cc=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=robh@kernel.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).