All of lore.kernel.org
 help / color / mirror / Atom feed
From: Boris Brezillon <boris.brezillon@free-electrons.com>
To: "Heiko Stübner" <heiko@sntech.de>
Cc: "Mike Turquette" <mturquette@linaro.org>,
	"Mikko Perttunen" <mikko.perttunen@kapsi.fi>,
	"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>,
	"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>
Subject: Re: [PATCH 1/2] clk: change clk_ops' ->round_rate() prototype
Date: Sun, 19 Apr 2015 17:30:06 +0200	[thread overview]
Message-ID: <20150419173006.0ce6cfe0@bbrezillon> (raw)
In-Reply-To: <7408975.lBcgZIN9hf@diego>

Hi Heiko,

On Sun, 19 Apr 2015 14:13:04 +0200
Heiko Stübner <heiko@sntech.de> wrote:

> Hi Boris,
> 
> Am Freitag, 17. April 2015, 09:29:28 schrieb Boris Brezillon:
> > 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>
> > ---
> 
> On a rk3288-veyron-pinky with the fix described below:
> Tested-by: Heiko Stuebner <heiko@sntech.de>
> 
> 
> > diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
> > index fa5a00e..1462ddc 100644
> > --- a/drivers/clk/clk.c
> > +++ b/drivers/clk/clk.c
> > @@ -1640,8 +1643,10 @@ static struct clk_core *clk_calc_new_rates(struct
> > clk_core *clk, &parent_hw);
> >  		parent = parent_hw ? parent_hw->core : NULL;
> >  	} else if (clk->ops->round_rate) {
> > -		new_rate = clk->ops->round_rate(clk->hw, rate,
> > -						&best_parent_rate);
> > +		if (clk->ops->round_rate(clk->hw, &new_rate,
> > +					 &best_parent_rate))
> > +			return NULL;
> > +
> >  		if (new_rate < min_rate || new_rate > max_rate)
> >  			return NULL;
> >  	} else if (!parent || !(clk->flags & CLK_SET_RATE_PARENT)) {
> 
> This is using new_rate uninitialized when calling into the round_rate
> callback. Which in turn pushed my PLLs up to 2.2GHz :-)

Indeed, thanks for the fix.

[...]

> 
> 
> And as I've stumbled onto this recently too, the clock-maintainership has
> expanded to Stephen Boyd and linux-clk@vger.kernel.org .

Noted. I'll add Stephen and the new linux-clk ML in the recipient list
next time.

Best Regards,

Boris


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

WARNING: multiple messages have this Message-ID (diff)
From: Boris Brezillon <boris.brezillon@free-electrons.com>
To: "Heiko Stübner" <heiko@sntech.de>
Cc: "Mike Turquette" <mturquette@linaro.org>,
	"Mikko Perttunen" <mikko.perttunen@kapsi.fi>,
	"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>,
	"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-kernel@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 1/2] clk: change clk_ops' ->round_rate() prototype
Date: Sun, 19 Apr 2015 17:30:06 +0200	[thread overview]
Message-ID: <20150419173006.0ce6cfe0@bbrezillon> (raw)
In-Reply-To: <7408975.lBcgZIN9hf@diego>

Hi Heiko,

On Sun, 19 Apr 2015 14:13:04 +0200
Heiko Stübner <heiko@sntech.de> wrote:

> Hi Boris,
> 
> Am Freitag, 17. April 2015, 09:29:28 schrieb Boris Brezillon:
> > 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>
> > ---
> 
> On a rk3288-veyron-pinky with the fix described below:
> Tested-by: Heiko Stuebner <heiko@sntech.de>
> 
> 
> > diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
> > index fa5a00e..1462ddc 100644
> > --- a/drivers/clk/clk.c
> > +++ b/drivers/clk/clk.c
> > @@ -1640,8 +1643,10 @@ static struct clk_core *clk_calc_new_rates(struct
> > clk_core *clk, &parent_hw);
> >  		parent = parent_hw ? parent_hw->core : NULL;
> >  	} else if (clk->ops->round_rate) {
> > -		new_rate = clk->ops->round_rate(clk->hw, rate,
> > -						&best_parent_rate);
> > +		if (clk->ops->round_rate(clk->hw, &new_rate,
> > +					 &best_parent_rate))
> > +			return NULL;
> > +
> >  		if (new_rate < min_rate || new_rate > max_rate)
> >  			return NULL;
> >  	} else if (!parent || !(clk->flags & CLK_SET_RATE_PARENT)) {
> 
> This is using new_rate uninitialized when calling into the round_rate
> callback. Which in turn pushed my PLLs up to 2.2GHz :-)

Indeed, thanks for the fix.

[...]

> 
> 
> And as I've stumbled onto this recently too, the clock-maintainership has
> expanded to Stephen Boyd and linux-clk@vger.kernel.org .

Noted. I'll add Stephen and the new linux-clk ML in the recipient list
next time.

Best Regards,

Boris


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

WARNING: multiple messages have this Message-ID (diff)
From: Boris Brezillon <boris.brezillon@free-electrons.com>
To: "Heiko Stübner" <heiko@sntech.de>
Cc: "Mike Turquette" <mturquette@linaro.org>,
	"Mikko Perttunen" <mikko.perttunen@kapsi.fi>,
	"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>,
	"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-kernel@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: [rtc-linux] Re: [PATCH 1/2] clk: change clk_ops' ->round_rate() prototype
Date: Sun, 19 Apr 2015 17:30:06 +0200	[thread overview]
Message-ID: <20150419173006.0ce6cfe0@bbrezillon> (raw)
In-Reply-To: <7408975.lBcgZIN9hf@diego>

Hi Heiko,

On Sun, 19 Apr 2015 14:13:04 +0200
Heiko St=C3=BCbner <heiko@sntech.de> wrote:

> Hi Boris,
>=20
> Am Freitag, 17. April 2015, 09:29:28 schrieb Boris Brezillon:
> > 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.
> >=20
> > 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.
> >=20
> > Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
> > ---
>=20
> On a rk3288-veyron-pinky with the fix described below:
> Tested-by: Heiko Stuebner <heiko@sntech.de>
>=20
>=20
> > diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
> > index fa5a00e..1462ddc 100644
> > --- a/drivers/clk/clk.c
> > +++ b/drivers/clk/clk.c
> > @@ -1640,8 +1643,10 @@ static struct clk_core *clk_calc_new_rates(struc=
t
> > clk_core *clk, &parent_hw);
> >  		parent =3D parent_hw ? parent_hw->core : NULL;
> >  	} else if (clk->ops->round_rate) {
> > -		new_rate =3D clk->ops->round_rate(clk->hw, rate,
> > -						&best_parent_rate);
> > +		if (clk->ops->round_rate(clk->hw, &new_rate,
> > +					 &best_parent_rate))
> > +			return NULL;
> > +
> >  		if (new_rate < min_rate || new_rate > max_rate)
> >  			return NULL;
> >  	} else if (!parent || !(clk->flags & CLK_SET_RATE_PARENT)) {
>=20
> This is using new_rate uninitialized when calling into the round_rate
> callback. Which in turn pushed my PLLs up to 2.2GHz :-)

Indeed, thanks for the fix.

[...]

>=20
>=20
> And as I've stumbled onto this recently too, the clock-maintainership has
> expanded to Stephen Boyd and linux-clk@vger.kernel.org .

Noted. I'll add Stephen and the new linux-clk ML in the recipient list
next time.

Best Regards,

Boris


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

--=20
--=20
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
---=20
You received this message because you are subscribed to the Google Groups "=
rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to rtc-linux+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

WARNING: multiple messages have this Message-ID (diff)
From: boris.brezillon@free-electrons.com (Boris Brezillon)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/2] clk: change clk_ops' ->round_rate() prototype
Date: Sun, 19 Apr 2015 17:30:06 +0200	[thread overview]
Message-ID: <20150419173006.0ce6cfe0@bbrezillon> (raw)
In-Reply-To: <7408975.lBcgZIN9hf@diego>

Hi Heiko,

On Sun, 19 Apr 2015 14:13:04 +0200
Heiko St?bner <heiko@sntech.de> wrote:

