From: Stephen Boyd <sboyd@kernel.org>
To: Alexandra Diupina <adiupina@astralinux.ru>, Andrew Lunn <andrew@lunn.ch>
Cc: Gregory Clement <gregory.clement@bootlin.com>,
Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>,
Michael Turquette <mturquette@baylibre.com>,
linux-arm-kernel@lists.infradead.org, linux-clk@vger.kernel.org,
linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org
Subject: Re: [PATCH v3] clk: mvebu: Prevent division by zero in clk_double_div_recalc_rate()
Date: Mon, 07 Oct 2024 15:56:29 -0700 [thread overview]
Message-ID: <c2250a7cd0e2af5077ade91279567c3b.sboyd@kernel.org> (raw)
In-Reply-To: <d05d9ebd-f954-482b-878b-9dcb422821a8@astralinux.ru>
Quoting Alexandra Diupina (2024-09-24 06:14:44)
> >> diff --git a/drivers/clk/mvebu/armada-37xx-periph.c b/drivers/clk/mvebu/armada-37xx-periph.c
> >> index 8701a58a5804..b32c6d4d7ee5 100644
> >> --- a/drivers/clk/mvebu/armada-37xx-periph.c
> >> +++ b/drivers/clk/mvebu/armada-37xx-periph.c
> >> @@ -343,7 +343,12 @@ static unsigned long clk_double_div_recalc_rate(struct clk_hw *hw,
> >> div = get_div(double_div->reg1, double_div->shift1);
> >> div *= get_div(double_div->reg2, double_div->shift2);
> >>
> >> - return DIV_ROUND_UP_ULL((u64)parent_rate, div);
> >> + if (!div) {
> >> + pr_err("Can't recalculate the rate of clock %s\n", hw->init->name);
> > hw->init is set to NULL after registration (see clk_register() code). If
> > div is 0 what does the hardware do?
>
> Thanks for noticing the error. Yes, hw->init is set to zero,
> I will replace that code with clk_hw_get_name(hw).
> If the value of div is 0, should I return 0 as stated in the
> comment for .recalc_rate (in struct clk_ops) or should I
> return parent_rate as in some other similar rate recalculation
> functions (in some other drivers)?
It depends on what the hardware does. Does the hardware pass on the
parent rate if the divider is zero? If so, then return parent_rate. Or
does it turn off completely? If so, return zero.
next prev parent reply other threads:[~2024-10-07 22:56 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-09 13:38 [PATCH] clk: mvebu: Prevent division by zero in clk_double_div_recalc_rate() Alexandra Diupina
2024-09-09 14:02 ` Andrew Lunn
2024-09-09 14:17 ` Alexandra Diupina
2024-09-09 14:34 ` Andrew Lunn
2024-09-10 17:31 ` [PATCH v2] " Alexandra Diupina
2024-09-10 18:59 ` Andrew Lunn
2024-09-17 13:22 ` [PATCH v3] " Alexandra Diupina
2024-09-19 10:24 ` Stephen Boyd
2024-09-24 13:14 ` Alexandra Diupina
2024-10-07 22:56 ` Stephen Boyd [this message]
2024-10-08 21:58 ` Andrew Lunn
2024-10-09 9:01 ` [lvc-project] " Fedor Pchelkin
2024-10-09 12:23 ` Andrew Lunn
2024-10-09 13:43 ` Fedor Pchelkin
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=c2250a7cd0e2af5077ade91279567c3b.sboyd@kernel.org \
--to=sboyd@kernel.org \
--cc=adiupina@astralinux.ru \
--cc=andrew@lunn.ch \
--cc=gregory.clement@bootlin.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lvc-project@linuxtesting.org \
--cc=mturquette@baylibre.com \
--cc=sebastian.hesselbarth@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