From patchwork Tue Jun 12 09:13:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zihan Yang X-Patchwork-Id: 928197 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="WykN5qWQ"; dkim-atps=neutral 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 414klQ3Wdxz9s1B for ; Tue, 12 Jun 2018 19:16:18 +1000 (AEST) Received: from localhost ([::1]:54003 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fSfPU-0005tT-6Y for incoming@patchwork.ozlabs.org; Tue, 12 Jun 2018 05:16:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58970) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fSfND-0004gc-0h for qemu-devel@nongnu.org; Tue, 12 Jun 2018 05:13:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fSfN9-0006in-OD for qemu-devel@nongnu.org; Tue, 12 Jun 2018 05:13:54 -0400 Received: from mail-pl0-x241.google.com ([2607:f8b0:400e:c01::241]:35243) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fSfN9-0006i7-Fc for qemu-devel@nongnu.org; Tue, 12 Jun 2018 05:13:51 -0400 Received: by mail-pl0-x241.google.com with SMTP id k1-v6so5604809plt.2 for ; Tue, 12 Jun 2018 02:13:51 -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=5ruNxPRXdcNUcw1hwtBupfkiFQfZSJiJzpIvsdyJ7dE=; b=WykN5qWQGM0Fr6rd4ReLCQdm4hbaH3+edECxNCFWcS9HILPjL7tGcy3OLeOc7UgBPx X6fLWTi2dDzDrZb512ocHP2m4/ouygVcp/HmESRiXcjXUXSlLcdZOiVBosstZO8g6tQO MRhU71fWpNnteHYPurEOEVG9p8m6SjbzrpFsL2yRMnfXdVDgj6KHdJBmP+odXi0kR7Nf H5bpeuUGsqVcoe4wySQ7xTjTpHq2fGIg+/7MIWMY0q3ujeoIW6bb3wbbAvx2P7JmjlfR 8q/3n1GqH7iolaI57049fLxMgX24CsRiQI2m0TqDrjvQ02y03/x0lL0QooK6p2qKoKh8 ljYA== 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=5ruNxPRXdcNUcw1hwtBupfkiFQfZSJiJzpIvsdyJ7dE=; b=VhiapRqRsuqMv4NqraoXcAyJtV1YWz9cZiX8U6G6KXMbjpTwYpVBPlJAOzeB+9Liyg 1Xdq4ehRONGgS0S78UgO5+84bXf4d3jdx/a81HJ2LzOwI3xuxoUGA+QeGAyC8slQp781 jX/CXvNeZti3n5h5pNmztIyYL1dfs+waaAZ4JwHEDsUWFyOz3TaFlpDwisxxdvN+RHPP iIbbS3aVNvHoMRO+YSJqfgdHCJo07+EuiXiwHIehdLRubgkrgP2O7YA8ksfwuwHNoS9S oIlznuEj0mio5TtOgDRZEskbBlqNaiDuqtoE/5fNMR9UCSkm6MG0aRd46Zm/VyyFp8E3 5XBQ== X-Gm-Message-State: APt69E2m++CMCbCqIdUrqwnEVQZaH3o7YbSFbLqhmyFauXjZknuBq5/x h4eIxahblpoR8E0jZKMBXrSwsA== X-Google-Smtp-Source: ADUXVKJsfdkgCRgnJTOVmx7xoZR2qSuF/JpIpZb9QNJKjXxi4QX1IV/VgHPVZa35hk3SU70iQOUQUw== X-Received: by 2002:a17:902:7896:: with SMTP id q22-v6mr3052805pll.243.1528794830369; Tue, 12 Jun 2018 02:13:50 -0700 (PDT) Received: from localhost.localdomain ([141.101.152.11]) by smtp.gmail.com with ESMTPSA id w11-v6sm1053676pfn.71.2018.06.12.02.13.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 12 Jun 2018 02:13:49 -0700 (PDT) From: Zihan Yang To: qemu-devel@nongnu.org Date: Tue, 12 Jun 2018 17:13:24 +0800 Message-Id: <1528794804-6289-3-git-send-email-whois.zihan.yang@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1528794804-6289-1-git-send-email-whois.zihan.yang@gmail.com> References: <1528794804-6289-1-git-send-email-whois.zihan.yang@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::241 Subject: [Qemu-devel] [RFC v2 3/3] acpi-build: describe new pci domain in AML 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: Eduardo Habkost , Zihan Yang , "Michael S. Tsirkin" , Paolo Bonzini , Igor Mammedov , Richard Henderson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Describe new pci segments of host bridges in AML. The host bridge list is replaced by QTAILQ to let q35 host be processed first in every traverse Signed-off-by: Zihan Yang --- hw/i386/acpi-build.c | 69 ++++++++++++++++++++++++++++++----------------- hw/pci/pci.c | 9 ++++--- include/hw/pci/pci_host.h | 2 +- 3 files changed, 50 insertions(+), 30 deletions(-) diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 104e52d..a9f1503 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -2123,36 +2123,55 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, sb_scope = aml_scope("\\_SB"); { Object *pci_host; + QObject *o; PCIBus *bus = NULL; + uint32_t domain_nr; + bool q35host = true; pci_host = acpi_get_i386_pci_host(); - if (pci_host) { + while (pci_host) { + o = object_property_get_qobject(pci_host, "domain_nr", NULL); + assert(o); + domain_nr = qnum_get_uint(qobject_to(QNum, o)); + qobject_unref(o); + + /* skip expander bridges that still reside in domain 0 */ + if (!q35host && domain_nr == 0) { + pci_host = OBJECT(QTAILQ_NEXT(PCI_HOST_BRIDGE(pci_host), next)); + continue; + } bus = PCI_HOST_BRIDGE(pci_host)->bus; - } - if (bus) { - Aml *scope = aml_scope("PCI0"); - /* Scan all PCI buses. Generate tables to support hotplug. */ - build_append_pci_bus_devices(scope, bus, pm->pcihp_bridge_en); + if (bus) { + Aml *scope = aml_scope("PCI0"); + aml_append(scope, aml_name_decl("_SEG", aml_int(domain_nr))); + /* For simplicity, base bus number starts from 0 */ + aml_append(scope, aml_name_decl("_BBN", aml_int(0))); + /* Scan all PCI buses. Generate tables to support hotplug. */ + build_append_pci_bus_devices(scope, bus, pm->pcihp_bridge_en); - if (TPM_IS_TIS(tpm_find())) { - dev = aml_device("ISA.TPM"); - aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0C31"))); - aml_append(dev, aml_name_decl("_STA", aml_int(0xF))); - crs = aml_resource_template(); - aml_append(crs, aml_memory32_fixed(TPM_TIS_ADDR_BASE, - TPM_TIS_ADDR_SIZE, AML_READ_WRITE)); - /* - FIXME: TPM_TIS_IRQ=5 conflicts with PNP0C0F irqs, - Rewrite to take IRQ from TPM device model and - fix default IRQ value there to use some unused IRQ - */ - /* aml_append(crs, aml_irq_no_flags(TPM_TIS_IRQ)); */ - aml_append(dev, aml_name_decl("_CRS", crs)); - aml_append(scope, dev); + if (TPM_IS_TIS(tpm_find())) { + dev = aml_device("ISA.TPM"); + aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0C31"))); + aml_append(dev, aml_name_decl("_STA", aml_int(0xF))); + crs = aml_resource_template(); + aml_append(crs, aml_memory32_fixed(TPM_TIS_ADDR_BASE, + TPM_TIS_ADDR_SIZE, AML_READ_WRITE)); + /* + FIXME: TPM_TIS_IRQ=5 conflicts with PNP0C0F irqs, + Rewrite to take IRQ from TPM device model and + fix default IRQ value there to use some unused IRQ + */ + /* aml_append(crs, aml_irq_no_flags(TPM_TIS_IRQ)); */ + aml_append(dev, aml_name_decl("_CRS", crs)); + aml_append(scope, dev); + } + + aml_append(sb_scope, scope); } - - aml_append(sb_scope, scope); + /* q35 host is the first one in the tail queue */ + q35host = false; + pci_host = OBJECT(QTAILQ_NEXT(PCI_HOST_BRIDGE(pci_host), next)); } } @@ -2645,7 +2664,7 @@ static AcpiMcfgInfo *acpi_get_mcfg(void) qobject_unref(o); /* skip q35 host and bridges that reside in the same domain with it */ if (domain_nr == 0) { - pci_host = OBJECT(QLIST_NEXT(PCI_HOST_BRIDGE(pci_host), next)); + pci_host = OBJECT(QTAILQ_NEXT(PCI_HOST_BRIDGE(pci_host), next)); continue; } @@ -2674,7 +2693,7 @@ static AcpiMcfgInfo *acpi_get_mcfg(void) assert(o); mcfg->domain_nr = qnum_get_uint(qobject_to(QNum, o)); - pci_host = OBJECT(QLIST_NEXT(PCI_HOST_BRIDGE(pci_host), next)); + pci_host = OBJECT(QTAILQ_NEXT(PCI_HOST_BRIDGE(pci_host), next)); } return head; diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 80bc459..f63385f 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -196,7 +196,8 @@ static void pci_del_option_rom(PCIDevice *pdev); static uint16_t pci_default_sub_vendor_id = PCI_SUBVENDOR_ID_REDHAT_QUMRANET; static uint16_t pci_default_sub_device_id = PCI_SUBDEVICE_ID_QEMU; -static QLIST_HEAD(, PCIHostState) pci_host_bridges; +static QTAILQ_HEAD(, PCIHostState) pci_host_bridges = + QTAILQ_HEAD_INITIALIZER(pci_host_bridges); int pci_bar(PCIDevice *d, int reg) { @@ -330,7 +331,7 @@ static void pci_host_bus_register(DeviceState *host) { PCIHostState *host_bridge = PCI_HOST_BRIDGE(host); - QLIST_INSERT_HEAD(&pci_host_bridges, host_bridge, next); + QTAILQ_INSERT_HEAD(&pci_host_bridges, host_bridge, next); } PCIBus *pci_device_root_bus(const PCIDevice *d) @@ -1798,7 +1799,7 @@ PciInfoList *qmp_query_pci(Error **errp) PciInfoList *info, *head = NULL, *cur_item = NULL; PCIHostState *host_bridge; - QLIST_FOREACH(host_bridge, &pci_host_bridges, next) { + QTAILQ_FOREACH(host_bridge, &pci_host_bridges, next) { info = g_malloc0(sizeof(*info)); info->value = qmp_query_pci_bus(host_bridge->bus, pci_bus_num(host_bridge->bus)); @@ -2493,7 +2494,7 @@ int pci_qdev_find_device(const char *id, PCIDevice **pdev) PCIHostState *host_bridge; int rc = -ENODEV; - QLIST_FOREACH(host_bridge, &pci_host_bridges, next) { + QTAILQ_FOREACH(host_bridge, &pci_host_bridges, next) { int tmp = pci_qdev_find_recursive(host_bridge->bus, id, pdev); if (!tmp) { rc = 0; diff --git a/include/hw/pci/pci_host.h b/include/hw/pci/pci_host.h index ba31595..a5617cf 100644 --- a/include/hw/pci/pci_host.h +++ b/include/hw/pci/pci_host.h @@ -47,7 +47,7 @@ struct PCIHostState { uint32_t config_reg; PCIBus *bus; - QLIST_ENTRY(PCIHostState) next; + QTAILQ_ENTRY(PCIHostState) next; }; typedef struct PCIHostBridgeClass {