Message ID | 1363180067-3698-1-git-send-email-luis.henriques@canonical.com |
---|---|
State | New |
Headers | show |
Luis, On Wed, Mar 13, 2013 at 01:07:47PM +0000, Luis Henriques wrote: > This is a note to let you know that I have just added a patch titled > > rtc: rtc-mv: Add support for clk to avoid lockups > > to the linux-3.5.y-queue branch of the 3.5.y.z extended stable tree > which can be found at: > > http://kernel.ubuntu.com/git?p=ubuntu/linux.git;a=shortlog;h=refs/heads/linux-3.5.y-queue > > If you, or anyone else, feels it should not be added to this tree, please > reply to this email. > > For more information about the 3.5.y.z tree, see > https://wiki.ubuntu.com/Kernel/Dev/ExtendedStable > > Thanks. > -Luis > > ------ > > From 9630368a7116e76efad66622f6d22758b301e8fc Mon Sep 17 00:00:00 2001 > From: Andrew Lunn <andrew@lunn.ch> > Date: Sun, 3 Feb 2013 12:32:06 +0100 > Subject: [PATCH] rtc: rtc-mv: Add support for clk to avoid lockups > > commit 89c58c198b252f2bc20657fdd72a2aea788c435c upstream. > > The Marvell RTC on Kirkwood makes use of the runit clock. Ensure the > driver clk_prepare_enable() this clock, otherwise there is a danger > the SoC will lockup when accessing RTC registers with the clock > disabled. > > Reported-by: Simon Baatz <gmbnomis@gmail.com> > Signed-off-by: Andrew Lunn <andrew@lunn.ch> > Tested-by: Simon Baatz <gmbnomis@gmail.com> > Signed-off-by: Jason Cooper <jason@lakedaemon.net> > Signed-off-by: Luis Henriques <luis.henriques@canonical.com> > --- > arch/arm/boot/dts/kirkwood.dtsi | 1 + > drivers/rtc/rtc-mv.c | 28 ++++++++++++++++++++++++---- > 2 files changed, 25 insertions(+), 4 deletions(-) Please drop this patch from the v3.5.x queue. The Marvell SoCs hadn't converted over to common clock yet. At best this patch is a no-op, at worst, it breaks the kirkwood.dtsi (there is no label &gate_clk yet). thx, Jason. > > diff --git a/arch/arm/boot/dts/kirkwood.dtsi b/arch/arm/boot/dts/kirkwood.dtsi > index 926528b..1c2e72c 100644 > --- a/arch/arm/boot/dts/kirkwood.dtsi > +++ b/arch/arm/boot/dts/kirkwood.dtsi > @@ -31,6 +31,7 @@ > compatible = "mrvl,kirkwood-rtc", "mrvl,orion-rtc"; > reg = <0x10300 0x20>; > interrupts = <53>; > + clocks = <&gate_clk 7>; > }; > > nand@3000000 { > diff --git a/drivers/rtc/rtc-mv.c b/drivers/rtc/rtc-mv.c > index b2185f4..39b213e 100644 > --- a/drivers/rtc/rtc-mv.c > +++ b/drivers/rtc/rtc-mv.c > @@ -14,6 +14,7 @@ > #include <linux/platform_device.h> > #include <linux/of.h> > #include <linux/delay.h> > +#include <linux/clk.h> > #include <linux/gfp.h> > #include <linux/module.h> > > @@ -41,6 +42,7 @@ struct rtc_plat_data { > struct rtc_device *rtc; > void __iomem *ioaddr; > int irq; > + struct clk *clk; > }; > > static int mv_rtc_set_time(struct device *dev, struct rtc_time *tm) > @@ -221,6 +223,7 @@ static int __devinit mv_rtc_probe(struct platform_device *pdev) > struct rtc_plat_data *pdata; > resource_size_t size; > u32 rtc_time; > + int ret = 0; > > res = platform_get_resource(pdev, IORESOURCE_MEM, 0); > if (!res) > @@ -239,11 +242,17 @@ static int __devinit mv_rtc_probe(struct platform_device *pdev) > if (!pdata->ioaddr) > return -ENOMEM; > > + pdata->clk = devm_clk_get(&pdev->dev, NULL); > + /* Not all SoCs require a clock.*/ > + if (!IS_ERR(pdata->clk)) > + clk_prepare_enable(pdata->clk); > + > /* make sure the 24 hours mode is enabled */ > rtc_time = readl(pdata->ioaddr + RTC_TIME_REG_OFFS); > if (rtc_time & RTC_HOURS_12H_MODE) { > dev_err(&pdev->dev, "24 Hours mode not supported.\n"); > - return -EINVAL; > + ret = -EINVAL; > + goto out; > } > > /* make sure it is actually functional */ > @@ -252,7 +261,8 @@ static int __devinit mv_rtc_probe(struct platform_device *pdev) > rtc_time = readl(pdata->ioaddr + RTC_TIME_REG_OFFS); > if (rtc_time == 0x01000000) { > dev_err(&pdev->dev, "internal RTC not ticking\n"); > - return -ENODEV; > + ret = -ENODEV; > + goto out; > } > } > > @@ -268,8 +278,10 @@ static int __devinit mv_rtc_probe(struct platform_device *pdev) > } else > pdata->rtc = rtc_device_register(pdev->name, &pdev->dev, > &mv_rtc_ops, THIS_MODULE); > - if (IS_ERR(pdata->rtc)) > - return PTR_ERR(pdata->rtc); > + if (IS_ERR(pdata->rtc)) { > + ret = PTR_ERR(pdata->rtc); > + goto out; > + } > > if (pdata->irq >= 0) { > writel(0, pdata->ioaddr + RTC_ALARM_INTERRUPT_MASK_REG_OFFS); > @@ -282,6 +294,11 @@ static int __devinit mv_rtc_probe(struct platform_device *pdev) > } > > return 0; > +out: > + if (!IS_ERR(pdata->clk)) > + clk_disable_unprepare(pdata->clk); > + > + return ret; > } > > static int __exit mv_rtc_remove(struct platform_device *pdev) > @@ -292,6 +309,9 @@ static int __exit mv_rtc_remove(struct platform_device *pdev) > device_init_wakeup(&pdev->dev, 0); > > rtc_device_unregister(pdata->rtc); > + if (!IS_ERR(pdata->clk)) > + clk_disable_unprepare(pdata->clk); > + > return 0; > } > > -- > 1.8.1.2 >
On Wed, Mar 13, 2013 at 09:23:30AM -0400, Jason Cooper wrote: > Luis, > > On Wed, Mar 13, 2013 at 01:07:47PM +0000, Luis Henriques wrote: > > This is a note to let you know that I have just added a patch titled > > > > rtc: rtc-mv: Add support for clk to avoid lockups > > > > to the linux-3.5.y-queue branch of the 3.5.y.z extended stable tree > > which can be found at: > > > > http://kernel.ubuntu.com/git?p=ubuntu/linux.git;a=shortlog;h=refs/heads/linux-3.5.y-queue > > > > If you, or anyone else, feels it should not be added to this tree, please > > reply to this email. > > > > For more information about the 3.5.y.z tree, see > > https://wiki.ubuntu.com/Kernel/Dev/ExtendedStable > > > > Thanks. > > -Luis > > > > ------ > > > > From 9630368a7116e76efad66622f6d22758b301e8fc Mon Sep 17 00:00:00 2001 > > From: Andrew Lunn <andrew@lunn.ch> > > Date: Sun, 3 Feb 2013 12:32:06 +0100 > > Subject: [PATCH] rtc: rtc-mv: Add support for clk to avoid lockups > > > > commit 89c58c198b252f2bc20657fdd72a2aea788c435c upstream. > > > > The Marvell RTC on Kirkwood makes use of the runit clock. Ensure the > > driver clk_prepare_enable() this clock, otherwise there is a danger > > the SoC will lockup when accessing RTC registers with the clock > > disabled. > > > > Reported-by: Simon Baatz <gmbnomis@gmail.com> > > Signed-off-by: Andrew Lunn <andrew@lunn.ch> > > Tested-by: Simon Baatz <gmbnomis@gmail.com> > > Signed-off-by: Jason Cooper <jason@lakedaemon.net> > > Signed-off-by: Luis Henriques <luis.henriques@canonical.com> > > --- > > arch/arm/boot/dts/kirkwood.dtsi | 1 + > > drivers/rtc/rtc-mv.c | 28 ++++++++++++++++++++++++---- > > 2 files changed, 25 insertions(+), 4 deletions(-) > > Please drop this patch from the v3.5.x queue. The Marvell SoCs hadn't > converted over to common clock yet. At best this patch is a no-op, at > worst, it breaks the kirkwood.dtsi (there is no label &gate_clk yet). Thank you Jason, I'll drop it. I actually saw your comment regarding this patch for the 3.4 kernel and, after taking a look at the code, it looked like it could be included in 3.5. I was wrong :-) Cheers, -- Luis > > thx, > > Jason. > > > > > diff --git a/arch/arm/boot/dts/kirkwood.dtsi b/arch/arm/boot/dts/kirkwood.dtsi > > index 926528b..1c2e72c 100644 > > --- a/arch/arm/boot/dts/kirkwood.dtsi > > +++ b/arch/arm/boot/dts/kirkwood.dtsi > > @@ -31,6 +31,7 @@ > > compatible = "mrvl,kirkwood-rtc", "mrvl,orion-rtc"; > > reg = <0x10300 0x20>; > > interrupts = <53>; > > + clocks = <&gate_clk 7>; > > }; > > > > nand@3000000 { > > diff --git a/drivers/rtc/rtc-mv.c b/drivers/rtc/rtc-mv.c > > index b2185f4..39b213e 100644 > > --- a/drivers/rtc/rtc-mv.c > > +++ b/drivers/rtc/rtc-mv.c > > @@ -14,6 +14,7 @@ > > #include <linux/platform_device.h> > > #include <linux/of.h> > > #include <linux/delay.h> > > +#include <linux/clk.h> > > #include <linux/gfp.h> > > #include <linux/module.h> > > > > @@ -41,6 +42,7 @@ struct rtc_plat_data { > > struct rtc_device *rtc; > > void __iomem *ioaddr; > > int irq; > > + struct clk *clk; > > }; > > > > static int mv_rtc_set_time(struct device *dev, struct rtc_time *tm) > > @@ -221,6 +223,7 @@ static int __devinit mv_rtc_probe(struct platform_device *pdev) > > struct rtc_plat_data *pdata; > > resource_size_t size; > > u32 rtc_time; > > + int ret = 0; > > > > res = platform_get_resource(pdev, IORESOURCE_MEM, 0); > > if (!res) > > @@ -239,11 +242,17 @@ static int __devinit mv_rtc_probe(struct platform_device *pdev) > > if (!pdata->ioaddr) > > return -ENOMEM; > > > > + pdata->clk = devm_clk_get(&pdev->dev, NULL); > > + /* Not all SoCs require a clock.*/ > > + if (!IS_ERR(pdata->clk)) > > + clk_prepare_enable(pdata->clk); > > + > > /* make sure the 24 hours mode is enabled */ > > rtc_time = readl(pdata->ioaddr + RTC_TIME_REG_OFFS); > > if (rtc_time & RTC_HOURS_12H_MODE) { > > dev_err(&pdev->dev, "24 Hours mode not supported.\n"); > > - return -EINVAL; > > + ret = -EINVAL; > > + goto out; > > } > > > > /* make sure it is actually functional */ > > @@ -252,7 +261,8 @@ static int __devinit mv_rtc_probe(struct platform_device *pdev) > > rtc_time = readl(pdata->ioaddr + RTC_TIME_REG_OFFS); > > if (rtc_time == 0x01000000) { > > dev_err(&pdev->dev, "internal RTC not ticking\n"); > > - return -ENODEV; > > + ret = -ENODEV; > > + goto out; > > } > > } > > > > @@ -268,8 +278,10 @@ static int __devinit mv_rtc_probe(struct platform_device *pdev) > > } else > > pdata->rtc = rtc_device_register(pdev->name, &pdev->dev, > > &mv_rtc_ops, THIS_MODULE); > > - if (IS_ERR(pdata->rtc)) > > - return PTR_ERR(pdata->rtc); > > + if (IS_ERR(pdata->rtc)) { > > + ret = PTR_ERR(pdata->rtc); > > + goto out; > > + } > > > > if (pdata->irq >= 0) { > > writel(0, pdata->ioaddr + RTC_ALARM_INTERRUPT_MASK_REG_OFFS); > > @@ -282,6 +294,11 @@ static int __devinit mv_rtc_probe(struct platform_device *pdev) > > } > > > > return 0; > > +out: > > + if (!IS_ERR(pdata->clk)) > > + clk_disable_unprepare(pdata->clk); > > + > > + return ret; > > } > > > > static int __exit mv_rtc_remove(struct platform_device *pdev) > > @@ -292,6 +309,9 @@ static int __exit mv_rtc_remove(struct platform_device *pdev) > > device_init_wakeup(&pdev->dev, 0); > > > > rtc_device_unregister(pdata->rtc); > > + if (!IS_ERR(pdata->clk)) > > + clk_disable_unprepare(pdata->clk); > > + > > return 0; > > } > > > > -- > > 1.8.1.2 > >
On Wed, Mar 13, 2013 at 01:45:36PM +0000, Luis Henriques wrote: > On Wed, Mar 13, 2013 at 09:23:30AM -0400, Jason Cooper wrote: > > Luis, > > > > On Wed, Mar 13, 2013 at 01:07:47PM +0000, Luis Henriques wrote: > > > This is a note to let you know that I have just added a patch titled > > > > > > rtc: rtc-mv: Add support for clk to avoid lockups > > > > > > to the linux-3.5.y-queue branch of the 3.5.y.z extended stable tree > > > which can be found at: > > > > > > http://kernel.ubuntu.com/git?p=ubuntu/linux.git;a=shortlog;h=refs/heads/linux-3.5.y-queue > > > > > > If you, or anyone else, feels it should not be added to this tree, please > > > reply to this email. > > > > > > For more information about the 3.5.y.z tree, see > > > https://wiki.ubuntu.com/Kernel/Dev/ExtendedStable > > > > > > Thanks. > > > -Luis > > > > > > ------ > > > > > > From 9630368a7116e76efad66622f6d22758b301e8fc Mon Sep 17 00:00:00 2001 > > > From: Andrew Lunn <andrew@lunn.ch> > > > Date: Sun, 3 Feb 2013 12:32:06 +0100 > > > Subject: [PATCH] rtc: rtc-mv: Add support for clk to avoid lockups > > > > > > commit 89c58c198b252f2bc20657fdd72a2aea788c435c upstream. > > > > > > The Marvell RTC on Kirkwood makes use of the runit clock. Ensure the > > > driver clk_prepare_enable() this clock, otherwise there is a danger > > > the SoC will lockup when accessing RTC registers with the clock > > > disabled. > > > > > > Reported-by: Simon Baatz <gmbnomis@gmail.com> > > > Signed-off-by: Andrew Lunn <andrew@lunn.ch> > > > Tested-by: Simon Baatz <gmbnomis@gmail.com> > > > Signed-off-by: Jason Cooper <jason@lakedaemon.net> > > > Signed-off-by: Luis Henriques <luis.henriques@canonical.com> > > > --- > > > arch/arm/boot/dts/kirkwood.dtsi | 1 + > > > drivers/rtc/rtc-mv.c | 28 ++++++++++++++++++++++++---- > > > 2 files changed, 25 insertions(+), 4 deletions(-) > > > > Please drop this patch from the v3.5.x queue. The Marvell SoCs hadn't > > converted over to common clock yet. At best this patch is a no-op, at > > worst, it breaks the kirkwood.dtsi (there is no label &gate_clk yet). > > Thank you Jason, I'll drop it. I actually saw your comment regarding > this patch for the 3.4 kernel and, after taking a look at the code, it > looked like it could be included in 3.5. I was wrong :-) No problem. Thanks for getting to these so quickly. thx, Jason.
diff --git a/arch/arm/boot/dts/kirkwood.dtsi b/arch/arm/boot/dts/kirkwood.dtsi index 926528b..1c2e72c 100644 --- a/arch/arm/boot/dts/kirkwood.dtsi +++ b/arch/arm/boot/dts/kirkwood.dtsi @@ -31,6 +31,7 @@ compatible = "mrvl,kirkwood-rtc", "mrvl,orion-rtc"; reg = <0x10300 0x20>; interrupts = <53>; + clocks = <&gate_clk 7>; }; nand@3000000 { diff --git a/drivers/rtc/rtc-mv.c b/drivers/rtc/rtc-mv.c index b2185f4..39b213e 100644 --- a/drivers/rtc/rtc-mv.c +++ b/drivers/rtc/rtc-mv.c @@ -14,6 +14,7 @@ #include <linux/platform_device.h> #include <linux/of.h> #include <linux/delay.h> +#include <linux/clk.h> #include <linux/gfp.h> #include <linux/module.h> @@ -41,6 +42,7 @@ struct rtc_plat_data { struct rtc_device *rtc; void __iomem *ioaddr; int irq; + struct clk *clk; }; static int mv_rtc_set_time(struct device *dev, struct rtc_time *tm) @@ -221,6 +223,7 @@ static int __devinit mv_rtc_probe(struct platform_device *pdev) struct rtc_plat_data *pdata; resource_size_t size; u32 rtc_time; + int ret = 0; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) @@ -239,11 +242,17 @@ static int __devinit mv_rtc_probe(struct platform_device *pdev) if (!pdata->ioaddr) return -ENOMEM; + pdata->clk = devm_clk_get(&pdev->dev, NULL); + /* Not all SoCs require a clock.*/ + if (!IS_ERR(pdata->clk)) + clk_prepare_enable(pdata->clk); + /* make sure the 24 hours mode is enabled */ rtc_time = readl(pdata->ioaddr + RTC_TIME_REG_OFFS); if (rtc_time & RTC_HOURS_12H_MODE) { dev_err(&pdev->dev, "24 Hours mode not supported.\n"); - return -EINVAL; + ret = -EINVAL; + goto out; } /* make sure it is actually functional */ @@ -252,7 +261,8 @@ static int __devinit mv_rtc_probe(struct platform_device *pdev) rtc_time = readl(pdata->ioaddr + RTC_TIME_REG_OFFS); if (rtc_time == 0x01000000) { dev_err(&pdev->dev, "internal RTC not ticking\n"); - return -ENODEV; + ret = -ENODEV; + goto out; } } @@ -268,8 +278,10 @@ static int __devinit mv_rtc_probe(struct platform_device *pdev) } else pdata->rtc = rtc_device_register(pdev->name, &pdev->dev, &mv_rtc_ops, THIS_MODULE); - if (IS_ERR(pdata->rtc)) - return PTR_ERR(pdata->rtc); + if (IS_ERR(pdata->rtc)) { + ret = PTR_ERR(pdata->rtc); + goto out; + } if (pdata->irq >= 0) { writel(0, pdata->ioaddr + RTC_ALARM_INTERRUPT_MASK_REG_OFFS); @@ -282,6 +294,11 @@ static int __devinit mv_rtc_probe(struct platform_device *pdev) } return 0; +out: + if (!IS_ERR(pdata->clk)) + clk_disable_unprepare(pdata->clk); + + return ret; } static int __exit mv_rtc_remove(struct platform_device *pdev) @@ -292,6 +309,9 @@ static int __exit mv_rtc_remove(struct platform_device *pdev) device_init_wakeup(&pdev->dev, 0); rtc_device_unregister(pdata->rtc); + if (!IS_ERR(pdata->clk)) + clk_disable_unprepare(pdata->clk); + return 0; }