All of lore.kernel.org
 help / color / mirror / Atom feed
From: Geert Uytterhoeven <geert@linux-m68k.org>
To: linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v13 4/6] clk: Add rate constraints to clocks
Date: Thu, 29 Jan 2015 13:31:12 +0000	[thread overview]
Message-ID: <CAMuHMdUGgA70o2SgdJR3X6AkCcMssHU0POLfzppADT-O=BrYDw@mail.gmail.com> (raw)
In-Reply-To: <1422011024-32283-5-git-send-email-tomeu.vizoso@collabora.com>

Hi Tomeu, Mike,

On Fri, Jan 23, 2015 at 12:03 PM, Tomeu Vizoso
<tomeu.vizoso@collabora.com> wrote:
> Adds a way for clock consumers to set maximum and minimum rates. This
> can be used for thermal drivers to set minimum rates, or by misc.
> drivers to set maximum rates to assure a minimum performance level.
>
> Changes the signature of the determine_rate callback by adding the
> parameters min_rate and max_rate.
>
> Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
> Reviewed-by: Stephen Boyd <sboyd@codeaurora.org>

This is now in clk-next, and causes division by zeroes on all shmobile
platforms that use renesas,cpg-div6-clock (verified on r8a73a4, r8a7740,
r8a7791, sh73a0):

Division by zero in kernel.
CPU: 0 PID: 0 Comm: swapper/0 Not tainted
3.19.0-rc6-koelsch-04360-g48d797d57c5932c8-dirty #792
Hardware name: Generic R8A7791 (Flattened Device Tree)
Backtrace:
[<c001216c>] (dump_backtrace) from [<c001238c>] (show_stack+0x18/0x1c)
 r6:c051b124 r5:00000000 r4:00000000 r3:00200000
[<c0012374>] (show_stack) from [<c03955d0>] (dump_stack+0x78/0x94)
[<c0395558>] (dump_stack) from [<c00122f4>] (__div0+0x18/0x20)
 r4:2e7ddb00 r3:c05093c8
[<c00122dc>] (__div0) from [<c01bdc9c>] (Ldiv0+0x8/0x10)
[<c02d8efc>] (cpg_div6_clock_round_rate) from [<c02d56a0>]
(clk_calc_new_rates+0xc8/0x1d4)
 r4:eec14e00 r3:c03cb52c
[<c02d55d8>] (clk_calc_new_rates) from [<c02d57f4>]
(clk_core_set_rate_nolock+0x48/0x90)
 r9:eec02f40 r8:00000001 r7:c051b0b8 r6:c051b124 r5:00000000 r4:eec14e00
[<c02d57ac>] (clk_core_set_rate_nolock) from [<c02d6848>] (__clk_put+0x78/0xdc)
 r7:c051b0b8 r6:c051b124 r5:eec08100 r4:eec029c0
[<c02d67d0>] (__clk_put) from [<c02d3238>] (clk_put+0x10/0x14)
 r5:eec08100 r4:00000000
[<c02d3228>] (clk_put) from [<c04db4d0>] (of_clk_init+0x144/0x178)
[<c04db38c>] (of_clk_init) from [<c04dbd34>] (rcar_gen2_clocks_init+0x1c/0x24)
 r10:c04ed098 r9:c05023c0 r8:ffffffff r7:19432124 r6:c0502404 r5:00989680
 r4:f0006000
[<c04dbd18>] (rcar_gen2_clocks_init) from [<c04c6a3c>]
(rcar_gen2_timer_init+0x130/0x14c)
[<c04c690c>] (rcar_gen2_timer_init) from [<c04c15b4>] (time_init+0x24/0x38)
 r7:00000000 r6:c0520c80 r5:00000000 r4:ef7fcbc0
[<c04c1590>] (time_init) from [<c04bdb84>] (start_kernel+0x248/0x3bc)
[<c04bd93c>] (start_kernel) from [<40008084>] (0x40008084)
 r10:00000000 r9:413fc0f2 r8:40007000 r7:c0505870 r6:c04ed094 r5:c0502440
 r4:c0521054


> --- a/drivers/clk/clk.c
> +++ b/drivers/clk/clk.c

> @@ -2391,25 +2543,24 @@ int __clk_get(struct clk *clk)
>         return 1;
>  }
>
> -static void clk_core_put(struct clk_core *core)
> +void __clk_put(struct clk *clk)
>  {
>         struct module *owner;
>
> -       owner = core->owner;
> +       if (!clk || WARN_ON_ONCE(IS_ERR(clk)))
> +               return;
>
>         clk_prepare_lock();
> -       kref_put(&core->ref, __clk_release);
> +
> +       hlist_del(&clk->child_node);
> +       clk_core_set_rate_nolock(clk->core, clk->core->req_rate);

At this point, clk->core->req_rate is still zero, causing
cpg_div6_clock_round_rate() to be called with a zero "rate" parameter,
e.g. on r8a7791:

cpg_div6_clock_round_rate: clock sd2 rate 0 parent_rate 780000000 div 1
cpg_div6_clock_round_rate: clock sd1 rate 0 parent_rate 780000000 div 1
cpg_div6_clock_round_rate: clock mmc0 rate 0 parent_rate 780000000 div 1
cpg_div6_clock_round_rate: clock sd1 rate 0 parent_rate 780000000 div 1
cpg_div6_clock_round_rate: clock sd1 rate 0 parent_rate 780000000 div 1
cpg_div6_clock_round_rate: clock sd2 rate 0 parent_rate 780000000 div 1
cpg_div6_clock_round_rate: clock sd2 rate 0 parent_rate 780000000 div 1

and cpg_div6_clock_calc_div() is called to calculate

        div = DIV_ROUND_CLOSEST(parent_rate, rate);

Why was this call to clk_core_set_rate_nolock() in __clk_put() added?
Before, there was no rate setting done at this point, and
cpg_div6_clock_round_rate() was not called.

Have the semantics changed? Should .round_rate() be ready to
accept a "zero" rate, and use e.g. the current rate instead?

> +       owner = clk->core->owner;
> +       kref_put(&clk->core->ref, __clk_release);
> +
>         clk_prepare_unlock();
>
>         module_put(owner);
> -}
> -
> -void __clk_put(struct clk *clk)
> -{
> -       if (!clk || WARN_ON_ONCE(IS_ERR(clk)))
> -               return;
>
> -       clk_core_put(clk->core);
>         kfree(clk);
>  }

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

WARNING: multiple messages have this Message-ID (diff)
From: Geert Uytterhoeven <geert@linux-m68k.org>
To: Tomeu Vizoso <tomeu.vizoso@collabora.com>,
	Mike Turquette <mturquette@linaro.org>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"Stephen Boyd" <sboyd@codeaurora.org>,
	"Javier Martinez Canillas" <javier.martinez@collabora.co.uk>,
	"Jonathan Corbet" <corbet@lwn.net>,
	"Tony Lindgren" <tony@atomide.com>,
	"Russell King" <linux@arm.linux.org.uk>,
	"Ralf Baechle" <ralf@linux-mips.org>,
	"Boris Brezillon" <boris.brezillon@free-electrons.com>,
	"Emilio López" <emilio@elopez.com.ar>,
	"Maxime Ripard" <maxime.ripard@free-electrons.com>,
	"Tero Kristo" <t-kristo@ti.com>,
	"Manuel Lauss" <manuel.lauss@gmail.com>,
	"Alex Elder" <elder@linaro.org>,
	"Matt Porter" <mporter@linaro.org>,
	"Haojian Zhuang" <haojian.zhuang@linaro.org>,
	"Zhangfei Gao" <zhangfei.gao@linaro.org>,
	"Bintian Wang" <bintian.wang@huawei.com>,
	"Chao Xie" <chao.xie@marvell.com>,
	"linux-doc@vger.kernel.org" <linux-doc@vger.kernel.org>,
	"linux-omap@vger.kernel.org" <linux-omap@vger.kernel.org>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	"Linux MIPS Mailing List" <linux-mips@linux-mips.org>,
	"Linux-sh list" <linux-sh@vger.kernel.org>
Subject: Re: [PATCH v13 4/6] clk: Add rate constraints to clocks
Date: Thu, 29 Jan 2015 14:31:12 +0100	[thread overview]
Message-ID: <CAMuHMdUGgA70o2SgdJR3X6AkCcMssHU0POLfzppADT-O=BrYDw@mail.gmail.com> (raw)
In-Reply-To: <1422011024-32283-5-git-send-email-tomeu.vizoso@collabora.com>

Hi Tomeu, Mike,

On Fri, Jan 23, 2015 at 12:03 PM, Tomeu Vizoso
<tomeu.vizoso@collabora.com> wrote:
> Adds a way for clock consumers to set maximum and minimum rates. This
> can be used for thermal drivers to set minimum rates, or by misc.
> drivers to set maximum rates to assure a minimum performance level.
>
> Changes the signature of the determine_rate callback by adding the
> parameters min_rate and max_rate.
>
> Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
> Reviewed-by: Stephen Boyd <sboyd@codeaurora.org>

This is now in clk-next, and causes division by zeroes on all shmobile
platforms that use renesas,cpg-div6-clock (verified on r8a73a4, r8a7740,
r8a7791, sh73a0):

Division by zero in kernel.
CPU: 0 PID: 0 Comm: swapper/0 Not tainted
3.19.0-rc6-koelsch-04360-g48d797d57c5932c8-dirty #792
Hardware name: Generic R8A7791 (Flattened Device Tree)
Backtrace:
[<c001216c>] (dump_backtrace) from [<c001238c>] (show_stack+0x18/0x1c)
 r6:c051b124 r5:00000000 r4:00000000 r3:00200000
[<c0012374>] (show_stack) from [<c03955d0>] (dump_stack+0x78/0x94)
[<c0395558>] (dump_stack) from [<c00122f4>] (__div0+0x18/0x20)
 r4:2e7ddb00 r3:c05093c8
[<c00122dc>] (__div0) from [<c01bdc9c>] (Ldiv0+0x8/0x10)
[<c02d8efc>] (cpg_div6_clock_round_rate) from [<c02d56a0>]
(clk_calc_new_rates+0xc8/0x1d4)
 r4:eec14e00 r3:c03cb52c
[<c02d55d8>] (clk_calc_new_rates) from [<c02d57f4>]
(clk_core_set_rate_nolock+0x48/0x90)
 r9:eec02f40 r8:00000001 r7:c051b0b8 r6:c051b124 r5:00000000 r4:eec14e00
[<c02d57ac>] (clk_core_set_rate_nolock) from [<c02d6848>] (__clk_put+0x78/0xdc)
 r7:c051b0b8 r6:c051b124 r5:eec08100 r4:eec029c0
[<c02d67d0>] (__clk_put) from [<c02d3238>] (clk_put+0x10/0x14)
 r5:eec08100 r4:00000000
[<c02d3228>] (clk_put) from [<c04db4d0>] (of_clk_init+0x144/0x178)
[<c04db38c>] (of_clk_init) from [<c04dbd34>] (rcar_gen2_clocks_init+0x1c/0x24)
 r10:c04ed098 r9:c05023c0 r8:ffffffff r7:19432124 r6:c0502404 r5:00989680
 r4:f0006000
[<c04dbd18>] (rcar_gen2_clocks_init) from [<c04c6a3c>]
(rcar_gen2_timer_init+0x130/0x14c)
[<c04c690c>] (rcar_gen2_timer_init) from [<c04c15b4>] (time_init+0x24/0x38)
 r7:00000000 r6:c0520c80 r5:00000000 r4:ef7fcbc0
[<c04c1590>] (time_init) from [<c04bdb84>] (start_kernel+0x248/0x3bc)
[<c04bd93c>] (start_kernel) from [<40008084>] (0x40008084)
 r10:00000000 r9:413fc0f2 r8:40007000 r7:c0505870 r6:c04ed094 r5:c0502440
 r4:c0521054


> --- a/drivers/clk/clk.c
> +++ b/drivers/clk/clk.c

> @@ -2391,25 +2543,24 @@ int __clk_get(struct clk *clk)
>         return 1;
>  }
>
> -static void clk_core_put(struct clk_core *core)
> +void __clk_put(struct clk *clk)
>  {
>         struct module *owner;
>
> -       owner = core->owner;
> +       if (!clk || WARN_ON_ONCE(IS_ERR(clk)))
> +               return;
>
>         clk_prepare_lock();
> -       kref_put(&core->ref, __clk_release);
> +
> +       hlist_del(&clk->child_node);
> +       clk_core_set_rate_nolock(clk->core, clk->core->req_rate);

At this point, clk->core->req_rate is still zero, causing
cpg_div6_clock_round_rate() to be called with a zero "rate" parameter,
e.g. on r8a7791:

cpg_div6_clock_round_rate: clock sd2 rate 0 parent_rate 780000000 div 1
cpg_div6_clock_round_rate: clock sd1 rate 0 parent_rate 780000000 div 1
cpg_div6_clock_round_rate: clock mmc0 rate 0 parent_rate 780000000 div 1
cpg_div6_clock_round_rate: clock sd1 rate 0 parent_rate 780000000 div 1
cpg_div6_clock_round_rate: clock sd1 rate 0 parent_rate 780000000 div 1
cpg_div6_clock_round_rate: clock sd2 rate 0 parent_rate 780000000 div 1
cpg_div6_clock_round_rate: clock sd2 rate 0 parent_rate 780000000 div 1

and cpg_div6_clock_calc_div() is called to calculate

        div = DIV_ROUND_CLOSEST(parent_rate, rate);

Why was this call to clk_core_set_rate_nolock() in __clk_put() added?
Before, there was no rate setting done at this point, and
cpg_div6_clock_round_rate() was not called.

Have the semantics changed? Should .round_rate() be ready to
accept a "zero" rate, and use e.g. the current rate instead?

> +       owner = clk->core->owner;
> +       kref_put(&clk->core->ref, __clk_release);
> +
>         clk_prepare_unlock();
>
>         module_put(owner);
> -}
> -
> -void __clk_put(struct clk *clk)
> -{
> -       if (!clk || WARN_ON_ONCE(IS_ERR(clk)))
> -               return;
>
> -       clk_core_put(clk->core);
>         kfree(clk);
>  }

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

WARNING: multiple messages have this Message-ID (diff)
From: Geert Uytterhoeven <geert@linux-m68k.org>
To: Tomeu Vizoso <tomeu.vizoso@collabora.com>,
	Mike Turquette <mturquette@linaro.org>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"Stephen Boyd" <sboyd@codeaurora.org>,
	"Javier Martinez Canillas" <javier.martinez@collabora.co.uk>,
	"Jonathan Corbet" <corbet@lwn.net>,
	"Tony Lindgren" <tony@atomide.com>,
	"Russell King" <linux@arm.linux.org.uk>,
	"Ralf Baechle" <ralf@linux-mips.org>,
	"Boris Brezillon" <boris.brezillon@free-electrons.com>,
	"Emilio López" <emilio@elopez.com.ar>,
	"Maxime Ripard" <maxime.ripard@free-electrons.com>,
	"Tero Kristo" <t-kristo@ti.com>,
	"Manuel Lauss" <manuel.lauss@gmail.com>,
	"Alex Elder" <elder@linaro.org>,
	"Matt Porter" <mporter@linaro.org>,
	"Haojian Zhuang" <haojian.zhuang@linaro.org>,
	"Zhangfei Gao" <zhangfei.gao@linaro.org>,
	"Bintian Wang" <bintian.wang@huawei.com>,
	"Chao Xie" <chao.xie@marvell.com>,
	"linux-doc@vger.kernel.org" <linux-doc@vger.kernel.org>,
	"linux-omap@vger.kernel.org" <linux-omap@vger.kernel.org>
Subject: Re: [PATCH v13 4/6] clk: Add rate constraints to clocks
Date: Thu, 29 Jan 2015 14:31:12 +0100	[thread overview]
Message-ID: <CAMuHMdUGgA70o2SgdJR3X6AkCcMssHU0POLfzppADT-O=BrYDw@mail.gmail.com> (raw)
In-Reply-To: <1422011024-32283-5-git-send-email-tomeu.vizoso@collabora.com>

Hi Tomeu, Mike,

On Fri, Jan 23, 2015 at 12:03 PM, Tomeu Vizoso
<tomeu.vizoso@collabora.com> wrote:
> Adds a way for clock consumers to set maximum and minimum rates. This
> can be used for thermal drivers to set minimum rates, or by misc.
> drivers to set maximum rates to assure a minimum performance level.
>
> Changes the signature of the determine_rate callback by adding the
> parameters min_rate and max_rate.
>
> Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
> Reviewed-by: Stephen Boyd <sboyd@codeaurora.org>

This is now in clk-next, and causes division by zeroes on all shmobile
platforms that use renesas,cpg-div6-clock (verified on r8a73a4, r8a7740,
r8a7791, sh73a0):

Division by zero in kernel.
CPU: 0 PID: 0 Comm: swapper/0 Not tainted
3.19.0-rc6-koelsch-04360-g48d797d57c5932c8-dirty #792
Hardware name: Generic R8A7791 (Flattened Device Tree)
Backtrace:
[<c001216c>] (dump_backtrace) from [<c001238c>] (show_stack+0x18/0x1c)
 r6:c051b124 r5:00000000 r4:00000000 r3:00200000
[<c0012374>] (show_stack) from [<c03955d0>] (dump_stack+0x78/0x94)
[<c0395558>] (dump_stack) from [<c00122f4>] (__div0+0x18/0x20)
 r4:2e7ddb00 r3:c05093c8
[<c00122dc>] (__div0) from [<c01bdc9c>] (Ldiv0+0x8/0x10)
[<c02d8efc>] (cpg_div6_clock_round_rate) from [<c02d56a0>]
(clk_calc_new_rates+0xc8/0x1d4)
 r4:eec14e00 r3:c03cb52c
[<c02d55d8>] (clk_calc_new_rates) from [<c02d57f4>]
(clk_core_set_rate_nolock+0x48/0x90)
 r9:eec02f40 r8:00000001 r7:c051b0b8 r6:c051b124 r5:00000000 r4:eec14e00
[<c02d57ac>] (clk_core_set_rate_nolock) from [<c02d6848>] (__clk_put+0x78/0xdc)
 r7:c051b0b8 r6:c051b124 r5:eec08100 r4:eec029c0
[<c02d67d0>] (__clk_put) from [<c02d3238>] (clk_put+0x10/0x14)
 r5:eec08100 r4:00000000
[<c02d3228>] (clk_put) from [<c04db4d0>] (of_clk_init+0x144/0x178)
[<c04db38c>] (of_clk_init) from [<c04dbd34>] (rcar_gen2_clocks_init+0x1c/0x24)
 r10:c04ed098 r9:c05023c0 r8:ffffffff r7:19432124 r6:c0502404 r5:00989680
 r4:f0006000
[<c04dbd18>] (rcar_gen2_clocks_init) from [<c04c6a3c>]
(rcar_gen2_timer_init+0x130/0x14c)
[<c04c690c>] (rcar_gen2_timer_init) from [<c04c15b4>] (time_init+0x24/0x38)
 r7:00000000 r6:c0520c80 r5:00000000 r4:ef7fcbc0
[<c04c1590>] (time_init) from [<c04bdb84>] (start_kernel+0x248/0x3bc)
[<c04bd93c>] (start_kernel) from [<40008084>] (0x40008084)
 r10:00000000 r9:413fc0f2 r8:40007000 r7:c0505870 r6:c04ed094 r5:c0502440
 r4:c0521054


> --- a/drivers/clk/clk.c
> +++ b/drivers/clk/clk.c

> @@ -2391,25 +2543,24 @@ int __clk_get(struct clk *clk)
>         return 1;
>  }
>
> -static void clk_core_put(struct clk_core *core)
> +void __clk_put(struct clk *clk)
>  {
>         struct module *owner;
>
> -       owner = core->owner;
> +       if (!clk || WARN_ON_ONCE(IS_ERR(clk)))
> +               return;
>
>         clk_prepare_lock();
> -       kref_put(&core->ref, __clk_release);
> +
> +       hlist_del(&clk->child_node);
> +       clk_core_set_rate_nolock(clk->core, clk->core->req_rate);

At this point, clk->core->req_rate is still zero, causing
cpg_div6_clock_round_rate() to be called with a zero "rate" parameter,
e.g. on r8a7791:

cpg_div6_clock_round_rate: clock sd2 rate 0 parent_rate 780000000 div 1
cpg_div6_clock_round_rate: clock sd1 rate 0 parent_rate 780000000 div 1
cpg_div6_clock_round_rate: clock mmc0 rate 0 parent_rate 780000000 div 1
cpg_div6_clock_round_rate: clock sd1 rate 0 parent_rate 780000000 div 1
cpg_div6_clock_round_rate: clock sd1 rate 0 parent_rate 780000000 div 1
cpg_div6_clock_round_rate: clock sd2 rate 0 parent_rate 780000000 div 1
cpg_div6_clock_round_rate: clock sd2 rate 0 parent_rate 780000000 div 1

and cpg_div6_clock_calc_div() is called to calculate

        div = DIV_ROUND_CLOSEST(parent_rate, rate);

Why was this call to clk_core_set_rate_nolock() in __clk_put() added?
Before, there was no rate setting done at this point, and
cpg_div6_clock_round_rate() was not called.

Have the semantics changed? Should .round_rate() be ready to
accept a "zero" rate, and use e.g. the current rate instead?

> +       owner = clk->core->owner;
> +       kref_put(&clk->core->ref, __clk_release);
> +
>         clk_prepare_unlock();
>
>         module_put(owner);
> -}
> -
> -void __clk_put(struct clk *clk)
> -{
> -       if (!clk || WARN_ON_ONCE(IS_ERR(clk)))
> -               return;
>
> -       clk_core_put(clk->core);
>         kfree(clk);
>  }

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

WARNING: multiple messages have this Message-ID (diff)
From: geert@linux-m68k.org (Geert Uytterhoeven)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v13 4/6] clk: Add rate constraints to clocks
Date: Thu, 29 Jan 2015 14:31:12 +0100	[thread overview]
Message-ID: <CAMuHMdUGgA70o2SgdJR3X6AkCcMssHU0POLfzppADT-O=BrYDw@mail.gmail.com> (raw)
In-Reply-To: <1422011024-32283-5-git-send-email-tomeu.vizoso@collabora.com>

Hi Tomeu, Mike,

On Fri, Jan 23, 2015 at 12:03 PM, Tomeu Vizoso
<tomeu.vizoso@collabora.com> wrote:
> Adds a way for clock consumers to set maximum and minimum rates. This
> can be used for thermal drivers to set minimum rates, or by misc.
> drivers to set maximum rates to assure a minimum performance level.
>
> Changes the signature of the determine_rate callback by adding the
> parameters min_rate and max_rate.
>
> Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
> Reviewed-by: Stephen Boyd <sboyd@codeaurora.org>

This is now in clk-next, and causes division by zeroes on all shmobile
platforms that use renesas,cpg-div6-clock (verified on r8a73a4, r8a7740,
r8a7791, sh73a0):

Division by zero in kernel.
CPU: 0 PID: 0 Comm: swapper/0 Not tainted
3.19.0-rc6-koelsch-04360-g48d797d57c5932c8-dirty #792
Hardware name: Generic R8A7791 (Flattened Device Tree)
Backtrace:
[<c001216c>] (dump_backtrace) from [<c001238c>] (show_stack+0x18/0x1c)
 r6:c051b124 r5:00000000 r4:00000000 r3:00200000
[<c0012374>] (show_stack) from [<c03955d0>] (dump_stack+0x78/0x94)
[<c0395558>] (dump_stack) from [<c00122f4>] (__div0+0x18/0x20)
 r4:2e7ddb00 r3:c05093c8
[<c00122dc>] (__div0) from [<c01bdc9c>] (Ldiv0+0x8/0x10)
[<c02d8efc>] (cpg_div6_clock_round_rate) from [<c02d56a0>]
(clk_calc_new_rates+0xc8/0x1d4)
 r4:eec14e00 r3:c03cb52c
[<c02d55d8>] (clk_calc_new_rates) from [<c02d57f4>]
(clk_core_set_rate_nolock+0x48/0x90)
 r9:eec02f40 r8:00000001 r7:c051b0b8 r6:c051b124 r5:00000000 r4:eec14e00
[<c02d57ac>] (clk_core_set_rate_nolock) from [<c02d6848>] (__clk_put+0x78/0xdc)
 r7:c051b0b8 r6:c051b124 r5:eec08100 r4:eec029c0
[<c02d67d0>] (__clk_put) from [<c02d3238>] (clk_put+0x10/0x14)
 r5:eec08100 r4:00000000
[<c02d3228>] (clk_put) from [<c04db4d0>] (of_clk_init+0x144/0x178)
[<c04db38c>] (of_clk_init) from [<c04dbd34>] (rcar_gen2_clocks_init+0x1c/0x24)
 r10:c04ed098 r9:c05023c0 r8:ffffffff r7:19432124 r6:c0502404 r5:00989680
 r4:f0006000
[<c04dbd18>] (rcar_gen2_clocks_init) from [<c04c6a3c>]
(rcar_gen2_timer_init+0x130/0x14c)
[<c04c690c>] (rcar_gen2_timer_init) from [<c04c15b4>] (time_init+0x24/0x38)
 r7:00000000 r6:c0520c80 r5:00000000 r4:ef7fcbc0
[<c04c1590>] (time_init) from [<c04bdb84>] (start_kernel+0x248/0x3bc)
[<c04bd93c>] (start_kernel) from [<40008084>] (0x40008084)
 r10:00000000 r9:413fc0f2 r8:40007000 r7:c0505870 r6:c04ed094 r5:c0502440
 r4:c0521054


> --- a/drivers/clk/clk.c
> +++ b/drivers/clk/clk.c

> @@ -2391,25 +2543,24 @@ int __clk_get(struct clk *clk)
>         return 1;
>  }
>
> -static void clk_core_put(struct clk_core *core)
> +void __clk_put(struct clk *clk)
>  {
>         struct module *owner;
>
> -       owner = core->owner;
> +       if (!clk || WARN_ON_ONCE(IS_ERR(clk)))
> +               return;
>
>         clk_prepare_lock();
> -       kref_put(&core->ref, __clk_release);
> +
> +       hlist_del(&clk->child_node);
> +       clk_core_set_rate_nolock(clk->core, clk->core->req_rate);

At this point, clk->core->req_rate is still zero, causing
cpg_div6_clock_round_rate() to be called with a zero "rate" parameter,
e.g. on r8a7791:

cpg_div6_clock_round_rate: clock sd2 rate 0 parent_rate 780000000 div 1
cpg_div6_clock_round_rate: clock sd1 rate 0 parent_rate 780000000 div 1
cpg_div6_clock_round_rate: clock mmc0 rate 0 parent_rate 780000000 div 1
cpg_div6_clock_round_rate: clock sd1 rate 0 parent_rate 780000000 div 1
cpg_div6_clock_round_rate: clock sd1 rate 0 parent_rate 780000000 div 1
cpg_div6_clock_round_rate: clock sd2 rate 0 parent_rate 780000000 div 1
cpg_div6_clock_round_rate: clock sd2 rate 0 parent_rate 780000000 div 1

and cpg_div6_clock_calc_div() is called to calculate

        div = DIV_ROUND_CLOSEST(parent_rate, rate);

Why was this call to clk_core_set_rate_nolock() in __clk_put() added?
Before, there was no rate setting done at this point, and
cpg_div6_clock_round_rate() was not called.

Have the semantics changed? Should .round_rate() be ready to
accept a "zero" rate, and use e.g. the current rate instead?

> +       owner = clk->core->owner;
> +       kref_put(&clk->core->ref, __clk_release);
> +
>         clk_prepare_unlock();
>
>         module_put(owner);
> -}
> -
> -void __clk_put(struct clk *clk)
> -{
> -       if (!clk || WARN_ON_ONCE(IS_ERR(clk)))
> -               return;
>
> -       clk_core_put(clk->core);
>         kfree(clk);
>  }

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert at linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

  reply	other threads:[~2015-01-29 13:31 UTC|newest]

Thread overview: 186+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-23 11:03 [PATCH v13 0/6] Per-user clock constraints Tomeu Vizoso
2015-01-23 11:03 ` [PATCH v13 1/6] clk: Remove unneeded NULL checks Tomeu Vizoso
2015-01-23 11:03 ` [PATCH v13 2/6] clk: Remove __clk_register Tomeu Vizoso
2015-01-23 11:03 ` [PATCH v13 3/6] clk: Make clk API return per-user struct clk instances Tomeu Vizoso
2015-01-23 11:03   ` Tomeu Vizoso
2015-02-01 21:24   ` Mike Turquette
2015-02-01 21:24     ` Mike Turquette
2015-02-01 21:24     ` Mike Turquette
2015-02-02 17:04     ` Tony Lindgren
2015-02-02 17:04       ` Tony Lindgren
2015-02-02 17:32       ` Mike Turquette
2015-02-02 17:32         ` Mike Turquette
2015-02-02 19:32     ` Tero Kristo
2015-02-02 19:32       ` Tero Kristo
2015-02-02 19:32       ` Tero Kristo
2015-02-02 20:44       ` Tony Lindgren
2015-02-02 20:44         ` Tony Lindgren
2015-02-02 22:48         ` Mike Turquette
2015-02-02 22:48           ` Mike Turquette
2015-02-02 23:11           ` Tony Lindgren
2015-02-02 23:11             ` Tony Lindgren
2015-02-02 22:41       ` Mike Turquette
2015-02-02 22:41         ` Mike Turquette
2015-02-02 22:52         ` Stephen Boyd
2015-02-02 22:52           ` Stephen Boyd
2015-02-03  7:03         ` Tomeu Vizoso
2015-02-03  7:03           ` Tomeu Vizoso
2015-02-03  8:46           ` Tero Kristo
2015-02-03  8:46             ` Tero Kristo
2015-02-03  8:46             ` Tero Kristo
2015-02-03 15:22             ` Tony Lindgren
2015-02-03 15:22               ` Tony Lindgren
2015-02-02 20:45     ` Stephen Boyd
2015-02-02 20:45       ` Stephen Boyd
2015-02-02 20:45       ` [Cocci] " Stephen Boyd
2015-02-02 21:31       ` Julia Lawall
2015-02-02 21:31         ` Julia Lawall
2015-02-02 21:31         ` [Cocci] " Julia Lawall
2015-02-02 22:35         ` Stephen Boyd
2015-02-02 22:35           ` Stephen Boyd
2015-02-02 22:35           ` [Cocci] " Stephen Boyd
2015-02-02 22:50           ` Mike Turquette
2015-02-02 22:50             ` Mike Turquette
2015-02-02 22:50             ` [Cocci] " Mike Turquette
2015-02-03 16:04             ` Quentin Lambert
2015-02-03 16:04               ` Quentin Lambert
2015-02-03 16:04               ` Quentin Lambert
2015-02-04 23:26               ` Stephen Boyd
2015-02-04 23:26                 ` Stephen Boyd
2015-02-04 23:26                 ` Stephen Boyd
2015-02-05 15:45                 ` Quentin Lambert
2015-02-05 15:45                   ` Quentin Lambert
2015-02-05 15:45                   ` Quentin Lambert
2015-02-05 16:02                   ` Quentin Lambert
2015-02-05 16:02                     ` Quentin Lambert
2015-02-05 16:02                     ` Quentin Lambert
2015-02-06  1:49                     ` Stephen Boyd
2015-02-06  1:49                       ` Stephen Boyd
2015-02-06  1:49                       ` Stephen Boyd
2015-02-06  2:15                   ` Stephen Boyd
2015-02-06  2:15                     ` Stephen Boyd
2015-02-06  2:15                     ` Stephen Boyd
2015-02-06  9:01                     ` Quentin Lambert
2015-02-06  9:01                       ` Quentin Lambert
2015-02-06  9:01                       ` Quentin Lambert
2015-02-06  9:12                       ` Julia Lawall
2015-02-06  9:12                         ` Julia Lawall
2015-02-06  9:12                         ` Julia Lawall
2015-02-06 17:15                         ` Stephen Boyd
2015-02-06 17:15                           ` Stephen Boyd
2015-02-06 17:15                           ` Stephen Boyd
2015-02-17 22:01                     ` Stephen Boyd
2015-02-17 22:01                       ` Stephen Boyd
2015-02-17 22:01                       ` Stephen Boyd
2015-03-12 17:20                       ` Sebastian Andrzej Siewior
2015-03-12 17:20                         ` Sebastian Andrzej Siewior
2015-03-12 17:20                         ` Sebastian Andrzej Siewior
2015-03-12 19:43                         ` Stephen Boyd
2015-03-12 19:43                           ` Stephen Boyd
2015-03-12 19:43                           ` Stephen Boyd
2015-03-13  3:29                           ` Shawn Guo
2015-03-13  3:29                             ` Shawn Guo
2015-03-13  3:29                             ` Shawn Guo
2015-03-13  8:20                             ` Sebastian Andrzej Siewior
2015-03-13  8:20                               ` Sebastian Andrzej Siewior
2015-03-13  8:20                               ` Sebastian Andrzej Siewior
2015-03-13 13:42                               ` Shawn Guo
2015-03-13 13:42                                 ` Shawn Guo
2015-03-13 13:42                                 ` Shawn Guo
2015-03-13 17:42                             ` Stephen Boyd
2015-03-13 17:42                               ` Stephen Boyd
2015-03-13 17:42                               ` Stephen Boyd
2015-02-05 19:44   ` Sylwester Nawrocki
2015-02-05 19:44     ` Sylwester Nawrocki
2015-02-05 20:06     ` Sylwester Nawrocki
2015-02-05 20:06       ` Sylwester Nawrocki
2015-02-05 20:07     ` Stephen Boyd
2015-02-05 20:07       ` Stephen Boyd
2015-02-05 22:14       ` Stephen Boyd
2015-02-05 22:14         ` Stephen Boyd
2015-02-06  0:42         ` Russell King - ARM Linux
2015-02-06  0:42           ` Russell King - ARM Linux
2015-02-06  1:35           ` Stephen Boyd
2015-02-06  1:35             ` Stephen Boyd
2015-02-06 13:39             ` Russell King - ARM Linux
2015-02-06 13:39               ` Russell King - ARM Linux
2015-02-06 19:30               ` Stephen Boyd
2015-02-06 19:30                 ` Stephen Boyd
2015-02-06 19:37                 ` Russell King - ARM Linux
2015-02-06 19:37                   ` Russell King - ARM Linux
2015-02-06 19:41                   ` Stephen Boyd
2015-02-06 19:41                     ` Stephen Boyd
2015-02-19 21:32                 ` Mike Turquette
2015-02-19 21:32                   ` Mike Turquette
2015-02-24 14:08                   ` Russell King - ARM Linux
2015-02-24 14:08                     ` Russell King - ARM Linux
2015-02-25  2:18                     ` Mike Turquette
2015-02-25  2:18                       ` Mike Turquette
2015-01-23 11:03 ` [PATCH v13 4/6] clk: Add rate constraints to clocks Tomeu Vizoso
2015-01-23 11:03   ` Tomeu Vizoso
2015-01-23 11:03   ` Tomeu Vizoso
2015-01-29 13:31   ` Geert Uytterhoeven [this message]
2015-01-29 13:31     ` Geert Uytterhoeven
2015-01-29 13:31     ` Geert Uytterhoeven
2015-01-29 13:31     ` Geert Uytterhoeven
2015-01-29 19:13     ` Stephen Boyd
2015-01-29 19:13       ` Stephen Boyd
2015-01-29 19:13       ` Stephen Boyd
2015-01-29 19:13       ` Stephen Boyd
2015-01-31  1:31       ` Stephen Boyd
2015-01-31  1:31         ` Stephen Boyd
2015-01-31  1:31         ` Stephen Boyd
2015-01-31  1:31         ` Stephen Boyd
2015-01-31  1:31         ` Stephen Boyd
2015-01-31 18:36         ` Tomeu Vizoso
2015-01-31 18:36           ` Tomeu Vizoso
2015-01-31 18:36           ` Tomeu Vizoso
2015-01-31 18:36           ` Tomeu Vizoso
2015-01-31 18:36           ` Tomeu Vizoso
2015-02-01 22:18           ` Mike Turquette
2015-02-01 22:18             ` Mike Turquette
2015-02-01 22:18             ` Mike Turquette
2015-02-01 22:18             ` Mike Turquette
2015-02-01 22:18             ` Mike Turquette
2015-02-02  7:59             ` Geert Uytterhoeven
2015-02-02  7:59               ` Geert Uytterhoeven
2015-02-02  7:59               ` Geert Uytterhoeven
2015-02-02  7:59               ` Geert Uytterhoeven
2015-02-02  7:59               ` Geert Uytterhoeven
2015-02-02 16:12               ` Tony Lindgren
2015-02-02 16:12                 ` Tony Lindgren
2015-02-02 16:12                 ` Tony Lindgren
2015-02-02 16:12                 ` Tony Lindgren
2015-02-02 16:12                 ` Tony Lindgren
2015-02-02 17:46                 ` Mike Turquette
2015-02-02 17:46                   ` Mike Turquette
2015-02-02 17:46                   ` Mike Turquette
2015-02-02 17:46                   ` Mike Turquette
2015-02-02 17:46                   ` Mike Turquette
2015-02-02 17:49                   ` Russell King - ARM Linux
2015-02-02 17:49                     ` Russell King - ARM Linux
2015-02-02 17:49                     ` Russell King - ARM Linux
2015-02-02 17:49                     ` Russell King - ARM Linux
2015-02-02 17:49                     ` Russell King - ARM Linux
2015-02-02 19:21                   ` Tony Lindgren
2015-02-02 19:21                     ` Tony Lindgren
2015-02-02 19:21                     ` Tony Lindgren
2015-02-02 19:21                     ` Tony Lindgren
2015-02-02 19:21                     ` Tony Lindgren
2015-02-02 20:47                     ` Tony Lindgren
2015-02-02 20:47                       ` Tony Lindgren
2015-02-02 20:47                       ` Tony Lindgren
2015-02-02 20:47                       ` Tony Lindgren
2015-02-02 20:47                       ` Tony Lindgren
2015-01-23 11:03 ` [PATCH v13 5/6] clkdev: Export clk_register_clkdev Tomeu Vizoso
2015-01-23 11:03   ` Tomeu Vizoso
2015-02-03 17:35   ` Andy Shevchenko
2015-02-03 17:35     ` Andy Shevchenko
2015-02-03 17:43     ` Andy Shevchenko
2015-02-03 17:43       ` Andy Shevchenko
2015-01-23 11:03 ` [PATCH v13 6/6] clk: Add module for unit tests Tomeu Vizoso
2015-01-27  0:55 ` [PATCH v13 0/6] Per-user clock constraints Stephen Boyd
2015-01-27  6:29   ` Tomeu Vizoso
2015-01-28  6:59   ` Tomeu Vizoso
     [not found]     ` <20150129022633.22722.78592@quantum>
2015-01-29  6:41       ` Tomeu Vizoso
2015-01-29 14:29         ` Mike Turquette

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='CAMuHMdUGgA70o2SgdJR3X6AkCcMssHU0POLfzppADT-O=BrYDw@mail.gmail.com' \
    --to=geert@linux-m68k.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    /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.