From: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
To: Diogo Ivo <diogo.ivo@tecnico.ulisboa.pt>,
thierry.reding@gmail.com, jonathanh@nvidia.com,
linux-tegra@vger.kernel.org
Subject: Re: [PATCH 6/7] memory: tegra: Move compare/update current delay values to a function
Date: Sat, 13 Apr 2024 10:07:44 +0200 [thread overview]
Message-ID: <54d2d6f5-4628-42d0-aea5-6c1790cf356d@linaro.org> (raw)
In-Reply-To: <20240409094632.62916-7-diogo.ivo@tecnico.ulisboa.pt>
On 09/04/2024 11:46, Diogo Ivo wrote:
> Separate the comparison/updating of the measured delay values with the
> values currently programmed into a separate function to simplify the
> code.
>
> Signed-off-by: Diogo Ivo <diogo.ivo@tecnico.ulisboa.pt>
> ---
> drivers/memory/tegra/tegra210-emc-cc-r21021.c | 84 +++++++++----------
> 1 file changed, 38 insertions(+), 46 deletions(-)
>
> diff --git a/drivers/memory/tegra/tegra210-emc-cc-r21021.c b/drivers/memory/tegra/tegra210-emc-cc-r21021.c
> index 566e5c65c854..ec2f84758d55 100644
> --- a/drivers/memory/tegra/tegra210-emc-cc-r21021.c
> +++ b/drivers/memory/tegra/tegra210-emc-cc-r21021.c
> @@ -113,19 +113,35 @@ enum {
> #define __MOVAVG(timing, dev) \
> ((timing)->ptfv_list[dev])
>
> +static bool tegra210_emc_compare_update_delay(struct tegra210_emc_timing *timing,
> + u32 measured, u32 idx)
> +{
> + u32 *curr = &timing->current_dram_clktree[idx];
> + u32 rate_mhz = timing->rate / 1000;
> + u32 tmdel;
> +
> + tmdel = abs(*curr - measured);
> +
> + if (tmdel * 128 * rate_mhz / 1000000 > timing->tree_margin) {
> + *curr = measured;
> + return true;
> + }
> +
> + return false;
> +}
> +
> static u32 update_clock_tree_delay(struct tegra210_emc *emc, int type)
> {
> bool periodic_training_update = type == PERIODIC_TRAINING_UPDATE;
> struct tegra210_emc_timing *last = emc->last;
> struct tegra210_emc_timing *next = emc->next;
> u32 last_timing_rate_mhz = last->rate / 1000;
> - u32 next_timing_rate_mhz = next->rate / 1000;
> bool dvfs_update = type == DVFS_UPDATE;
> - s32 tdel = 0, tmdel = 0, adel = 0;
> bool dvfs_pt1 = type == DVFS_PT1;
> u32 temp[2][2], value, udelay;
> unsigned long cval = 0;
> unsigned int c, d, idx;
> + bool over = false;
>
> if (dvfs_pt1 || periodic_training_update) {
> udelay = tegra210_emc_actual_osc_clocks(last->run_clocks);
> @@ -174,17 +190,9 @@ static u32 update_clock_tree_delay(struct tegra210_emc *emc, int type)
> else if (periodic_training_update)
> __WEIGHTED_UPDATE_PTFV(idx, cval);
>
> - if (dvfs_update || periodic_training_update) {
> - tdel = next->current_dram_clktree[idx] -
> - __MOVAVG_AC(next, idx);
> - tmdel = (tdel < 0) ? -1 * tdel : tdel;
> - adel = tmdel;
> -
> - if (tmdel * 128 * next_timing_rate_mhz / 1000000 >
> - next->tree_margin)
> - next->current_dram_clktree[idx] =
> - __MOVAVG_AC(next, idx);
> - }
> + if (dvfs_update || periodic_training_update)
> + over |= tegra210_emc_compare_update_delay(next,
> + __MOVAVG_AC(next, idx), idx);
>
> /* C[c]D[d]U[1] */
> idx++;
> @@ -202,35 +210,26 @@ static u32 update_clock_tree_delay(struct tegra210_emc *emc, int type)
> else if (periodic_training_update)
> __WEIGHTED_UPDATE_PTFV(idx, cval);
>
> - if (dvfs_update || periodic_training_update) {
> - tdel = next->current_dram_clktree[idx] -
> - __MOVAVG_AC(next, idx);
> - tmdel = (tdel < 0) ? -1 * tdel : tdel;
> -
> - if (tmdel > adel)
> - adel = tmdel;
> -
> - if (tmdel * 128 * next_timing_rate_mhz / 1000000 >
> - next->tree_margin)
> - next->current_dram_clktree[idx] =
> - __MOVAVG_AC(next, idx);
> - }
> + if (dvfs_update || periodic_training_update)
> + over |= tegra210_emc_compare_update_delay(next,
> + __MOVAVG_AC(next, idx), idx);
> }
> }
>
> - return adel;
> + return over;
You are now returning always 0 or 1, while previously it was tmdel,
which I suppose is not 0/1.
This looks odd, especially that function prototype did not change.
Best regards,
Krzysztof
next prev parent reply other threads:[~2024-04-13 8:07 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-09 9:46 [PATCH 0/7] Cleanup Tegra210 EMC frequency scaling Diogo Ivo
2024-04-09 9:46 ` [PATCH 1/7] memory: tegra: Remove periodic compensation duplicate calls Diogo Ivo
2024-04-09 9:46 ` [PATCH 2/7] memory: tegra: Move DQSOSC measurement to common place Diogo Ivo
2024-04-09 9:46 ` [PATCH 3/7] memory: tegra: Reword and correct comments Diogo Ivo
2024-04-09 9:46 ` [PATCH 4/7] memory: tegra: Change macros to interpret parameter as integer Diogo Ivo
2024-04-13 8:02 ` Krzysztof Kozlowski
2024-04-15 11:07 ` Diogo Ivo
2024-04-09 9:46 ` [PATCH 5/7] memory: tegra: Loop update_clock_tree_delay() Diogo Ivo
2024-04-09 9:46 ` [PATCH 6/7] memory: tegra: Move compare/update current delay values to a function Diogo Ivo
2024-04-13 8:07 ` Krzysztof Kozlowski [this message]
2024-04-15 11:17 ` Diogo Ivo
2024-04-09 9:46 ` [PATCH 7/7] memory: tegra: Rework update_clock_tree_delay() Diogo Ivo
2024-04-13 8:08 ` Krzysztof Kozlowski
2024-04-15 11:22 ` Diogo Ivo
2024-04-18 17:19 ` Krzysztof Kozlowski
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=54d2d6f5-4628-42d0-aea5-6c1790cf356d@linaro.org \
--to=krzysztof.kozlowski@linaro.org \
--cc=diogo.ivo@tecnico.ulisboa.pt \
--cc=jonathanh@nvidia.com \
--cc=linux-tegra@vger.kernel.org \
--cc=thierry.reding@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