From patchwork Mon Aug 10 11:29:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ani Sinha X-Patchwork-Id: 11707339 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8AC52739 for ; Mon, 10 Aug 2020 11:30:41 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 21E2920709 for ; Mon, 10 Aug 2020 11:30:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=anisinha-ca.20150623.gappssmtp.com header.i=@anisinha-ca.20150623.gappssmtp.com header.b="Qr9eYjrC" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 21E2920709 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=anisinha.ca Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:34236 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k560l-0002po-PR for patchwork-qemu-devel@patchwork.kernel.org; Mon, 10 Aug 2020 07:30:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44368) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k560D-0002LC-1M for qemu-devel@nongnu.org; Mon, 10 Aug 2020 07:30:05 -0400 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]:40008) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1k560A-0001v7-T0 for qemu-devel@nongnu.org; Mon, 10 Aug 2020 07:30:04 -0400 Received: by mail-pl1-x641.google.com with SMTP id u10so4640280plr.7 for ; Mon, 10 Aug 2020 04:30:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anisinha-ca.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=lPfCDODgZUcS20IzAK0sens4LanQKMofrc5tBOoJuwk=; b=Qr9eYjrCT2BoxdcjpJdWvCAgXorW9sdnKf/VOxBH7I3LyU29RNzb2gwEegkI+SktLE MlqFppfXfQlKT2O7DxRzC0yBI9SVXnbrcYas5D5fxelQaY/DPeGKjeSKpcGtb2uZ9gyJ y14LH8wx/mOOXVCEnJdHaM0d/lWUcoMxpAhxAbyYVqkevHuMxQQNfx7rGWg9qp+foYPy pUU+ij+q+dYvisdRZBQimOSh/Rj+Aj8czLbBaAB+qjMNV8KfasmBRJ8hm2C9kIQC0cas +6XAx24sq1zfsCyROI1JS5EiEnIvVRk5VbpwNM4NEBhMA5ShYoflAlu3noXbuNtMDds7 q4hg== 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; bh=lPfCDODgZUcS20IzAK0sens4LanQKMofrc5tBOoJuwk=; b=uTrSd0zxmLU5CYbikseyCxsbSGl74twJXYoFYbaOCtzffapjeeltwFLjkSg1ymSIX6 0FZYY1c2C4gDAqJGqJLXaQVQh7CIAIwGy8Emcc/mtz8Uc9gxpfutJxYVeYKAVIwlP7Pg Nu//jDFSnC5BvDg/4OfEPBHZOWXSQd4X69YCwzwnc+dq2RQ+4mXztwlc/UOJDCpCJT5Y F28FvzGenrPhF+T8hhj7VL4tTRhSE6sCmBbw5Sw2ScYUcUmsBA42Ww8emSNtzMcadyvb PYNaNJux9fOkh6bBwJchGoKMrmIzd2/74Ea1LjmnOINepJfe2t2WiN/9hz/P6AxPxj1+ F4cA== X-Gm-Message-State: AOAM53267VtZ0YrgR8oIrGHln5EDnrGIpatpHxSoqgOqr0Wz2YmV92Io kp6rTlEw9MjBhT/SqnsBw1qU7HEkNUBxlg== X-Google-Smtp-Source: ABdhPJwSwlBh3b0o4JCL9v9LisOGxSDR+s9vdQpAMA0Xp64MQSF/b5m2cNn2zt3DDJ8xilybjcNkWQ== X-Received: by 2002:a17:90a:1384:: with SMTP id i4mr27705192pja.157.1597058999986; Mon, 10 Aug 2020 04:29:59 -0700 (PDT) Received: from localhost.localdomain ([203.163.233.127]) by smtp.gmail.com with ESMTPSA id t13sm18196985pgm.32.2020.08.10.04.29.54 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 10 Aug 2020 04:29:59 -0700 (PDT) From: Ani Sinha To: qemu-devel@nongnu.org Subject: [PATCH] Introduce global piix flag to disable PCI hotplug Date: Mon, 10 Aug 2020 16:59:41 +0530 Message-Id: <1597058982-70090-1-git-send-email-ani@anisinha.ca> X-Mailer: git-send-email 2.7.4 Received-SPF: none client-ip=2607:f8b0:4864:20::641; envelope-from=ani@anisinha.ca; helo=mail-pl1-x641.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , "Michael S. Tsirkin" , Aleksandar Markovic , Paolo Bonzini , ani@anisinha.ca, Igor Mammedov , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Aurelien Jarno , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" We introduce a new global flag for PIIX with which we can turn on or off PCI device hotplug. This flag can be used to prevent all PCI devices from getting hotplugged/unplugged on the PCI bus. The new options disables all hotpluh HW initialization code as well as the ACPI AMLs. Signed-off-by: Ani Sinha --- hw/acpi/piix4.c | 8 ++++++-- hw/i386/acpi-build.c | 20 ++++++++++++++------ 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c index 26bac4f..8b13e86 100644 --- a/hw/acpi/piix4.c +++ b/hw/acpi/piix4.c @@ -78,6 +78,7 @@ typedef struct PIIX4PMState { AcpiPciHpState acpi_pci_hotplug; bool use_acpi_hotplug_bridge; + bool use_acpi_pci_hotplug; uint8_t disable_s3; uint8_t disable_s4; @@ -595,8 +596,9 @@ static void piix4_acpi_system_hot_add_init(MemoryRegion *parent, "acpi-gpe0", GPE_LEN); memory_region_add_subregion(parent, GPE_BASE, &s->io_gpe); - acpi_pcihp_init(OBJECT(s), &s->acpi_pci_hotplug, bus, parent, - s->use_acpi_hotplug_bridge); + if (s->use_acpi_pci_hotplug) + acpi_pcihp_init(OBJECT(s), &s->acpi_pci_hotplug, bus, parent, + s->use_acpi_hotplug_bridge); s->cpu_hotplug_legacy = true; object_property_add_bool(OBJECT(s), "cpu-hotplug-legacy", @@ -635,6 +637,8 @@ static Property piix4_pm_properties[] = { DEFINE_PROP_UINT8(ACPI_PM_PROP_S4_VAL, PIIX4PMState, s4_val, 2), DEFINE_PROP_BOOL("acpi-pci-hotplug-with-bridge-support", PIIX4PMState, use_acpi_hotplug_bridge, true), + DEFINE_PROP_BOOL("acpi-pci-hotplug", PIIX4PMState, + use_acpi_pci_hotplug, true), DEFINE_PROP_BOOL("memory-hotplug-support", PIIX4PMState, acpi_memory_hotplug.is_enabled, true), DEFINE_PROP_END_OF_LIST(), diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index b7bcbbb..343b9b6 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -95,6 +95,7 @@ typedef struct AcpiPmInfo { bool s3_disabled; bool s4_disabled; bool pcihp_bridge_en; + bool pcihp_en; uint8_t s4_val; AcpiFadtData fadt; uint16_t cpu_hp_io_base; @@ -245,6 +246,9 @@ static void acpi_get_pm_info(MachineState *machine, AcpiPmInfo *pm) pm->pcihp_bridge_en = object_property_get_bool(obj, "acpi-pci-hotplug-with-bridge-support", NULL); + pm->pcihp_en = + object_property_get_bool(obj, "acpi-pci-hotplug", NULL); + } static void acpi_get_misc_info(AcpiMiscInfo *info) @@ -337,14 +341,16 @@ static void build_append_pcihp_notify_entry(Aml *method, int slot) } static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus, - bool pcihp_bridge_en) + bool pcihp_bridge_en, bool pcihp_en) { Aml *dev, *notify_method = NULL, *method; - QObject *bsel; + QObject *bsel = NULL; PCIBus *sec; int i; - bsel = object_property_get_qobject(OBJECT(bus), ACPI_PCIHP_PROP_BSEL, NULL); + if (pcihp_en) + bsel = object_property_get_qobject(OBJECT(bus), + ACPI_PCIHP_PROP_BSEL, NULL); if (bsel) { uint64_t bsel_val = qnum_get_uint(qobject_to(QNum, bsel)); @@ -439,7 +445,8 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus, */ PCIBus *sec_bus = pci_bridge_get_sec_bus(PCI_BRIDGE(pdev)); - build_append_pci_bus_devices(dev, sec_bus, pcihp_bridge_en); + build_append_pci_bus_devices(dev, sec_bus, pcihp_bridge_en, + pcihp_en); } /* slot descriptor has been composed, add it into parent context */ aml_append(parent_scope, dev); @@ -468,7 +475,7 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus, } /* Notify about child bus events in any case */ - if (pcihp_bridge_en) { + if (pcihp_bridge_en && pcihp_en) { QLIST_FOREACH(sec, &bus->child, sibling) { int32_t devfn = sec->parent_dev->devfn; @@ -1818,7 +1825,8 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, 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); + build_append_pci_bus_devices(scope, bus, pm->pcihp_bridge_en, + pm->pcihp_en); if (TPM_IS_TIS_ISA(tpm)) { if (misc->tpm_version == TPM_VERSION_2_0) {