From patchwork Wed Apr 29 13:20:15 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laszlo Ersek X-Patchwork-Id: 466040 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 8B32B140320 for ; Wed, 29 Apr 2015 23:35:55 +1000 (AEST) Received: from localhost ([::1]:39073 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YnS9Z-0006tc-JG for incoming@patchwork.ozlabs.org; Wed, 29 Apr 2015 09:35:53 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34769) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YnRut-0002vQ-K5 for qemu-devel@nongnu.org; Wed, 29 Apr 2015 09:20:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YnRun-0007cW-TB for qemu-devel@nongnu.org; Wed, 29 Apr 2015 09:20:43 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50862) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YnRun-0007cF-Mm for qemu-devel@nongnu.org; Wed, 29 Apr 2015 09:20:37 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id A32C98E3CC; Wed, 29 Apr 2015 13:20:36 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-116-82.ams2.redhat.com [10.36.116.82]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t3TDKKLM006464; Wed, 29 Apr 2015 09:20:32 -0400 From: Laszlo Ersek To: qemu-devel@nongnu.org, lersek@redhat.com Date: Wed, 29 Apr 2015 15:20:15 +0200 Message-Id: <1430313616-27348-3-git-send-email-lersek@redhat.com> In-Reply-To: <1430313616-27348-1-git-send-email-lersek@redhat.com> References: <1430313616-27348-1-git-send-email-lersek@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Eduardo Habkost , "Michael S. Tsirkin" , Amit Shah , Paolo Bonzini , Leon Alrae , Aurelien Jarno , Richard Henderson Subject: [Qemu-devel] [PATCH 2/3] hw/acpi: move "etc/system-states" fw_cfg file from PIIX4 to core 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 The acpi_pm1_cnt_init() core function is responsible for setting up the register block that will ultimately react to S3 and S4 requests (see acpi_pm1_cnt_write()). It makes sense to advertise this configuration to the guest firmware via an easy to parse fw_cfg file (ACPI is too complex for firmware to parse), and indeed PIIX4 does that. However, since acpi_pm1_cnt_init() is not specific to PIIX4, neither should be the fw_cfg file. This patch makes "etc/system-states" appear on all chipsets modified in the previous patch, not just PIIX4 (assuming they have fw_cfg at all). RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1204696 Cc: Amit Shah Cc: "Michael S. Tsirkin" Cc: Paolo Bonzini Cc: Richard Henderson Cc: Eduardo Habkost Cc: Aurelien Jarno Cc: Leon Alrae Signed-off-by: Laszlo Ersek --- hw/acpi/core.c | 12 ++++++++++++ hw/acpi/piix4.c | 8 -------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/hw/acpi/core.c b/hw/acpi/core.c index c19be8f..f70377f 100644 --- a/hw/acpi/core.c +++ b/hw/acpi/core.c @@ -22,6 +22,7 @@ #include "hw/hw.h" #include "hw/i386/pc.h" #include "hw/acpi/acpi.h" +#include "hw/nvram/fw_cfg.h" #include "qemu/config-file.h" #include "qapi/opts-visitor.h" #include "qapi/dealloc-visitor.h" @@ -595,12 +596,23 @@ static const MemoryRegionOps acpi_pm_cnt_ops = { void acpi_pm1_cnt_init(ACPIREGS *ar, MemoryRegion *parent, bool disable_s3, bool disable_s4, uint8_t s4_val) { + FWCfgState *fw_cfg; + ar->pm1.cnt.s4_val = s4_val; ar->wakeup.notify = acpi_notify_wakeup; qemu_register_wakeup_notifier(&ar->wakeup); memory_region_init_io(&ar->pm1.cnt.io, memory_region_owner(parent), &acpi_pm_cnt_ops, ar, "acpi-cnt", 2); memory_region_add_subregion(parent, 4, &ar->pm1.cnt.io); + + fw_cfg = fw_cfg_find(); + if (fw_cfg) { + uint8_t suspend[6] = {128, 0, 0, 129, 128, 128}; + suspend[3] = 1 | ((!disable_s3) << 7); + suspend[4] = s4_val | ((!disable_s4) << 7); + + fw_cfg_add_file(fw_cfg, "etc/system-states", g_memdup(suspend, 6), 6); + } } void acpi_pm1_cnt_reset(ACPIREGS *ar) diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c index 321b309..c53a31a 100644 --- a/hw/acpi/piix4.c +++ b/hw/acpi/piix4.c @@ -514,14 +514,6 @@ I2CBus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base, qdev_init_nofail(dev); - if (fw_cfg) { - uint8_t suspend[6] = {128, 0, 0, 129, 128, 128}; - suspend[3] = 1 | ((!s->disable_s3) << 7); - suspend[4] = s->s4_val | ((!s->disable_s4) << 7); - - fw_cfg_add_file(fw_cfg, "etc/system-states", g_memdup(suspend, 6), 6); - } - return s->smb.smbus; }