From patchwork Fri Jan 31 13:27:08 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 315581 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 C67C72C00B2 for ; Sat, 1 Feb 2014 00:33:29 +1100 (EST) Received: from localhost ([::1]:55621 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W9EDn-00072F-Ms for incoming@patchwork.ozlabs.org; Fri, 31 Jan 2014 08:33:27 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33290) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W9ED8-0005ur-Lf for qemu-devel@nongnu.org; Fri, 31 Jan 2014 08:32:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W9ED2-0000CB-Dj for qemu-devel@nongnu.org; Fri, 31 Jan 2014 08:32:46 -0500 Received: from mx1.redhat.com ([209.132.183.28]:48696) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W9ED2-0000C6-1O for qemu-devel@nongnu.org; Fri, 31 Jan 2014 08:32:40 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s0VDWdvL029035 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 31 Jan 2014 08:32:39 -0500 Received: from dell-pet610-01.lab.eng.brq.redhat.com (dell-pet610-01.lab.eng.brq.redhat.com [10.34.42.20]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s0VDWXNV005381; Fri, 31 Jan 2014 08:32:38 -0500 From: Igor Mammedov To: qemu-devel@nongnu.org Date: Fri, 31 Jan 2014 14:27:08 +0100 Message-Id: <1391174830-5866-4-git-send-email-imammedo@redhat.com> In-Reply-To: <1391174830-5866-1-git-send-email-imammedo@redhat.com> References: <1391174830-5866-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: aliguori@amazon.com, mst@redhat.com Subject: [Qemu-devel] [PATCH v3 3/5] pcihp: make pci_read() mmio calback compatible with legacy ACPI hotplug 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 due to recent change introduced by: "pcihp: reduce number of device check events" 'up' field is cleared right after it's read. This is incompatible with legacy BIOS ACPI code where PCNF ACPI method reads this field 32 times. To make pci_read mmio callback compatible with legacy 'up' behavior, pcihp code will need to know in which mode it runs so move 'use_acpi_pci_hotplug' into AcpiPciHpState structure and alter register behavior accordingly. PS: And since field 'use_acpi_pci_hotplug' is touched anyway rename it to reflect its meaning more crearly to 'legacy_piix' and corresponding property to 'legacy-acpi-pci-hotplug'. Signed-off-by: Igor Mammedov --- hw/acpi/pcihp.c | 4 +++- hw/acpi/piix4.c | 15 +++++++-------- include/hw/acpi/pcihp.h | 1 + include/hw/i386/pc.h | 4 ++-- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/hw/acpi/pcihp.c b/hw/acpi/pcihp.c index 64c8cf2..a7353f6 100644 --- a/hw/acpi/pcihp.c +++ b/hw/acpi/pcihp.c @@ -215,7 +215,9 @@ static uint64_t pci_read(void *opaque, hwaddr addr, unsigned int size) switch (addr) { case PCI_UP_BASE: val = s->acpi_pcihp_pci_status[bsel].up; - s->acpi_pcihp_pci_status[bsel].up = 0; + if (!s->legacy_piix) { + s->acpi_pcihp_pci_status[bsel].up = 0; + } ACPI_PCIHP_DPRINTF("pci_up_read %" PRIu32 "\n", val); break; case PCI_DOWN_BASE: diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c index 5d55a3c..33c9516 100644 --- a/hw/acpi/piix4.c +++ b/hw/acpi/piix4.c @@ -88,7 +88,6 @@ typedef struct PIIX4PMState { /* for new pci hotplug (with PCI2PCI bridge support) */ AcpiPciHpState acpi_pci_hotplug; - bool use_acpi_pci_hotplug; uint8_t disable_s3; uint8_t disable_s4; @@ -263,13 +262,13 @@ static int acpi_load_old(QEMUFile *f, void *opaque, int version_id) static bool vmstate_test_use_acpi_pci_hotplug(void *opaque, int version_id) { PIIX4PMState *s = opaque; - return s->use_acpi_pci_hotplug; + return !s->acpi_pci_hotplug.legacy_piix; } static bool vmstate_test_no_use_acpi_pci_hotplug(void *opaque, int version_id) { PIIX4PMState *s = opaque; - return !s->use_acpi_pci_hotplug; + return s->acpi_pci_hotplug.legacy_piix; } /* qemu-kvm 1.2 uses version 3 but advertised as 2 @@ -377,7 +376,7 @@ static void piix4_reset(void *opaque) pci_conf[0x5B] = 0x02; } pm_io_space_update(s); - if (s->use_acpi_pci_hotplug) { + if (!s->acpi_pci_hotplug.legacy_piix) { acpi_pcihp_reset(&s->acpi_pci_hotplug); } else { piix4_update_hotplug(s); @@ -426,7 +425,7 @@ static void piix4_pm_machine_ready(Notifier *n, void *opaque) pci_conf[0x67] = (memory_region_present(io_as, 0x3f8) ? 0x08 : 0) | (memory_region_present(io_as, 0x2f8) ? 0x90 : 0); - if (s->use_acpi_pci_hotplug) { + if (!s->acpi_pci_hotplug.legacy_piix) { pci_for_each_bus(d->bus, piix4_update_bus_hotplug, s); } } @@ -550,8 +549,8 @@ static Property piix4_pm_properties[] = { DEFINE_PROP_UINT8(ACPI_PM_PROP_S3_DISABLED, PIIX4PMState, disable_s3, 0), DEFINE_PROP_UINT8(ACPI_PM_PROP_S4_DISABLED, PIIX4PMState, disable_s4, 0), DEFINE_PROP_UINT8(ACPI_PM_PROP_S4_VAL, PIIX4PMState, s4_val, 2), - DEFINE_PROP_BOOL("acpi-pci-hotplug-with-bridge-support", PIIX4PMState, - use_acpi_pci_hotplug, true), + DEFINE_PROP_BOOL("legacy-acpi-pci-hotplug", PIIX4PMState, + acpi_pci_hotplug.legacy_piix, false), DEFINE_PROP_END_OF_LIST(), }; @@ -694,7 +693,7 @@ static void piix4_acpi_system_hot_add_init(MemoryRegion *parent, "acpi-gpe0", GPE_LEN); memory_region_add_subregion(parent, GPE_BASE, &s->io_gpe); - if (s->use_acpi_pci_hotplug) { + if (!s->acpi_pci_hotplug.legacy_piix) { acpi_pcihp_init(&s->acpi_pci_hotplug, bus, parent); } else { memory_region_init_io(&s->io_pci, OBJECT(s), &piix4_pci_ops, s, diff --git a/include/hw/acpi/pcihp.h b/include/hw/acpi/pcihp.h index aa297c2..6877892 100644 --- a/include/hw/acpi/pcihp.h +++ b/include/hw/acpi/pcihp.h @@ -46,6 +46,7 @@ typedef struct AcpiPciHpState { uint32_t hotplug_select; PCIBus *root; MemoryRegion io; + bool legacy_piix; } AcpiPciHpState; void acpi_pcihp_init(AcpiPciHpState *, PCIBus *root, diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index 3e1e81b..68d75d8 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -268,8 +268,8 @@ int e820_add_entry(uint64_t, uint64_t, uint32_t); },\ {\ .driver = "PIIX4_PM",\ - .property = "acpi-pci-hotplug-with-bridge-support",\ - .value = "off",\ + .property = "legacy-acpi-pci-hotplug",\ + .value = "on",\ } #define PC_COMPAT_1_6 \