From mboxrd@z Thu Jan 1 00:00:00 1970 From: LW@KARO-electronics.de (=?iso-8859-15?Q?Lothar_Wa=DFmann?=) Date: Fri, 26 Nov 2010 11:38:47 +0100 Subject: [PATCH 03/15] ARM: mxs: Add reset routines In-Reply-To: <20101126095733.GA27637@pengutronix.de> References: <1290754154-9428-1-git-send-email-shawn.guo@freescale.com> <1290754154-9428-4-git-send-email-shawn.guo@freescale.com> <19695.32386.279224.624305@ipc1.ka-ro> <20101126095733.GA27637@pengutronix.de> Message-ID: <19695.36407.793411.550458@ipc1.ka-ro> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org Hi, Uwe Kleine-K?nig writes: > On Fri, Nov 26, 2010 at 10:31:46AM +0100, Lothar Wa?mann wrote: > > Shawn Guo writes: > > [...] > > > diff --git a/arch/arm/mach-mxs/system.c b/arch/arm/mach-mxs/system.c > > > new file mode 100644 > > > index 0000000..de33c66 > > > --- /dev/null > > > +++ b/arch/arm/mach-mxs/system.c > > > @@ -0,0 +1,152 @@ > > > +/* > > > + * Copyright (C) 1999 ARM Limited > > > + * Copyright (C) 2000 Deep Blue Solutions Ltd > > > + * Copyright 2006-2007,2010 Freescale Semiconductor, Inc. All Rights Reserved. > > > + * Copyright 2008 Juergen Beisert, kernel at pengutronix.de > > > + * Copyright 2009 Ilya Yanok, Emcraft Systems Ltd, yanok at emcraft.com > > > + * > > > + * This program is free software; you can redistribute it and/or modify > > > + * it under the terms of the GNU General Public License as published by > > > + * the Free Software Foundation; either version 2 of the License, or > > > + * (at your option) any later version. > > > + * > > > + * This program is distributed in the hope that it will be useful, > > > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > > > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > > > + * GNU General Public License for more details. > > > + */ > > > + > > > +#include > > > +#include > > > +#include > > > +#include > > > +#include > > > + > > > +#include > > > +#include > > > + > > > +#include > > > +#include > > > + > > > +#define MXS_RTC_WATCHDOG 0x50 > > > +#define MXS_WATCHDOG_EN (1 << 4) > > > + > > > +#define MXS_MODULE_CLKGATE (1 << 30) > > > +#define MXS_MODULE_SFTRST (1 << 31) > > > + > > > +static void __iomem *wdog_base; > > > + > > > +/* > > > + * Reset the system. It is called by machine_restart(). > > > + */ > > > +void arch_reset(char mode, const char *cmd) > > > +{ > > > + struct clk *clk; > > > + > > > + clk = clk_get_sys("rtc", NULL); > > > + if (!IS_ERR(clk)) > > > + clk_enable(clk); > > > + > > > > > Since arch_reset() may be called from interrupt context (e.g. due to > > SYSRQ-B) it must not call any functions that may sleep like clk_get*() > > or clk_enable(). The clock should be acquired and enabled in the init > > routine. > This is a problem that also exist in arch/arm/plat-mxc/system.c's > arch_reset. > > Did you already verify that this is indeed a problem? I guess there are > more architectures that use clk_get in arch_reset, aren't there? > If you consider this a problem: BUG: sleeping function called from invalid context at /usr/local/src/arm-linux/kernel/mutex.c: 280 in_atomic(): 1, irqs_disabled(): 128, pid: 0, name: swapper 2 locks held by swapper/0: #0: (&port_lock_key){-.-...}, at: [] imx_rxint+0x24/0x20c #1: (sysrq_key_table_lock){-.....}, at: [] __handle_sysrq+0x20/0x170 irq event stamp: 130658 hardirqs last enabled at (130657): [] default_idle+0x2c/0x3c hardirqs last disabled at (130658): [] __irq_svc+0x34/0xa8 softirqs last enabled at (130648): [] __do_softirq+0x144/0x164 softirqs last disabled at (130637): [] irq_exit+0x60/0xb4 Backtrace: [] (dump_backtrace+0x0/0x114) from [] (dump_stack+0x18/0x1c) r7:00000000 r6:c0326000 r5:00000000 r4:c0326000 [] (dump_stack+0x0/0x1c) from [] (__might_sleep+0x11c/0x13c) [] (__might_sleep+0x0/0x13c) from [] (mutex_lock_nested+0x34/0x31c) r4:c032afd4 [] (mutex_lock_nested+0x0/0x31c) from [] (clk_get_sys+0x30/0xe8) [] (clk_get_sys+0x0/0xe8) from [] (arch_reset+0x18/0x8c) [] (arch_reset+0x0/0x8c) from [] (arm_machine_restart+0x2c/0x5c) r5:00000000 r4:00000068 [] (arm_machine_restart+0x0/0x5c) from [] (machine_restart+0x20/0x28) r5:d186b9c0 r4:00000062 [] (machine_restart+0x0/0x28) from [] (emergency_restart+0x14/0x18) [] (emergency_restart+0x0/0x18) from [] (sysrq_handle_reboot+0x24/0x28) [] (sysrq_handle_reboot+0x0/0x28) from [] (__handle_sysrq+0xc0/0x170) [] (__handle_sysrq+0x0/0x170) from [] (handle_sysrq+0x34/0x40) [] (handle_sysrq+0x0/0x40) from [] (imx_rxint+0xec/0x20c) [] (imx_rxint+0x0/0x20c) from [] (imx_int+0x28/0x68) [] (imx_int+0x0/0x68) from [] (handle_IRQ_event+0x2c/0x100) r7:0000002d r6:00000000 r5:00000000 r4:d1eab800 [] (handle_IRQ_event+0x0/0x100) from [] (handle_level_irq+0xbc/0x120) r7:d1eab800 r6:c03340b8 r5:0000002d r4:c033407c [] (handle_level_irq+0x0/0x120) from [] (_text+0x70/0x8c) r7:00000002 r6:002d0000 r5:00000000 r4:0000002d [] (_text+0x0/0x8c) from [] (__irq_svc+0x54/0xa8) Exception stack(0xc0327f48 to 0xc0327f90) 7f40: 00000001 0016e240 20000093 20000013 c0326000 c032aaa8 7f60: c03541e4 c032aaa0 8001ecc4 41069264 8001ec90 c0327f9c c0327f68 c0327f90 7f80: c006c620 c0027f8c 20000013 ffffffff r5:fc400000 r4:0000001f [] (default_idle+0x0/0x3c) from [] (cpu_idle+0x70/0xcc) [] (cpu_idle+0x0/0xcc) from [] (rest_init+0x70/0x84) r7:c032aaa0 r6:c0020e14 r5:c0020e18 r4:c0853ad8 [] (rest_init+0x0/0x84) from [] (start_kernel+0x280/0x2d8) [] (start_kernel+0x0/0x2d8) from [<80008034>] (0x80008034) r5:c0354284 r4:00053175 ------------[ cut here ]------------ WARNING: at /usr/local/src/arm-linux/kernel/mutex.c:207 mutex_lock_nested+0xb4/0x31c() Modules linked in: Backtrace: [] (dump_backtrace+0x0/0x114) from [] (dump_stack+0x18/0x1c) r7:c02e09d3 r6:000000cf r5:c026189c r4:00000000 [] (dump_stack+0x0/0x1c) from [] (warn_slowpath_common+0x50/0x68) [] (warn_slowpath_common+0x0/0x68) from [] (warn_slowpath_null+0x18/0x1c) r7:00000000 r6:c0326000 r5:c0329868 r4:c032afd4 [] (warn_slowpath_null+0x0/0x1c) from [] (mutex_lock_nested+0xb4/0x31c) [] (mutex_lock_nested+0x0/0x31c) from [] (clk_get_sys+0x30/0xe8) [] (clk_get_sys+0x0/0xe8) from [] (arch_reset+0x18/0x8c) [] (arch_reset+0x0/0x8c) from [] (arm_machine_restart+0x2c/0x5c) r5:00000000 r4:00000068 [] (arm_machine_restart+0x0/0x5c) from [] (machine_restart+0x20/0x28) r5:d186b9c0 r4:00000062 [] (machine_restart+0x0/0x28) from [] (emergency_restart+0x14/0x18) [] (emergency_restart+0x0/0x18) from [] (sysrq_handle_reboot+0x24/0x28) [] (sysrq_handle_reboot+0x0/0x28) from [] (__handle_sysrq+0xc0/0x170) [] (__handle_sysrq+0x0/0x170) from [] (handle_sysrq+0x34/0x40) [] (handle_sysrq+0x0/0x40) from [] (imx_rxint+0xec/0x20c) [] (imx_rxint+0x0/0x20c) from [] (imx_int+0x28/0x68) [] (imx_int+0x0/0x68) from [] (handle_IRQ_event+0x2c/0x100) r7:0000002d r6:00000000 r5:00000000 r4:d1eab800 [] (handle_IRQ_event+0x0/0x100) from [] (handle_level_irq+0xbc/0x120) r7:d1eab800 r6:c03340b8 r5:0000002d r4:c033407c [] (handle_level_irq+0x0/0x120) from [] (_text+0x70/0x8c) r7:00000002 r6:002d0000 r5:00000000 r4:0000002d [] (_text+0x0/0x8c) from [] (__irq_svc+0x54/0xa8) Exception stack(0xc0327f48 to 0xc0327f90) 7f40: 00000001 0016e240 20000093 20000013 c0326000 c032aaa8 7f60: c03541e4 c032aaa0 8001ecc4 41069264 8001ec90 c0327f9c c0327f68 c0327f90 7f80: c006c620 c0027f8c 20000013 ffffffff r5:fc400000 r4:0000001f [] (default_idle+0x0/0x3c) from [] (cpu_idle+0x70/0xcc) [] (cpu_idle+0x0/0xcc) from [] (rest_init+0x70/0x84) r7:c032aaa0 r6:c0020e14 r5:c0020e18 r4:c0853ad8 [] (rest_init+0x0/0x84) from [] (start_kernel+0x280/0x2d8) [] (start_kernel+0x0/0x2d8) from [<80008034>] (0x80008034) r5:c0354284 r4:00053175 ---[ end trace b484fc13651ee6f1 ]--- Lothar Wa?mann -- ___________________________________________________________ Ka-Ro electronics GmbH | Pascalstra?e 22 | D - 52076 Aachen Phone: +49 2408 1402-0 | Fax: +49 2408 1402-10 Gesch?ftsf?hrer: Matthias Kaussen Handelsregistereintrag: Amtsgericht Aachen, HRB 4996 www.karo-electronics.de | info at karo-electronics.de ___________________________________________________________