RE: [PATCH v3] ARM: Samsung: fix watchdog reset issue with clk_get()
Marek Szyprowski wrote: clkdev framework uses global mutex to protect clock tree, so it is not possible to call clk_get() in interrupt context. This patch fixes this issue and makes system reset by watchdog call working again. Signed-off-by: Marek Szyprowski m.szyprow...@samsung.com Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com --- arch/arm/plat-samsung/clock.c | 11 +++ arch/arm/plat-samsung/include/plat/clock.h |3 +++ .../arm/plat-samsung/include/plat/watchdog-reset.h | 10 +++--- 3 files changed, 17 insertions(+), 7 deletions(-) history: v3: - moved initialization to arch_initcall, cleaned the code v2: - added missing '__init' section modifiers diff --git a/arch/arm/plat-samsung/clock.c b/arch/arm/plat-samsung/clock.c index 302c426..3b44519 100644 --- a/arch/arm/plat-samsung/clock.c +++ b/arch/arm/plat-samsung/clock.c @@ -64,6 +64,17 @@ static LIST_HEAD(clocks); */ DEFINE_SPINLOCK(clocks_lock); +/* Global watchdog clock used by arch_wtd_reset() callback */ +struct clk *s3c2410_wdtclk; +static int __init s3c_wdt_reset_init(void) +{ + s3c2410_wdtclk = clk_get(NULL, watchdog); + if (IS_ERR(s3c2410_wdtclk)) + printk(KERN_WARNING %s: warning: cannot get watchdog clock\n, __func__); + return 0; +} +arch_initcall(s3c_wdt_reset_init); + /* enable and disable calls for use with the clk struct */ static int clk_null_enable(struct clk *clk, int enable) diff --git a/arch/arm/plat-samsung/include/plat/clock.h b/arch/arm/plat- samsung/include/plat/clock.h index 87d5b38..8f95700 100644 --- a/arch/arm/plat-samsung/include/plat/clock.h +++ b/arch/arm/plat-samsung/include/plat/clock.h @@ -121,3 +121,6 @@ extern int s3c64xx_sclk_ctrl(struct clk *clk, int enable); extern void s3c_pwmclk_init(void); +/* Global watchdog clock used by arch_wtd_reset() callback */ + +extern struct clk *s3c2410_wdtclk; diff --git a/arch/arm/plat-samsung/include/plat/watchdog-reset.h b/arch/arm/plat- samsung/include/plat/watchdog-reset.h index 54b762a..40dbb2b 100644 --- a/arch/arm/plat-samsung/include/plat/watchdog-reset.h +++ b/arch/arm/plat-samsung/include/plat/watchdog-reset.h @@ -10,6 +10,7 @@ * published by the Free Software Foundation. */ +#include plat/clock.h #include plat/regs-watchdog.h #include mach/map.h @@ -19,17 +20,12 @@ static inline void arch_wdt_reset(void) { - struct clk *wdtclk; - printk(arch_reset: attempting watchdog reset\n); __raw_writel(0, S3C2410_WTCON); /* disable watchdog, to be safe */ - wdtclk = clk_get(NULL, watchdog); - if (!IS_ERR(wdtclk)) { - clk_enable(wdtclk); - } else - printk(KERN_WARNING %s: warning: cannot get watchdog clock\n, __func__); + if (s3c2410_wdtclk) + clk_enable(s3c2410_wdtclk); /* put initial values into count and data */ __raw_writel(0x80, S3C2410_WTCNT); -- 1.7.1.569.g6f426 Looks ok to me, applied. Thanks. Best regards, Kgene. -- Kukjin Kim kgene@samsung.com, Senior Engineer, SW Solution Development Team, Samsung Electronics Co., Ltd. -- To unsubscribe from this list: send the line unsubscribe linux-samsung-soc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v3] ARM: Samsung: fix watchdog reset issue with clk_get()
Hi Kyungmin, On Friday 19 August 2011 04:14 PM, Kyungmin Park wrote: Interesting. there's no s5p_reset_hook at exynos4. Anyway, after implement the s5p_reset_hook, it's working without hacking of v7-fin. Thanks for the pointer. After adding s5p_reset_hook, tested soft-reboot successfully on ORIGEN. Send it another mail. Thank you, Kyungmin Park -- Tushar Behera -- To unsubscribe from this list: send the line unsubscribe linux-samsung-soc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v3] ARM: Samsung: fix watchdog reset issue with clk_get()
Hi, On Thursday 18 August 2011 03:55 PM, Marek Szyprowski wrote: clkdev framework uses global mutex to protect clock tree, so it is not possible to call clk_get() in interrupt context. This patch fixes this issue and makes system reset by watchdog call working again. Signed-off-by: Marek Szyprowskim.szyprow...@samsung.com Signed-off-by: Kyungmin Parkkyungmin.p...@samsung.com --- arch/arm/plat-samsung/clock.c | 11 +++ arch/arm/plat-samsung/include/plat/clock.h |3 +++ .../arm/plat-samsung/include/plat/watchdog-reset.h | 10 +++--- 3 files changed, 17 insertions(+), 7 deletions(-) history: v3: - moved initialization to arch_initcall, cleaned the code v2: - added missing '__init' section modifiers (snip) I tried to test this patch with ORIGEN board. I took the ORIGEN board support patch from kgene's next-samsung-board-v3.1 branch and rebased it onto the for-next branch for testing. The system reboot stops at a message saying Restarting system and hangs. However applying below patch reboots the system without even applying Marek's patch. Is there something wrong with mach-origen.c or u-boot [1]? [1] git://git.linaro.org/people/angus/u-boot.git (origen) From: Tushar Behera tushar.beh...@linaro.org Date: Fri, 19 Aug 2011 14:47:04 +0530 Subject: [PATCH] [TEST] ARM: Disabling cache operation during system reset On ORIGEN/SMDKV310 board, system reboot hangs during cache disabling call in arm_machine_restart()=cpu_proc_fin(). Applying given patch enables the system to reboot properly. This patch is no way a proposed solution. It is intended for further investigation. Signed-off-by: Tushar Behera tushar.beh...@linaro.org --- arch/arm/mm/proc-v7.S |2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/arch/arm/mm/proc-v7.S b/arch/arm/mm/proc-v7.S index a30e785..1bffc35 100644 --- a/arch/arm/mm/proc-v7.S +++ b/arch/arm/mm/proc-v7.S @@ -43,10 +43,12 @@ ENTRY(cpu_v7_proc_init) ENDPROC(cpu_v7_proc_init) ENTRY(cpu_v7_proc_fin) +#if 0 mrc p15, 0, r0, c1, c0, 0 @ ctrl register bic r0, r0, #0x1000 @ ...i bic r0, r0, #0x0006 @ .ca. mcr p15, 0, r0, c1, c0, 0 @ disable caches +#endif mov pc, lr ENDPROC(cpu_v7_proc_fin) -- 1.7.4.1 -- Tushar Behera -- To unsubscribe from this list: send the line unsubscribe linux-samsung-soc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
RE: [PATCH v3] ARM: Samsung: fix watchdog reset issue with clk_get()
Hello, On Friday, August 19, 2011 11:38 AM Tushar Behera wrote: Hi, On Thursday 18 August 2011 03:55 PM, Marek Szyprowski wrote: clkdev framework uses global mutex to protect clock tree, so it is not possible to call clk_get() in interrupt context. This patch fixes this issue and makes system reset by watchdog call working again. Signed-off-by: Marek Szyprowskim.szyprow...@samsung.com Signed-off-by: Kyungmin Parkkyungmin.p...@samsung.com --- arch/arm/plat-samsung/clock.c | 11 +++ arch/arm/plat-samsung/include/plat/clock.h |3 +++ .../arm/plat-samsung/include/plat/watchdog-reset.h | 10 +++--- 3 files changed, 17 insertions(+), 7 deletions(-) history: v3: - moved initialization to arch_initcall, cleaned the code v2: - added missing '__init' section modifiers (snip) I tried to test this patch with ORIGEN board. I took the ORIGEN board support patch from kgene's next-samsung-board-v3.1 branch and rebased it onto the for-next branch for testing. The system reboot stops at a message saying Restarting system and hangs. However applying below patch reboots the system without even applying Marek's patch. Is there something wrong with mach-origen.c or u-boot [1]? [1] git://git.linaro.org/people/angus/u-boot.git (origen) From: Tushar Behera tushar.beh...@linaro.org Date: Fri, 19 Aug 2011 14:47:04 +0530 Subject: [PATCH] [TEST] ARM: Disabling cache operation during system reset On ORIGEN/SMDKV310 board, system reboot hangs during cache disabling call in arm_machine_restart()=cpu_proc_fin(). Applying given patch enables the system to reboot properly. This patch is no way a proposed solution. It is intended for further investigation. My patch solves the following issue on all Samsung platforms: [ 32.636689] SysRq : Resetting [ 32.638319] arch_reset: attempting watchdog reset [ 32.642864] BUG: sleeping function called from invalid context at kernel/mutex.c:271 [ 32.650589] in_atomic(): 1, irqs_disabled(): 128, pid: 0, name: swapper [ 32.657183] INFO: lockdep is turned off. [ 32.661090] irq event stamp: 6363 [ 32.664388] hardirqs last enabled at (6363): [c0395ae4] _raw_spin_unlock_irq+0x24/0x50 [ 32.672547] hardirqs last disabled at (6362): [c0395370] _raw_spin_lock_irq+0x18/0x58 [ 32.680532] softirqs last enabled at (6358): [c002d4f0] irq_exit+0x58/0x68 [ 32.687650] softirqs last disabled at (6291): [c002d4f0] irq_exit+0x58/0x68 [ 32.694782] [c0012fd0] (unwind_backtrace+0x0/0xf0) from [c03942e0] (mutex_lock_nested+0x30/0x324) [ 32.703980] [c03942e0] (mutex_lock_nested+0x30/0x324) from [c0280d2c] (clk_get_sys+0x28/0xd0) [ 32.712834] [c0280d2c] (clk_get_sys+0x28/0xd0) from [c000f0a0] (arm_machine_restart+0x68/0x120) [ 32.721859] [c000f0a0] (arm_machine_restart+0x68/0x120) from [c000ea38] (machine_restart+0x18/0x20) [ 32.731233] [c000ea38] (machine_restart+0x18/0x20) from [c01c475c] (__handle_sysrq+0xc0/0x16c) [ 32.740175] [c01c475c] (__handle_sysrq+0xc0/0x16c) from [c01d7c50] (s3c24xx_serial_rx_chars+0x1c0/0x2d0) [ 32.749985] [c01d7c50] (s3c24xx_serial_rx_chars+0x1c0/0x2d0) from [c005f3ac] (handle_irq_event_percpu+0x30/0x178) [ 32.760572] [c005f3ac] (handle_irq_event_percpu+0x30/0x178) from [c005f530] (handle_irq_event+0x3c/0x5c) [ 32.770380] [c005f530] (handle_irq_event+0x3c/0x5c) from [c00615bc] (handle_level_irq+0xc4/0xf4) [ 32.779494] [c00615bc] (handle_level_irq+0xc4/0xf4) from [c005f0a0] (generic_handle_irq+0x28/0x3c) [ 32.788782] [c005f0a0] (generic_handle_irq+0x28/0x3c) from [c001cf24] (s3c_irq_demux_uart+0x68/0xc0) [ 32.798242] [c001cf24] (s3c_irq_demux_uart+0x68/0xc0) from [c005f0a0] (generic_handle_irq+0x28/0x3c) [ 32.807704] [c005f0a0] (generic_handle_irq+0x28/0x3c) from [c000e94c] (handle_IRQ+0x60/0x84) [ 32.816470] [c000e94c] (handle_IRQ+0x60/0x84) from [c000d58c] (__irq_svc+0x4c/0xb0) [ 32.824457] [c000d58c] (__irq_svc+0x4c/0xb0) from [c001a2a0] (exynos4_idle+0x28/0x2c) [ 32.832615] [c001a2a0] (exynos4_idle+0x28/0x2c) from [c000efe8] (cpu_idle+0x48/0x98) [ 32.840689] [c000efe8] (cpu_idle+0x48/0x98) from [c04ca740] (start_kernel+0x268PMIC:ONOFF1 (LSB=LDO5):0 It looks that there is at least one more issue related to system reset call, which is fixed or worked around by your patch. Best regards -- Marek Szyprowski Samsung Poland RD Center -- To unsubscribe from this list: send the line unsubscribe linux-samsung-soc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v3] ARM: Samsung: fix watchdog reset issue with clk_get()
Interesting. there's no s5p_reset_hook at exynos4. Anyway, after implement the s5p_reset_hook, it's working without hacking of v7-fin. Send it another mail. Thank you, Kyungmin Park On Fri, Aug 19, 2011 at 7:25 PM, Marek Szyprowski m.szyprow...@samsung.com wrote: Hello, On Friday, August 19, 2011 11:38 AM Tushar Behera wrote: Hi, On Thursday 18 August 2011 03:55 PM, Marek Szyprowski wrote: clkdev framework uses global mutex to protect clock tree, so it is not possible to call clk_get() in interrupt context. This patch fixes this issue and makes system reset by watchdog call working again. Signed-off-by: Marek Szyprowskim.szyprow...@samsung.com Signed-off-by: Kyungmin Parkkyungmin.p...@samsung.com --- arch/arm/plat-samsung/clock.c | 11 +++ arch/arm/plat-samsung/include/plat/clock.h | 3 +++ .../arm/plat-samsung/include/plat/watchdog-reset.h | 10 +++--- 3 files changed, 17 insertions(+), 7 deletions(-) history: v3: - moved initialization to arch_initcall, cleaned the code v2: - added missing '__init' section modifiers (snip) I tried to test this patch with ORIGEN board. I took the ORIGEN board support patch from kgene's next-samsung-board-v3.1 branch and rebased it onto the for-next branch for testing. The system reboot stops at a message saying Restarting system and hangs. However applying below patch reboots the system without even applying Marek's patch. Is there something wrong with mach-origen.c or u-boot [1]? [1] git://git.linaro.org/people/angus/u-boot.git (origen) From: Tushar Behera tushar.beh...@linaro.org Date: Fri, 19 Aug 2011 14:47:04 +0530 Subject: [PATCH] [TEST] ARM: Disabling cache operation during system reset On ORIGEN/SMDKV310 board, system reboot hangs during cache disabling call in arm_machine_restart()=cpu_proc_fin(). Applying given patch enables the system to reboot properly. This patch is no way a proposed solution. It is intended for further investigation. My patch solves the following issue on all Samsung platforms: [ 32.636689] SysRq : Resetting [ 32.638319] arch_reset: attempting watchdog reset [ 32.642864] BUG: sleeping function called from invalid context at kernel/mutex.c:271 [ 32.650589] in_atomic(): 1, irqs_disabled(): 128, pid: 0, name: swapper [ 32.657183] INFO: lockdep is turned off. [ 32.661090] irq event stamp: 6363 [ 32.664388] hardirqs last enabled at (6363): [c0395ae4] _raw_spin_unlock_irq+0x24/0x50 [ 32.672547] hardirqs last disabled at (6362): [c0395370] _raw_spin_lock_irq+0x18/0x58 [ 32.680532] softirqs last enabled at (6358): [c002d4f0] irq_exit+0x58/0x68 [ 32.687650] softirqs last disabled at (6291): [c002d4f0] irq_exit+0x58/0x68 [ 32.694782] [c0012fd0] (unwind_backtrace+0x0/0xf0) from [c03942e0] (mutex_lock_nested+0x30/0x324) [ 32.703980] [c03942e0] (mutex_lock_nested+0x30/0x324) from [c0280d2c] (clk_get_sys+0x28/0xd0) [ 32.712834] [c0280d2c] (clk_get_sys+0x28/0xd0) from [c000f0a0] (arm_machine_restart+0x68/0x120) [ 32.721859] [c000f0a0] (arm_machine_restart+0x68/0x120) from [c000ea38] (machine_restart+0x18/0x20) [ 32.731233] [c000ea38] (machine_restart+0x18/0x20) from [c01c475c] (__handle_sysrq+0xc0/0x16c) [ 32.740175] [c01c475c] (__handle_sysrq+0xc0/0x16c) from [c01d7c50] (s3c24xx_serial_rx_chars+0x1c0/0x2d0) [ 32.749985] [c01d7c50] (s3c24xx_serial_rx_chars+0x1c0/0x2d0) from [c005f3ac] (handle_irq_event_percpu+0x30/0x178) [ 32.760572] [c005f3ac] (handle_irq_event_percpu+0x30/0x178) from [c005f530] (handle_irq_event+0x3c/0x5c) [ 32.770380] [c005f530] (handle_irq_event+0x3c/0x5c) from [c00615bc] (handle_level_irq+0xc4/0xf4) [ 32.779494] [c00615bc] (handle_level_irq+0xc4/0xf4) from [c005f0a0] (generic_handle_irq+0x28/0x3c) [ 32.788782] [c005f0a0] (generic_handle_irq+0x28/0x3c) from [c001cf24] (s3c_irq_demux_uart+0x68/0xc0) [ 32.798242] [c001cf24] (s3c_irq_demux_uart+0x68/0xc0) from [c005f0a0] (generic_handle_irq+0x28/0x3c) [ 32.807704] [c005f0a0] (generic_handle_irq+0x28/0x3c) from [c000e94c] (handle_IRQ+0x60/0x84) [ 32.816470] [c000e94c] (handle_IRQ+0x60/0x84) from [c000d58c] (__irq_svc+0x4c/0xb0) [ 32.824457] [c000d58c] (__irq_svc+0x4c/0xb0) from [c001a2a0] (exynos4_idle+0x28/0x2c) [ 32.832615] [c001a2a0] (exynos4_idle+0x28/0x2c) from [c000efe8] (cpu_idle+0x48/0x98) [ 32.840689] [c000efe8] (cpu_idle+0x48/0x98) from [c04ca740] (start_kernel+0x268PMIC:ONOFF1 (LSB=LDO5):0 It looks that there is at least one more issue related to system reset call, which is fixed or worked around by your patch. Best regards -- Marek Szyprowski Samsung Poland RD Center -- To unsubscribe from this list: send the line unsubscribe linux-samsung-soc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html -- To unsubscribe from this list: send the line unsubscribe
RE: [PATCH v3] ARM: Samsung: fix watchdog reset issue with clk_get()
Marek Szyprowski wrote: clkdev framework uses global mutex to protect clock tree, so it is not possible to call clk_get() in interrupt context. This patch fixes this issue and makes system reset by watchdog call working again. Signed-off-by: Marek Szyprowski m.szyprow...@samsung.com Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com --- arch/arm/plat-samsung/clock.c | 11 +++ arch/arm/plat-samsung/include/plat/clock.h |3 +++ .../arm/plat-samsung/include/plat/watchdog-reset.h | 10 +++--- 3 files changed, 17 insertions(+), 7 deletions(-) history: v3: - moved initialization to arch_initcall, cleaned the code v2: - added missing '__init' section modifiers diff --git a/arch/arm/plat-samsung/clock.c b/arch/arm/plat-samsung/clock.c index 302c426..3b44519 100644 --- a/arch/arm/plat-samsung/clock.c +++ b/arch/arm/plat-samsung/clock.c @@ -64,6 +64,17 @@ static LIST_HEAD(clocks); */ DEFINE_SPINLOCK(clocks_lock); +/* Global watchdog clock used by arch_wtd_reset() callback */ +struct clk *s3c2410_wdtclk; +static int __init s3c_wdt_reset_init(void) +{ + s3c2410_wdtclk = clk_get(NULL, watchdog); + if (IS_ERR(s3c2410_wdtclk)) + printk(KERN_WARNING %s: warning: cannot get watchdog clock\n, __func__); + return 0; +} +arch_initcall(s3c_wdt_reset_init); + /* enable and disable calls for use with the clk struct */ static int clk_null_enable(struct clk *clk, int enable) diff --git a/arch/arm/plat-samsung/include/plat/clock.h b/arch/arm/plat- samsung/include/plat/clock.h index 87d5b38..8f95700 100644 --- a/arch/arm/plat-samsung/include/plat/clock.h +++ b/arch/arm/plat-samsung/include/plat/clock.h @@ -121,3 +121,6 @@ extern int s3c64xx_sclk_ctrl(struct clk *clk, int enable); extern void s3c_pwmclk_init(void); +/* Global watchdog clock used by arch_wtd_reset() callback */ + +extern struct clk *s3c2410_wdtclk; diff --git a/arch/arm/plat-samsung/include/plat/watchdog-reset.h b/arch/arm/plat- samsung/include/plat/watchdog-reset.h index 54b762a..40dbb2b 100644 --- a/arch/arm/plat-samsung/include/plat/watchdog-reset.h +++ b/arch/arm/plat-samsung/include/plat/watchdog-reset.h @@ -10,6 +10,7 @@ * published by the Free Software Foundation. */ +#include plat/clock.h #include plat/regs-watchdog.h #include mach/map.h @@ -19,17 +20,12 @@ static inline void arch_wdt_reset(void) { - struct clk *wdtclk; - printk(arch_reset: attempting watchdog reset\n); __raw_writel(0, S3C2410_WTCON); /* disable watchdog, to be safe */ - wdtclk = clk_get(NULL, watchdog); - if (!IS_ERR(wdtclk)) { - clk_enable(wdtclk); - } else - printk(KERN_WARNING %s: warning: cannot get watchdog clock\n, __func__); + if (s3c2410_wdtclk) + clk_enable(s3c2410_wdtclk); /* put initial values into count and data */ __raw_writel(0x80, S3C2410_WTCNT); -- 1.7.1.569.g6f426 Looks good but happens following: Hmm... With s3c2410_defconfig: In file included from arch/arm/plat-s3c24xx/cpu.c:48: arch/arm/plat-samsung/include/plat/clock.h:32: error: redefinition of 'struct clk_ops' arch/arm/plat-samsung/include/plat/clock.h:39: error: redefinition of 'struct clk' arch/arm/plat-samsung/include/plat/clock.h:60: error: conflicting types for 's3c24xx_dclk0' arch/arm/plat-samsung/include/plat/clock.h:60: note: previous declaration of 's3c24xx_dclk0' was here arch/arm/plat-samsung/include/plat/clock.h:61: error: conflicting types for 's3c24xx_dclk1' arch/arm/plat-samsung/include/plat/clock.h:61: note: previous declaration of 's3c24xx_dclk1' was here arch/arm/plat-samsung/include/plat/clock.h:62: error: conflicting types for 's3c24xx_clkout0' arch/arm/plat-samsung/include/plat/clock.h:62: note: previous declaration of 's3c24xx_clkout0' was here (snip) arch/arm/plat-samsung/include/plat/clock.h:101: error: conflicting types for 's3c_disable_clocks' arch/arm/plat-samsung/include/plat/clock.h:101: note: previous declaration of 's3c_disable_clocks' was here arch/arm/plat-samsung/include/plat/clock.h:118: error: conflicting types for 's3c64xx_sclk_ctrl' arch/arm/plat-samsung/include/plat/clock.h:118: note: previous declaration of 's3c64xx_sclk_ctrl' was here arch/arm/plat-samsung/include/plat/clock.h:126: error: conflicting types for 's3c2410_wdtclk' arch/arm/plat-samsung/include/plat/clock.h:126: note: previous declaration of 's3c2410_wdtclk' was here make[1]: *** [arch/arm/plat-s3c24xx/cpu.o] Error 1 make[1]: *** Waiting for unfinished jobs make: *** [arch/arm/plat-s3c24xx] Error 2 make: *** Waiting for unfinished jobs And, with s5p64x0_defconfig: CHK include/linux/version.h CHK include/generated/utsrelease.h make[1]: `include/generated/mach-types.h' is up to date. CALLscripts/checksyscalls.sh CHK include/generated/compile.h KSYM.tmp_kallsyms1.S AS .tmp_kallsyms1.o LD
RE: [PATCH v3] ARM: Samsung: fix watchdog reset issue with clk_get()
Hello, On Friday, August 19, 2011 3:06 PM Kukjin Kim wrote: Marek Szyprowski wrote: clkdev framework uses global mutex to protect clock tree, so it is not possible to call clk_get() in interrupt context. This patch fixes this issue and makes system reset by watchdog call working again. Signed-off-by: Marek Szyprowski m.szyprow...@samsung.com Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com --- arch/arm/plat-samsung/clock.c | 11 +++ arch/arm/plat-samsung/include/plat/clock.h |3 +++ .../arm/plat-samsung/include/plat/watchdog-reset.h | 10 +++--- 3 files changed, 17 insertions(+), 7 deletions(-) history: v3: - moved initialization to arch_initcall, cleaned the code v2: - added missing '__init' section modifiers diff --git a/arch/arm/plat-samsung/clock.c b/arch/arm/plat-samsung/clock.c index 302c426..3b44519 100644 --- a/arch/arm/plat-samsung/clock.c +++ b/arch/arm/plat-samsung/clock.c @@ -64,6 +64,17 @@ static LIST_HEAD(clocks); */ DEFINE_SPINLOCK(clocks_lock); +/* Global watchdog clock used by arch_wtd_reset() callback */ +struct clk *s3c2410_wdtclk; +static int __init s3c_wdt_reset_init(void) +{ + s3c2410_wdtclk = clk_get(NULL, watchdog); + if (IS_ERR(s3c2410_wdtclk)) + printk(KERN_WARNING %s: warning: cannot get watchdog clock\n, __func__); + return 0; +} +arch_initcall(s3c_wdt_reset_init); + /* enable and disable calls for use with the clk struct */ static int clk_null_enable(struct clk *clk, int enable) diff --git a/arch/arm/plat-samsung/include/plat/clock.h b/arch/arm/plat- samsung/include/plat/clock.h index 87d5b38..8f95700 100644 --- a/arch/arm/plat-samsung/include/plat/clock.h +++ b/arch/arm/plat-samsung/include/plat/clock.h @@ -121,3 +121,6 @@ extern int s3c64xx_sclk_ctrl(struct clk *clk, int enable); extern void s3c_pwmclk_init(void); +/* Global watchdog clock used by arch_wtd_reset() callback */ + +extern struct clk *s3c2410_wdtclk; diff --git a/arch/arm/plat-samsung/include/plat/watchdog-reset.h b/arch/arm/plat- samsung/include/plat/watchdog-reset.h index 54b762a..40dbb2b 100644 --- a/arch/arm/plat-samsung/include/plat/watchdog-reset.h +++ b/arch/arm/plat-samsung/include/plat/watchdog-reset.h @@ -10,6 +10,7 @@ * published by the Free Software Foundation. */ +#include plat/clock.h #include plat/regs-watchdog.h #include mach/map.h @@ -19,17 +20,12 @@ static inline void arch_wdt_reset(void) { - struct clk *wdtclk; - printk(arch_reset: attempting watchdog reset\n); __raw_writel(0, S3C2410_WTCON); /* disable watchdog, to be safe */ - wdtclk = clk_get(NULL, watchdog); - if (!IS_ERR(wdtclk)) { - clk_enable(wdtclk); - } else - printk(KERN_WARNING %s: warning: cannot get watchdog clock\n, __func__); + if (s3c2410_wdtclk) + clk_enable(s3c2410_wdtclk); /* put initial values into count and data */ __raw_writel(0x80, S3C2410_WTCNT); -- 1.7.1.569.g6f426 Looks good but happens following: Hmm... With s3c2410_defconfig: In file included from arch/arm/plat-s3c24xx/cpu.c:48: arch/arm/plat-samsung/include/plat/clock.h:32: error: redefinition of 'struct clk_ops' arch/arm/plat-samsung/include/plat/clock.h:39: error: redefinition of 'struct clk' arch/arm/plat-samsung/include/plat/clock.h:60: error: conflicting types for 's3c24xx_dclk0' arch/arm/plat-samsung/include/plat/clock.h:60: note: previous declaration of 's3c24xx_dclk0' was here arch/arm/plat-samsung/include/plat/clock.h:61: error: conflicting types for 's3c24xx_dclk1' arch/arm/plat-samsung/include/plat/clock.h:61: note: previous declaration of 's3c24xx_dclk1' was here arch/arm/plat-samsung/include/plat/clock.h:62: error: conflicting types for 's3c24xx_clkout0' arch/arm/plat-samsung/include/plat/clock.h:62: note: previous declaration of 's3c24xx_clkout0' was here (snip) arch/arm/plat-samsung/include/plat/clock.h:101: error: conflicting types for 's3c_disable_clocks' arch/arm/plat-samsung/include/plat/clock.h:101: note: previous declaration of 's3c_disable_clocks' was here arch/arm/plat-samsung/include/plat/clock.h:118: error: conflicting types for 's3c64xx_sclk_ctrl' arch/arm/plat-samsung/include/plat/clock.h:118: note: previous declaration of 's3c64xx_sclk_ctrl' was here arch/arm/plat-samsung/include/plat/clock.h:126: error: conflicting types for 's3c2410_wdtclk' arch/arm/plat-samsung/include/plat/clock.h:126: note: previous declaration of 's3c2410_wdtclk' was here make[1]: *** [arch/arm/plat-s3c24xx/cpu.o] Error 1 make[1]: *** Waiting for unfinished jobs make: *** [arch/arm/plat-s3c24xx] Error 2 make: *** Waiting for unfinished jobs And, with s5p64x0_defconfig: CHK include/linux/version.h CHK include/generated/utsrelease.h make[1]:
RE: [PATCH v3] ARM: Samsung: fix watchdog reset issue with clk_get()
Marek Szyprowski wrote: Hello, On Friday, August 19, 2011 3:06 PM Kukjin Kim wrote: Marek Szyprowski wrote: clkdev framework uses global mutex to protect clock tree, so it is not possible to call clk_get() in interrupt context. This patch fixes this issue and makes system reset by watchdog call working again. Signed-off-by: Marek Szyprowski m.szyprow...@samsung.com Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com --- arch/arm/plat-samsung/clock.c | 11 +++ arch/arm/plat-samsung/include/plat/clock.h |3 +++ .../arm/plat-samsung/include/plat/watchdog-reset.h | 10 +++--- 3 files changed, 17 insertions(+), 7 deletions(-) history: v3: - moved initialization to arch_initcall, cleaned the code v2: - added missing '__init' section modifiers diff --git a/arch/arm/plat-samsung/clock.c b/arch/arm/plat-samsung/clock.c index 302c426..3b44519 100644 --- a/arch/arm/plat-samsung/clock.c +++ b/arch/arm/plat-samsung/clock.c @@ -64,6 +64,17 @@ static LIST_HEAD(clocks); */ DEFINE_SPINLOCK(clocks_lock); +/* Global watchdog clock used by arch_wtd_reset() callback */ +struct clk *s3c2410_wdtclk; +static int __init s3c_wdt_reset_init(void) +{ + s3c2410_wdtclk = clk_get(NULL, watchdog); + if (IS_ERR(s3c2410_wdtclk)) + printk(KERN_WARNING %s: warning: cannot get watchdog clock\n, __func__); + return 0; +} +arch_initcall(s3c_wdt_reset_init); + /* enable and disable calls for use with the clk struct */ static int clk_null_enable(struct clk *clk, int enable) diff --git a/arch/arm/plat-samsung/include/plat/clock.h b/arch/arm/plat- samsung/include/plat/clock.h index 87d5b38..8f95700 100644 --- a/arch/arm/plat-samsung/include/plat/clock.h +++ b/arch/arm/plat-samsung/include/plat/clock.h @@ -121,3 +121,6 @@ extern int s3c64xx_sclk_ctrl(struct clk *clk, int enable); extern void s3c_pwmclk_init(void); +/* Global watchdog clock used by arch_wtd_reset() callback */ + +extern struct clk *s3c2410_wdtclk; diff --git a/arch/arm/plat-samsung/include/plat/watchdog-reset.h b/arch/arm/plat- samsung/include/plat/watchdog-reset.h index 54b762a..40dbb2b 100644 --- a/arch/arm/plat-samsung/include/plat/watchdog-reset.h +++ b/arch/arm/plat-samsung/include/plat/watchdog-reset.h @@ -10,6 +10,7 @@ * published by the Free Software Foundation. */ +#include plat/clock.h #include plat/regs-watchdog.h #include mach/map.h @@ -19,17 +20,12 @@ static inline void arch_wdt_reset(void) { - struct clk *wdtclk; - printk(arch_reset: attempting watchdog reset\n); __raw_writel(0, S3C2410_WTCON); /* disable watchdog, to be safe */ - wdtclk = clk_get(NULL, watchdog); - if (!IS_ERR(wdtclk)) { - clk_enable(wdtclk); - } else - printk(KERN_WARNING %s: warning: cannot get watchdog clock\n, __func__); + if (s3c2410_wdtclk) + clk_enable(s3c2410_wdtclk); /* put initial values into count and data */ __raw_writel(0x80, S3C2410_WTCNT); -- 1.7.1.569.g6f426 Looks good but happens following: Hmm... With s3c2410_defconfig: In file included from arch/arm/plat-s3c24xx/cpu.c:48: arch/arm/plat-samsung/include/plat/clock.h:32: error: redefinition of 'struct clk_ops' arch/arm/plat-samsung/include/plat/clock.h:39: error: redefinition of 'struct clk' arch/arm/plat-samsung/include/plat/clock.h:60: error: conflicting types for 's3c24xx_dclk0' arch/arm/plat-samsung/include/plat/clock.h:60: note: previous declaration of 's3c24xx_dclk0' was here arch/arm/plat-samsung/include/plat/clock.h:61: error: conflicting types for 's3c24xx_dclk1' arch/arm/plat-samsung/include/plat/clock.h:61: note: previous declaration of 's3c24xx_dclk1' was here arch/arm/plat-samsung/include/plat/clock.h:62: error: conflicting types for 's3c24xx_clkout0' arch/arm/plat-samsung/include/plat/clock.h:62: note: previous declaration of 's3c24xx_clkout0' was here (snip) arch/arm/plat-samsung/include/plat/clock.h:101: error: conflicting types for 's3c_disable_clocks' arch/arm/plat-samsung/include/plat/clock.h:101: note: previous declaration of 's3c_disable_clocks' was here arch/arm/plat-samsung/include/plat/clock.h:118: error: conflicting types for 's3c64xx_sclk_ctrl' arch/arm/plat-samsung/include/plat/clock.h:118: note: previous declaration of 's3c64xx_sclk_ctrl' was here arch/arm/plat-samsung/include/plat/clock.h:126: error: conflicting types for 's3c2410_wdtclk' arch/arm/plat-samsung/include/plat/clock.h:126: note: previous declaration of 's3c2410_wdtclk' was here make[1]: *** [arch/arm/plat-s3c24xx/cpu.o] Error 1 make[1]: *** Waiting for unfinished jobs make: *** [arch/arm/plat-s3c24xx] Error 2 make: *** Waiting for unfinished jobs And, with
[PATCH v3] ARM: Samsung: fix watchdog reset issue with clk_get()
clkdev framework uses global mutex to protect clock tree, so it is not possible to call clk_get() in interrupt context. This patch fixes this issue and makes system reset by watchdog call working again. Signed-off-by: Marek Szyprowski m.szyprow...@samsung.com Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com --- arch/arm/plat-samsung/clock.c | 11 +++ arch/arm/plat-samsung/include/plat/clock.h |3 +++ .../arm/plat-samsung/include/plat/watchdog-reset.h | 10 +++--- 3 files changed, 17 insertions(+), 7 deletions(-) history: v3: - moved initialization to arch_initcall, cleaned the code v2: - added missing '__init' section modifiers diff --git a/arch/arm/plat-samsung/clock.c b/arch/arm/plat-samsung/clock.c index 302c426..3b44519 100644 --- a/arch/arm/plat-samsung/clock.c +++ b/arch/arm/plat-samsung/clock.c @@ -64,6 +64,17 @@ static LIST_HEAD(clocks); */ DEFINE_SPINLOCK(clocks_lock); +/* Global watchdog clock used by arch_wtd_reset() callback */ +struct clk *s3c2410_wdtclk; +static int __init s3c_wdt_reset_init(void) +{ + s3c2410_wdtclk = clk_get(NULL, watchdog); + if (IS_ERR(s3c2410_wdtclk)) + printk(KERN_WARNING %s: warning: cannot get watchdog clock\n, __func__); + return 0; +} +arch_initcall(s3c_wdt_reset_init); + /* enable and disable calls for use with the clk struct */ static int clk_null_enable(struct clk *clk, int enable) diff --git a/arch/arm/plat-samsung/include/plat/clock.h b/arch/arm/plat-samsung/include/plat/clock.h index 87d5b38..8f95700 100644 --- a/arch/arm/plat-samsung/include/plat/clock.h +++ b/arch/arm/plat-samsung/include/plat/clock.h @@ -121,3 +121,6 @@ extern int s3c64xx_sclk_ctrl(struct clk *clk, int enable); extern void s3c_pwmclk_init(void); +/* Global watchdog clock used by arch_wtd_reset() callback */ + +extern struct clk *s3c2410_wdtclk; diff --git a/arch/arm/plat-samsung/include/plat/watchdog-reset.h b/arch/arm/plat-samsung/include/plat/watchdog-reset.h index 54b762a..40dbb2b 100644 --- a/arch/arm/plat-samsung/include/plat/watchdog-reset.h +++ b/arch/arm/plat-samsung/include/plat/watchdog-reset.h @@ -10,6 +10,7 @@ * published by the Free Software Foundation. */ +#include plat/clock.h #include plat/regs-watchdog.h #include mach/map.h @@ -19,17 +20,12 @@ static inline void arch_wdt_reset(void) { - struct clk *wdtclk; - printk(arch_reset: attempting watchdog reset\n); __raw_writel(0, S3C2410_WTCON); /* disable watchdog, to be safe */ - wdtclk = clk_get(NULL, watchdog); - if (!IS_ERR(wdtclk)) { - clk_enable(wdtclk); - } else - printk(KERN_WARNING %s: warning: cannot get watchdog clock\n, __func__); + if (s3c2410_wdtclk) + clk_enable(s3c2410_wdtclk); /* put initial values into count and data */ __raw_writel(0x80, S3C2410_WTCNT); -- 1.7.1.569.g6f426 -- To unsubscribe from this list: send the line unsubscribe linux-samsung-soc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html