From patchwork Wed Jul 8 09:41:44 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 492783 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id BE9041402BA for ; Wed, 8 Jul 2015 19:42:31 +1000 (AEST) Received: from localhost ([::1]:33958 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZCls5-0003PS-Gr for incoming@patchwork.ozlabs.org; Wed, 08 Jul 2015 05:42:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50904) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZClrR-0002AQ-Dc for qemu-devel@nongnu.org; Wed, 08 Jul 2015 05:41:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZClrQ-00040M-8b for qemu-devel@nongnu.org; Wed, 08 Jul 2015 05:41:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41148) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZClrQ-00040A-2B for qemu-devel@nongnu.org; Wed, 08 Jul 2015 05:41:48 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 97390BE288; Wed, 8 Jul 2015 09:41:47 +0000 (UTC) Received: from redhat.com (ovpn-116-52.ams2.redhat.com [10.36.116.52]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id t689fjaG027110; Wed, 8 Jul 2015 05:41:45 -0400 Date: Wed, 8 Jul 2015 12:41:44 +0300 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Message-ID: <1436348444-907-7-git-send-email-mst@redhat.com> References: <1436348444-907-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1436348444-907-1-git-send-email-mst@redhat.com> X-Mutt-Fcc: =sent X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Paulo Alcantara , Peter Maydell , Paulo Alcantara , Igor Mammedov Subject: [Qemu-devel] [PULL v2 06/16] ich9: implement strap SPKR pin logic X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Paulo Alcantara If the signal is sampled high, this indicates that the system is strapped to the "No Reboot" mode (ICH9 will disable the TCO Timer system reboot feature). The status of this strap is readable via the NO_REBOOT bit (CC: offset 0x3410:bit 5). The NO_REBOOT bit is set when SPKR pin on ICH9 is sampled high. This bit may be set or cleared by software if the strap is sampled low but may not override the strap when it indicates "No Reboot". This patch implements the logic where hardware has ability to set SPKR pin through a property named "noreboot" and it's sampled high by default. Signed-off-by: Paulo Alcantara Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/i386/ich9.h | 5 +++++ hw/acpi/tco.c | 2 +- hw/isa/lpc_ich9.c | 6 ++++++ tests/tco-test.c | 18 ++++++++++++++++-- 4 files changed, 28 insertions(+), 3 deletions(-) diff --git a/include/hw/i386/ich9.h b/include/hw/i386/ich9.h index ecb3b10..b9d2b04 100644 --- a/include/hw/i386/ich9.h +++ b/include/hw/i386/ich9.h @@ -46,6 +46,11 @@ typedef struct ICH9LPCState { ICH9LPCPMRegs pm; uint32_t sci_level; /* track sci level */ + /* 2.24 Pin Straps */ + struct { + bool spkr_hi; + } pin_strap; + /* 10.1 Chipset Configuration registers(Memory Space) which is pointed by RCBA */ uint8_t chip_config[ICH9_CC_SIZE]; diff --git a/hw/acpi/tco.c b/hw/acpi/tco.c index 1794a54..7a026c2 100644 --- a/hw/acpi/tco.c +++ b/hw/acpi/tco.c @@ -64,7 +64,7 @@ static void tco_timer_expired(void *opaque) tr->tco.sts2 |= TCO_BOOT_STS; tr->timeouts_no = 0; - if (!(gcs & ICH9_CC_GCS_NO_REBOOT)) { + if (!lpc->pin_strap.spkr_hi && !(gcs & ICH9_CC_GCS_NO_REBOOT)) { watchdog_perform_action(); tco_timer_stop(tr); return; diff --git a/hw/isa/lpc_ich9.c b/hw/isa/lpc_ich9.c index 7af24fa..360699f 100644 --- a/hw/isa/lpc_ich9.c +++ b/hw/isa/lpc_ich9.c @@ -692,6 +692,11 @@ static const VMStateDescription vmstate_ich9_lpc = { } }; +static Property ich9_lpc_properties[] = { + DEFINE_PROP_BOOL("noreboot", ICH9LPCState, pin_strap.spkr_hi, true), + DEFINE_PROP_END_OF_LIST(), +}; + static void ich9_lpc_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); @@ -703,6 +708,7 @@ static void ich9_lpc_class_init(ObjectClass *klass, void *data) dc->reset = ich9_lpc_reset; k->init = ich9_lpc_init; dc->vmsd = &vmstate_ich9_lpc; + dc->props = ich9_lpc_properties; k->config_write = ich9_lpc_config_write; dc->desc = "ICH9 LPC bridge"; k->vendor_id = PCI_VENDOR_ID_INTEL; diff --git a/tests/tco-test.c b/tests/tco-test.c index 1a2fe3d..6a48188 100644 --- a/tests/tco-test.c +++ b/tests/tco-test.c @@ -42,6 +42,7 @@ enum { typedef struct { const char *args; + bool noreboot; QPCIDevice *dev; void *lpc_base; void *tco_io_base; @@ -53,7 +54,9 @@ static void test_init(TestData *d) QTestState *qs; char *s; - s = g_strdup_printf("-machine q35 %s", !d->args ? "" : d->args); + s = g_strdup_printf("-machine q35 %s %s", + d->noreboot ? "" : "-global ICH9-LPC.noreboot=false", + !d->args ? "" : d->args); qs = qtest_start(s); qtest_irq_intercept_in(qs, "ioapic"); g_free(s); @@ -135,6 +138,7 @@ static void test_tco_defaults(void) TestData d; d.args = NULL; + d.noreboot = true; test_init(&d); g_assert_cmpint(qpci_io_readw(d.dev, d.tco_io_base + TCO_RLD), ==, TCO_RLD_DEFAULT); @@ -167,6 +171,7 @@ static void test_tco_timeout(void) int ret; d.args = NULL; + d.noreboot = true; test_init(&d); stop_tco(&d); @@ -210,6 +215,7 @@ static void test_tco_max_timeout(void) int ret; d.args = NULL; + d.noreboot = true; test_init(&d); stop_tco(&d); @@ -253,6 +259,7 @@ static void test_tco_second_timeout_pause(void) QDict *ad; td.args = "-watchdog-action pause"; + td.noreboot = false; test_init(&td); stop_tco(&td); @@ -277,6 +284,7 @@ static void test_tco_second_timeout_reset(void) QDict *ad; td.args = "-watchdog-action reset"; + td.noreboot = false; test_init(&td); stop_tco(&td); @@ -301,6 +309,7 @@ static void test_tco_second_timeout_shutdown(void) QDict *ad; td.args = "-watchdog-action shutdown"; + td.noreboot = false; test_init(&td); stop_tco(&td); @@ -325,6 +334,7 @@ static void test_tco_second_timeout_none(void) QDict *ad; td.args = "-watchdog-action none"; + td.noreboot = false; test_init(&td); stop_tco(&td); @@ -349,6 +359,7 @@ static void test_tco_ticks_counter(void) uint16_t rld; d.args = NULL; + d.noreboot = true; test_init(&d); stop_tco(&d); @@ -375,6 +386,7 @@ static void test_tco1_control_bits(void) uint16_t val; d.args = NULL; + d.noreboot = true; test_init(&d); val = TCO_LOCK; @@ -394,6 +406,7 @@ static void test_tco1_status_bits(void) int ret; d.args = NULL; + d.noreboot = true; test_init(&d); stop_tco(&d); @@ -421,7 +434,8 @@ static void test_tco2_status_bits(void) uint16_t val; int ret; - d.args = "-watchdog-action none"; + d.args = NULL; + d.noreboot = true; test_init(&d); stop_tco(&d);