linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Boris Brezillon <boris.brezillon@free-electrons.com>
To: Stephen Boyd <sboyd@codeaurora.org>
Cc: "Mike Turquette" <mturquette@linaro.org>,
	linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org,
	"Jonathan Corbet" <corbet@lwn.net>,
	"Shawn Guo" <shawn.guo@linaro.org>,
	"ascha Hauer" <kernel@pengutronix.de>,
	"David Brown" <davidb@codeaurora.org>,
	"Daniel Walker" <dwalker@fifo99.com>,
	"Bryan Huntsman" <bryanh@codeaurora.org>,
	"Tony Lindgren" <tony@atomide.com>,
	"Paul Walmsley" <paul@pwsan.com>,
	"Liviu Dudau" <liviu.dudau@arm.com>,
	"Sudeep Holla" <sudeep.holla@arm.com>,
	"Lorenzo Pieralisi" <lorenzo.pieralisi@arm.com>,
	"Ralf Baechle" <ralf@linux-mips.org>,
	"Max Filippov" <jcmvbkbc@gmail.com>,
	"Heiko Stuebner" <heiko@sntech.de>,
	"Sylwester Nawrocki" <s.nawrocki@samsung.com>,
	"Tomasz Figa" <tomasz.figa@gmail.com>,
	"Barry Song" <baohua@kernel.org>,
	"Viresh Kumar" <viresh.linux@gmail.com>,
	"Emilio López" <emilio@elopez.com.ar>,
	"Maxime Ripard" <maxime.ripard@free-electrons.com>,
	"Peter De Schrijver" <pdeschrijver@nvidia.com>,
	"Prashant Gaikwad" <pgaikwad@nvidia.com>,
	"Stephen Warren" <swarren@wwwdotorg.org>,
	"Thierry Reding" <thierry.reding@gmail.com>,
	"Alexandre Courbot" <gnurou@gmail.com>,
	"Tero Kristo" <t-kristo@ti.com>,
	"Ulf Hansson" <ulf.hansson@linaro.org>,
	"Michal Simek" <michal.simek@xilinx.com>,
	"Philipp Zabel" <p.zabel@pengutronix.de>,
	linux-doc@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-arm-msm@vger.kernel.org, linux-omap@vger.kernel.org,
	linux-mips@linux-mips.org, patches@opensource.wolfsonmicro.com,
	linux-rockchip@lists.infradead.org,
	linux-samsung-soc@vger.kernel.org, spear-devel@list.st.com,
	linux-tegra@vger.kernel.org, dri-devel@lists.freedesktop.org,
	linux-media@vger.kernel.org, rtc-linux@googlegroups.com
Subject: Re: [PATCH v2 1/2] clk: change clk_ops' ->round_rate() prototype
Date: Thu, 7 May 2015 09:37:02 +0200	[thread overview]
Message-ID: <20150507093702.0b58753d@bbrezillon> (raw)
In-Reply-To: <20150507063953.GC32399@codeaurora.org>

Hi Stephen,

On Wed, 6 May 2015 23:39:53 -0700
Stephen Boyd <sboyd@codeaurora.org> wrote:

> On 04/30, Boris Brezillon wrote:
> > Clock rates are stored in an unsigned long field, but ->round_rate()
> > (which returns a rounded rate from a requested one) returns a long
> > value (errors are reported using negative error codes), which can lead
> > to long overflow if the clock rate exceed 2Ghz.
> > 
> > Change ->round_rate() prototype to return 0 or an error code, and pass the
> > requested rate as a pointer so that it can be adjusted depending on
> > hardware capabilities.
> > 
> > Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
> > Tested-by: Heiko Stuebner <heiko@sntech.de>
> > Tested-by: Mikko Perttunen <mikko.perttunen@kapsi.fi>
> > Reviewed-by: Heiko Stuebner <heiko@sntech.de>
> 
> This patch is fairly invasive, and it probably doesn't even
> matter for most of these clock providers to be able to round a
> rate above 2GHz.

Fair enough.

> I've been trying to remove the .round_rate op
> from the framework by encouraging new features via the
> .determine_rate op.

Oh, I wasn't aware of that (BTW, that's a good thing).
Maybe this should be clearly stated (both in the struct clk_ops
kerneldoc header and in Documentation/clk.txt).

> Sadly, we still have to do a flag day and
> change all the .determine_rate ops when we want to add things.

