From patchwork Thu Feb 24 17:44:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 12759088 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 9DC2BC433F5 for ; Thu, 24 Feb 2022 17:52:15 +0000 (UTC) Received: from localhost ([::1]:48226 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nNIHm-0001UZ-Aq for qemu-devel@archiver.kernel.org; Thu, 24 Feb 2022 12:52:14 -0500 Received: from eggs.gnu.org ([209.51.188.92]:39152) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nNIBW-0001Ur-Cc for qemu-devel@nongnu.org; Thu, 24 Feb 2022 12:45:46 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:53023) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nNIBU-0002TG-AE for qemu-devel@nongnu.org; Thu, 24 Feb 2022 12:45:46 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1645724743; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QI9X/zpXFUd7V6NniMez8SnNpm4htCxFv7oefly+mkg=; b=XYkmo9NBhP8iAzO4KP24P1pDTwUIh9+cZRTozw2+mxMQFwzc11bAfRyZMsa8IbkFrRD7P/ XWbHTL1Bv/N5RHl4GWQvHJneSfcDWEiVYg4WuNkURBkDf3deV9qNgEeJa/GOrrQHP0zqEk SxoaKSIXNZjfrFHAtV10jaKKtHSC1Bo= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-496-KTQF9CdCMC6h3Sqp00PJyA-1; Thu, 24 Feb 2022 12:45:42 -0500 X-MC-Unique: KTQF9CdCMC6h3Sqp00PJyA-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 914B051D5 for ; Thu, 24 Feb 2022 17:45:41 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8C317710AC; Thu, 24 Feb 2022 17:44:54 +0000 (UTC) From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH 1/4] pci: expose TYPE_XIO3130_DOWNSTREAM name Date: Thu, 24 Feb 2022 12:44:08 -0500 Message-Id: <20220224174411.3296848-2-imammedo@redhat.com> In-Reply-To: <20220224174411.3296848-1-imammedo@redhat.com> References: <20220224174411.3296848-1-imammedo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=imammedo@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=170.10.133.124; envelope-from=imammedo@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kraxel@redhat.com, mst@redhat.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Type name will be used in followup patch for cast check in pcihp code. Signed-off-by: Igor Mammedov --- include/hw/pci-bridge/xio3130_downstream.h | 15 +++++++++++++++ hw/pci-bridge/xio3130_downstream.c | 3 ++- 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 include/hw/pci-bridge/xio3130_downstream.h diff --git a/include/hw/pci-bridge/xio3130_downstream.h b/include/hw/pci-bridge/xio3130_downstream.h new file mode 100644 index 0000000000..1d10139aea --- /dev/null +++ b/include/hw/pci-bridge/xio3130_downstream.h @@ -0,0 +1,15 @@ +/* + * TI X3130 pci express downstream port switch + * + * Copyright (C) 2022 Igor Mammedov + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef HW_PCI_BRIDGE_XIO3130_DOWNSTREAM_H +#define HW_PCI_BRIDGE_XIO3130_DOWNSTREAM_H + +#define TYPE_XIO3130_DOWNSTREAM "xio3130-downstream" + +#endif + diff --git a/hw/pci-bridge/xio3130_downstream.c b/hw/pci-bridge/xio3130_downstream.c index 04aae72cd6..b17cafd359 100644 --- a/hw/pci-bridge/xio3130_downstream.c +++ b/hw/pci-bridge/xio3130_downstream.c @@ -28,6 +28,7 @@ #include "migration/vmstate.h" #include "qapi/error.h" #include "qemu/module.h" +#include "hw/pci-bridge/xio3130_downstream.h" #define PCI_DEVICE_ID_TI_XIO3130D 0x8233 /* downstream port */ #define XIO3130_REVISION 0x1 @@ -173,7 +174,7 @@ static void xio3130_downstream_class_init(ObjectClass *klass, void *data) } static const TypeInfo xio3130_downstream_info = { - .name = "xio3130-downstream", + .name = TYPE_XIO3130_DOWNSTREAM, .parent = TYPE_PCIE_SLOT, .class_init = xio3130_downstream_class_init, .interfaces = (InterfaceInfo[]) { From patchwork Thu Feb 24 17:44:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 12759086 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 6F92AC433F5 for ; Thu, 24 Feb 2022 17:47:36 +0000 (UTC) Received: from localhost ([::1]:39176 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nNIDG-0003hp-1u for qemu-devel@archiver.kernel.org; Thu, 24 Feb 2022 12:47:34 -0500 Received: from eggs.gnu.org ([209.51.188.92]:39228) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nNIC2-0001lQ-93 for qemu-devel@nongnu.org; Thu, 24 Feb 2022 12:46:18 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:46073) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nNIBt-0002VQ-ED for qemu-devel@nongnu.org; Thu, 24 Feb 2022 12:46:17 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1645724758; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dHYpuN/ALkxd3ga2HMxALEv4o/lFFAEjKJ81OR2oV/4=; b=Jr1twSYVHJ1/h7ZuDXXsA7hdFRuxh/wY2s4tugABnmxKrz9gvpwUQh/bvmPUSMslVhnMQJ CrLiuP96bgh+qhrns/pMArvVzBMqzj67IPsMu1VBBLvuRp8pS8S0wMx6GMvELmK1ijrhIr piEvDDoqAr3UkUDlzWVBZk0q9AJLlFM= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-657-o0lNQ3VNPaaU0YHVo20y6g-1; Thu, 24 Feb 2022 12:45:57 -0500 X-MC-Unique: o0lNQ3VNPaaU0YHVo20y6g-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 61E54180FD73 for ; Thu, 24 Feb 2022 17:45:56 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id D94F9710AC; Thu, 24 Feb 2022 17:45:41 +0000 (UTC) From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH 2/4] pcie: update slot power status only is power control is enabled Date: Thu, 24 Feb 2022 12:44:09 -0500 Message-Id: <20220224174411.3296848-3-imammedo@redhat.com> In-Reply-To: <20220224174411.3296848-1-imammedo@redhat.com> References: <20220224174411.3296848-1-imammedo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=imammedo@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=170.10.129.124; envelope-from=imammedo@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kraxel@redhat.com, mst@redhat.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" on creation a PCIDevice has power turned on at the end of pci_qdev_realize() however later on if PCIe slot isn't populated with any children it's power is turned off. It's fine if native hotplug is used as plug callback will power slot on among other things. However when ACPI hotplug is enabled it replaces native PCIe plug callbacks with ACPI specific ones (acpi_pcihp_device_*plug_cb) and as result slot stays powered off. It works fine as ACPI hotplug on guest side takes care of enumerating/initializing hotplugged device. But when later guest is migrated, call chain introduced by [1] pcie_cap_slot_post_load() -> pcie_cap_update_power() -> pcie_set_power_device() -> pci_set_power() -> pci_update_mappings() will disable earlier initialized BARs for the hotplugged device in powered off slot due to commit [2] which disables BARs if power is off. As result guest OS after migration will be very much confused [3], still thinking that it has working device, which isn't true anymore due to disabled BARs. Fix it by honoring PCI_EXP_SLTCAP_PCP and updating power status only if capability is enabled. Follow up patch will disable PCI_EXP_SLTCAP_PCP overriding COMPAT_PROP_PCP property when PCIe slot is under ACPI PCI hotplug control. See [3] for reproducer. 1) Fixes: commit d5daff7d312 (pcie: implement slot power control for pcie root ports) 2) commit 23786d13441 (pci: implement power state) 3) Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2053584 Signed-off-by: Igor Mammedov --- hw/pci/pcie.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c index d7d73a31e4..2339729a7c 100644 --- a/hw/pci/pcie.c +++ b/hw/pci/pcie.c @@ -383,10 +383,9 @@ static void pcie_cap_update_power(PCIDevice *hotplug_dev) if (sltcap & PCI_EXP_SLTCAP_PCP) { power = (sltctl & PCI_EXP_SLTCTL_PCC) == PCI_EXP_SLTCTL_PWR_ON; + pci_for_each_device(sec_bus, pci_bus_num(sec_bus), + pcie_set_power_device, &power); } - - pci_for_each_device(sec_bus, pci_bus_num(sec_bus), - pcie_set_power_device, &power); } /* From patchwork Thu Feb 24 17:44:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 12759091 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 403C8C433F5 for ; Thu, 24 Feb 2022 17:54:22 +0000 (UTC) Received: from localhost ([::1]:54034 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nNIJp-0005TO-9u for qemu-devel@archiver.kernel.org; Thu, 24 Feb 2022 12:54:21 -0500 Received: from eggs.gnu.org ([209.51.188.92]:39224) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nNIC3-0001lP-VI for qemu-devel@nongnu.org; Thu, 24 Feb 2022 12:46:20 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:42908) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nNIBy-0002Z7-Ne for qemu-devel@nongnu.org; Thu, 24 Feb 2022 12:46:17 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1645724771; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6Aj9T10glahEHERQa7XalzUZWUCHxTU7/MVvMSBEwek=; b=Fqafj7IrLsw1Z/QfwnKVv365TS+QJMHPoB+XXoMzu+I5xjMD6abYr3CgZ1Kvp+NQoMaBzT tvV9NfWrqFtGKc0fMsuPtAF+9/70xPBPdqxR+fGaIbMfM0aBqaZ897SegT6R29Ddxf92Xs Kt+7+qYbWlRF3x7PdIDanHfbXBasB2I= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-553-PSotJuvKN6OaPbYqCuiFcQ-1; Thu, 24 Feb 2022 12:46:08 -0500 X-MC-Unique: PSotJuvKN6OaPbYqCuiFcQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 712D0100C610 for ; Thu, 24 Feb 2022 17:46:07 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id AA56C710AC; Thu, 24 Feb 2022 17:45:56 +0000 (UTC) From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH 3/4] acpi: pcihp: disable power control on PCIe slot Date: Thu, 24 Feb 2022 12:44:10 -0500 Message-Id: <20220224174411.3296848-4-imammedo@redhat.com> In-Reply-To: <20220224174411.3296848-1-imammedo@redhat.com> References: <20220224174411.3296848-1-imammedo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=imammedo@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=170.10.129.124; envelope-from=imammedo@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kraxel@redhat.com, mst@redhat.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Previous patch [1] fixed unconditional power handling on a PCIe slot, and make it honor PCI_EXP_SLTCAP_PCP capability. Use COMPAT_PROP_PCP to disable power control (PCI_EXP_SLTCAP_PCP) on PCIe slot when its plug callbacks are wired to ACPI pcihp, which effectively leaves stop always powered. PS: See [1] for detailed description of the issue [2] and how it's being addressed. 1) "pcie: update slot power status only is power control is enabled" 2) Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2053584 Signed-off-by: Igor Mammedov --- hw/acpi/pcihp.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/hw/acpi/pcihp.c b/hw/acpi/pcihp.c index 6befd23e16..bc47d1bf64 100644 --- a/hw/acpi/pcihp.c +++ b/hw/acpi/pcihp.c @@ -32,6 +32,7 @@ #include "hw/pci/pci_bridge.h" #include "hw/pci/pci_host.h" #include "hw/pci/pcie_port.h" +#include "hw/pci-bridge/xio3130_downstream.h" #include "hw/i386/acpi-build.h" #include "hw/acpi/acpi.h" #include "hw/pci/pci_bus.h" @@ -329,6 +330,15 @@ void acpi_pcihp_device_pre_plug_cb(HotplugHandler *hotplug_dev, GINT_TO_POINTER(pdev->acpi_index), g_cmp_uint32, NULL); } + + /* + * since acpi_pcihp manages hotplug, disable PCI-E power control on slot + */ + if (object_dynamic_cast(OBJECT(dev), TYPE_PCIE_ROOT_PORT) || + object_dynamic_cast(OBJECT(dev), TYPE_XIO3130_DOWNSTREAM)) { + object_property_set_bool(OBJECT(dev), COMPAT_PROP_PCP, false, + &error_abort); + } } void acpi_pcihp_device_plug_cb(HotplugHandler *hotplug_dev, AcpiPciHpState *s, From patchwork Thu Feb 24 17:44:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 12759087 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 13822C433EF for ; Thu, 24 Feb 2022 17:47:57 +0000 (UTC) Received: from localhost ([::1]:39640 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nNIDc-00040r-3Q for qemu-devel@archiver.kernel.org; Thu, 24 Feb 2022 12:47:56 -0500 Received: from eggs.gnu.org ([209.51.188.92]:39258) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nNICB-0001yb-1X for qemu-devel@nongnu.org; Thu, 24 Feb 2022 12:46:27 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:41756) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nNIC8-0002bq-UH for qemu-devel@nongnu.org; Thu, 24 Feb 2022 12:46:26 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1645724784; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vriZp6BD32M3Unm0N7ZbBok++Lc8htWYCM6k1uQTT/I=; b=CL+8QKuhSKo+LliRHW1UfN0ZYyKTv8psQD4D3LELyuzDDn9rgyCiiZEcicKrRPqomISDrU u+S+3qlFbNv5/CeFYBcCNkYbJVlOUL8wqJQQKdG9vIyYVyyHVW/CvACX/l33RNCvb+xQdy 1DeJItHrLIEvJ4Cn6Uv+GLEg6seqrUg= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-15-aBN1JwD_Mhmss4JDeiJBrA-1; Thu, 24 Feb 2022 12:46:23 -0500 X-MC-Unique: aBN1JwD_Mhmss4JDeiJBrA-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id F1D5551E6 for ; Thu, 24 Feb 2022 17:46:21 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id BA23F710AC; Thu, 24 Feb 2022 17:46:07 +0000 (UTC) From: Igor Mammedov To: qemu-devel@nongnu.org Subject: [PATCH 4/4] q35: compat: keep hotplugged PCIe device broken after migration for 6.2-older machine types Date: Thu, 24 Feb 2022 12:44:11 -0500 Message-Id: <20220224174411.3296848-5-imammedo@redhat.com> In-Reply-To: <20220224174411.3296848-1-imammedo@redhat.com> References: <20220224174411.3296848-1-imammedo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=imammedo@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=170.10.129.124; envelope-from=imammedo@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kraxel@redhat.com, mst@redhat.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Q35 switched to ACPI PCI hotplug by default in since 6.1 machine type and migration worked as expected (with BARs on target being the same as on source) However native PCIe fixes [1] merged in 6.2 time, regressed migration part, resulting in disabled BARs on target. The issue affects pc-q35-6.2 and pc-q35-6.1 machine types (and older if qemu-6.2 binary is used on source with manually enabled ACPI PCI hotplug). Introduce x-pcihp-enable-pcie-pcp-cap compat property to keep 6.2 and older machine types in broken state when ACPI PCI hotplug is enabled to make sure that guest does see the same PCIe device and slot on rc & dst (i.e. with or without power control present/configured). 1) commit d5daff7d312 (pcie: implement slot power control for pcie root ports) Signed-off-by: Igor Mammedov --- include/hw/acpi/pcihp.h | 4 +++- hw/acpi/acpi-pci-hotplug-stub.c | 3 ++- hw/acpi/ich9.c | 21 ++++++++++++++++++++- hw/acpi/pcihp.c | 20 ++++++++++++-------- hw/acpi/piix4.c | 3 ++- hw/core/machine.c | 4 +++- 6 files changed, 42 insertions(+), 13 deletions(-) diff --git a/include/hw/acpi/pcihp.h b/include/hw/acpi/pcihp.h index af1a169fc3..06466dd2a8 100644 --- a/include/hw/acpi/pcihp.h +++ b/include/hw/acpi/pcihp.h @@ -52,6 +52,7 @@ typedef struct AcpiPciHpState { bool legacy_piix; uint16_t io_base; uint16_t io_len; + bool enable_pcie_pcp_cap; } AcpiPciHpState; void acpi_pcihp_init(Object *owner, AcpiPciHpState *, PCIBus *root, @@ -59,7 +60,8 @@ void acpi_pcihp_init(Object *owner, AcpiPciHpState *, PCIBus *root, uint16_t io_base); void acpi_pcihp_device_pre_plug_cb(HotplugHandler *hotplug_dev, - DeviceState *dev, Error **errp); + AcpiPciHpState *s, DeviceState *dev, + Error **errp); void acpi_pcihp_device_plug_cb(HotplugHandler *hotplug_dev, AcpiPciHpState *s, DeviceState *dev, Error **errp); void acpi_pcihp_device_unplug_cb(HotplugHandler *hotplug_dev, AcpiPciHpState *s, diff --git a/hw/acpi/acpi-pci-hotplug-stub.c b/hw/acpi/acpi-pci-hotplug-stub.c index 734e4c5986..6904b772b3 100644 --- a/hw/acpi/acpi-pci-hotplug-stub.c +++ b/hw/acpi/acpi-pci-hotplug-stub.c @@ -18,7 +18,8 @@ void acpi_pcihp_device_plug_cb(HotplugHandler *hotplug_dev, AcpiPciHpState *s, } void acpi_pcihp_device_pre_plug_cb(HotplugHandler *hotplug_dev, - DeviceState *dev, Error **errp) + AcpiPciHpState *s, DeviceState *dev, + Error **errp) { return; } diff --git a/hw/acpi/ich9.c b/hw/acpi/ich9.c index bd9bbade70..928d5c101c 100644 --- a/hw/acpi/ich9.c +++ b/hw/acpi/ich9.c @@ -430,6 +430,21 @@ static void ich9_pm_set_keep_pci_slot_hpc(Object *obj, bool value, Error **errp) s->pm.keep_pci_slot_hpc = value; } +static bool ich9_pm_get_enable_pcie_pcp_cap(Object *obj, Error **errp) +{ + ICH9LPCState *s = ICH9_LPC_DEVICE(obj); + + return s->pm.acpi_pci_hotplug.enable_pcie_pcp_cap; +} + +static void ich9_pm_set_enable_pcie_pcp_cap(Object *obj, bool value, + Error **errp) +{ + ICH9LPCState *s = ICH9_LPC_DEVICE(obj); + + s->pm.acpi_pci_hotplug.enable_pcie_pcp_cap = value; +} + void ich9_pm_add_properties(Object *obj, ICH9LPCPMRegs *pm) { static const uint32_t gpe0_len = ICH9_PMIO_GPE0_LEN; @@ -469,6 +484,9 @@ void ich9_pm_add_properties(Object *obj, ICH9LPCPMRegs *pm) object_property_add_bool(obj, "x-keep-pci-slot-hpc", ich9_pm_get_keep_pci_slot_hpc, ich9_pm_set_keep_pci_slot_hpc); + object_property_add_bool(obj, "x-pcihp-enable-pcie-pcp-cap", + ich9_pm_get_enable_pcie_pcp_cap, + ich9_pm_set_enable_pcie_pcp_cap); } void ich9_pm_device_pre_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, @@ -477,7 +495,8 @@ void ich9_pm_device_pre_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, ICH9LPCState *lpc = ICH9_LPC_DEVICE(hotplug_dev); if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) { - acpi_pcihp_device_pre_plug_cb(hotplug_dev, dev, errp); + acpi_pcihp_device_pre_plug_cb(hotplug_dev, &lpc->pm.acpi_pci_hotplug, + dev, errp); return; } diff --git a/hw/acpi/pcihp.c b/hw/acpi/pcihp.c index bc47d1bf64..4c1fdb2211 100644 --- a/hw/acpi/pcihp.c +++ b/hw/acpi/pcihp.c @@ -291,7 +291,8 @@ void acpi_pcihp_reset(AcpiPciHpState *s, bool acpihp_root_off) #define ONBOARD_INDEX_MAX (16 * 1024 - 1) void acpi_pcihp_device_pre_plug_cb(HotplugHandler *hotplug_dev, - DeviceState *dev, Error **errp) + AcpiPciHpState *s, DeviceState *dev, + Error **errp) { PCIDevice *pdev = PCI_DEVICE(dev); @@ -331,13 +332,16 @@ void acpi_pcihp_device_pre_plug_cb(HotplugHandler *hotplug_dev, g_cmp_uint32, NULL); } - /* - * since acpi_pcihp manages hotplug, disable PCI-E power control on slot - */ - if (object_dynamic_cast(OBJECT(dev), TYPE_PCIE_ROOT_PORT) || - object_dynamic_cast(OBJECT(dev), TYPE_XIO3130_DOWNSTREAM)) { - object_property_set_bool(OBJECT(dev), COMPAT_PROP_PCP, false, - &error_abort); + /* compat knob to preserve pci_config as in 6.2 & older when pcihp in use */ + if (s->enable_pcie_pcp_cap == false) { + /* + * since acpi_pcihp manages hotplug, disable PCI-E power control on slot + */ + if (object_dynamic_cast(OBJECT(dev), TYPE_PCIE_ROOT_PORT) || + object_dynamic_cast(OBJECT(dev), TYPE_XIO3130_DOWNSTREAM)) { + object_property_set_bool(OBJECT(dev), COMPAT_PROP_PCP, false, + &error_abort); + } } } diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c index cc37fa3416..0d25f75112 100644 --- a/hw/acpi/piix4.c +++ b/hw/acpi/piix4.c @@ -350,7 +350,8 @@ static void piix4_device_pre_plug_cb(HotplugHandler *hotplug_dev, PIIX4PMState *s = PIIX4_PM(hotplug_dev); if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) { - acpi_pcihp_device_pre_plug_cb(hotplug_dev, dev, errp); + acpi_pcihp_device_pre_plug_cb(hotplug_dev, &s->acpi_pci_hotplug, dev, + errp); } else if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { if (!s->acpi_memory_hotplug.is_enabled) { error_setg(errp, diff --git a/hw/core/machine.c b/hw/core/machine.c index d856485cb4..48ffc85f8d 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -37,7 +37,9 @@ #include "hw/virtio/virtio.h" #include "hw/virtio/virtio-pci.h" -GlobalProperty hw_compat_6_2[] = {}; +GlobalProperty hw_compat_6_2[] = { + { "ICH9-LPC", "x-pcihp-enable-pcie-pcp-cap", "on" }, +}; const size_t hw_compat_6_2_len = G_N_ELEMENTS(hw_compat_6_2); GlobalProperty hw_compat_6_1[] = {