From: Sivaram Nair <sivaramn@nvidia.com>
To: Mikko Perttunen <mperttunen@nvidia.com>
Cc: <pdeschrijver@nvidia.com>, <mturquette@baylibre.com>,
<sboyd@kernel.org>, <thierry.reding@gmail.com>,
<jonathanh@nvidia.com>, <linux-clk@vger.kernel.org>,
<linux-tegra@vger.kernel.org>
Subject: Re: [PATCH] clk: tegra: bpmp: Clamp clock rates on requests
Date: Wed, 21 Oct 2020 16:01:37 -0700 [thread overview]
Message-ID: <20201021230137.GA3933@krlm> (raw)
In-Reply-To: <20201021101054.2836146-1-mperttunen@nvidia.com>
On Wed, Oct 21, 2020 at 01:10:54PM +0300, Mikko Perttunen wrote:
> From: Sivaram Nair <sivaramn@nvidia.com>
>
> BPMP firmware ABI expects the rate inputs in int64_t. However,
> tegra_bpmp_clk_round_rate() and tegra_bpmp_clk_set_rate() functions
> directly assign 'unsigned long' inputs to a int64_t value causing
> unexpected rounding errors.
>
> Fix this by clipping the input rate to S64_MAX.
>
> Signed-off-by: Sivaram Nair <sivaramn@nvidia.com>
> [mperttunen: slight cleanup]
> Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>
> ---
> drivers/clk/tegra/clk-bpmp.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/clk/tegra/clk-bpmp.c b/drivers/clk/tegra/clk-bpmp.c
> index a66263b6490d..6ecf18f71c32 100644
> --- a/drivers/clk/tegra/clk-bpmp.c
> +++ b/drivers/clk/tegra/clk-bpmp.c
> @@ -1,6 +1,6 @@
> // SPDX-License-Identifier: GPL-2.0-only
> /*
> - * Copyright (C) 2016 NVIDIA Corporation
> + * Copyright (C) 2016-2020 NVIDIA Corporation
> */
>
> #include <linux/clk-provider.h>
> @@ -174,7 +174,7 @@ static long tegra_bpmp_clk_round_rate(struct clk_hw *hw, unsigned long rate,
> int err;
>
> memset(&request, 0, sizeof(request));
> - request.rate = rate;
> + request.rate = min_t(u64, rate, S64_MAX);
>
> memset(&msg, 0, sizeof(msg));
> msg.cmd = CMD_CLK_ROUND_RATE;
> @@ -256,7 +256,7 @@ static int tegra_bpmp_clk_set_rate(struct clk_hw *hw, unsigned long rate,
> struct tegra_bpmp_clk_message msg;
>
> memset(&request, 0, sizeof(request));
> - request.rate = rate;
> + request.rate = min_t(u64, rate, S64_MAX);
>
> memset(&msg, 0, sizeof(msg));
> msg.cmd = CMD_CLK_SET_RATE;
> --
> 2.28.0
>
Reviewed-by: Sivaram Nair
prev parent reply other threads:[~2020-10-21 23:01 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-21 10:10 [PATCH] clk: tegra: bpmp: Clamp clock rates on requests Mikko Perttunen
2020-10-21 23:01 ` Sivaram Nair [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=20201021230137.GA3933@krlm \
--to=sivaramn@nvidia.com \
--cc=jonathanh@nvidia.com \
--cc=linux-clk@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=mperttunen@nvidia.com \
--cc=mturquette@baylibre.com \
--cc=pdeschrijver@nvidia.com \
--cc=sboyd@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;
as well as URLs for NNTP newsgroup(s).