Yes, but the number of clk drivers implementing ->determine_rate() is
still quite limited compared to those implementing ->round_rate().

> 
> What if we changed determine_rate ops to take a struct
> clk_determine_info (or some better named structure) instead of
> the current list of arguments that it currently takes? Then when
> we want to make these sorts of framework wide changes we can just
> throw a new member into that structure and be done.

I really like this idea, especially since I was wondering if we could
pass other 'clk rate requirements' like the rounding policy (down,
closest, up), or the maximum clk inaccuracy.

> 
> It doesn't solve the unsigned long to int return value problem
> though. We can solve that by gradually introducing a new op and
> handling another case in the rounding path. If we can come up
> with some good name for that new op like .decide_rate or
> something then it makes things nicer in the long run. I like the
> name .determine_rate though :/

Why not changing the ->determine_rate() prototype. As said above, the
number of clk drivers implementing this function is still quite
limited, and I guess we can have an ack for all of them.

> 
> The benefit of all this is that we don't have to worry about
> finding the random clk providers that get added into other
> subsystems and fixing them up. If drivers actually care about
> this problem then they'll be fixed to use the proper op. FYI,
> last time we updated the function signature of .determine_rate we
> broke a couple drivers along the way.
> 

Hm, IMHO, adding a new op is not a good thing. I agree that it eases
the transition, but ITOH you'll have to live with old/deprecated ops in
your clk_ops structure with people introducing new drivers still using
the old ops (see the number of clk drivers implementing ->round_rate()
instead of ->determine_rate()).

Best Regards,

Boris

-- 
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

  reply	other threads:[~2015-05-07  7:37 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-30 15:30 [PATCH v2 0/2] clk: adapt ->round_rate()/->determine_rate() prototypes Boris Brezillon
2015-04-30 15:30 ` [PATCH v2 1/2] clk: change clk_ops' ->round_rate() prototype Boris Brezillon
2015-05-07  6:39   ` Stephen Boyd
2015-05-07  7:37     ` Boris Brezillon [this message]
2015-05-15 15:40       ` Boris Brezillon
2015-05-16 11:14         ` Mikko Perttunen
2015-05-20  1:01           ` Stephen Boyd
2015-06-04 23:02   ` Paul Walmsley
2015-06-05  8:46     ` Jon Hunter
2015-06-05 11:39       ` Boris Brezillon
2015-06-08  8:46         ` Jon Hunter
2015-06-05 11:38     ` Boris Brezillon
2015-04-30 15:30 ` [PATCH v2 2/2] clk: change clk_ops' ->determine_rate() prototype Boris Brezillon

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=20150507093702.0b58753d@bbrezillon \
    --to=boris.brezillon@free-electrons.com \
    --cc=baohua@kernel.org \
    --cc=bryanh@codeaurora.org \
    --cc=corbet@lwn.net \
    --cc=davidb@codeaurora.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=dwalker@fifo99.com \
    --cc=emilio@elopez.com.ar \
    --cc=gnurou@gmail.com \
    --cc=heiko@sntech.de \
    --cc=jcmvbkbc@gmail.com \
    --cc=kernel@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-mips@linux-mips.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=liviu.dudau@arm.com \
    --cc=lorenzo.pieralisi@arm.com \
    --cc=maxime.ripard@free-electrons.com \
    --cc=michal.simek@xilinx.com \
    --cc=mturquette@linaro.org \
    --cc=p.zabel@pengutronix.de \
    --cc=patches@opensource.wolfsonmicro.com \
    --cc=paul@pwsan.com \
    --cc=pdeschrijver@nvidia.com \
    --cc=pgaikwad@nvidia.com \
    --cc=ralf@linux-mips.org \
    --cc=rtc-linux@googlegroups.com \
    --cc=s.nawrocki@samsung.com \
    --cc=sboyd@codeaurora.org \
    --cc=shawn.guo@linaro.org \
    --cc=spear-devel@list.st.com \
    --cc=sudeep.holla@arm.com \
    --cc=swarren@wwwdotorg.org \
    --cc=t-kristo@ti.com \
    --cc=thierry.reding@gmail.com \
    --cc=tomasz.figa@gmail.com \
    --cc=tony@atomide.com \
    --cc=ulf.hansson@linaro.org \
    --cc=viresh.linux@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).