From patchwork Thu Jun 29 21:56:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleksandr Bezzubikov X-Patchwork-Id: 9818057 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 38474602B1 for ; Thu, 29 Jun 2017 22:01:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2D07B2845C for ; Thu, 29 Jun 2017 22:01:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1F4322847A; Thu, 29 Jun 2017 22:01:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 87FA12845C for ; Thu, 29 Jun 2017 22:01:47 +0000 (UTC) Received: from localhost ([::1]:41431 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dQhVS-0001Ji-Qj for patchwork-qemu-devel@patchwork.kernel.org; Thu, 29 Jun 2017 18:01:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34425) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dQhQL-0005kz-JF for qemu-devel@nongnu.org; Thu, 29 Jun 2017 17:56:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dQhQK-0000Sg-Mr for qemu-devel@nongnu.org; Thu, 29 Jun 2017 17:56:29 -0400 Received: from mail-lf0-x242.google.com ([2a00:1450:4010:c07::242]:34991) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dQhQK-0000Rs-Bk for qemu-devel@nongnu.org; Thu, 29 Jun 2017 17:56:28 -0400 Received: by mail-lf0-x242.google.com with SMTP id n136so8680281lfn.2 for ; Thu, 29 Jun 2017 14:56:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=7/xbdj9px7S5ZrC6BIGh27tvV6k8zxRYC/cKPAElrF0=; b=daTni0zhmX8JB2GTTBYXlvBpOgUK/oNNOYOXLgb/bI255+nW43gp892I2rvyV2K3zB cQ4QHBa0RWuQo7pF7dpn0EACJ/cGTRiKcDSG8bzycnPCy3JgLoxEgld70PBUArCWFIrs KGFBF51VPoUJezuG8q2TiVwihmZb94M1vk7voIn7fMGhvTGyigphCPgsh5W9RmbZMJ0D 8G1nKXBVvTxm1bXcdWdLxmOy+bEPM5Y8ntoI2gP8vYM8lN4HmCz6gEQZXKHUUYzBaHDN bm4bL3SnDw9A2qNXNZ4ps2izmTV0mKLYvDLkyZPDEHoQdsQKoxfX6w/fqAKGHkNf5KiS I+IA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=7/xbdj9px7S5ZrC6BIGh27tvV6k8zxRYC/cKPAElrF0=; b=WGOrOec8h4b8nLlfFicIEL58Lyc+CWNz2x9HBtrzoM/eujoejsstFJva1T2Z0d3Jck +sq5hScqgpVE9l49XSpmtRcN0sKXVmR7K4wjvRjRqygPbJRfg+i2pRUnrA2lDVxWGIEN 6VScfJ7yLn1whyka8lFd7WUoXXQ0IfHMn8DIDZxp3GlaE68gfB9K4A8qKd2Y1UJPuN5D fyusadO6Mm92rDQRyLLIJJXQGFDtlHRscyreMiLs6WYaU5Z/ZPdP7ZEO2XZp3KWALDaF fyWqGONaY86RrgSiJd5GvJJ3pDJE9GLnflH6nDvbhqsI7cCdhD+UlRS3n2dYckidhkgV Qguw== X-Gm-Message-State: AKS2vOwpJZUYy85F3hsxwPinWrVwMcHwe/ifHG8nMbWPQO34hCw07hk6 ZrYzZOs+cmx2zA0zX60= X-Received: by 10.25.235.69 with SMTP id j66mr6195963lfh.141.1498773386690; Thu, 29 Jun 2017 14:56:26 -0700 (PDT) Received: from localhost.localdomain (broadband-5-228-183-39.moscow.rt.ru. [5.228.183.39]) by smtp.gmail.com with ESMTPSA id l69sm1532906lfl.10.2017.06.29.14.56.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 29 Jun 2017 14:56:25 -0700 (PDT) From: Aleksandr Bezzubikov To: qemu-devel@nongnu.org Date: Fri, 30 Jun 2017 00:56:01 +0300 Message-Id: <1498773362-18675-6-git-send-email-zuban32s@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1498773362-18675-1-git-send-email-zuban32s@gmail.com> References: <1498773362-18675-1-git-send-email-zuban32s@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4010:c07::242 Subject: [Qemu-devel] [PATCH RFC 5/6] hw/acpi: extend acpi pci hotplug support for pci express X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: ehabkost@redhat.com, mst@redhat.com, Aleksandr Bezzubikov , pbonzini@redhat.com, marcel@redhat.com, imammedo@redhat.com, rth@twiddle.net Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Aleksandr Bezzubikov --- hw/i386/acpi-build.c | 47 +++++++++++++++++++++++++++++++---------------- 1 file changed, 31 insertions(+), 16 deletions(-) diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index e434efe..8bbece5 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -254,6 +254,11 @@ static void acpi_get_pci_holes(Range *hole, Range *hole64) NULL)); } +static void acpi_test_pci_bus(PCIBus *bus, void *opaque) +{ + *(bool *)opaque |= !pci_bus_is_express(bus); +} + #define ACPI_PORT_SMI_CMD 0x00b2 /* TODO: this is APM_CNT_IOPORT */ static void acpi_align_size(GArray *blob, unsigned align) @@ -489,7 +494,7 @@ static void *acpi_set_bsel(PCIBus *bus, void *opaque) unsigned *bsel_alloc = opaque; unsigned *bus_bsel; - if (qbus_is_hotpluggable(BUS(bus))) { + if (qbus_is_hotpluggable(BUS(bus)) && !pci_bus_is_express(bus)) { bus_bsel = g_malloc(sizeof *bus_bsel); *bus_bsel = (*bsel_alloc)++; @@ -500,15 +505,12 @@ static void *acpi_set_bsel(PCIBus *bus, void *opaque) return bsel_alloc; } -static void acpi_set_pci_info(void) +static void acpi_set_pci_info(PCIBus *bus) { - PCIBus *bus = find_i440fx(); /* TODO: Q35 support */ unsigned bsel_alloc = ACPI_PCIHP_BSEL_DEFAULT; - if (bus) { - /* Scan all PCI buses. Set property to enable acpi based hotplug. */ - pci_for_each_bus_depth_first(bus, acpi_set_bsel, NULL, &bsel_alloc); - } + /* Scan all PCI buses. Set property to enable acpi based hotplug. */ + pci_for_each_bus_depth_first(bus, acpi_set_bsel, NULL, &bsel_alloc); } static void build_append_pcihp_notify_entry(Aml *method, int slot) @@ -570,7 +572,7 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus, * In this case they aren't themselves hot-pluggable. * Hotplugged bridges *are* hot-pluggable. */ - bridge_in_acpi = pc->is_bridge && pcihp_bridge_en && + bridge_in_acpi = pc->is_bridge && !pc->is_express && pcihp_bridge_en && !DEVICE(pdev)->hotplugged; hotplug_enabled_dev = bsel && dc->hotpluggable && !bridge_in_acpi; @@ -1787,7 +1789,7 @@ static void build_piix4_isa_bridge(Aml *table) aml_append(table, scope); } -static void build_piix4_pci_hotplug(Aml *table) +static void build_acpi_pci_hotplug(Aml *table) { Aml *scope; Aml *field; @@ -1889,6 +1891,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, uint32_t nr_mem = machine->ram_slots; int root_bus_limit = 0xFF; PCIBus *root_bus = NULL; + bool has_pci_bus = false; int i; dsdt = init_aml_allocator(); @@ -1910,7 +1913,6 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, build_piix4_pm(dsdt); build_piix4_isa_bridge(dsdt); build_isa_devices_aml(dsdt); - build_piix4_pci_hotplug(dsdt); build_piix4_pci0_int(dsdt); } else { sb_scope = aml_scope("_SB"); @@ -1932,6 +1934,11 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, root_bus = PC_MACHINE(machine)->bus; assert(root_bus); + pci_for_each_bus(root_bus, acpi_test_pci_bus, &has_pci_bus); + if (pm->pcihp_bridge_en && has_pci_bus) { + build_acpi_pci_hotplug(dsdt); + } + if (pcmc->legacy_cpu_hotplug) { build_legacy_cpu_hotplug_aml(dsdt, machine, pm->cpu_hp_io_base); } else { @@ -1947,7 +1954,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, { aml_append(scope, aml_name_decl("_HID", aml_string("ACPI0006"))); - if (misc->is_piix4) { + if (pm->pcihp_bridge_en && has_pci_bus) { method = aml_method("_E01", 0, AML_NOTSERIALIZED); aml_append(method, aml_acquire(aml_name("\\_SB.PCI0.BLCK"), 0xFFFF)); @@ -2080,7 +2087,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, crs_range_set_free(&crs_range_set); /* reserve PCIHP resources */ - if (pm->pcihp_io_len) { + if (pm->pcihp_bridge_en && has_pci_bus && pm->pcihp_io_len) { dev = aml_device("PHPR"); aml_append(dev, aml_name_decl("_HID", aml_string("PNP0A06"))); aml_append(dev, @@ -2212,8 +2219,13 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, sb_scope = aml_scope("\\_SB"); { Aml *scope = aml_scope("PCI0"); - /* Scan all PCI buses. Generate tables to support hotplug. */ - build_append_pci_bus_devices(scope, root_bus, pm->pcihp_bridge_en); + bool scope_used = false; + + if (pm->pcihp_bridge_en && has_pci_bus) { + /* Scan all PCI buses. Generate tables to support hotplug. */ + build_append_pci_bus_devices(scope, root_bus, pm->pcihp_bridge_en); + scope_used = true; + } if (misc->tpm_version != TPM_VERSION_UNSPEC) { dev = aml_device("ISA.TPM"); @@ -2230,9 +2242,12 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, /* aml_append(crs, aml_irq_no_flags(TPM_TIS_IRQ)); */ aml_append(dev, aml_name_decl("_CRS", crs)); aml_append(scope, dev); + scope_used = true; } - aml_append(sb_scope, scope); + if (scope_used) { + aml_append(sb_scope, scope); + } } aml_append(dsdt, sb_scope); @@ -2866,7 +2881,7 @@ void acpi_setup(void) build_state = g_malloc0(sizeof *build_state); - acpi_set_pci_info(); + acpi_set_pci_info(pcms->bus); acpi_build_tables_init(&tables); acpi_build(&tables, MACHINE(pcms));