From patchwork Sun Dec 12 11:15:12 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Richard W.M. Jones" X-Patchwork-Id: 75226 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id B161DB70A5 for ; Sun, 12 Dec 2010 22:15:56 +1100 (EST) Received: from localhost ([127.0.0.1]:48807 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PRjuC-0002Ye-Ob for incoming@patchwork.ozlabs.org; Sun, 12 Dec 2010 06:15:52 -0500 Received: from [140.186.70.92] (port=56878 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PRjtf-0002YJ-6B for qemu-devel@nongnu.org; Sun, 12 Dec 2010 06:15:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PRjtd-0008I3-Om for qemu-devel@nongnu.org; Sun, 12 Dec 2010 06:15:19 -0500 Received: from mx1.redhat.com ([209.132.183.28]:60263) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PRjtd-0008Hr-9o for qemu-devel@nongnu.org; Sun, 12 Dec 2010 06:15:17 -0500 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id oBCBFFcK005379 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sun, 12 Dec 2010 06:15:15 -0500 Received: from localhost (vpn2-9-105.ams2.redhat.com [10.36.9.105]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id oBCBFDwC006385; Sun, 12 Dec 2010 06:15:13 -0500 Date: Sun, 12 Dec 2010 11:15:12 +0000 From: "Richard W.M. Jones" To: Blue Swirl Subject: Re: [Qemu-devel] [PATCH] wdt_i6300esb: register a reset function Message-ID: <20101212111512.GC2601@amd.home.annexia.org> References: <1291820395-30335-1-git-send-email-bernhard.kohl@nsn.com> <20101212100809.GA17286@amd.home.annexia.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: Bernhard Kohl , qemu-devel@nongnu.org X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org On Sun, Dec 12, 2010 at 10:59:59AM +0000, Blue Swirl wrote: > On Sun, Dec 12, 2010 at 10:08 AM, Richard W.M. Jones wrote: > > On Sat, Dec 11, 2010 at 06:39:03PM +0000, Blue Swirl wrote: > >> Thanks, applied. > > > > Wait!  This patch is incomplete. > > > > I already posted a complete patch already some months ago (twice) but > > it was ignored both times: > > > > http://www.mail-archive.com/qemu-devel@nongnu.org/msg42716.html > > http://www.mail-archive.com/qemu-devel@nongnu.org/msg43142.html > > The difference is that previous_reboot_flag should not be cleared in > reset, right? Yes, and: - Bernhard removed the call to i6300esb_reset after the watchdog fires. I'm not sure why this was done, since AFAIK the watchdog should be completely reset by this event (as in a real machine). - The same change is needed to IB700 as well. > Could you make a new patch, please? New patch attached. Rich. diff --git a/hw/wdt_i6300esb.c b/hw/wdt_i6300esb.c index 8443b41..90bf5f6 100644 --- a/hw/wdt_i6300esb.c +++ b/hw/wdt_i6300esb.c @@ -149,6 +149,8 @@ static void i6300esb_reset(DeviceState *dev) i6300esb_disable_timer(d); + /* NB: Don't change d->previous_reboot_flag in this function. */ + d->reboot_enabled = 1; d->clock_scale = CLOCK_SCALE_1KHZ; d->int_type = INT_TYPE_IRQ; @@ -159,7 +161,6 @@ static void i6300esb_reset(DeviceState *dev) d->timer2_preload = 0xfffff; d->stage = 1; d->unlock_state = 0; - d->previous_reboot_flag = 0; } /* This function is called when the watchdog expires. Note that @@ -193,6 +194,7 @@ static void i6300esb_timer_expired(void *vp) if (d->reboot_enabled) { d->previous_reboot_flag = 1; watchdog_perform_action(); /* This reboots, exits, etc */ + i6300esb_reset(&d->dev.qdev); } /* In "free running mode" we start stage 1 again. */ @@ -409,6 +411,7 @@ static int i6300esb_init(PCIDevice *dev) i6300esb_debug("I6300State = %p\n", d); d->timer = qemu_new_timer(vm_clock, i6300esb_timer_expired, d); + d->previous_reboot_flag = 0; pci_conf = d->dev.config; pci_config_set_vendor_id(pci_conf, PCI_VENDOR_ID_INTEL); diff --git a/hw/wdt_ib700.c b/hw/wdt_ib700.c index c34687b..b6235eb 100644 --- a/hw/wdt_ib700.c +++ b/hw/wdt_ib700.c @@ -97,6 +97,8 @@ static int wdt_ib700_init(ISADevice *dev) { IB700State *s = DO_UPCAST(IB700State, dev, dev); + ib700_debug("watchdog init\n"); + s->timer = qemu_new_timer(vm_clock, ib700_timer_expired, s); register_ioport_write(0x441, 2, 1, ib700_write_disable_reg, s); register_ioport_write(0x443, 2, 1, ib700_write_enable_reg, s); @@ -104,16 +106,26 @@ static int wdt_ib700_init(ISADevice *dev) return 0; } +static void wdt_ib700_reset(DeviceState *dev) +{ + IB700State *s = DO_UPCAST(IB700State, dev.qdev, dev); + + ib700_debug("watchdog reset\n"); + + qemu_del_timer(s->timer); +} + static WatchdogTimerModel model = { .wdt_name = "ib700", .wdt_description = "iBASE 700", }; static ISADeviceInfo wdt_ib700_info = { - .qdev.name = "ib700", - .qdev.size = sizeof(IB700State), - .qdev.vmsd = &vmstate_ib700, - .init = wdt_ib700_init, + .qdev.name = "ib700", + .qdev.size = sizeof(IB700State), + .qdev.vmsd = &vmstate_ib700, + .qdev.reset = wdt_ib700_reset, + .init = wdt_ib700_init, }; static void wdt_ib700_register_devices(void)