From: jamie@jamieiles.com (Jamie Iles)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCHv2 5/5] ARM: picoxcell: implement watchdog restart
Date: Sun, 18 Dec 2011 00:05:23 +0000 [thread overview]
Message-ID: <20111218000523.GA2376@gallagher> (raw)
In-Reply-To: <1771411.xn5pEUbjJo@wuerfel>
Hi Arnd,
On Sat, Dec 17, 2011 at 09:17:00PM +0100, Arnd Bergmann wrote:
> On Saturday 17 December 2011 13:42:37 Jamie Iles wrote:
> > Allow the platform to be restarted by triggering the watchdog to expire
> > with the shortest possible expiry. This should reset the CPU core and
> > all on-chip peripherals.
> >
> > Signed-off-by: Jamie Iles <jamie@jamieiles.com>
>
> Hi Jamie,
>
> > @@ -23,6 +24,22 @@
> >
> > #include "common.h"
> >
> > +#define WDT_CTRL_REG_EN_MASK (1 << 0)
> > +#define WDT_CTRL_REG_OFFS (0x00)
> > +#define WDT_TIMEOUT_REG_OFFS (0x04)
> > +static void __iomem *wdt_regs;
> > +
> > +static void picoxcell_setup_restart(void)
> > +{
> > + struct device_node *np = of_find_compatible_node(NULL, NULL,
> > + "snps,dw-apb-wdg");
> > + if (WARN(!np, "unable to setup watchdog restart"))
> > + return;
> > +
> > + wdt_regs = of_iomap(np, 0);
> > + WARN(!wdt_regs, "failed to remap watchdog regs");
> > +}
>
> Can you do this at restart time? I think it would be nicer to
> avoid the global variable and init function and instead have
> everything in a single function call for restart
>
> > +static void picoxcell_wdt_restart(char mode, const char *cmd)
> > +{
> > + /*
> > + * Configure the watchdog to reset with the shortest possible timeout
> > + * and give it chance to do the reset.
> > + */
> > + if (wdt_regs) {
> > + __raw_writel(WDT_CTRL_REG_EN_MASK, wdt_regs + WDT_CTRL_REG_OFFS);
> > + __raw_writel(0, wdt_regs + WDT_TIMEOUT_REG_OFFS);
> > + mdelay(500);
> > + }
> > +}
>
> Does this work if the real watchdog is still running, on a preemtible kernel?
Yes, this sets the timeout period to about 3us on this platform so
there's no way the driver should be pinging it that fast even if it was
still active.
> Also, please always use writel_relaxed instead of __raw_writel, and try to use
> msleep instead of mdelay by default. If msleep doesn't work here because it
> actually causes the system not to be reset, just add a comment.
OK fair point. I was a bit wary of doing too much in the actual reboot
time as it wasn't clear what services are available at that time, but
all of your changes work so I'll go ahead and implement them.
Thanks,
Jamie
next prev parent reply other threads:[~2011-12-18 0:05 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-17 13:42 [PATCHv2 0/5] Misc picoxcell updates for 3.3 Jamie Iles
2011-12-17 13:42 ` [PATCHv2 1/5] ARM: picoxcell: remove mach/memory.h Jamie Iles
2011-12-17 13:42 ` [PATCHv2 2/5] ARM: picoxcell: don't reserve irq_descs Jamie Iles
2011-12-17 13:42 ` [PATCHv2 3/5] ARM: picoxcell: move io mappings to common.c Jamie Iles
2011-12-17 13:42 ` [PATCHv2 4/5] MAINTAINERS: add maintainer entry for Picochip picoxcell Jamie Iles
2011-12-17 13:42 ` [PATCHv2 5/5] ARM: picoxcell: implement watchdog restart Jamie Iles
2011-12-17 20:17 ` Arnd Bergmann
2011-12-18 0:05 ` Jamie Iles [this message]
2011-12-18 8:13 ` Russell King - ARM Linux
2011-12-18 9:41 ` Jamie Iles
2011-12-17 20:18 ` [PATCHv2 0/5] Misc picoxcell updates for 3.3 Arnd Bergmann
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=20111218000523.GA2376@gallagher \
--to=jamie@jamieiles.com \
--cc=linux-arm-kernel@lists.infradead.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).