> Hi Boris,
> 
> Am Freitag, 17. April 2015, 09:29:28 schrieb Boris Brezillon:
> > 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>
> > ---
> 
> On a rk3288-veyron-pinky with the fix described below:
> Tested-by: Heiko Stuebner <heiko@sntech.de>
> 
> 
> > diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
> > index fa5a00e..1462ddc 100644
> > --- a/drivers/clk/clk.c
> > +++ b/drivers/clk/clk.c
> > @@ -1640,8 +1643,10 @@ static struct clk_core *clk_calc_new_rates(struct
> > clk_core *clk, &parent_hw);
> >  		parent = parent_hw ? parent_hw->core : NULL;
> >  	} else if (clk->ops->round_rate) {
> > -		new_rate = clk->ops->round_rate(clk->hw, rate,
> > -						&best_parent_rate);
> > +		if (clk->ops->round_rate(clk->hw, &new_rate,
> > +					 &best_parent_rate))
> > +			return NULL;
> > +
> >  		if (new_rate < min_rate || new_rate > max_rate)
> >  			return NULL;
> >  	} else if (!parent || !(clk->flags & CLK_SET_RATE_PARENT)) {
> 
> This is using new_rate uninitialized when calling into the round_rate
> callback. Which in turn pushed my PLLs up to 2.2GHz :-)

Indeed, thanks for the fix.

[...]

> 
> 
> And as I've stumbled onto this recently too, the clock-maintainership has
> expanded to Stephen Boyd and linux-clk at vger.kernel.org .

Noted. I'll add Stephen and the new linux-clk ML in the recipient list
next time.

Best Regards,

Boris


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

  reply	other threads:[~2015-04-19 15:30 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1429255769-13639-1-git-send-email-boris.brezillon@free-electrons.com>
2015-04-17  7:29 ` [PATCH 1/2] clk: change clk_ops' ->round_rate() prototype Boris Brezillon
2015-04-17  7:29   ` Boris Brezillon
2015-04-17  7:29   ` [rtc-linux] " Boris Brezillon
2015-04-17  7:29   ` Boris Brezillon
2015-04-19 12:13   ` Heiko Stübner
2015-04-19 12:13     ` Heiko Stübner
2015-04-19 12:13     ` [rtc-linux] " Heiko Stübner
2015-04-19 12:13     ` Heiko Stübner
2015-04-19 15:30     ` Boris Brezillon [this message]
2015-04-19 15:30       ` Boris Brezillon
2015-04-19 15:30       ` [rtc-linux] " Boris Brezillon
2015-04-19 15:30       ` Boris Brezillon
2015-04-28 15:11   ` Mikko Perttunen
2015-04-28 15:11     ` Mikko Perttunen
2015-04-28 15:11     ` [rtc-linux] " Mikko Perttunen
2015-04-28 15:11     ` Mikko Perttunen
2015-04-17  7:29 ` [PATCH 2/2] clk: change clk_ops' ->determine_rate() prototype Boris Brezillon
2015-04-17  7:29   ` 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=20150419173006.0ce6cfe0@bbrezillon \
    --to=boris.brezillon@free-electrons.com \
    --cc=baohua@kernel.org \
    --cc=bryanh@codeaurora.org \
    --cc=corbet@lwn.net \
    --cc=davidb@codeaurora.org \
    --cc=dwalker@fifo99.com \
    --cc=emilio@elopez.com.ar \
    --cc=heiko@sntech.de \
    --cc=jcmvbkbc@gmail.com \
    --cc=kernel@pengutronix.de \
    --cc=liviu.dudau@arm.com \
    --cc=lorenzo.pieralisi@arm.com \
    --cc=maxime.ripard@free-electrons.com \
    --cc=mikko.perttunen@kapsi.fi \
    --cc=mturquette@linaro.org \
    --cc=paul@pwsan.com \
    --cc=pdeschrijver@nvidia.com \
    --cc=ralf@linux-mips.org \
    --cc=s.nawrocki@samsung.com \
    --cc=shawn.guo@linaro.org \
    --cc=sudeep.holla@arm.com \
    --cc=tomasz.figa@gmail.com \
    --cc=tony@atomide.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.