From: Sylwester Nawrocki <s.nawrocki@samsung.com>
To: Vivek Gautam <gautam.vivek@samsung.com>
Cc: rtc-linux@googlegroups.com, linux-kernel@vger.kernel.org,
linux-samsung-soc@vger.kernel.org, a.zummo@towertech.it,
kgene.kim@samsung.com, dianders@chromium.org
Subject: Re: [PATCH RFC] rtc: rtc-s3c: use clk_prepare_enable and clk_disable_unprepare
Date: Tue, 09 Apr 2013 12:09:47 +0200 [thread overview]
Message-ID: <5163E8EB.1050803@samsung.com> (raw)
In-Reply-To: <1365500744-14839-1-git-send-email-gautam.vivek@samsung.com>
On 04/09/2013 11:45 AM, Vivek Gautam wrote:
> Convert clk_enable/clk_disable to clk_prepare_enable/clk_disable_unprepare
> calls as required by common clock framework, to get rid of
> WARN_ON on prepare_count.
Hmm, do you think warnings like below are any better that WARN_ON() on wrong
clock's prepare_count value ? :)
> Signed-off-by: Vivek Gautam <gautam.vivek@samsung.com>
> ---
>
> This fixes the warnings in the boot log coming out of enabling
> the common clock framework in exynos platform.
>
> However, on doing system suspend/resume using rtc wake mechanism
> we still get following warning dump for the first time we suspend
> using commands:
> echo +10 > /sys/class/rtc/rtc0/wakealarm
> echo mem > /sys/power/state
>
> [ 12.530000] ------------[ cut here ]------------
> [ 12.530000] WARNING: at kernel/mutex.c:199 __mutex_lock_slowpath+0x2c0/0x340()
> [ 12.530000] Modules linked in:
> [ 12.530000] [<80014c60>] (unwind_backtrace+0x0/0xf8) from [<8001ebd0>] (warn_slowpath_common+0x54/0x68)
> [ 12.530000] [<8001ebd0>] (warn_slowpath_common+0x54/0x68) from [<8001ec00>] (warn_slowpath_null+0x1c/0x24)
> [ 12.530000] [<8001ec00>] (warn_slowpath_null+0x1c/0x24) from [<8033f548>] (__mutex_lock_slowpath+0x2c0/0x340)
> [ 12.530000] [<8033f548>] (__mutex_lock_slowpath+0x2c0/0x340) from [<8033f5d4>] (mutex_lock+0xc/0x24)
> [ 12.530000] [<8033f5d4>] (mutex_lock+0xc/0x24) from [<80299e18>] (clk_prepare+0x18/0x34)
> [ 12.530000] [<80299e18>] (clk_prepare+0x18/0x34) from [<802862d8>] (s3c_rtc_alarmirq+0x1c/0x98)
> [ 12.530000] [<802862d8>] (s3c_rtc_alarmirq+0x1c/0x98) from [<8006ad78>] (handle_irq_event_percpu+0x54/0x194)
> [ 12.530000] [<8006ad78>] (handle_irq_event_percpu+0x54/0x194) from [<8006aef4>] (handle_irq_event+0x3c/0x5c)
> [ 12.530000] [<8006aef4>] (handle_irq_event+0x3c/0x5c) from [<8006db00>] (handle_fasteoi_irq+0xa4/0x134)
> [ 12.530000] [<8006db00>] (handle_fasteoi_irq+0xa4/0x134) from [<8006a594>] (generic_handle_irq+0x30/0x40)
> [ 12.530000] [<8006a594>] (generic_handle_irq+0x30/0x40) from [<8000f4fc>] (handle_IRQ+0x40/0x90)
> [ 12.530000] [<8000f4fc>] (handle_IRQ+0x40/0x90) from [<80008544>] (gic_handle_irq+0x38/0x68)
> [ 12.530000] [<80008544>] (gic_handle_irq+0x38/0x68) from [<8000e200>] (__irq_svc+0x40/0x70)
> [ 12.530000] Exception stack(0x8182be60 to 0x8182bea8)
> [ 12.530000] be60: 00000000 00000000 0000000c ffffffff 60000013 8049fc50 00000000 80479a10
> [ 12.530000] be80: 60000013 ee97de98 804799c0 00000001 0000000d 8182bea8 803412dc 803412e0
> [ 12.530000] bea0: 60000013 ffffffff
> [ 12.530000] [<8000e200>] (__irq_svc+0x40/0x70) from [<803412e0>] (_raw_spin_unlock_irqrestore+0x10/0x38)
> [ 12.530000] [<803412e0>] (_raw_spin_unlock_irqrestore+0x10/0x38) from [<80070bc4>] (resume_irqs+0x9c/0xb8)
> [ 12.530000] [<80070bc4>] (resume_irqs+0x9c/0xb8) from [<8021d528>] (dpm_resume_start+0xc/0x18)
> [ 12.530000] [<8021d528>] (dpm_resume_start+0xc/0x18) from [<800544ac>] (suspend_devices_and_enter+0x118/0x2e4)
> [ 12.530000] [<800544ac>] (suspend_devices_and_enter+0x118/0x2e4) from [<80054814>] (pm_suspend+0x19c/0x214)
> [ 12.530000] [<80054814>] (pm_suspend+0x19c/0x214) from [<80053a58>] (state_store+0x120/0x12c)
> [ 12.530000] [<80053a58>] (state_store+0x120/0x12c) from [<801ae9d8>] (kobj_attr_store+0x14/0x20)
> [ 12.530000] [<801ae9d8>] (kobj_attr_store+0x14/0x20) from [<801092c8>] (sysfs_write_file+0xfc/0x17c)
> [ 12.530000] [<801092c8>] (sysfs_write_file+0xfc/0x17c) from [<800b0d84>] (vfs_write+0xa8/0x138)
> [ 12.530000] [<800b0d84>] (vfs_write+0xa8/0x138) from [<800b10e4>] (sys_write+0x40/0x68)
> [ 12.530000] [<800b10e4>] (sys_write+0x40/0x68) from [<8000e600>] (ret_fast_syscall+0x0/0x30)
> [ 12.530000] ---[ end trace 8643216fba2e8cb5 ]---
>
> drivers/rtc/rtc-s3c.c | 58 ++++++++++++++++++++++++------------------------
> 1 files changed, 29 insertions(+), 29 deletions(-)
>
> diff --git a/drivers/rtc/rtc-s3c.c b/drivers/rtc/rtc-s3c.c
> index fb994e9..75637ad 100644
> --- a/drivers/rtc/rtc-s3c.c
> +++ b/drivers/rtc/rtc-s3c.c
> @@ -65,12 +65,12 @@ static void s3c_rtc_alarm_clk_enable(bool enable)
> spin_lock_irqsave(&s3c_rtc_alarm_clk_lock, irq_flags);
> if (enable) {
> if (!alarm_clk_enabled) {
> - clk_enable(rtc_clk);
> + clk_prepare_enable(rtc_clk);
> alarm_clk_enabled = true;
> }
> } else {
> if (alarm_clk_enabled) {
> - clk_disable(rtc_clk);
> + clk_disable_unprepare(rtc_clk);
> alarm_clk_enabled = false;
> }
> }
> @@ -83,13 +83,13 @@ static irqreturn_t s3c_rtc_alarmirq(int irq, void *id)
> {
> struct rtc_device *rdev = id;
>
> - clk_enable(rtc_clk);
> + clk_prepare_enable(rtc_clk);
The reason for the above failure is that clk_prepare is called from an interrupt
context. You are not supposed to use clk_prepare_enable()/clk_unprepare_disble()
like this. Instead, prepare the clock in s3c_rtc_probe() and unprepare in the
driver's remove() callback. And clk_enable()/clk_disable calls could stay untouched.
> rtc_update_irq(rdev, 1, RTC_AF | RTC_IRQF);
>
> if (s3c_rtc_cpu_type == TYPE_S3C64XX)
> writeb(S3C2410_INTP_ALM, s3c_rtc_base + S3C2410_INTP);
>
> - clk_disable(rtc_clk);
> + clk_disable_unprepare(rtc_clk);
>
> s3c_rtc_alarm_clk_enable(false);
>
> @@ -100,13 +100,13 @@ static irqreturn_t s3c_rtc_tickirq(int irq, void *id)
> {
> struct rtc_device *rdev = id;
>
> - clk_enable(rtc_clk);
> + clk_prepare_enable(rtc_clk);
> rtc_update_irq(rdev, 1, RTC_PF | RTC_IRQF);
>
> if (s3c_rtc_cpu_type == TYPE_S3C64XX)
> writeb(S3C2410_INTP_TIC, s3c_rtc_base + S3C2410_INTP);
>
> - clk_disable(rtc_clk);
> + clk_disable_unprepare(rtc_clk);
> return IRQ_HANDLED;
> }
Regards,
Sylwester
next prev parent reply other threads:[~2013-04-09 10:09 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-09 9:45 [PATCH RFC] rtc: rtc-s3c: use clk_prepare_enable and clk_disable_unprepare Vivek Gautam
2013-04-09 10:09 ` Sylwester Nawrocki [this message]
2013-04-09 12:51 ` Vivek Gautam
2013-04-09 13:34 ` Vivek Gautam
2013-04-09 13:59 ` Sylwester Nawrocki
2013-04-09 14:20 ` Vivek Gautam
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=5163E8EB.1050803@samsung.com \
--to=s.nawrocki@samsung.com \
--cc=a.zummo@towertech.it \
--cc=dianders@chromium.org \
--cc=gautam.vivek@samsung.com \
--cc=kgene.kim@samsung.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-samsung-soc@vger.kernel.org \
--cc=rtc-linux@googlegroups.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.