From: Stephen Boyd <sboyd@kernel.org>
To: Radu Nicolae Pirea <radu_nicolae.pirea@upb.ro>,
York Sun <york.sun@nxp.com>,
linux-clk@vger.kernel.org
Cc: York Sun <yorksun@freescale.com>,
Mike Turquette <mturquette@baylibre.com>,
Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>,
Guenter Roeck <linux@roeck-us.net>,
Andrey Filippov <andrey@elphel.com>,
Paul Bolle <pebolle@tiscali.nl>,
Stephen Boyd <sboyd@codeaurora.org>,
Rob Herring <robh+dt@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [Patch v9] driver/clk/clk-si5338: Add common clock framework driver for si5338
Date: Thu, 06 Jun 2019 11:05:07 -0700 [thread overview]
Message-ID: <20190606180508.1A76F20868@mail.kernel.org> (raw)
In-Reply-To: <96cb1e730ea5afd651d4c79f20f365df5fe8a29b.camel@upb.ro>
Quoting Radu Nicolae Pirea (2019-05-31 07:06:03)
> > + remove_common_factor(&rate[1]);
> > + dev_dbg(&drvdata->client->dev,
> > + "PLL output frequency: %llu+%llu/%llu Hz\n",
> > + rate[0], rate[1], rate[2]);
> > +
> > + return rate[0];
> > +}
> > +
> > +static long si5338_pll_round_rate(struct clk_hw *hw, unsigned long
> > rate,
> > + unsigned long *parent_rate)
> > +{
> I think is a designs problem in clock subsystem.
> Description of the function round_rate is this.
>
> @round_rate: Given a target rate as input, returns the closest rate
> actually supported by the clock. The parent rate is an input/output
> parameter.
>
> If given rate is unsigned long and the return value is long, we have a
> problem. Return value can be an error value but can also be a 32 bit
> frequency value that can be huge enoguh to set MSB bit and if MSB bit
> is set, the return value is a negative value and will be considered
> error code.
>
> In drivers/clk/clk.c, in function clk_core_determine_round_nolock, on
> line 1199 is this sequence of code that checks if the value returned by
> round_rate function is negative:
>
> } else if (core->ops->round_rate) {
> rate = core->ops->round_rate(core->hw, req->rate,
> &req->best_parent_rate);
> if (rate < 0)
> return rate;
>
> In drivers/clk/clk.c, in function clk_calc_new_rates, on line 1780, is
> the next sequence of code that checks if
> clk_core_determine_round_nolock returns a negative value:
>
> ret = clk_core_determine_round_nolock(core, &req);
> if (ret < 0)
> return NULL;
>
> and... if function clk_calc_new_rates returns NULL, in function
> clk_core_set_rate_nolock from drivers/clk/clk.c, on line 2023, is the
> next sequence of code that evaluates NULL, returned by
> clk_calc_new_rates as -EINVAL
>
> top = clk_calc_new_rates(core, req_rate);
> if (!top)
> return -EINVAL;
>
> So... si5338_pll_round_rate can return 32 bit values like 2500000000 Hz
> who have MSB bit set and are interpreted as error codes.
>
> Have someone a suggestion to fix this issue?
>
Can you use the determine_rate clk op? It won't work for rounding
outside of the framework though so things like clk_round_rate() still
fail.
prev parent reply other threads:[~2019-06-06 18:05 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-26 21:45 [Patch v9] driver/clk/clk-si5338: Add common clock framework driver for si5338 York Sun
[not found] ` <1472247978-29312-1-git-send-email-york.sun-3arQi8VN3Tc@public.gmane.org>
2016-09-02 14:04 ` Rob Herring
2016-09-02 15:57 ` york sun
2019-05-31 14:06 ` Radu Nicolae Pirea
2019-05-31 16:47 ` [EXT] " York Sun
2019-06-06 18:05 ` Stephen Boyd [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=20190606180508.1A76F20868@mail.kernel.org \
--to=sboyd@kernel.org \
--cc=andrey@elphel.com \
--cc=devicetree@vger.kernel.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=mark.rutland@arm.com \
--cc=mturquette@baylibre.com \
--cc=pebolle@tiscali.nl \
--cc=radu_nicolae.pirea@upb.ro \
--cc=robh+dt@kernel.org \
--cc=sboyd@codeaurora.org \
--cc=sebastian.hesselbarth@gmail.com \
--cc=york.sun@nxp.com \
--cc=yorksun@freescale.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).