From patchwork Mon Mar 12 18:34:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey G X-Patchwork-Id: 10276999 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 7858B60211 for ; Mon, 12 Mar 2018 18:37:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6850928BE4 for ; Mon, 12 Mar 2018 18:37:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5D2A628C6A; Mon, 12 Mar 2018 18:37:07 +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 D479428BE4 for ; Mon, 12 Mar 2018 18:37:06 +0000 (UTC) Received: from localhost ([::1]:33867 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1evSJm-00012e-0r for patchwork-qemu-devel@patchwork.kernel.org; Mon, 12 Mar 2018 14:37:06 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44593) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1evSIG-0007zz-Mh for qemu-devel@nongnu.org; Mon, 12 Mar 2018 14:35:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1evSIF-0005Gy-IR for qemu-devel@nongnu.org; Mon, 12 Mar 2018 14:35:32 -0400 Received: from mail-pl0-x231.google.com ([2607:f8b0:400e:c01::231]:46576) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1evSIF-0005GQ-AV for qemu-devel@nongnu.org; Mon, 12 Mar 2018 14:35:31 -0400 Received: by mail-pl0-x231.google.com with SMTP id f5-v6so2245861plj.13 for ; Mon, 12 Mar 2018 11:35:31 -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 :in-reply-to:references; bh=eTmytw3BqwcEJXRPKJSwiCUAAoHu1s+OfOoYLB44ySI=; b=FNk0+5/HN4tIOD0a2NE8q/7aOYugYl1DsaS5z9r+iGdzHJu4xDkEjOLuqDbdE9l03a JGxPRtbm23q/L9GHhgG0G6rhWd83UpCR6er3IQokI4CTXo9jHzHba1qQUV8T4SvAuug+ K4Jytbs5X/F/6sKJsOG5Y7dKc/7/s+eBwBz+gf+JO5mpobDf3FQMw/c/eW8kGxBTKY7b kozo9IoKx+fH+4bLe21k9vY7x9Ivn3scGTg2DXeyuQ8o+K1mRTMo5O5sonV4/Dk5k2B6 x1ahN5YlkLIkB16qot/ZJ/1wF6zb8Gr3e/dXAKiJfpOP6kjGk+ObP9Hqq6lCTD17FoNi MmSA== 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:in-reply-to:references; bh=eTmytw3BqwcEJXRPKJSwiCUAAoHu1s+OfOoYLB44ySI=; b=Unxd/Qa0+5ZeUPhKyBEKlbQ4kKlaNdsSK207W09a+42G5HwAqSLhnj2xIF/denJEmB 9jdqyhcGrdU69wfmpr47VRvWRvO+tAMGcIE3UKYB3HIbNRfBfNcm5Kf+7yRQ7D7bINot MG/2WkUABgUtzes927olIwIy1uyO1NSJvO/eQVm1ZiuigPa/albe2syIiweYSoG0vyMH dEyjpnIZb4METl6oXp0tXhd8GNj1IOyh9bbCyTOTzYBCUJUwNjc+XLZpBymItAOAp4oy VphGZustuzLCEQyEWV0sU/4f3x7tnIfueEL5+jPvTTiirwGqyF3j4yt72cVeC+HkbY3/ Phmw== X-Gm-Message-State: AElRT7FVI9Q4DnenN/o4sbYiRyS4lrggNJFESmcVxsP5s2B4S/84ydNa v2xPu2NDVxPy2kld0SNovOo= X-Google-Smtp-Source: AG47ELu48MKfgQv5R2xfnCEIn1uWWzs0R16/4gMY6LdgHZorI6TTtrTB/ZFDSTbT8M9omACG4rjBcQ== X-Received: by 2002:a17:902:468:: with SMTP id 95-v6mr3579411ple.360.1520879730443; Mon, 12 Mar 2018 11:35:30 -0700 (PDT) Received: from localhost.localdomain ([217.150.73.25]) by smtp.gmail.com with ESMTPSA id w10sm14468666pgr.57.2018.03.12.11.35.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Mar 2018 11:35:29 -0700 (PDT) From: Alexey Gerasimenko To: xen-devel@lists.xenproject.org Date: Tue, 13 Mar 2018 04:34:00 +1000 Message-Id: <7379b9a20e56554ec683261d0bdcd8d706d2232a.1520867956.git.x1917x@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::231 Subject: [Qemu-devel] [RFC PATCH 15/30] q35/acpi/xen: Provide ACPI PCI hotplug interface for Xen on Q35 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: Marcel Apfelbaum , Igor Mammedov , "Michael S. Tsirkin" , Alexey Gerasimenko , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP This patch allows to use ACPI PCI hotplug functionality for Xen on Q35. All added code depends on xen_enabled(), so no functionality change for non-Xen usage. We need to call the acpi_set_pci_info function from ich9_pm_init as well, so it was made globally visible again (as it was before). Signed-off-by: Alexey Gerasimenko --- hw/acpi/ich9.c | 24 ++++++++++++++++++++++++ hw/acpi/pcihp.c | 2 +- include/hw/acpi/ich9.h | 2 ++ include/hw/acpi/pcihp.h | 2 ++ 4 files changed, 29 insertions(+), 1 deletion(-) diff --git a/hw/acpi/ich9.c b/hw/acpi/ich9.c index c5d8646abc..62e2582e1a 100644 --- a/hw/acpi/ich9.c +++ b/hw/acpi/ich9.c @@ -37,6 +37,7 @@ #include "hw/i386/ich9.h" #include "hw/mem/pc-dimm.h" +#include "hw/xen/xen.h" //#define DEBUG @@ -258,6 +259,10 @@ static void pm_reset(void *opaque) pm->smi_en_wmask = ~0; acpi_update_sci(&pm->acpi_regs, pm->irq); + + if (xen_enabled()) { + acpi_pcihp_reset(&pm->acpi_pci_hotplug); + } } static void pm_powerdown_req(Notifier *n, void *opaque) @@ -300,6 +305,17 @@ void ich9_pm_init(PCIDevice *lpc_pci, ICH9LPCPMRegs *pm, pm->powerdown_notifier.notify = pm_powerdown_req; qemu_register_powerdown_notifier(&pm->powerdown_notifier); + if (xen_enabled()) { + PCIBus *bus = pci_get_bus(lpc_pci); + + qbus_set_hotplug_handler(BUS(bus), DEVICE(lpc_pci), &error_abort); + + acpi_pcihp_init(OBJECT(lpc_pci), &pm->acpi_pci_hotplug, bus, + pci_address_space_io(lpc_pci), false); + + acpi_set_pci_info(); + } + legacy_acpi_cpu_hotplug_init(pci_address_space_io(lpc_pci), OBJECT(lpc_pci), &pm->gpe_cpu, ICH9_CPU_HOTPLUG_IO_BASE); @@ -496,6 +512,10 @@ void ich9_pm_device_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, acpi_memory_plug_cb(hotplug_dev, &lpc->pm.acpi_memory_hotplug, dev, errp); } + } else if (xen_enabled() && + object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) { + acpi_pcihp_device_plug_cb(hotplug_dev, &lpc->pm.acpi_pci_hotplug, + dev, errp); } else if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) { if (lpc->pm.cpu_hotplug_legacy) { legacy_acpi_cpu_plug_cb(hotplug_dev, &lpc->pm.gpe_cpu, dev, errp); @@ -522,6 +542,10 @@ void ich9_pm_device_unplug_request_cb(HotplugHandler *hotplug_dev, !lpc->pm.cpu_hotplug_legacy) { acpi_cpu_unplug_request_cb(hotplug_dev, &lpc->pm.cpuhp_state, dev, errp); + } else if (xen_enabled() && + object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) { + acpi_pcihp_device_unplug_cb(hotplug_dev, &lpc->pm.acpi_pci_hotplug, + dev, errp); } else { error_setg(errp, "acpi: device unplug request for not supported device" " type: %s", object_get_typename(OBJECT(dev))); diff --git a/hw/acpi/pcihp.c b/hw/acpi/pcihp.c index f70d8620d7..d822f93293 100644 --- a/hw/acpi/pcihp.c +++ b/hw/acpi/pcihp.c @@ -94,7 +94,7 @@ static void *acpi_set_bsel(PCIBus *bus, void *opaque) return bsel_alloc; } -static void acpi_set_pci_info(void) +void acpi_set_pci_info(void) { static bool bsel_is_set; PCIBus *bus; diff --git a/include/hw/acpi/ich9.h b/include/hw/acpi/ich9.h index 59aeb06393..4a47d93745 100644 --- a/include/hw/acpi/ich9.h +++ b/include/hw/acpi/ich9.h @@ -26,6 +26,7 @@ #include "hw/acpi/cpu.h" #include "hw/acpi/memory_hotplug.h" #include "hw/acpi/acpi_dev_interface.h" +#include "hw/acpi/pcihp.h" #include "hw/acpi/tco.h" typedef struct ICH9LPCPMRegs { @@ -52,6 +53,7 @@ typedef struct ICH9LPCPMRegs { bool cpu_hotplug_legacy; AcpiCpuHotplug gpe_cpu; CPUHotplugState cpuhp_state; + AcpiPciHpState acpi_pci_hotplug; MemHotplugState acpi_memory_hotplug; diff --git a/include/hw/acpi/pcihp.h b/include/hw/acpi/pcihp.h index 8a65f99fc8..0a685dd228 100644 --- a/include/hw/acpi/pcihp.h +++ b/include/hw/acpi/pcihp.h @@ -64,6 +64,8 @@ void acpi_pcihp_device_unplug_cb(HotplugHandler *hotplug_dev, AcpiPciHpState *s, /* Called on reset */ void acpi_pcihp_reset(AcpiPciHpState *s); +void acpi_set_pci_info(void); + extern const VMStateDescription vmstate_acpi_pcihp_pci_status; #define VMSTATE_PCI_HOTPLUG(pcihp, state, test_pcihp) \