From patchwork Mon Oct 22 18:36:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Ortiz X-Patchwork-Id: 987872 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=none (p=none dis=none) header.from=linux.intel.com Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42f5Rf4fLlz9sD4 for ; Tue, 23 Oct 2018 05:59:42 +1100 (AEDT) Received: from localhost ([::1]:36715 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gEfQS-0002MK-90 for incoming@patchwork.ozlabs.org; Mon, 22 Oct 2018 14:59:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39800) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gEf7G-0001mS-HR for qemu-devel@nongnu.org; Mon, 22 Oct 2018 14:39:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gEf7D-0005lu-8t for qemu-devel@nongnu.org; Mon, 22 Oct 2018 14:39:50 -0400 Received: from mga01.intel.com ([192.55.52.88]:7887) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gEf7B-0004fU-BX for qemu-devel@nongnu.org; Mon, 22 Oct 2018 14:39:46 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Oct 2018 11:39:04 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,413,1534834800"; d="scan'208";a="90378144" Received: from omccarth-mobl.ger.corp.intel.com (HELO localhost.localdomain) ([10.252.18.99]) by FMSMGA003.fm.intel.com with ESMTP; 22 Oct 2018 11:39:02 -0700 From: Samuel Ortiz To: qemu-devel@nongnu.org Date: Mon, 22 Oct 2018 20:36:56 +0200 Message-Id: <20181022183656.4902-27-sameo@linux.intel.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20181022183656.4902-1-sameo@linux.intel.com> References: <20181022183656.4902-1-sameo@linux.intel.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 192.55.52.88 Subject: [Qemu-devel] [PATCH 26/26] hw: acpi: reduced: Add PCI hotplug support 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: Igor Mammedov , Sebastien Boeuf , "Michael S. Tsirkin" Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Sebastien Boeuf In order to support PCI hotplug through a hardware-reduced GED, we need to modify the GED device definition in the DSDT table, so that a PCI hotplug related interrupt will trigger a new PCI scan. We also need to modify the DSDT PCI bus definition in order to make sure a PCI scan of all available slots can be performed when an interrupt comes in. Cc: "Michael S. Tsirkin" Cc: Igor Mammedov Signed-off-by: Sebastien Boeuf Signed-off-by: Jing Liu --- hw/acpi/aml-build.c | 8 +++++++- hw/acpi/reduced.c | 7 +++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c index 752642a67a..99f04a3e71 100644 --- a/hw/acpi/aml-build.c +++ b/hw/acpi/aml-build.c @@ -2510,7 +2510,7 @@ void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus, void acpi_dsdt_add_pci_bus(Aml *dsdt, AcpiPciBus *pci_host) { - Aml *dev, *pci_scope; + Aml *dev, *pci_scope, *hp_scope; dev = aml_device("\\_SB.PCI0"); aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0A08"))); @@ -2522,6 +2522,12 @@ void acpi_dsdt_add_pci_bus(Aml *dsdt, AcpiPciBus *pci_host) aml_append(dev, build_osc_method(0x1F)); aml_append(dsdt, dev); + /* PCIHP */ + hp_scope = aml_scope("\\_SB.PCI0"); + build_acpi_pci_hotplug(hp_scope); + build_append_pci_bus_devices(hp_scope, pci_host->pci_bus, false); + aml_append(dsdt, hp_scope); + pci_scope = build_pci_host_bridge(dsdt, pci_host); aml_append(dsdt, pci_scope); } diff --git a/hw/acpi/reduced.c b/hw/acpi/reduced.c index fac19a978a..7faccdc634 100644 --- a/hw/acpi/reduced.c +++ b/hw/acpi/reduced.c @@ -331,6 +331,8 @@ void acpi_reduced_setup(MachineState *machine, AcpiConfiguration *conf) static Aml *ged_event_aml(GedEvent *event) { + Aml *method; + if (!event) { return NULL; } @@ -343,6 +345,11 @@ static Aml *ged_event_aml(GedEvent *event) /* We run a complete memory SCAN when getting a memory hotplug event */ return aml_call0("\\_SB.MHPC." MEMORY_SLOT_SCAN_METHOD); case GED_PCI_HOTPLUG: + /* Take the PCI lock and trigger a PCI rescan */ + method = aml_acquire(aml_name("\\_SB.PCI0.BLCK"), 0xFFFF); + aml_append(method, aml_call0("\\_SB.PCI0.PCNT")); + aml_append(method, aml_release(aml_name("\\_SB.PCI0.BLCK"))); + return method; case GED_NVDIMM_HOTPLUG: return aml_notify(aml_name("\\_SB.NVDR"), aml_int(0x80)); default: