ARM: mach-shmobile: sh7372 divide-by-zero FSIDIV fix
Magnus Damm
maintainerPATCH 1/1 ARM: mach-shmobile: sh7372 divide-by-zero FSIDIV fix
From: Magnus Damm <[email protected]>
Update the sh7372 FSIDIV clock code to bail out
with -EINVAL in case of rate is zero.
Without this fix divide-by-zero is triggering
on sh7372 platforms during system wide resume
of Suspend-to-RAM.
---
arch/arm/mach-shmobile/clock-sh7372.c | 3 +++ 1 file changed, 3 insertions(+)
arch/arm/mach-shmobile/clock-sh7372.c +3 -0
@@ -460,6 +460,9 @@ static int fsidiv_set_rate(struct clk *c {int idx; +if (!rate) +return -EINVAL ; + idx = (clk->parent->rate / rate) &0xffff ;if (idx <2 )return -EINVAL ;
Quoted 8 lines · Magnus Damm
From: Magnus Damm <[email protected]>
Update the sh7372 FSIDIV clock code to bail out
with-EINVALin case of rate is zero.Without this fix divide-by-zero is triggering
on sh7372 platforms during system wide resume
of Suspend-to-RAM.
Hi Magnus,
I'm unsure that I understand how rate ends up being zero in the situation you describe.
Quoted 24 lines
Signed-off-by Magnus Damm <[email protected]>---
arch/arm/mach-shmobile/clock-sh7372.c | 3 +++ 1 file changed, 3 insertions(+)arch/arm/mach-shmobile/clock-sh7372.c +3
-1@@ -460,6 +460,9 @@ static int fsidiv_set_rate(struct clk *c {int idx; +if (!rate) +return -EINVAL ; + idx = (clk->parent->rate / rate) &0xffff ;if (idx <2 )return -EINVAL ; --To unsubscribe from this list: send the line "unsubscribe linux-sh" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Magnus Damm
maintainerQuoted 6 lines · Simon Horman
Quoted 5 lines · Magnus Damm
From: Magnus Damm <[email protected]>
Update the sh7372 FSIDIV clock code to bail out
with-EINVALin case of rate is zero.
Quoted 8 lines
Quoted 3 lines
Without this fix divide-by-zero is triggering
on sh7372 platforms during system wide resume
of Suspend-to-RAM.Hi Magnus,
I'm unsure that I understand how rate ends up being zero in the situation you describe.
Hi Simon,
During Suspend-to-RAM resume the function clks_core_resume() in drivers/sh/clk/core.c gets executed. This function goes through all clocks and sets their rate. In some cases the rate happens to be zero, and for the FSIDIV the zero turns into a divide-by-zero.
This can easily be triggered by using Suspend-to-RAM on for instance a Mackerel board.
/ magnus
Quoted 16 lines · Magnus Damm
Quoted 6 lines · Simon Horman
Quoted 5 lines · Magnus Damm
From: Magnus Damm <[email protected]>
Update the sh7372 FSIDIV clock code to bail out
with-EINVALin case of rate is zero.Quoted 8 lines
Quoted 3 lines
Without this fix divide-by-zero is triggering
on sh7372 platforms during system wide resume
of Suspend-to-RAM.Hi Magnus,
I'm unsure that I understand how rate ends up being zero in the situation you describe.
Quoted 6 lines
Hi Simon,
During Suspend-to-RAM resume the function
clks_core_resume()indrivers/sh/clk/core.cgets executed. This function goes through all clocks and sets their rate. In some cases the rate happens to be zero, and for the FSIDIV the zero turns into a divide-by-zero.
Ok, understood.