From owner-freebsd-bugs@FreeBSD.ORG Sat Oct 11 11:40:01 2008 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 10263106568C for ; Sat, 11 Oct 2008 11:40:01 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id E01BA8FC15 for ; Sat, 11 Oct 2008 11:40:00 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.2/8.14.2) with ESMTP id m9BBe0t6010756 for ; Sat, 11 Oct 2008 11:40:00 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.2/8.14.1/Submit) id m9BBe0u8010755; Sat, 11 Oct 2008 11:40:00 GMT (envelope-from gnats) Resent-Date: Sat, 11 Oct 2008 11:40:00 GMT Resent-Message-Id: <200810111140.m9BBe0u8010755@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Patrick Lamaiziere Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 70FA51065692 for ; Sat, 11 Oct 2008 11:39:06 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21]) by mx1.freebsd.org (Postfix) with ESMTP id 613358FC23 for ; Sat, 11 Oct 2008 11:39:06 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.14.3/8.14.3) with ESMTP id m9BBd55i085301 for ; Sat, 11 Oct 2008 11:39:05 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.14.3/8.14.3/Submit) id m9BBd5Sc085300; Sat, 11 Oct 2008 11:39:05 GMT (envelope-from nobody) Message-Id: <200810111139.m9BBd5Sc085300@www.freebsd.org> Date: Sat, 11 Oct 2008 11:39:05 GMT From: Patrick Lamaiziere To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: kern/128014: AMD Geode CS5536 watchdog(9) not disabled X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 11 Oct 2008 11:40:01 -0000 >Number: 128014 >Category: kern >Synopsis: AMD Geode CS5536 watchdog(9) not disabled >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Sat Oct 11 11:40:00 UTC 2008 >Closed-Date: >Last-Modified: >Originator: Patrick Lamaiziere >Release: 8.0-CURRENT/i386 >Organization: >Environment: FreeBSD malpractice.lamaiziere.net 8.0-CURRENT FreeBSD 8.0-CURRENT #2: Fri Oct 10 11:19:40 CEST 2008 patrick@malpractice.lamaiziere.net:/usr/obj/usr/src/sys/NET5501 i386 >Description: On the AMD Geode companion chipset CS5536 (by instance on a Soekris Net5501), the hardware watchdog is implemented by a MFGPT timer. When the timer has elapsed, the chipset does a hardware reset. When the watchdog is disabled, the actual code (sys/i386/i386/geode.c) does not stop the timer, only the the hardware reset is disabled. So if the watchdog is enabled again after the timer has been elapsed, the chipset does a reset and the box reboots immediatly. >How-To-Repeat: watchdog -t 16; watchdog -t 0 (wait a bit) watchdog -t 16 => hardware reset >Fix: The attached patch stops and resets the timer when the watchdog is disabled and never disables the hardware reset - if the timer has elapsed it's too late - Patch attached with submission follows: --- geode.c 2008-10-09 20:52:47.000000000 +0200 +++ /usr/src/sys/i386/i386/geode.c 2008-10-10 10:25:47.000000000 +0200 @@ -208,14 +208,11 @@ static void cs5536_watchdog(void *foo __unused, u_int cmd, int *error) { - u_int u, p; + u_int u, p, s; uint16_t a; uint32_t m; a = rdmsr(0x5140000d); - m = rdmsr(0x51400029); - m &= ~(1 << 24); - wrmsr(0x51400029, m); u = cmd & WD_INTERVAL; if (u >= 30 && u <= 44) { @@ -228,12 +225,24 @@ /* reset counter */ outw(a + 4, 0); /* Arm reset mechanism */ + m = rdmsr(0x51400029); m |= (1 << 24); wrmsr(0x51400029, m); /* Start counter */ outw(a + 6, 0x8000); *error = 0; + } else { + /* + * MFGPT_SETUP is write-once + * Check if the counter has been setup + */ + s = inw(a + 6); + if (s & (1 << 12)) { + /* Stop and reset counter */ + outw(a + 6, 0); + outw(a + 4, 0); + } } } >Release-Note: >Audit-Trail: >Unformatted: