From patchwork Thu Aug 17 16:23:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony PERARD X-Patchwork-Id: 9906667 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 2137D60386 for ; Thu, 17 Aug 2017 16:26:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 14A2928B47 for ; Thu, 17 Aug 2017 16:26:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 094A528B61; Thu, 17 Aug 2017 16:26:18 +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=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8C29C28B47 for ; Thu, 17 Aug 2017 16:26:17 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1diNab-0005BQ-4E; Thu, 17 Aug 2017 16:24:09 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1diNaZ-0005AL-G7 for xen-devel@lists.xenproject.org; Thu, 17 Aug 2017 16:24:07 +0000 Received: from [193.109.254.147] by server-7.bemta-6.messagelabs.com id D8/0A-03557-623C5995; Thu, 17 Aug 2017 16:24:06 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprAIsWRWlGSWpSXmKPExsXitHRDpK7a4am RBm1LJSy+b5nM5MDocfjDFZYAxijWzLyk/IoE1owL+2cwFiySrzj04jZbA2OHZBcjJ4eEgL/E mUmf2EFsNgEDiRXTrzKC2CIC0hL9c9qB4lwczAIPmCQO/znLCpIQFvCUmNDUzgRiswioSrw91 8oGYvMK2Ers6WtkgxgqL3HuwW1mEJtTwE7i/a0DQIM4OISAat5M4gMJCwmoSdxYuIwFolVQ4u TMJ2A2s4CExMEXL5gnMPLOQpKahSS1gJFpFaN6cWpRWWqRrrleUlFmekZJbmJmjq6hgZlebmp xcWJ6ak5iUrFecn7uJkZg6DAAwQ7GmZf9DzFKcjApifL+njUlUogvKT+lMiOxOCO+qDQntfgQ owwHh5IEb/TBqZFCgkWp6akVaZk5wCCGSUtw8CiJ8E4ESfMWFyTmFmemQ6ROMepyvJrw/xuTE Etefl6qlDhvLUiRAEhRRmke3AhYRF1ilJUS5mUEOkqIpyC1KDezBFX+FaM4B6OSMMQUnsy8Er hNr4COYAI64kr7JJAjShIRUlINjDa5XNlatbp/0/0jNjKUrvVsU7nF57YzdNcv9W3xTae7Jj7 2nxn3faHwWxv7reciVINl73NuDq7ss+dfbFhe/yDm0ONM2fz3R2XuFVvmxojV+qzmiz5x9zSf 86c/kj/+sU2fFKETvolpje+sACdGvfqj6iwczrf+/o7MvLD3mN3rLTuM1K7+UGIpzkg01GIuK k4EAElrbCajAgAA X-Env-Sender: prvs=3958fb005=anthony.perard@citrix.com X-Msg-Ref: server-10.tower-27.messagelabs.com!1502987043!89073473!2 X-Originating-IP: [66.165.176.89] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni44OSA9PiAyMDMwMDc=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 16183 invoked from network); 17 Aug 2017 16:24:06 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-10.tower-27.messagelabs.com with RC4-SHA encrypted SMTP; 17 Aug 2017 16:24:06 -0000 X-IronPort-AV: E=Sophos;i="5.41,388,1498521600"; d="scan'208";a="435915303" From: Anthony PERARD To: Date: Thu, 17 Aug 2017 17:23:46 +0100 Message-ID: <20170817162347.1590-3-anthony.perard@citrix.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20170817162347.1590-1-anthony.perard@citrix.com> References: <20170817162347.1590-1-anthony.perard@citrix.com> MIME-Version: 1.0 Cc: Stefano Stabellini , Eduardo Habkost , "Michael S. Tsirkin" , Bruce Rogers , Paolo Bonzini , Igor Mammedov , Anthony PERARD , xen-devel@lists.xenproject.org, Richard Henderson Subject: [Xen-devel] [PATCH for-2.10 v3 2/3] hw/acpi: Move acpi_set_pci_info to pcihp X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP This means that the function will be call and the property acpi-pcihp-bsel will be set even if ACPI build is disable. To do PCI passthrough with Xen, the property acpi-pcihp-bsel needs to be set, but this was done only when ACPI tables are built which is not needed for a Xen guest. The need for the property starts with commit "pc: pcihp: avoid adding ACPI_PCIHP_PROP_BSEL twice" (f0c9d64a68b776374ec4732424a3e27753ce37b6). Reported-by: Sander Eikelenboom Signed-off-by: Anthony PERARD --- Changes in V3: - move acpi_set_pci_info to pcihp instead Changes in V2: - check for acpi_enabled before calling acpi_set_pci_info. - set the property on the root bus only. This patch would be a canditade to backport to 2.9, along with "hw/acpi: Limit hotplug to root bus on legacy mode" CC: Stefano Stabellini CC: Bruce Rogers --- hw/acpi/pcihp.c | 31 +++++++++++++++++++++++++++++++ hw/i386/acpi-build.c | 32 -------------------------------- 2 files changed, 31 insertions(+), 32 deletions(-) diff --git a/hw/acpi/pcihp.c b/hw/acpi/pcihp.c index 9db3c2eaf2..44e8842db8 100644 --- a/hw/acpi/pcihp.c +++ b/hw/acpi/pcihp.c @@ -75,6 +75,36 @@ static int acpi_pcihp_get_bsel(PCIBus *bus) } } +/* Assign BSEL property to all buses. In the future, this can be changed + * to only assign to buses that support hotplug. + */ +static void *acpi_set_bsel(PCIBus *bus, void *opaque) +{ + unsigned *bsel_alloc = opaque; + unsigned *bus_bsel; + + if (qbus_is_hotpluggable(BUS(bus))) { + bus_bsel = g_malloc(sizeof *bus_bsel); + + *bus_bsel = (*bsel_alloc)++; + object_property_add_uint32_ptr(OBJECT(bus), ACPI_PCIHP_PROP_BSEL, + bus_bsel, &error_abort); + } + + return bsel_alloc; +} + +static void acpi_set_pci_info(void) +{ + 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); + } +} + static void acpi_pcihp_test_hotplug_bus(PCIBus *bus, void *opaque) { AcpiPciHpFind *find = opaque; @@ -177,6 +207,7 @@ static void acpi_pcihp_update(AcpiPciHpState *s) void acpi_pcihp_reset(AcpiPciHpState *s) { + acpi_set_pci_info(); acpi_pcihp_update(s); } diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 98dd424678..4d19d91e1b 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -493,36 +493,6 @@ build_madt(GArray *table_data, BIOSLinker *linker, PCMachineState *pcms) table_data->len - madt_start, 1, NULL, NULL); } -/* Assign BSEL property to all buses. In the future, this can be changed - * to only assign to buses that support hotplug. - */ -static void *acpi_set_bsel(PCIBus *bus, void *opaque) -{ - unsigned *bsel_alloc = opaque; - unsigned *bus_bsel; - - if (qbus_is_hotpluggable(BUS(bus))) { - bus_bsel = g_malloc(sizeof *bus_bsel); - - *bus_bsel = (*bsel_alloc)++; - object_property_add_uint32_ptr(OBJECT(bus), ACPI_PCIHP_PROP_BSEL, - bus_bsel, &error_abort); - } - - return bsel_alloc; -} - -static void acpi_set_pci_info(void) -{ - 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); - } -} - static void build_append_pcihp_notify_entry(Aml *method, int slot) { Aml *if_ctx; @@ -2888,8 +2858,6 @@ void acpi_setup(void) build_state = g_malloc0(sizeof *build_state); - acpi_set_pci_info(); - acpi_build_tables_init(&tables); acpi_build(&tables, MACHINE(pcms));