Date: Sun, 15 May 2011 01:08:51 +0000 (UTC) From: Attilio Rao <attilio@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org Subject: svn commit: r221939 - in stable/8/sys: amd64/amd64 arm/arm ddb dev/watchdog i386/i386 ia64/ia64 kern mips/mips powerpc/powerpc sys x86/x86 Message-ID: <201105150108.p4F18pnU021626@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: attilio Date: Sun May 15 01:08:51 2011 New Revision: 221939 URL: http://svn.freebsd.org/changeset/base/221939 Log: MFC r221121,221173: - Add the possibility to reuse the already last used timeout when patting the watchdog, via the watchdog(9) interface. - Add the possibility to pat the watchdogs installed via the watchdog(9) interface from the kernel. - Avoid to pass WD_ACTIVE down in the watchdog handlers. All the control bit processing should over to the upper layer functions and not passed down to the handlers at all. - Add the watchdogs patting during the (shutdown time) disk syncing and disk dumping. Sponsored by: Sandvine Incorporated Modified: stable/8/sys/amd64/amd64/minidump_machdep.c stable/8/sys/arm/arm/dump_machdep.c stable/8/sys/arm/arm/minidump_machdep.c stable/8/sys/ddb/db_command.c stable/8/sys/dev/watchdog/watchdog.c stable/8/sys/i386/i386/minidump_machdep.c stable/8/sys/ia64/ia64/dump_machdep.c stable/8/sys/kern/kern_shutdown.c stable/8/sys/kern/vfs_subr.c stable/8/sys/mips/mips/dump_machdep.c stable/8/sys/powerpc/powerpc/dump_machdep.c stable/8/sys/sys/watchdog.h stable/8/sys/x86/x86/dump_machdep.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/amd64/amd64/minidump_machdep.c ============================================================================== --- stable/8/sys/amd64/amd64/minidump_machdep.c Sun May 15 01:01:53 2011 (r221938) +++ stable/8/sys/amd64/amd64/minidump_machdep.c Sun May 15 01:08:51 2011 (r221939) @@ -27,6 +27,8 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); +#include "opt_watchdog.h" + #include <sys/param.h> #include <sys/systm.h> #include <sys/conf.h> @@ -34,6 +36,9 @@ __FBSDID("$FreeBSD$"); #include <sys/kernel.h> #include <sys/kerneldump.h> #include <sys/msgbuf.h> +#ifdef SW_WATCHDOG +#include <sys/watchdog.h> +#endif #include <vm/vm.h> #include <vm/pmap.h> #include <machine/atomic.h> @@ -135,6 +140,9 @@ blk_write(struct dumperinfo *di, char *p printf(" %ld", PG2MB(progress >> PAGE_SHIFT)); counter &= (1<<24) - 1; } +#ifdef SW_WATCHDOG + wdog_kern_pat(WD_LASTVAL); +#endif if (ptr) { error = dump_write(di, ptr, 0, dumplo, len); if (error) Modified: stable/8/sys/arm/arm/dump_machdep.c ============================================================================== --- stable/8/sys/arm/arm/dump_machdep.c Sun May 15 01:01:53 2011 (r221938) +++ stable/8/sys/arm/arm/dump_machdep.c Sun May 15 01:08:51 2011 (r221939) @@ -27,6 +27,8 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); +#include "opt_watchdog.h" + #include <sys/param.h> #include <sys/systm.h> #include <sys/conf.h> @@ -35,6 +37,9 @@ __FBSDID("$FreeBSD$"); #include <sys/kernel.h> #include <sys/proc.h> #include <sys/kerneldump.h> +#ifdef SW_WATCHDOG +#include <sys/watchdog.h> +#endif #include <vm/vm.h> #include <vm/pmap.h> #include <machine/elf.h> @@ -189,6 +194,9 @@ cb_dumpdata(struct md_pa *mdp, int seqnr cpu_tlb_flushID_SE(0); cpu_cpwait(); } +#ifdef SW_WATCHDOG + wdog_kern_pat(WD_LASTVAL); +#endif error = dump_write(di, (void *)(pa - (pa & L1_ADDR_BITS)),0, dumplo, sz); if (error) Modified: stable/8/sys/arm/arm/minidump_machdep.c ============================================================================== --- stable/8/sys/arm/arm/minidump_machdep.c Sun May 15 01:01:53 2011 (r221938) +++ stable/8/sys/arm/arm/minidump_machdep.c Sun May 15 01:08:51 2011 (r221939) @@ -29,6 +29,8 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); +#include "opt_watchdog.h" + #include <sys/param.h> #include <sys/systm.h> #include <sys/conf.h> @@ -36,6 +38,9 @@ __FBSDID("$FreeBSD$"); #include <sys/kernel.h> #include <sys/kerneldump.h> #include <sys/msgbuf.h> +#ifdef SW_WATCHDOG +#include <sys/watchdog.h> +#endif #include <vm/vm.h> #include <vm/pmap.h> #include <machine/pmap.h> @@ -138,6 +143,9 @@ blk_write(struct dumperinfo *di, char *p counter &= (1<<22) - 1; } +#ifdef SW_WATCHDOG + wdog_kern_pat(WD_LASTVAL); +#endif if (ptr) { error = dump_write(di, ptr, 0, dumplo, len); if (error) Modified: stable/8/sys/ddb/db_command.c ============================================================================== --- stable/8/sys/ddb/db_command.c Sun May 15 01:01:53 2011 (r221938) +++ stable/8/sys/ddb/db_command.c Sun May 15 01:08:51 2011 (r221939) @@ -724,14 +724,6 @@ db_watchdog(dummy1, dummy2, dummy3, dumm } else if ((tout & WD_INTERVAL) == WD_TO_NEVER) { db_error("Out of range watchdog interval\n"); return; - } else { - - /* - * XXX: Right now we only support WD_ACTIVE, in the future we - * may be possibly needing a more convoluted function for - * dealing with different cases. - */ - tout |= WD_ACTIVE; } EVENTHANDLER_INVOKE(watchdog_list, tout, &i); } Modified: stable/8/sys/dev/watchdog/watchdog.c ============================================================================== --- stable/8/sys/dev/watchdog/watchdog.c Sun May 15 01:01:53 2011 (r221938) +++ stable/8/sys/dev/watchdog/watchdog.c Sun May 15 01:08:51 2011 (r221939) @@ -40,35 +40,73 @@ __FBSDID("$FreeBSD$"); #include <machine/bus.h> static struct cdev *wd_dev; +static volatile u_int wd_last_u; + +static int +kern_do_pat(u_int utim) +{ + int error; + + if ((utim & WD_LASTVAL) != 0 && (utim & WD_INTERVAL) > 0) + return (EINVAL); + + if ((utim & WD_LASTVAL) != 0) { + MPASS((wd_last_u & ~WD_INTERVAL) == 0); + utim &= ~WD_LASTVAL; + utim |= wd_last_u; + } else + wd_last_u = (utim & WD_INTERVAL); + if ((utim & WD_INTERVAL) == WD_TO_NEVER) { + utim = 0; + + /* Assume all is well; watchdog signals failure. */ + error = 0; + } else { + /* Assume no watchdog available; watchdog flags success */ + error = EOPNOTSUPP; + } + EVENTHANDLER_INVOKE(watchdog_list, utim, &error); + return (error); +} static int wd_ioctl(struct cdev *dev __unused, u_long cmd, caddr_t data, int flags __unused, struct thread *td) { - int error; u_int u; if (cmd != WDIOCPATPAT) return (ENOIOCTL); u = *(u_int *)data; - if (u & ~(WD_ACTIVE | WD_PASSIVE | WD_INTERVAL)) + if (u & ~(WD_ACTIVE | WD_PASSIVE | WD_LASTVAL | WD_INTERVAL)) return (EINVAL); if ((u & (WD_ACTIVE | WD_PASSIVE)) == (WD_ACTIVE | WD_PASSIVE)) return (EINVAL); - if ((u & (WD_ACTIVE | WD_PASSIVE)) == 0 && (u & WD_INTERVAL) > 0) + if ((u & (WD_ACTIVE | WD_PASSIVE)) == 0 && ((u & WD_INTERVAL) > 0 || + (u & WD_LASTVAL) != 0)) return (EINVAL); if (u & WD_PASSIVE) return (ENOSYS); /* XXX Not implemented yet */ - if ((u & WD_INTERVAL) == WD_TO_NEVER) { - u = 0; - /* Assume all is well; watchdog signals failure. */ - error = 0; - } else { - /* Assume no watchdog available; watchdog flags success */ - error = EOPNOTSUPP; - } - EVENTHANDLER_INVOKE(watchdog_list, u, &error); - return (error); + u &= ~(WD_ACTIVE | WD_PASSIVE); + + return (kern_do_pat(u)); +} + +u_int +wdog_kern_last_timeout(void) +{ + + return (wd_last_u); +} + +int +wdog_kern_pat(u_int utim) +{ + + if (utim & ~(WD_LASTVAL | WD_INTERVAL)) + return (EINVAL); + + return (kern_do_pat(utim)); } static struct cdevsw wd_cdevsw = { Modified: stable/8/sys/i386/i386/minidump_machdep.c ============================================================================== --- stable/8/sys/i386/i386/minidump_machdep.c Sun May 15 01:01:53 2011 (r221938) +++ stable/8/sys/i386/i386/minidump_machdep.c Sun May 15 01:08:51 2011 (r221939) @@ -27,6 +27,8 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); +#include "opt_watchdog.h" + #include <sys/param.h> #include <sys/systm.h> #include <sys/conf.h> @@ -34,6 +36,9 @@ __FBSDID("$FreeBSD$"); #include <sys/kernel.h> #include <sys/kerneldump.h> #include <sys/msgbuf.h> +#ifdef SW_WATCHDOG +#include <sys/watchdog.h> +#endif #include <vm/vm.h> #include <vm/pmap.h> #include <machine/atomic.h> @@ -138,6 +143,9 @@ blk_write(struct dumperinfo *di, char *p printf(" %lld", PG2MB(progress >> PAGE_SHIFT)); counter &= (1<<24) - 1; } +#ifdef SW_WATCHDOG + wdog_kern_pat(WD_LASTVAL); +#endif if (ptr) { error = dump_write(di, ptr, 0, dumplo, len); if (error) Modified: stable/8/sys/ia64/ia64/dump_machdep.c ============================================================================== --- stable/8/sys/ia64/ia64/dump_machdep.c Sun May 15 01:01:53 2011 (r221938) +++ stable/8/sys/ia64/ia64/dump_machdep.c Sun May 15 01:08:51 2011 (r221939) @@ -27,12 +27,17 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); +#include "opt_watchdog.h" + #include <sys/param.h> #include <sys/systm.h> #include <sys/conf.h> #include <sys/cons.h> #include <sys/kernel.h> #include <sys/kerneldump.h> +#ifdef SW_WATCHDOG +#include <sys/watchdog.h> +#endif #include <vm/vm.h> #include <vm/pmap.h> #include <machine/efi.h> @@ -125,6 +130,9 @@ cb_dumpdata(struct efi_md *mdp, int seqn printf("%c\b", "|/-\\"[twiddle++ & 3]); counter &= (1<<24) - 1; } +#ifdef SW_WATCHDOG + wdog_kern_pat(WD_LASTVAL); +#endif error = dump_write(di, (void*)pa, 0, dumplo, sz); if (error) break; Modified: stable/8/sys/kern/kern_shutdown.c ============================================================================== --- stable/8/sys/kern/kern_shutdown.c Sun May 15 01:01:53 2011 (r221938) +++ stable/8/sys/kern/kern_shutdown.c Sun May 15 01:08:51 2011 (r221939) @@ -42,6 +42,7 @@ __FBSDID("$FreeBSD$"); #include "opt_panic.h" #include "opt_show_busybufs.h" #include "opt_sched.h" +#include "opt_watchdog.h" #include <sys/param.h> #include <sys/systm.h> @@ -65,6 +66,9 @@ __FBSDID("$FreeBSD$"); #include <sys/smp.h> #include <sys/sysctl.h> #include <sys/sysproto.h> +#ifdef SW_WATCHDOG +#include <sys/watchdog.h> +#endif #include <ddb/ddb.h> @@ -311,6 +315,9 @@ boot(int howto) waittime = 0; +#ifdef SW_WATCHDOG + wdog_kern_pat(WD_LASTVAL); +#endif sync(curthread, NULL); /* @@ -336,6 +343,9 @@ boot(int howto) if (nbusy < pbusy) iter = 0; pbusy = nbusy; +#ifdef SW_WATCHDOG + wdog_kern_pat(WD_LASTVAL); +#endif sync(curthread, NULL); #ifdef PREEMPTION Modified: stable/8/sys/kern/vfs_subr.c ============================================================================== --- stable/8/sys/kern/vfs_subr.c Sun May 15 01:01:53 2011 (r221938) +++ stable/8/sys/kern/vfs_subr.c Sun May 15 01:08:51 2011 (r221939) @@ -42,6 +42,7 @@ __FBSDID("$FreeBSD$"); #include "opt_ddb.h" +#include "opt_watchdog.h" #include <sys/param.h> #include <sys/systm.h> @@ -72,6 +73,9 @@ __FBSDID("$FreeBSD$"); #include <sys/syslog.h> #include <sys/vmmeter.h> #include <sys/vnode.h> +#ifdef SW_WATCHDOG +#include <sys/watchdog.h> +#endif #include <machine/stdarg.h> @@ -1842,6 +1846,10 @@ sched_sync(void) LIST_INSERT_HEAD(next, bo, bo_synclist); continue; } +#ifdef SW_WATCHDOG + if (first_printf == 0) + wdog_kern_pat(WD_LASTVAL); +#endif } if (!LIST_EMPTY(gslp)) { mtx_unlock(&sync_mtx); Modified: stable/8/sys/mips/mips/dump_machdep.c ============================================================================== --- stable/8/sys/mips/mips/dump_machdep.c Sun May 15 01:01:53 2011 (r221938) +++ stable/8/sys/mips/mips/dump_machdep.c Sun May 15 01:08:51 2011 (r221939) @@ -27,6 +27,8 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); +#include "opt_watchdog.h" + #include <sys/param.h> #include <sys/systm.h> #include <sys/conf.h> @@ -35,6 +37,9 @@ __FBSDID("$FreeBSD$"); #include <sys/kernel.h> #include <sys/proc.h> #include <sys/kerneldump.h> +#ifdef SW_WATCHDOG +#include <sys/watchdog.h> +#endif #include <vm/vm.h> #include <vm/pmap.h> #include <machine/elf.h> @@ -182,6 +187,9 @@ cb_dumpdata(struct md_pa *mdp, int seqnr counter &= (1<<24) - 1; } +#ifdef SW_WATCHDOG + wdog_kern_path(WD_LASTVAL); +#endif error = dump_write(di, (void *)(pa),0, dumplo, sz); if (error) break; Modified: stable/8/sys/powerpc/powerpc/dump_machdep.c ============================================================================== --- stable/8/sys/powerpc/powerpc/dump_machdep.c Sun May 15 01:01:53 2011 (r221938) +++ stable/8/sys/powerpc/powerpc/dump_machdep.c Sun May 15 01:08:51 2011 (r221939) @@ -27,6 +27,8 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); +#include "opt_watchdog.h" + #include <sys/param.h> #include <sys/systm.h> #include <sys/conf.h> @@ -34,6 +36,9 @@ __FBSDID("$FreeBSD$"); #include <sys/kernel.h> #include <sys/kerneldump.h> #include <sys/sysctl.h> +#ifdef SW_WATCHDOG +#include <sys/watchdog.h> +#endif #include <vm/vm.h> #include <vm/pmap.h> #include <machine/elf.h> @@ -129,6 +134,9 @@ cb_dumpdata(struct pmap_md *md, int seqn printf("%c\b", "|/-\\"[twiddle++ & 3]); counter &= (1<<24) - 1; } +#ifdef SW_WATCHDOG + wdog_kern_pat(WD_LASTVAL); +#endif error = di->dumper(di->priv, (void*)va, 0, dumplo, sz); pmap_dumpsys_unmap(md, ofs, va); if (error) Modified: stable/8/sys/sys/watchdog.h ============================================================================== --- stable/8/sys/sys/watchdog.h Sun May 15 01:01:53 2011 (r221938) +++ stable/8/sys/sys/watchdog.h Sun May 15 01:08:51 2011 (r221939) @@ -50,6 +50,12 @@ * right to the kernel. */ +#define WD_LASTVAL 0x0200000 + /* + * Use the already last used timeout value. + * The kernel will use as timeout the last valid timeout provided. + */ + #define WD_INTERVAL 0x00000ff /* * Mask for duration bits. @@ -78,6 +84,9 @@ typedef void (*watchdog_fn)(void *, u_int, int *); EVENTHANDLER_DECLARE(watchdog_list, watchdog_fn); + +u_int wdog_kern_last_timeout(void); +int wdog_kern_pat(u_int utim); #endif #endif /* _SYS_WATCHDOG_H */ Modified: stable/8/sys/x86/x86/dump_machdep.c ============================================================================== --- stable/8/sys/x86/x86/dump_machdep.c Sun May 15 01:01:53 2011 (r221938) +++ stable/8/sys/x86/x86/dump_machdep.c Sun May 15 01:08:51 2011 (r221939) @@ -27,6 +27,8 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); +#include "opt_watchdog.h" + #include <sys/param.h> #include <sys/systm.h> #include <sys/conf.h> @@ -34,6 +36,9 @@ __FBSDID("$FreeBSD$"); #include <sys/sysctl.h> #include <sys/kernel.h> #include <sys/kerneldump.h> +#ifdef SW_WATCHDOG +#include <sys/watchdog.h> +#endif #include <vm/vm.h> #include <vm/pmap.h> #include <machine/elf.h> @@ -193,6 +198,9 @@ cb_dumpdata(struct md_pa *mdp, int seqnr a = pa + i * PAGE_SIZE; va = pmap_kenter_temporary(trunc_page(a), i); } +#ifdef SW_WATCHDOG + wdog_kern_pat(WD_LASTVAL); +#endif error = dump_write(di, va, 0, dumplo, sz); if (error) break;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201105150108.p4F18pnU021626>